Add a method to get CSS property values from AnonymousContent without flushing
Categories
(Core :: Layout, defect, P3)
Tracking
()
People
(Reporter: mconley, Unassigned)
Details
(Whiteboard: [layout:triage-discuss])
I want to be able to read some variables from the Picture-in-Picture toggle.css sheet, but I can only do that via getComputedStylePropertyValue, and from what I can tell, that can cause us to both style and layout flush.
I'm working around this for now by memoizing the values after I've read them once, but I'd love to be able to do this without flushing.
Comment 1•6 years ago
|
||
Do you just need the specified style of the CSS Variables? You could do something like call InspectorUtils.getCSSStyleRules()
on your target element, which I think doesn't flush, and then search through the rules that are returned.
Updated•6 years ago
|
Comment 2•6 years ago
|
||
(In reply to Cameron McCormack (:heycam) from comment #1)
Do you just need the specified style of the CSS Variables? You could do something like call
InspectorUtils.getCSSStyleRules()
on your target element, which I think doesn't flush, and then search through the rules that are returned.
That's also pretty heavy-weight, since it calls EnsureUniqueInnerOnCssSheets. CSS variables cannot cause a layout flush.
Bug 1358495 was closed as WONTFIX but we could revisit that I guess.
Comment 4•6 years ago
|
||
There's also InspectorUtils::GetCleanComputedStyleForElement
that we could expose. Though that also calls EnsureSafeToHandOutCSSRules
.
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Comment 5•6 years ago
|
||
Any of these will do for my use case, but I'll also need to be able to do it through the AnonymousContent layer, which doesn't give me direct access to the node that I care about.
To be clear, for my use case, what I need to do is be able to read some CSS variable values off of a node without causing a flush. For now, to work around this, I'm flushing and memo-izing the value the first time I need it.
Reporter | ||
Comment 6•6 years ago
|
||
In bug 1542756, I'm having to switch tack, and not use AnonymousContent for the Picture-in-Picture toggle. So this is no longer necessary.
Sorry for the churn!
Description
•