Changeset 286433 in webkit
- Timestamp:
- Dec 2, 2021 9:36:50 AM (8 months ago)
- Location:
- trunk
- Files:
-
- 8 added
- 6 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-adjacent-position-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-adjacent-position.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-ancestor-position-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-ancestor-position.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-parent-position-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-parent-position.html (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-sibling-position-expected.txt (added)
-
LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-sibling-position.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/style/ChildChangeInvalidation.cpp (modified) (3 diffs)
-
Source/WebCore/style/RuleFeature.cpp (modified) (4 diffs)
-
Source/WebCore/style/RuleFeature.h (modified) (2 diffs)
-
Source/WebCore/style/StyleInvalidator.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r286427 r286433 1 2021-12-02 Antti Koivisto <antti@apple.com> 2 3 [:has() pseudo-class] Invalidation in non-subject position 4 https://bugs.webkit.org/show_bug.cgi?id=233758 5 6 Reviewed by Simon Fraser. 7 8 * web-platform-tests/css/selectors/invalidation/has-in-adjacent-position-expected.txt: Added. 9 * web-platform-tests/css/selectors/invalidation/has-in-adjacent-position.html: Added. 10 * web-platform-tests/css/selectors/invalidation/has-in-ancestor-position-expected.txt: Added. 11 * web-platform-tests/css/selectors/invalidation/has-in-ancestor-position.html: Added. 12 * web-platform-tests/css/selectors/invalidation/has-in-parent-position-expected.txt: Added. 13 * web-platform-tests/css/selectors/invalidation/has-in-parent-position.html: Added. 14 * web-platform-tests/css/selectors/invalidation/has-in-sibling-position-expected.txt: Added. 15 * web-platform-tests/css/selectors/invalidation/has-in-sibling-position.html: Added. 16 1 17 2021-12-02 Andreu Botella <andreu@andreubotella.com> 2 18 -
trunk/Source/WebCore/ChangeLog
r286427 r286433 1 2021-12-02 Antti Koivisto <antti@apple.com> 2 3 [:has() pseudo-class] Invalidation in non-subject position 4 https://bugs.webkit.org/show_bug.cgi?id=233758 5 6 Reviewed by Simon Fraser. 7 8 Invalidation for selectors like '.ancestor:has(.foo) #target'. 9 10 Tests: imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-adjacent-position.html 11 imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-ancestor-position.html 12 imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-parent-position.html 13 imported/w3c/web-platform-tests/css/selectors/invalidation/has-in-sibling-position.html 14 15 * style/ChildChangeInvalidation.cpp: 16 (WebCore::Style::ChildChangeInvalidation::invalidateForChangedElement): 17 (WebCore::Style::needsTraversal): 18 (WebCore::Style::needsDescendantTraversal): 19 * style/RuleFeature.cpp: 20 (WebCore::Style::isSiblingOrSubject): 21 (WebCore::Style::isHasPseudoClassMatchElement): 22 (WebCore::Style::computeHasPseudoClassMatchElement): 23 (WebCore::Style::computeSubSelectorMatchElement): 24 25 Use new MatchElement::HasNonSubject as a catch-all for cases where :has() is in a non-subject position. 26 In the future this can be optimized better by computing both the :has match element and the overall 27 match element separately. 28 29 * style/RuleFeature.h: 30 * style/StyleInvalidator.cpp: 31 (WebCore::Style::Invalidator::invalidateStyleWithMatchElement): 32 33 Worst-case invalidation. 34 1 35 2021-12-02 Andreu Botella <andreu@andreubotella.com> 2 36 -
trunk/Source/WebCore/style/ChildChangeInvalidation.cpp
r286365 r286433 76 76 if (!isHasPseudoClassMatchElement(invalidationRuleSet.matchElement)) 77 77 continue; 78 if (isDescendant && invalidationRuleSet.matchElement != MatchElement::HasDescendant) 79 continue; 78 if (isDescendant) { 79 // Elements deeper in the tree can't affect anything except when :has() selector uses descendant combinator. 80 if (invalidationRuleSet.matchElement != MatchElement::HasDescendant && invalidationRuleSet.matchElement != MatchElement::HasNonSubject) 81 continue; 82 } 80 83 Invalidator::addToMatchElementRuleSets(matchElementRuleSets, invalidationRuleSet); 81 84 } … … 114 117 if (features.usesMatchElement(MatchElement::HasSiblingDescendant)) 115 118 return true; 119 if (features.usesMatchElement(MatchElement::HasNonSubject)) 120 return true; 116 121 return features.usesMatchElement(MatchElement::HasSibling) && childChange.previousSiblingElement; 117 122 }; … … 119 124 static bool needsDescendantTraversal(const RuleFeatureSet& features) 120 125 { 126 if (features.usesMatchElement(MatchElement::HasNonSubject)) 127 return true; 121 128 return features.usesMatchElement(MatchElement::HasDescendant) || features.usesMatchElement(MatchElement::HasSiblingDescendant); 122 129 }; -
trunk/Source/WebCore/style/RuleFeature.cpp
r286365 r286433 54 54 case MatchElement::HasDescendant: 55 55 case MatchElement::HasSiblingDescendant: 56 case MatchElement::HasNonSubject: 56 57 return false; 57 58 } … … 67 68 case MatchElement::HasSibling: 68 69 case MatchElement::HasSiblingDescendant: 70 case MatchElement::HasNonSubject: 69 71 return true; 70 72 default: … … 158 160 case MatchElement::HasSibling: 159 161 case MatchElement::HasSiblingDescendant: 162 case MatchElement::HasNonSubject: 160 163 case MatchElement::Host: 161 164 ASSERT_NOT_REACHED(); … … 177 180 return MatchElement::Host; 178 181 179 if (type == CSSSelector::PseudoClassHas) 182 if (type == CSSSelector::PseudoClassHas) { 183 if (matchElement != MatchElement::Subject) 184 return MatchElement::HasNonSubject; 180 185 return computeHasPseudoClassMatchElement(childSelector); 186 } 181 187 } 182 188 if (selector.match() == CSSSelector::PseudoElement) { -
trunk/Source/WebCore/style/RuleFeature.h
r286365 r286433 37 37 class RuleData; 38 38 39 // FIXME: Has* values should be separated so we could describe both the :has() argument and its position in the selector. 39 40 enum class MatchElement : uint8_t { 40 41 Subject, … … 50 51 HasSibling, 51 52 HasSiblingDescendant, 53 HasNonSubject, // FIXME: This is a catch-all for cases where :has() is in non-subject position. 52 54 Host 53 55 }; -
trunk/Source/WebCore/style/StyleInvalidator.cpp
r286365 r286433 347 347 break; 348 348 } 349 case MatchElement::HasNonSubject: { 350 SelectorMatchingState selectorMatchingState; 351 invalidateStyleForDescendants(*element.document().documentElement(), &selectorMatchingState); 352 break; 353 } 349 354 case MatchElement::Host: 350 355 invalidateInShadowTreeIfNeeded(element);
Note: See TracChangeset
for help on using the changeset viewer.