[webkit-changes] [WebKit/WebKit] ae0d40: Prevent :has(:scope ...) from breaking the :has scope

Cameron McCormack noreply at github.com
Fri Sep 8 13:07:42 PDT 2023


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

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-argument-with-explicit-scope-expected.txt
    M Source/WebCore/css/CSSSelector.cpp
    M Source/WebCore/css/CSSSelector.h
    M Source/WebCore/css/SelectorChecker.cpp
    M Source/WebCore/css/SelectorChecker.h
    M Source/WebCore/css/parser/CSSSelectorParser.cpp
    M Source/WebCore/cssjit/SelectorCompiler.cpp
    M Source/WebCore/style/ChildChangeInvalidation.cpp

  Log Message:
  -----------
  Prevent :has(:scope ...) from breaking the :has scope
https://bugs.webkit.org/show_bug.cgi?id=261320
rdar://problem/115158183

Reviewed by Antti Koivisto.

This content:

<div id=x><span></span></div>
<script>
alert(x.matches(":has(:scope span)"));
</script>

currently alerts "true", but it should show "false".

We treat :scope as something that can match the :has() scope, but that
is not supported by the spec. Instead it should only match against the
scope induced by the matches() call.

We also need to unconditionally insert the implicit pseudo-class at the
start of the :has() selector argument that matches the :has scope.
Currently we skip this if :scope is present in the select argument
(irrelevant) or if the :has relation is DescendantSpace. But we still
need to check for the :has scope element in these cases.

* LayoutTests/imported/w3c/web-platform-tests/css/selectors/has-argument-with-explicit-scope-expected.txt:
* Source/WebCore/css/CSSSelector.cpp:
(WebCore::simpleSelectorSpecificity):
(WebCore::CSSSelector::selectorText const):
* Source/WebCore/css/CSSSelector.h:
* Source/WebCore/css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne const):
(WebCore::SelectorChecker::matchHasPseudoClass const):
* Source/WebCore/css/SelectorChecker.h:
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumeRelativeScopeSelector):
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::addPseudoClassType):
* Source/WebCore/style/ChildChangeInvalidation.cpp:
(WebCore::Style::ChildChangeInvalidation::invalidateForChangedElement):

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




More information about the webkit-changes mailing list