StyleResolver resolve_style should account for element-backed pseudo elements
Categories
(Core :: CSS Parsing and Computation, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox143 | --- | fixed |
People
(Reporter: lwarlow, Assigned: keithamus)
References
(Blocks 1 open bug)
Details
(Keywords: perf-alert)
Attachments
(1 file)
This is needed for ::details-content support.
| Reporter | ||
Comment 1•1 year ago
|
||
I've tried to do this on top of my parser change (which does seem to mostly work as CSS.supports('selector(details::details-content::before)') now returns true. I changed the check to if !self.element.implemented_pseudo_element().is_some_and(|p| !p.is_element_backed()) { it doesn't fix the resolution of the styles for ::before etc. I'm assuming it needs more changes to the logic for resolution, would you be able to point me in the right direction?
Comment 2•1 year ago
|
||
Yeah so most likely you're not finding the right rules for the ::before pseudo.
We bucket selectors by pseudo-element, so if you have something like ::details-content::before, see PerPseudoElementMap and so on in stylist.rs
For ::part() we do something a bit subtler (see PartElementAndPseudoRules). I suspect we need to either treat element-backed pseudos more like part, or generalize our lookups to support nested pseudo-elements more generally.
The later implies making rule_collector.rs deal with these maps recursively, probably. I haven't dug into this, but that probably means having rule_collector.rs keep the rule_hash_target (which should be the top-level originating element, so <details> in this case), but multiple pseudo-elements [::details-content, ::before], rather than just one). I think per spec we're supposed to support stuff like ::before::marker and so on, so that seems like a better approach.
So TLDR the way I'd go about this would be:
- Change GenericElementAndPseudoRules to support nested pseudo maps (so probably something like
Box<Self>rather thanBox<Map>). - Teach stylist to walk the multiple pseudo-elements that you parse to store the
Rulento the right map. So fordetails::details-content::before, it should be in the::details-contentmap of the::beforepseudo. - Teach
RuleCollectorto carry multiple pseudo-elements (so probably make this aSmallVec<[&'a PseudoElement; 1]>or so). - Teach
RuleCollectorto look up using the(rule_hash, pseudo_element)into the right map.
Or something like that. Maybe we can, as a simpler version of this, keep the data structures as they are, but put the rules into the "global" rules, but that'd mean that ::details-content::before would be matched for every ::before pseudo-element, which is a bit unfortunate. Maybe fine tho.
Hope that helps?
I found that Firefox does not currently support ::details-content::before::marker
Comment 5•1 year ago
|
||
(In reply to 一丝 from comment #4)
I found that Firefox does not currently support
::details-content::before::marker
Yup -- unless I'm misunderstanding, I think that's precisely the sort of thing that this bug is addressing. (At least :details-content::before, and I assume ::marker as well, though maybe emilio or Luke can confirm if that's got some distinct/additional specialness outside the scope of this bug.)
Interop test relevancy note: I think this bug is what's needed in order for us to pass this WPT (which uses details::details-content::before & ::after):
https://wpt.fyi/results/html/rendering/the-details-element/details-pseudo-elements-004.html
test: https://wpt.live/html/rendering/the-details-element/details-pseudo-elements-004.html
ref: https://wpt.live/html/rendering/the-details-element/details-pseudo-elements-004-ref.html
And probably also this one (which uses details::details-content::first-letter & ::first-line):
https://wpt.fyi/results/html/rendering/the-details-element/details-pseudo-elements-005.html
test: https://wpt.live/html/rendering/the-details-element/details-pseudo-elements-005.html
ref: https://wpt.live/html/rendering/the-details-element/details-pseudo-elements-005-ref.html
(Right now, with layout.css.details-content.enabled toggled to true, we fail both of those^ tests.)
Comment 6•1 year ago
|
||
Hi Luke! Just checking in, are you planning on taking this one? (No worries if not, but if so let's mark you as the assignee to reflect reality.)
Thanks for all your recent help in this details/details-content area!
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Updated•1 year ago
|
| Reporter | ||
Comment 7•1 year ago
|
||
| Assignee | ||
Updated•11 months ago
|
| Assignee | ||
Updated•11 months ago
|
Comment 11•11 months ago
|
||
Comment 12•11 months ago
|
||
Comment 13•11 months ago
|
||
Backed out for causing failures at details-pseudo-elements-005.html.
Backout link: https://hg-edge.mozilla.org/integration/autoland/rev/b95f29d530590921e31991be6a80da8400881013
Failure log: https://treeherder.mozilla.org/logviewer?job_id=520398796&repo=autoland&lineNumber=3269
| Assignee | ||
Updated•11 months ago
|
Comment 14•11 months ago
|
||
| Assignee | ||
Updated•11 months ago
|
Comment 15•11 months ago
|
||
Updated•11 months ago
|
| Assignee | ||
Updated•11 months ago
|
Comment 17•11 months ago
|
||
Comment 18•11 months ago
|
||
| bugherder | ||
Comment 19•11 months ago
|
||
(In reply to pstanciu from comment #10)
Backed out for causing mass failures
Perfherder has detected a awsy performance change from push c61d7c5764c840cee1dfc7a46098bd9cf6f582b4.
If you have any questions, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.
Improvements:
| Ratio | Test | Platform | Options | Absolute values (old vs new) |
|---|---|---|---|---|
| 0.07% | Base Content Explicit | windows11-64-24h2-shippable | fission | 8,207,227.00 -> 8,201,523.33 |
Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.
If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.
You can run all of these tests on try with ./mach try perf --alert 46141
The following documentation link provides more information about this command.
Comment 20•11 months ago
|
||
(In reply to Florin Bilt from comment #19)
Perfherder has detected a awsy performance change from push c61d7c5764c840cee1dfc7a46098bd9cf6f582b4.
That push was a backout, FWIW. Either it was noise (0.07% delta seems maybe-random) or it was an indication that this bug's actual patch was a very-slight regression here (and the benefit from the backout would presumably have been undone by the re-landing).
Florin, can you tell whether that benefit was balanced by regressions from the original landing (comment 14) and the eventual re-landing (comment 17)?
Comment 21•11 months ago
|
||
(or maybe it was just noise; not sure it's worth spending time on. 0.07% seems pretty inconsequential whether it's a benefit or a regression.)
Comment 22•11 months ago
•
|
||
Comment 24•11 months ago
|
||
Thanks, Mayank and Florin! Sounds like this bug's patch made us use ever-so-slightly more memory (0.1% more) for an empty content process.
Judging by the commit message (which indicates that it's making us account for something we were previously ignoring), that seems probably fine and unsurprising. I'll defer to Emilio if he chooses to be worried by this, though. :)
(Looking at the documentation on this measurement, it looks like it's mostly there to watch for added content/JS that might get loaded synchronously at startup and hence gets forced to be included in this base amount of memory. That makes sense as something to watch for; and that's not the sort of thing that happened here -- rather, this just made the stuff-that-already-gets-loaded very slightly more expensive, for correctness reasons -- so I think we're OK.)
Comment 25•11 months ago
|
||
We should fix this tho, the new entries do waste a fair bit of space. Bug 1981540 is where the investigation is happening.
Comment 26•11 months ago
|
||
OK! Thanks.
Updated•10 months ago
|
Description
•