edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] :before :after
@ 2018-02-20 11:56 Karl Dahlke
  2018-02-21 23:07 ` Adam Thompson
  0 siblings, 1 reply; 3+ messages in thread
From: Karl Dahlke @ 2018-02-20 11:56 UTC (permalink / raw)
  To: Edbrowse-dev

[-- Attachment #1: Type: text/plain, Size: 1795 bytes --]

This is just me thinking out loud; you can ignore if you like.

css can inject text into your document. I had no idea!
It's not just colors and fonts and decorations, it can inject words.
https://www.w3.org/TR/CSS21/generate.html

The first thing you'll notice is that :before is on the wrong side of the descriptor. It is a bad design that is cast in stone.
:before is a selector but it is always true, it doesn't select anything.
It is an action, and should be on the right.
So we have to move it, functionally, if not physically, to the right.
If present, *none* of the directives apply to the current node, except for content.
Content:blah puts blah before, or after, everything under the current node.

p.note:before { content: "Note: " }

I need to create a text node, or a span, probably a text node, with contents blah,
and then use either insertBefore or appendChild to paste it in.
>From there it will be rendered and you'll see it as usual.
Not too hard, but there is fallout.

Here's the really bad news.
I don't do any of this stuff, because I didn't think I had to.
And that shaves almost 2 minutes off the browse time for stackoverflow, with its 5,000 selectors.
I apply selectors to each node on demand, if and when you access the style element, and I thought that was really clever, and I guess it is,
because I don't spend 2 minutes on stuff that doesn't matter, yet I still do what needs to be done on demand, but,
I'm not injecting snippets of text before or after elements,
and that changes the way the document might read.

All this may have to wait until after 3.7.2, because right now I'm not even sure how to procede.
BTW, I still hope we can cut 3.7.2 on Sunday, assuming we quit finding bugs, or at least problematic bugs.

Karl Dahlke

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Edbrowse-dev] :before :after
  2018-02-20 11:56 [Edbrowse-dev] :before :after Karl Dahlke
@ 2018-02-21 23:07 ` Adam Thompson
  2018-02-22  0:00   ` Karl Dahlke
  0 siblings, 1 reply; 3+ messages in thread
From: Adam Thompson @ 2018-02-21 23:07 UTC (permalink / raw)
  To: Karl Dahlke; +Cc: Edbrowse-dev

On Tue, Feb 20, 2018 at 06:56:52AM -0500, Karl Dahlke wrote:
> css can inject text into your document. I had no idea!
> It's not just colors and fonts and decorations, it can inject words.
> https://www.w3.org/TR/CSS21/generate.html

Wow, yeah... I never even imagined it'd do something like that.

> The first thing you'll notice is that :before is on the wrong side of the descriptor. It is a bad design that is cast in stone.
> :before is a selector but it is always true, it doesn't select anything.
> It is an action, and should be on the right.
> So we have to move it, functionally, if not physically, to the right.
> If present, *none* of the directives apply to the current node, except for content.
> Content:blah puts blah before, or after, everything under the current node.
> 
> p.note:before { content: "Note: " }
> 
> I need to create a text node, or a span, probably a text node, with contents blah,
> and then use either insertBefore or appendChild to paste it in.
> From there it will be rendered and you'll see it as usual.
> Not too hard, but there is fallout.

Should it actually appear in the DOM as a node or is it just for display i.e. should js see this node, or does it matter if it can?
Also, what happens if someone shoves html in there (if that's even possible).  Should it be rendered and parsed into the DOM?

> Here's the really bad news.
> I don't do any of this stuff, because I didn't think I had to.
> And that shaves almost 2 minutes off the browse time for stackoverflow, with its 5,000 selectors.
> I apply selectors to each node on demand, if and when you access the style element, and I thought that was really clever, and I guess it is,
> because I don't spend 2 minutes on stuff that doesn't matter, yet I still do what needs to be done on demand, but,
> I'm not injecting snippets of text before or after elements,
> and that changes the way the document might read.

Yeah, it's annoying we lose this.  I've not looked through the CSS parsing logic but is it possible to only apply *these* selectors and quickly skim over the rest and do the on-demand stuff for them?

> All this may have to wait until after 3.7.2, because right now I'm not even sure how to procede.
> BTW, I still hope we can cut 3.7.2 on Sunday, assuming we quit finding bugs, or at least problematic bugs.

Sounds like a plan.

Cheers,
Adam.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Edbrowse-dev] :before :after
  2018-02-21 23:07 ` Adam Thompson
@ 2018-02-22  0:00   ` Karl Dahlke
  0 siblings, 0 replies; 3+ messages in thread
From: Karl Dahlke @ 2018-02-22  0:00 UTC (permalink / raw)
  To: Edbrowse-dev

> is it possible to only apply *these* selectors and quickly skim over the
> rest and do the on-demand stuff for them?

Well you're thinking exactly as I.
I did some stats, and 280 out of 5000 selectors in stackoverflow are of the before after type.
Applying 280, rather than 5000, is probably feasible.
And remember, stackoverflow is almost certainly a worst case.
Other sites don't have 5000 selectors, or 280 injecting selectors.
I laid some groundwork, wherein these selectors are flagged as generating text.

cssList[i].gentext = true;

Still I may want to optimize the way these selectors are applied.
Maybe some of the hashing code that I wrote, then decided I didn't need and threw away,
but it's still in github if I want it.

Karl Dahlke

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-21 23:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-20 11:56 [Edbrowse-dev] :before :after Karl Dahlke
2018-02-21 23:07 ` Adam Thompson
2018-02-22  0:00   ` Karl Dahlke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).