Changeset 281928 in webkit
- Timestamp:
- Sep 2, 2021 9:33:06 AM (11 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-import-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/StyleRuleImport.cpp (modified) (1 diff)
-
Source/WebCore/css/StyleRuleImport.h (modified) (4 diffs)
-
Source/WebCore/css/parser/CSSParserImpl.cpp (modified) (4 diffs)
-
Source/WebCore/style/RuleSet.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r281926 r281928 1 2021-09-02 Antti Koivisto <antti@apple.com> 2 3 [CSS Cascade Layers] Support layer argument in @import rules 4 https://bugs.webkit.org/show_bug.cgi?id=229795 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/css/css-cascade/layer-import-expected.txt: 9 1 10 2021-09-02 Youenn Fablet <youenn@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/layer-import-expected.txt
r281917 r281928 4 4 PASS A3 Layer rules with import 5 5 PASS A4 Layer rules with import 6 FAIL B1 Anonymous imports assert_equals: B1 Anonymous imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 7 FAIL B2 Anonymous imports assert_equals: B2 Anonymous imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 6 PASS B1 Anonymous imports 7 PASS B2 Anonymous imports 8 8 PASS B3 Anonymous imports 9 FAIL B4 Anonymous imports assert_equals: B4 Anonymous imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 10 FAIL C1 Named imports assert_equals: C1 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 11 FAIL C2 Named imports assert_equals: C2 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 9 PASS B4 Anonymous imports 10 PASS C1 Named imports 11 PASS C2 Named imports 12 12 PASS C3 Named imports 13 FAIL C4 Named imports assert_equals: C4 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 13 PASS C4 Named imports 14 14 PASS C5 Named imports 15 15 PASS C6 Named imports 16 FAIL C7 Named imports assert_equals: C7 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 17 FAIL C8 Named imports assert_equals: C8 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 18 FAIL C9 Named imports assert_equals: C9 Named imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 19 FAIL D1 Layer statement with imports assert_equals: D1 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 16 PASS C7 Named imports 17 PASS C8 Named imports 18 PASS C9 Named imports 19 PASS D1 Layer statement with imports 20 20 FAIL D2 Layer statement with imports assert_equals: D2 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 21 21 FAIL D3 Layer statement with imports assert_equals: D3 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 22 22 FAIL D4 Layer statement with imports assert_equals: D4 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 23 23 FAIL D5 Layer statement with imports assert_equals: D5 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 24 FAIL D6 Layer statement with imports assert_equals: D6 Layer statement with imports, target 'first' expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)" 24 PASS D6 Layer statement with imports 25 25 -
trunk/Source/WebCore/ChangeLog
r281926 r281928 1 2021-09-02 Antti Koivisto <antti@apple.com> 2 3 [CSS Cascade Layers] Support layer argument in @import rules 4 https://bugs.webkit.org/show_bug.cgi?id=229795 5 6 Reviewed by Simon Fraser. 7 8 Add support for 9 10 @import "style.css" layer; 11 @import "style.css" layer(foo); 12 13 * css/StyleRuleImport.cpp: 14 (WebCore::StyleRuleImport::create): 15 (WebCore::StyleRuleImport::StyleRuleImport): 16 17 Add layer name member. 18 19 * css/StyleRuleImport.h: 20 * css/parser/CSSParserImpl.cpp: 21 (WebCore::consumeCascadeLayerName): 22 23 Factor into a standalone function. 24 25 (WebCore::CSSParserImpl::consumeImportRule): 26 27 Parse layer and layer() arguments for @import. 28 29 (WebCore::CSSParserImpl::consumeLayerRule): 30 * style/RuleSet.cpp: 31 (WebCore::Style::RuleSet::Builder::addRulesFromSheet): 32 33 Register the layers specified in import rules. 34 1 35 2021-09-02 Youenn Fablet <youenn@apple.com> 2 36 -
trunk/Source/WebCore/css/StyleRuleImport.cpp
r278185 r281928 37 37 namespace WebCore { 38 38 39 Ref<StyleRuleImport> StyleRuleImport::create(const String& href, Ref<MediaQuerySet>&& media )39 Ref<StyleRuleImport> StyleRuleImport::create(const String& href, Ref<MediaQuerySet>&& media, std::optional<CascadeLayerName>&& cascadeLayerName) 40 40 { 41 return adoptRef(*new StyleRuleImport(href, WTFMove(media) ));41 return adoptRef(*new StyleRuleImport(href, WTFMove(media), WTFMove(cascadeLayerName))); 42 42 } 43 43 44 StyleRuleImport::StyleRuleImport(const String& href, Ref<MediaQuerySet>&& media )44 StyleRuleImport::StyleRuleImport(const String& href, Ref<MediaQuerySet>&& media, std::optional<CascadeLayerName>&& cascadeLayerName) 45 45 : StyleRuleBase(StyleRuleType::Import) 46 46 , m_styleSheetClient(this) 47 47 , m_strHref(href) 48 48 , m_mediaQueries(WTFMove(media)) 49 , m_cascadeLayerName(WTFMove(cascadeLayerName)) 49 50 { 50 51 if (!m_mediaQueries) -
trunk/Source/WebCore/css/StyleRuleImport.h
r251655 r281928 36 36 WTF_MAKE_FAST_ALLOCATED; 37 37 public: 38 static Ref<StyleRuleImport> create(const String& href, Ref<MediaQuerySet>&& );38 static Ref<StyleRuleImport> create(const String& href, Ref<MediaQuerySet>&&, std::optional<CascadeLayerName>&&); 39 39 40 40 ~StyleRuleImport(); … … 53 53 const CachedCSSStyleSheet* cachedCSSStyleSheet() const { return m_cachedSheet.get(); } 54 54 55 const std::optional<CascadeLayerName>& cascadeLayerName() const { return m_cascadeLayerName; } 56 55 57 private: 56 58 // NOTE: We put the CachedStyleSheetClient in a member instead of inheriting from it 57 59 // to avoid adding a vptr to StyleRuleImport. 58 class ImportedStyleSheetClient final : public CachedStyleSheetClient {60 class ImportedStyleSheetClient final : public CachedStyleSheetClient { 59 61 public: 60 62 ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { } … … 71 73 friend class ImportedStyleSheetClient; 72 74 73 StyleRuleImport(const String& href, Ref<MediaQuerySet>&& );75 StyleRuleImport(const String& href, Ref<MediaQuerySet>&&, std::optional<CascadeLayerName>&&); 74 76 75 77 StyleSheetContents* m_parentStyleSheet { nullptr }; … … 79 81 RefPtr<MediaQuerySet> m_mediaQueries; 80 82 RefPtr<StyleSheetContents> m_styleSheet; 83 std::optional<CascadeLayerName> m_cascadeLayerName; 81 84 CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet; 82 85 bool m_loading { false }; -
trunk/Source/WebCore/css/parser/CSSParserImpl.cpp
r281701 r281928 508 508 } 509 509 510 enum class AllowAnonymous { Yes, No }; 511 static std::optional<CascadeLayerName> consumeCascadeLayerName(CSSParserTokenRange& range, AllowAnonymous allowAnonymous) 512 { 513 CascadeLayerName name; 514 if (range.atEnd()) { 515 if (allowAnonymous == AllowAnonymous::Yes) 516 return name; 517 return { }; 518 } 519 520 while (true) { 521 auto nameToken = range.consume(); 522 if (nameToken.type() != IdentToken) 523 return { }; 524 525 name.append(nameToken.value().toAtomString()); 526 527 if (range.peek().type() != DelimiterToken || range.peek().delimiter() != '.') 528 break; 529 range.consume(); 530 } 531 532 range.consumeWhitespace(); 533 return name; 534 } 535 510 536 RefPtr<StyleRuleImport> CSSParserImpl::consumeImportRule(CSSParserTokenRange prelude) 511 537 { … … 521 547 m_observerWrapper->observer().endRuleBody(endOffset); 522 548 } 549 550 prelude.consumeWhitespace(); 551 552 auto consumeCascadeLayer = [&]() -> std::optional<CascadeLayerName> { 553 if (!m_context.cascadeLayersEnabled) 554 return { }; 555 556 auto& token = prelude.peek(); 557 if (token.type() == FunctionToken && equalIgnoringASCIICase(token.value(), "layer")) { 558 auto contents = CSSPropertyParserHelpers::consumeFunction(prelude); 559 return consumeCascadeLayerName(contents, AllowAnonymous::No); 560 } 561 if (token.type() == IdentToken && equalIgnoringASCIICase(token.value(), "layer")) { 562 prelude.consumeIncludingWhitespace(); 563 return CascadeLayerName { }; 564 } 565 return { }; 566 }; 567 568 auto cascadeLayerName = consumeCascadeLayer(); 569 auto mediaQuerySet = MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)); 523 570 524 return StyleRuleImport::create(uri, MediaQueryParser::parseMediaQuerySet(prelude, MediaQueryParserContext(m_context)).releaseNonNull());571 return StyleRuleImport::create(uri, mediaQuerySet.releaseNonNull(), WTFMove(cascadeLayerName)); 525 572 } 526 573 … … 688 735 auto preludeCopy = prelude; 689 736 690 auto consumeName = [&]() -> std::optional<CascadeLayerName> {691 CascadeLayerName name;692 // Anonymous case.693 if (prelude.atEnd())694 return name;695 696 while (true) {697 auto nameToken = prelude.consume();698 if (nameToken.type() != IdentToken)699 return { };700 701 name.append(nameToken.value().toAtomString());702 703 if (prelude.peek().type() != DelimiterToken || prelude.peek().delimiter() != '.')704 break;705 prelude.consume();706 }707 708 prelude.consumeWhitespace();709 return name;710 };711 712 737 if (!block) { 713 738 // List syntax. 714 739 Vector<CascadeLayerName> nameList; 715 740 while (true) { 716 auto name = consume Name();741 auto name = consumeCascadeLayerName(prelude, AllowAnonymous::No); 717 742 if (!name) 718 743 return nullptr; … … 738 763 } 739 764 740 auto name = consume Name();765 auto name = consumeCascadeLayerName(prelude, AllowAnonymous::Yes); 741 766 if (!name) 742 767 return nullptr; -
trunk/Source/WebCore/style/RuleSet.cpp
r281798 r281928 377 377 if (!rule->styleSheet()) 378 378 continue; 379 380 if (mediaQueryCollector.pushAndEvaluate(rule->mediaQueries())) 379 380 if (mediaQueryCollector.pushAndEvaluate(rule->mediaQueries())) { 381 auto& cascadeLayerName = rule->cascadeLayerName(); 382 if (cascadeLayerName) 383 pushCascadeLayer(*cascadeLayerName); 384 381 385 addRulesFromSheet(*rule->styleSheet()); 386 387 if (cascadeLayerName) 388 popCascadeLayer(*cascadeLayerName); 389 } 382 390 mediaQueryCollector.pop(rule->mediaQueries()); 383 391 }
Note: See TracChangeset
for help on using the changeset viewer.