Closed Bug 1827886 Opened 1 year ago Closed 1 year ago

Display support conditions for @import CSS rules

Categories

(DevTools :: Inspector, task)

task

Tracking

(firefox115 fixed)

RESOLVED FIXED
115 Branch
Tracking Status
firefox115 --- fixed

People

(Reporter: nchevobbe, Assigned: canadahonk)

References

Details

(Keywords: dev-doc-needed, Whiteboard: [devtools:relnote])

Attachments

(1 file)

As we're doing it for the media conditions (see Bug 1827801), we should also display support() bit in the @import item we display on top of the rule view, when this lands (Bug 1427715)

Note that at the moment there's no properties in the CSSImportRule that holds the support information (see https://github.com/w3c/csswg-drafts/issues/8710)

Depends on: 1829590

With the patch from Bug 1829590, the data can be displayed with something like:

diff --git a/devtools/server/actors/style-rule.js b/devtools/server/actors/style-rule.js
--- a/devtools/server/actors/style-rule.js
+++ b/devtools/server/actors/style-rule.js
@@ -324,11 +324,22 @@ class StyleRuleActor extends Actor {
 
         // If the rule is in a imported stylesheet with specified media conditions,
         // put them at the top of the ancestor data array.
-        // XXX We should also handle `supports()` when it gets implemented (See Bug 1827886).
-        if (this._parentSheet.ownerRule.media?.mediaText) {
+        if (
+          this._parentSheet.ownerRule.media?.mediaText ||
+          this._parentSheet.ownerRule.supportsText
+        ) {
+          const parts = [];
+          if (this._parentSheet.ownerRule.supportsText) {
+            parts.push(`supports(${this._parentSheet.ownerRule.supportsText})`);
+          }
+
+          if (this._parentSheet.ownerRule.media?.mediaText) {
+            parts.push(this._parentSheet.ownerRule.media.mediaText);
+          }
+
           form.ancestorData.unshift({
             type: "import",
-            value: this._parentSheet.ownerRule.media.mediaText,
+            value: parts.join(" "),
           });
         }
       }

Added displaying support conditions for @import CSS rules
(@import supports(...)) to DevTools like media conditions (Bug 1827801).

Also added new tests for conditional imports to test support conditions.

Assignee: nobody → oj
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/38da755ec589
Display support conditions for @import CSS rules r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch
Keywords: dev-doc-needed
Whiteboard: [devtools:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: