Changeset 292635 in webkit
- Timestamp:
- Apr 8, 2022 2:35:00 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-for-shadow-dom-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/style/ContainerQueryEvaluator.cpp (modified) (5 diffs)
-
Source/WebCore/style/ContainerQueryEvaluator.h (modified) (3 diffs)
-
Source/WebCore/style/ElementRuleCollector.cpp (modified) (2 diffs)
-
Source/WebCore/style/ElementRuleCollector.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r292606 r292635 1 2022-04-08 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Search query containers for ::slotted and and ::part rules in their scope 4 https://bugs.webkit.org/show_bug.cgi?id=238997 5 6 Reviewed by Sam Weinig. 7 8 * web-platform-tests/css/css-contain/container-queries/container-for-shadow-dom-expected.txt: 9 1 10 2022-04-08 Alan Bujtas <zalan@apple.com> 2 11 -
trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-for-shadow-dom-expected.txt
r292592 r292635 2 2 PASS Match container in outer tree 3 3 PASS Match container in same tree, not walking flat tree ancestors 4 FAIL Match container in ::slotted selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" 4 PASS Match container in ::slotted selector's originating element tree 5 5 PASS Match container in outer tree for :host 6 FAIL Match container in ::part selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" 7 FAIL Match container for ::before in ::slotted selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" 6 PASS Match container in ::part selector's originating element tree 7 PASS Match container for ::before in ::slotted selector's originating element tree 8 8 PASS Match container in outer tree for :host::before 9 FAIL Match container for ::before in ::part selector's originating element tree assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" 10 FAIL Match container for ::part selector's originating element tree for exportparts assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" 9 PASS Match container for ::before in ::part selector's originating element tree 10 PASS Match container for ::part selector's originating element tree for exportparts 11 11 PASS Match container for slot light tree child fallback 12 12 -
trunk/Source/WebCore/ChangeLog
r292633 r292635 1 2022-04-08 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Search query containers for ::slotted and and ::part rules in their scope 4 https://bugs.webkit.org/show_bug.cgi?id=238997 5 6 Reviewed by Sam Weinig. 7 8 "For selectors with pseudo elements, query containers can be established by the shadow-including inclusive ancestors of 9 the ultimate originating element." 10 11 https://drafts.csswg.org/css-contain-3/#container-queries 12 13 * style/ContainerQueryEvaluator.cpp: 14 (WebCore::Style::ContainerQueryEvaluator::ContainerQueryEvaluator): 15 (WebCore::Style::ContainerQueryEvaluator::selectContainer const): 16 (WebCore::Style::ContainerQueryEvaluator::selectContainer): 17 18 For rules coming from a non-local scope, search query container starting from the originating element in that scope. 19 20 * style/ContainerQueryEvaluator.h: 21 * style/ElementRuleCollector.cpp: 22 (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList): 23 (WebCore::Style::ElementRuleCollector::containerQueriesMatch): 24 25 Pass rule's style scope ordinal so we can find the right scope. 26 27 * style/ElementRuleCollector.h: 28 1 29 2022-04-08 Brent Fulgham <bfulgham@apple.com> 2 30 -
trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp
r292592 r292635 36 36 #include "RenderView.h" 37 37 #include "StyleRule.h" 38 #include "StyleScope.h" 38 39 39 40 namespace WebCore::Style { … … 44 45 }; 45 46 46 ContainerQueryEvaluator::ContainerQueryEvaluator(const Element& element, PseudoId pseudoId, S electorMatchingState* selectorMatchingState)47 ContainerQueryEvaluator::ContainerQueryEvaluator(const Element& element, PseudoId pseudoId, ScopeOrdinal scopeOrdinal, SelectorMatchingState* selectorMatchingState) 47 48 : m_element(element) 48 49 , m_pseudoId(pseudoId) 50 , m_scopeOrdinal(scopeOrdinal) 49 51 , m_selectorMatchingState(selectorMatchingState) 50 52 { … … 81 83 auto* cachedQueryContainers = m_selectorMatchingState ? &m_selectorMatchingState->queryContainers : nullptr; 82 84 83 auto* container = selectContainer(filteredContainerQuery.axisFilter, filteredContainerQuery.nameFilter, m_element.get(), cachedQueryContainers, m_pseudoId );85 auto* container = selectContainer(filteredContainerQuery.axisFilter, filteredContainerQuery.nameFilter, m_element.get(), cachedQueryContainers, m_pseudoId, m_scopeOrdinal); 84 86 if (!container) 85 87 return { }; … … 88 90 } 89 91 90 const Element* ContainerQueryEvaluator::selectContainer(OptionSet<CQ::Axis> axes, const String& name, const Element& element, const CachedQueryContainers* cachedQueryContainers, PseudoId pseudoId )92 const Element* ContainerQueryEvaluator::selectContainer(OptionSet<CQ::Axis> axes, const String& name, const Element& element, const CachedQueryContainers* cachedQueryContainers, PseudoId pseudoId, ScopeOrdinal scopeOrdinal) 91 93 { 92 94 // "For each element, the query container to be queried is selected from among the element’s … … 124 126 }; 125 127 128 auto findOriginatingElement = [&]() -> const Element* { 129 // ::part() selectors can query its originating host, but not internal query containers inside the shadow tree. 130 if (scopeOrdinal <= ScopeOrdinal::ContainingHost) 131 return hostForScopeOrdinal(element, scopeOrdinal); 132 // ::slotted() selectors can query containers inside the shadow tree, including the slot itself. 133 if (scopeOrdinal >= ScopeOrdinal::FirstSlot && scopeOrdinal <= ScopeOrdinal::SlotLimit) 134 return assignedSlotForScopeOrdinal(element, scopeOrdinal); 135 return nullptr; 136 }; 137 138 if (auto* originatingElement = findOriginatingElement()) { 139 // For selectors with pseudo elements, query containers can be established by the shadow-including inclusive ancestors of the ultimate originating element. 140 for (auto* ancestor = originatingElement; ancestor; ancestor = ancestor->parentOrShadowHostElement()) { 141 if (isContainerForQuery(*ancestor)) 142 return ancestor; 143 } 144 return nullptr; 145 } 146 126 147 if (cachedQueryContainers) { 127 148 for (auto& container : makeReversedRange(*cachedQueryContainers)) { -
trunk/Source/WebCore/style/ContainerQueryEvaluator.h
r292375 r292635 27 27 #include "ContainerQuery.h" 28 28 #include "SelectorMatchingState.h" 29 #include "StyleScopeOrdinal.h" 29 30 #include <wtf/Ref.h> 30 31 … … 39 40 class ContainerQueryEvaluator { 40 41 public: 41 ContainerQueryEvaluator(const Element&, PseudoId, S electorMatchingState*);42 ContainerQueryEvaluator(const Element&, PseudoId, ScopeOrdinal, SelectorMatchingState*); 42 43 43 44 bool evaluate(const FilteredContainerQuery&) const; 44 45 45 static const Element* selectContainer(OptionSet<CQ::Axis>, const String& name, const Element&, const CachedQueryContainers*, PseudoId = PseudoId::None );46 static const Element* selectContainer(OptionSet<CQ::Axis>, const String& name, const Element&, const CachedQueryContainers*, PseudoId = PseudoId::None, ScopeOrdinal = ScopeOrdinal::Element); 46 47 47 48 private: … … 55 56 const Ref<const Element> m_element; 56 57 const PseudoId m_pseudoId; 58 ScopeOrdinal m_scopeOrdinal; 57 59 SelectorMatchingState* m_selectorMatchingState; 58 60 }; -
trunk/Source/WebCore/style/ElementRuleCollector.cpp
r291594 r292635 488 488 continue; 489 489 490 if (matchRequest.ruleSet.hasContainerQueries() && !containerQueriesMatch( matchRequest.ruleSet.containerQueriesFor(ruleData)))490 if (matchRequest.ruleSet.hasContainerQueries() && !containerQueriesMatch(ruleData, matchRequest)) 491 491 continue; 492 492 … … 506 506 } 507 507 508 bool ElementRuleCollector::containerQueriesMatch(const Vector<const FilteredContainerQuery*>& queries) 509 { 508 bool ElementRuleCollector::containerQueriesMatch(const RuleData& ruleData, const MatchRequest& matchRequest) 509 { 510 auto queries = matchRequest.ruleSet.containerQueriesFor(ruleData); 511 510 512 if (queries.isEmpty()) 511 513 return true; 512 514 513 515 // "Style rules defined on an element inside multiple nested container queries apply when all of the wrapping container queries are true for that element." 514 ContainerQueryEvaluator evaluator(element(), m_pseudoElementRequest.pseudoId, m _selectorMatchingState);516 ContainerQueryEvaluator evaluator(element(), m_pseudoElementRequest.pseudoId, matchRequest.styleScopeOrdinal, m_selectorMatchingState); 515 517 for (auto* query : queries) { 516 518 if (!evaluator.evaluate(*query)) -
trunk/Source/WebCore/style/ElementRuleCollector.h
r291594 r292635 115 115 void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&); 116 116 bool ruleMatches(const RuleData&, unsigned& specificity, ScopeOrdinal); 117 bool containerQueriesMatch(const Vector<const FilteredContainerQuery*>&);117 bool containerQueriesMatch(const RuleData&, const MatchRequest&); 118 118 119 119 void sortMatchedRules();
Note: See TracChangeset
for help on using the changeset viewer.