[webkit-changes] [WebKit/WebKit] f658df: [CSS] Scoped style rules accept relative selector ...

Matthieu Dubet noreply at github.com
Thu Nov 30 05:46:47 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: f658dff67d19b38c9e0ddff921d51fd7d8f722fb
      https://github.com/WebKit/WebKit/commit/f658dff67d19b38c9e0ddff921d51fd7d8f722fb
  Author: Matthieu Dubet <m_dubet at apple.com>
  Date:   2023-11-30 (Thu, 30 Nov 2023)

  Changed paths:
    M LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-cssom.html
    M LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-specificity-expected.txt
    M LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-visited-cssom-expected.txt
    M Source/WebCore/css/CSSSelector.cpp
    M Source/WebCore/css/CSSSelector.h
    M Source/WebCore/css/StyleRule.h
    M Source/WebCore/css/parser/CSSParserImpl.cpp
    M Source/WebCore/css/parser/CSSParserImpl.h
    M Source/WebCore/css/parser/CSSParserSelector.cpp
    M Source/WebCore/css/parser/CSSParserSelector.h
    M Source/WebCore/css/parser/CSSSelectorParser.cpp

  Log Message:
  -----------
  [CSS] Scoped style rules accept relative selector list
https://bugs.webkit.org/show_bug.cgi?id=265289
rdar://118749004

Reviewed by Antti Koivisto.

Like nested style rule, scoped style rules accept a relative selector
list as the prelude for their rule list.
The implicit ":scope" or "&" in their prelude has to be added explicitely when necessary.

https://drafts.csswg.org/css-cascade-6/#scoped-style-rules

* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-cssom.html:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-nesting-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-specificity-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-cascade/scope-visited-cssom-expected.txt:

For the moment, until the @scope feature is more complete, those tests passing or failing don't mean anything.

* Source/WebCore/css/CSSSelector.cpp:
(WebCore::CSSSelector::hasExplicitPseudoClassScope const):
* Source/WebCore/css/CSSSelector.h:
* Source/WebCore/css/StyleRule.h:
(WebCore::StyleRuleBase::isGroupRule const):
* Source/WebCore/css/parser/CSSParserImpl.cpp:
(WebCore::CSSParserImpl::consumeRegularRuleList):
(WebCore::CSSParserImpl::consumeScopeRule):
(WebCore::CSSParserImpl::consumeStyleRule):
* Source/WebCore/css/parser/CSSParserImpl.h:
(WebCore::CSSParserImpl::isStyleNestedContext):
(WebCore::CSSParserImpl::isNestedContext):
* Source/WebCore/css/parser/CSSParserSelector.cpp:
(WebCore::CSSParserSelector::hasExplicitPseudoClassScope const):
(WebCore::CSSParserSelector::appendTagHistoryAsRelative):
* Source/WebCore/css/parser/CSSParserSelector.h:
* Source/WebCore/css/parser/CSSSelectorParser.cpp:
(WebCore::CSSSelectorParser::consumeNestedComplexSelector):

We move the code to add the prepend the implicit selector from CSSSelectorParser
to CSSParserImpl where we know the type of the parent rule
(because we need to preprend either & or :scope)

(WebCore::CSSSelectorParser::resolveNestingParent):

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




More information about the webkit-changes mailing list