Changeset 292819 in webkit
- Timestamp:
- Apr 13, 2022 12:12:47 PM (3 months ago)
- Location:
- trunk
- Files:
-
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSPrimitiveValue.cpp (modified) (1 diff)
-
Source/WebCore/style/ContainerQueryEvaluator.cpp (modified) (5 diffs)
-
Source/WebCore/style/ContainerQueryEvaluator.h (modified) (2 diffs)
-
Source/WebCore/style/ElementRuleCollector.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r292817 r292819 1 2022-04-13 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Correct container selection for pseudo-elements 4 https://bugs.webkit.org/show_bug.cgi?id=239279 5 6 Reviewed by Simon Fraser. 7 8 * TestExpectations: 9 1 10 2022-04-13 Alan Bujtas <zalan@apple.com> 2 11 -
trunk/LayoutTests/TestExpectations
r292720 r292819 4702 4702 # Container queries 4703 4703 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-layout-container-001.https.html [ ImageOnlyFailure ] 4704 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.html [ ImageOnlyFailure ]4705 4704 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/svg-foreignobject-no-size-container.html [ Skip ] 4706 4705 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ] -
trunk/Source/WebCore/ChangeLog
r292817 r292819 1 2022-04-13 Antti Koivisto <antti@apple.com> 2 3 [CSS Container Queries] Correct container selection for pseudo-elements 4 https://bugs.webkit.org/show_bug.cgi?id=239279 5 6 Reviewed by Simon Fraser. 7 8 The element itself may be the container for its pseudo-elements. 9 10 * css/CSSPrimitiveValue.cpp: 11 (WebCore::CSSPrimitiveValue::computeNonCalcLengthDouble): 12 * style/ContainerQueryEvaluator.cpp: 13 (WebCore::Style::ContainerQueryEvaluator::ContainerQueryEvaluator): 14 (WebCore::Style::ContainerQueryEvaluator::selectContainer const): 15 (WebCore::Style::ContainerQueryEvaluator::selectContainer): 16 * style/ContainerQueryEvaluator.h: 17 18 Instead of passing the pseudo-element being matched, pass a container selection mode flag. The exact pseudo-element type 19 doesn't matter. 20 21 * style/ElementRuleCollector.cpp: 22 (WebCore::Style::ElementRuleCollector::containerQueriesMatch): 23 24 We need to use the pseudo-element mode when matching a rule that matches a pseudo-element, even when we are not actually resolving 25 the pseudo element. This is because regular element rule matching sets the style bits that indicate what pseudo-elements the 26 element has. 27 1 28 2022-04-13 Alan Bujtas <zalan@apple.com> 2 29 -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r291863 r292819 827 827 return nullptr; 828 828 // FIXME: Use cached query containers when available. 829 auto* container = Style::ContainerQueryEvaluator::selectContainer(axis, nullString(), *conversionData.element() , nullptr);829 auto* container = Style::ContainerQueryEvaluator::selectContainer(axis, nullString(), *conversionData.element()); 830 830 if (!container) 831 831 return nullptr; -
trunk/Source/WebCore/style/ContainerQueryEvaluator.cpp
r292635 r292819 45 45 }; 46 46 47 ContainerQueryEvaluator::ContainerQueryEvaluator(const Element& element, PseudoId pseudoId, ScopeOrdinal scopeOrdinal, SelectorMatchingState* selectorMatchingState)47 ContainerQueryEvaluator::ContainerQueryEvaluator(const Element& element, SelectionMode selectionMode, ScopeOrdinal scopeOrdinal, SelectorMatchingState* selectorMatchingState) 48 48 : m_element(element) 49 , m_ pseudoId(pseudoId)49 , m_selectionMode(selectionMode) 50 50 , m_scopeOrdinal(scopeOrdinal) 51 51 , m_selectorMatchingState(selectorMatchingState) … … 83 83 auto* cachedQueryContainers = m_selectorMatchingState ? &m_selectorMatchingState->queryContainers : nullptr; 84 84 85 auto* container = selectContainer(filteredContainerQuery.axisFilter, filteredContainerQuery.nameFilter, m_element.get(), cachedQueryContainers, m_pseudoId, m_scopeOrdinal);85 auto* container = selectContainer(filteredContainerQuery.axisFilter, filteredContainerQuery.nameFilter, m_element.get(), m_selectionMode, m_scopeOrdinal, cachedQueryContainers); 86 86 if (!container) 87 87 return { }; … … 90 90 } 91 91 92 const Element* ContainerQueryEvaluator::selectContainer(OptionSet<CQ::Axis> axes, const String& name, const Element& element, const CachedQueryContainers* cachedQueryContainers, PseudoId pseudoId, ScopeOrdinal scopeOrdinal)92 const Element* ContainerQueryEvaluator::selectContainer(OptionSet<CQ::Axis> axes, const String& name, const Element& element, SelectionMode selectionMode, ScopeOrdinal scopeOrdinal, const CachedQueryContainers* cachedQueryContainers) 93 93 { 94 94 // "For each element, the query container to be queried is selected from among the element’s … … 145 145 } 146 146 147 if (selectionMode == SelectionMode::PseudoElement) { 148 if (isContainerForQuery(element)) 149 return &element; 150 } 151 147 152 if (cachedQueryContainers) { 148 153 for (auto& container : makeReversedRange(*cachedQueryContainers)) { … … 151 156 } 152 157 return { }; 153 }154 155 if (pseudoId != PseudoId::None) {156 if (isContainerForQuery(element))157 return &element;158 158 } 159 159 -
trunk/Source/WebCore/style/ContainerQueryEvaluator.h
r292635 r292819 40 40 class ContainerQueryEvaluator { 41 41 public: 42 ContainerQueryEvaluator(const Element&, PseudoId, ScopeOrdinal, SelectorMatchingState*); 42 enum class SelectionMode : bool { Element, PseudoElement }; 43 ContainerQueryEvaluator(const Element&, SelectionMode, ScopeOrdinal, SelectorMatchingState*); 43 44 44 45 bool evaluate(const FilteredContainerQuery&) const; 45 46 46 static const Element* selectContainer(OptionSet<CQ::Axis>, const String& name, const Element&, const CachedQueryContainers*, PseudoId = PseudoId::None, ScopeOrdinal = ScopeOrdinal::Element);47 static const Element* selectContainer(OptionSet<CQ::Axis>, const String& name, const Element&, SelectionMode = SelectionMode::Element, ScopeOrdinal = ScopeOrdinal::Element, const CachedQueryContainers* = nullptr); 47 48 48 49 private: … … 55 56 56 57 const Ref<const Element> m_element; 57 const PseudoId m_pseudoId;58 ScopeOrdinal m_scopeOrdinal;58 const SelectionMode m_selectionMode; 59 const ScopeOrdinal m_scopeOrdinal; 59 60 SelectorMatchingState* m_selectorMatchingState; 60 61 }; -
trunk/Source/WebCore/style/ElementRuleCollector.cpp
r292635 r292819 513 513 return true; 514 514 515 // Style bits indicating which pseudo-elements match are set during regular element matching. Container queries need to be evaluate in the right mode. 516 auto selectionMode = ruleData.canMatchPseudoElement() ? ContainerQueryEvaluator::SelectionMode::PseudoElement : ContainerQueryEvaluator::SelectionMode::Element; 517 515 518 // "Style rules defined on an element inside multiple nested container queries apply when all of the wrapping container queries are true for that element." 516 ContainerQueryEvaluator evaluator(element(), m_pseudoElementRequest.pseudoId, matchRequest.styleScopeOrdinal, m_selectorMatchingState);519 ContainerQueryEvaluator evaluator(element(), selectionMode, matchRequest.styleScopeOrdinal, m_selectorMatchingState); 517 520 for (auto* query : queries) { 518 521 if (!evaluator.evaluate(*query))
Note: See TracChangeset
for help on using the changeset viewer.