Open Bug 1602535 Opened 4 years ago Updated 1 year ago

[meta] Ensure DevTools supports Constructable Stylesheets

Categories

(DevTools :: General, task, P3)

task

Tracking

(Not tracked)

People

(Reporter: rcaliman, Unassigned)

References

(Depends on 4 open bugs)

Details

(Keywords: meta)

In principle, DevTools Inspector and Style Editor should support Constructable Stylesheets out-of-the box with little or no modifications necessary. This bug is to track this assumption and any changes if necessary.

For Constructable Stylesheets to be visible to/editable by DevTools, the following should be true:

Summary: Ensure Inspector supports Constructable Stylesheets → Ensure DevTools Inspector supports Constructable Stylesheets

The StyleSheetActor also fetches the text of each stylesheet here. Razvan, does this need to be specifically called out here too as an API to be supported?

Flags: needinfo?(rcaliman)

From my understanding, Constructable Stylesheets are not a new type of stylesheet, but rather a way to associate a stylesheet with a ShadowRoot. The way the stylesheet is created and accessed via CSSOM remains the same. See bug 1590280 comment 15. Pinging Emilio to check this statement.

If this hypothesis holds true, all the existing stylesheet accessors should continue to apply. That includes events and the ability to fetch() a stylesheet by URL.

I will add it to the list above just to remember to check it.

It's not yet clear to me if DevTools would need to use the CSSStyleSheet.replace() or CSSStyleSheet.replaceSync() when mutating the contents of an adopted stylesheet. Those look like a way to mitigate Flash of Unstyled Content when first attaching the sheet and/or a convenience for CSS-in-JS approach.

Flags: needinfo?(rcaliman) → needinfo?(emilio)

(In reply to Razvan Caliman [:rcaliman] from comment #2)

If this hypothesis holds true, all the existing stylesheet accessors should continue to apply. That includes events and the ability to fetch() a stylesheet by URL.

Constructable stylesheets have no URL. We'd need to preserve the input when you call replace() or replaceSync(), I guess.

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #3)

Constructable stylesheets have no URL. We'd need to preserve the input when you call replace() or replaceSync(), I guess.

Neither do inline stylesheets. The only callsite for fetchStyleSheet() is getSheetText() which accounts for the missing href and accesses the text content of the sheet's owner node, the <style> element.

Would this be possible with Constructable Stylesheets or are they devoid of an ownerNode as well?

Flags: needinfo?(emilio)

No, there's no owner node; that's the point of the feature. So you can't access textContent. That's why we'd need to save the text content input, and expose it for devtools.

Flags: needinfo?(emilio)

Thank you for for the clarification! I have updated the bug description accordingly.

Firefox can't inspect constructable stylesheets yet.

shipped in Chrome 85.
https://developers.google.com/web/updates/2020/06/devtools

Severity: normal → S3
No longer blocks: 1769933

Should also make sure StyleEditor supports those.

Component: Inspector: Rules → General
Keywords: meta
Summary: Ensure DevTools Inspector supports Constructable Stylesheets → [meta] Ensure DevTools supports Constructable Stylesheets

Some stats for using Constructable Stylesheets
https://chromestatus.com/metrics/feature/timeline/popularity/2846
(searching for adoptedstylesheets prop)

You need to log in before you can comment on or make changes to this bug.