Closed Bug 1541207 Opened 6 years ago Closed 6 years ago

Add a method to get CSS property values from AnonymousContent without flushing

Categories

(Core :: Layout, defect, P3)

defect

Tracking

()

RESOLVED INVALID

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.

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.

Whiteboard: [layout:triage-discuss]

(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.

P3 for now to get it off the board :)

Priority: -- → P3

There's also InspectorUtils::GetCleanComputedStyleForElement that we could expose. Though that also calls EnsureSafeToHandOutCSSRules.

Flags: needinfo?(mconley)

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.

Flags: needinfo?(mconley)

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!

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.