Hi Rune,
On 08/22/2017 11:50 AM, Rune Lillesveen wrote:
> I tried to do a quick test implementation which stored the first and
> last generated layout object on the ::before and ::after pseudo
> elements, but that broke down for ::first-letter because for
> ::first-letter the text layout objects are first built as if there was
> no ::first-letter and afterwards comes the ::first-letter code to detach
> the original layout object and replaces it with one box for the first
> letter and one for the remaining text (causing dangling pointers to
> layout boxes in my simple implementation).
I also got bit by exactly the same problem, fwiw, when I was trying to
implement that.
> My current thought is to actually generate Node objects for the
> generated content and store first/last DOM nodes on ::before and ::after
> PseudoElement objects and let them point to the layout objects and vice
> versa. Any of you style/layout people who have any other ideas?
I had a WIP implementation for this (I think you took a look at it
actually) that basically allowed an anonymous layout object to have a
reference to a PseudoElement instead of a Document in the `m_node`
field, so that you want to restyle the pseudo, or it gets detached,
you'd just walk the parent layout tree if the pseudo had display:
contents, looking for the "owned" layout objects (the anonymous objects
that have a pseudo-element pointer pointing back to us).
It became kind of gross with first-letter (you need to "propagate" the
`m_node` field properly), but it seemed to work, if you don't mind the
potential extra layout-object walkup in the display: contents case.
Not sure if you've considered it and discarded it already. It doesn't
seem at a glance more complex than creating anonymous nodes (though I
could be wrong).
> As a side-note, I think it might have been better for the ::first-letter
> code to actually build the proper first-letter layout structure on the
> first pass, but that's really a separate thing.
Indeed, I wonder if LayoutNG changes any of that?
Hi Rune,
In case it's useful, WebKit implemented it creating an anonymous inline
box for the pseudo-element:
https://bugs.webkit.org/show_bug.cgi?id=178584
I think this is a nice approach because you recreate the content layout
objects anyway when the content property changes, and there are only
inlines inside the generated content if I'm not wrong, so shouldn't be
observable.
-- Emilio
> --
> You received this message because you are subscribed to the Google
> Groups "layout-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to layout-dev+...@chromium.org
> <mailto:layout-dev+...@chromium.org>.
> To post to this group, send email to layou...@chromium.org
> <mailto:layou...@chromium.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/chromium.org/d/msgid/layout-dev/135e4a2c-7cdd-4142-9704-3f3c542e5849%40chromium.org
> <https://groups.google.com/a/chromium.org/d/msgid/layout-dev/135e4a2c-7cdd-4142-9704-3f3c542e5849%40chromium.org?utm_medium=email&utm_source=footer>.
On Fri, Nov 17, 2017 at 3:56 PM Hayato Ito <hay...@chromium.org> wrote:On Fri, Nov 17, 2017 at 12:13 AM Rune Lillesveen <fut...@chromium.org> wrote:Right, I actually started looking at creating anonymous inlines wrapping text nodes which are direct children of display:contents in order to "inherit" computed style properly (which WebKit also does).One thing that could be good about having anonymous nodes for generated content is that you wouldn't have to re-attach the pseudo element itself when the generated content changes.On Thu, Nov 16, 2017 at 4:05 PM Emilio Cobos Álvarez <emi...@crisal.io> wrote:Hi Rune,
In case it's useful, WebKit implemented it creating an anonymous inline
box for the pseudo-element:
https://bugs.webkit.org/show_bug.cgi?id=178584
I think this is a nice approach because you recreate the content layout
objects anyway when the content property changes, and there are only
inlines inside the generated content if I'm not wrong, so shouldn't be
observable.
> My current thought is to actually generate Node objects for the
> generated content and store first/last DOM nodes on ::before and
> ::after PseudoElement objects and let them point to the layout
> objects and vice versa. Any of you style/layout people who have any
> other ideas?
>Hmm. I think we don't want to add a node for a pseudo element in DOM trees.Usually, we object to that. That is the first exceptional case, isn't it?Ah, your proposal is adding a node object as a child of pseudo elements.Then, please ignore my previous comment.
I don't think dom-team has the best person to answer about pseudo elements.My current assumption is that PseudoElements objects already join a DOM tree, and we have a lot of special treatments for PseudoElements, so that it is not exposed to JavaScript.
Is my understanding correct?
> <style>
> div::before {
> display: contents;
> content: "PASS" url(image.png);
> }I am wondering what is the use case of "display: contents" for ::before / ::after ?If there is no strong use case for that, can we disable "display: contents" for pseudo elements all together, spec-wise?