Changeset 281692 in webkit


Ignore:
Timestamp:
Aug 27, 2021 6:21:29 AM (11 months ago)
Author:
emilio
Message:

Don't forget about the outer selector when matching ::slotted().
https://bugs.webkit.org/show_bug.cgi?id=229438

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-scoping/slotted-specificity-002-expected.html: Added.
  • web-platform-tests/css/css-scoping/slotted-specificity-002.html: Added.
  • web-platform-tests/css/css-scoping/w3c-import.log:

Source/WebCore:

Test: imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity-002.html

  • css/CSSSelector.cpp:

(WebCore::simpleSelectorSpecificityInternal):

  • style/ElementRuleCollector.cpp:

(WebCore::Style::ElementRuleCollector::ruleMatches):

Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r281689 r281692  
     12021-08-27  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Don't forget about the outer selector when matching ::slotted().
     4        https://bugs.webkit.org/show_bug.cgi?id=229438
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * web-platform-tests/css/css-scoping/slotted-specificity-002-expected.html: Added.
     9        * web-platform-tests/css/css-scoping/slotted-specificity-002.html: Added.
     10        * web-platform-tests/css/css-scoping/w3c-import.log:
     11
    1122021-08-27  Martin Robinson  <mrobinson@webkit.org>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/w3c-import.log

    r264522 r281692  
    135135/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-placeholder.html
    136136/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-slot.html
     137/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity-002-expected.html
     138/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity-002.html
    137139/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity-expected.html
    138140/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity.html
  • trunk/Source/WebCore/ChangeLog

    r281691 r281692  
     12021-08-27  Emilio Cobos Álvarez  <emilio@crisal.io>
     2
     3        Don't forget about the outer selector when matching ::slotted().
     4        https://bugs.webkit.org/show_bug.cgi?id=229438
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Test: imported/w3c/web-platform-tests/css/css-scoping/slotted-specificity-002.html
     9
     10        * css/CSSSelector.cpp:
     11        (WebCore::simpleSelectorSpecificityInternal):
     12        * style/ElementRuleCollector.cpp:
     13        (WebCore::Style::ElementRuleCollector::ruleMatches):
     14
    1152021-08-27  Andres Gonzalez  <andresg_22@apple.com>
    216
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r281503 r281692  
    147147        return (simpleSelector.tagQName().localName() != starAtom()) ? static_cast<unsigned>(SelectorSpecificityIncrement::ClassC) : 0;
    148148    case CSSSelector::PseudoElement:
     149        // Slotted only competes with other slotted selectors for specificity,
     150        // so whether we add the ClassC specificity shouldn't be observable.
     151        if (simpleSelector.pseudoElementType() == CSSSelector::PseudoElementSlotted)
     152            return maxSpecificity(*simpleSelector.selectorList());
    149153        return static_cast<unsigned>(SelectorSpecificityIncrement::ClassC);
    150154    case CSSSelector::Unknown:
  • trunk/Source/WebCore/style/ElementRuleCollector.cpp

    r278277 r281692  
    485485    {
    486486        auto* selector = ruleData.selector();
     487        auto* selectorForMatching = selector;
    487488        if (m_isMatchingSlottedPseudoElements) {
    488             selector = findSlottedPseudoElementSelector(ruleData.selector());
    489             if (!selector)
     489            selectorForMatching = findSlottedPseudoElementSelector(ruleData.selector());
     490            if (!selectorForMatching)
    490491                return false;
    491492        }
    492493        // Slow path.
    493494        SelectorChecker selectorChecker(element().document());
    494         selectorMatches = selectorChecker.match(*selector, element(), context);
     495        selectorMatches = selectorChecker.match(*selectorForMatching, element(), context);
    495496        if (selectorMatches)
    496497            specificity = selector->computeSpecificity();
Note: See TracChangeset for help on using the changeset viewer.