[webkit-changes] [WebKit/WebKit] 630e53: Invalidate :has() with nested positional pseudo-cl...

Cameron McCormack noreply at github.com
Thu Sep 7 23:32:58 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 630e5323e6dcbd3c95adb5b8caedb9d8038b445b
      https://github.com/WebKit/WebKit/commit/630e5323e6dcbd3c95adb5b8caedb9d8038b445b
  Author: Cameron McCormack <heycam at apple.com>
  Date:   2023-09-07 (Thu, 07 Sep 2023)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/child-indexed-pseudo-classes-in-has-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/typed-child-indexed-pseudo-classes-in-has-expected.txt
    M Source/WebCore/css/SelectorChecker.cpp
    M Source/WebCore/style/ChildChangeInvalidation.cpp
    M Source/WebCore/style/ChildChangeInvalidation.h

  Log Message:
  -----------
  Invalidate :has() with nested positional pseudo-class selectors correctly
https://bugs.webkit.org/show_bug.cgi?id=253943
rdar://106768224

Reviewed by Antti Koivisto.

ChildChangeInvalidation currently handles :has() invalidation by
traversing the newly inserted or removed subtree and checking whether
there are any :has() rules whose nested selector could match the elements
in the subtree. This is not sufficient to invalidate rules like:

:has(:first-child)
:has(:nth-child(2n+1))
:has(:nth-child(n2+1 of .foo))

When the parent of the changed subtree has any of these flags:

ChildrenAffectedByFirstChildRules
ChildrenAffectedByLastChildRules
ChildrenAffectedByForwardPositionalRules
ChildrenAffectedByBackwardPositionalRules

we must invalidate some siblings of the subtree, to determine if the
:has() selector might have changed.

The "check the existing sibling" optimization that
ChildChangeInvalidation::invalidateForChangedElement does is not valid
if it's called with a sibling of the changed subtree, so we pass in
a ChangedElementRelation value to control whether to skip it.

* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/child-indexed-pseudo-classes-in-has-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/typed-child-indexed-pseudo-classes-in-has-expected.txt:
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::matchHasPseudoClass const):
* Source/WebCore/style/ChildChangeInvalidation.cpp:
(WebCore::Style::ChildChangeInvalidation::invalidateForChangedElement):
(WebCore::Style::ChildChangeInvalidation::invalidateForHasBeforeMutation):
(WebCore::Style::ChildChangeInvalidation::invalidateForHasAfterMutation):
(WebCore::Style::ChildChangeInvalidation::traverseRemovedElements):
(WebCore::Style::ChildChangeInvalidation::traverseAddedElements):
(WebCore::Style::ChildChangeInvalidation::traverseRemainingExistingSiblings):
* Source/WebCore/style/ChildChangeInvalidation.h:

Canonical link: https://commits.webkit.org/267771@main




More information about the webkit-changes mailing list