Closed Bug 1427715 Opened 8 years ago Closed 3 years ago

Implement supports() syntax for @import rules

Categories

(Core :: CSS Parsing and Computation, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox114 --- fixed

People

(Reporter: sebo, Assigned: canadahonk)

References

(Blocks 1 open bug, )

Details

(Keywords: dev-doc-needed)

Attachments

(1 file, 4 external files)

CSS Cascading 4 defines a supports() syntax for @import rules allowing support-dependent importing of other style sheets. This feature should be implemented accordingly. Sebastian
Priority: -- → P3
Severity: normal → S3

Implemented supports conditions using supports() in @import rules as per
CSS Cascading and Inheritance Level 4.

Spec: https://drafts.csswg.org/css-cascade-4/#conditional-import
WPT tests: https://wpt.fyi/results/css/css-cascade/import-conditions.html

WIP. Todo:

  • Format
  • Test functionality
  • Update WPT expectations
  • Potentially add more WPT tests for supports()?
Assignee: nobody → oj
Status: NEW → ASSIGNED

You can use this as:

input.try_parse(SupportsCondition::parse_for_import).ok()

Or so.

The #target in the data URI is the url hash, not a selector.

Depends on D172668

Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5ff4991cd681 Add (unused for now) parsing for support conditions in @import. r=CanadaHonk https://hg.mozilla.org/integration/autoland/rev/5abfd5ad2e35 Fix @import supports() test. r=CanadaHonk
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/39013 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Attachment #9323123 - Attachment description: WIP: Bug 1427715 - Implement supports() syntax for @import rules → Bug 1427715 - Implement supports() syntax for @import rules
Attachment #9323123 - Attachment description: Bug 1427715 - Implement supports() syntax for @import rules → WIP: Bug 1427715 - Implement supports() syntax for @import rules
Attached file crash.html —

@emilio could you have a poke at this crash case, still can't trace locally on my machine. Happens specifically when using a not in an @import supports() and then accessing the CSS rule in JS. Checked some areas, it is not related to serialization/to_css at least.

Flags: needinfo?(emilio)

You need something like comment 9. This unwrap is failing.

This is technically a spec issue or mismatch (https://github.com/w3c/csswg-drafts/issues/8608), but I think it's an oversight, and we should assert that CSSImportRule.styleSheet is null when the supports() condition doesn't match and probably remove some of the comments referencing bug 1326509 from dom/webidl/CSSImportRule.webidl.

Flags: needinfo?(emilio)

We should tweak this code to probably pass around the condition, so that we don't load these speculatively.

https://searchfox.org/mozilla-central/source/layout/style/test/gtest/ImportScannerTest.cpp has some tests where we want to add some. Follow-up is probably ok tho.

Attachment #9323692 - Attachment description: WIP: Bug 1427715 - Allow null style-sheet. → Bug 1427715 - Allow CSSImportRule.styleSheet to be null. r=#style,#layout,canadahonk
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d6f0f149da07 Allow CSSImportRule.styleSheet to be null. r=CanadaHonk,webidl,smaug
Attachment #9323123 - Attachment description: WIP: Bug 1427715 - Implement supports() syntax for @import rules → Bug 1427715 - Implement supports() syntax for @import rules
See Also: → 1827801
Pushed by oj@oojmed.com: https://hg.mozilla.org/integration/autoland/rev/22cb06c53db5 Implement supports() syntax for @import rules r=emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/39521 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Blocks: 1829430
Blocks: 1830779
Target Milestone: --- → 114 Branch
Regressions: 1953050
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: