Changeset 284865 in webkit


Ignore:
Timestamp:
Oct 26, 2021 7:55:58 AM (9 months ago)
Author:
Antti Koivisto
Message:

Fix ::part(foo):hover
https://bugs.webkit.org/show_bug.cgi?id=232301

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html: Added.
  • web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html: Added.
  • web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt: Added.
  • web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html: Added.
  • web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html: Added.
  • web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html: Added.
  • web-platform-tests/css/css-shadow-parts/w3c-import.log:

Source/WebCore:

We fail to match on shadow tree border if the right side of ::part() has other selectors.

Tests: imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html

  • css/CSSSelector.cpp:

(WebCore::CSSSelector::selectorText const):

  • css/CSSSelector.h:

Add a new ShadowPartDescendant relation type that behaves like the existing ShadowDescendant relation
except it is only used for ::part.

  • css/SelectorChecker.cpp:

(WebCore::SelectorChecker::matchRecursively const):

We can now identify the ::part case easily from the relation type.

(WebCore::canMatchHoverOrActiveInQuirksMode):

  • css/SelectorFilter.cpp:

(WebCore::collectSelectorHashes):

  • css/parser/CSSParserSelector.h:

(WebCore::CSSParserSelector::hasShadowDescendant const): Deleted.

  • css/parser/CSSSelectorParser.cpp:

(WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):

Use ShadowPartDescendant as appropriate.

  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):
(WebCore::SelectorCompiler::constructFragmentsInternal):

  • style/RuleFeature.cpp:

(WebCore::Style::RuleFeatureSet::computeNextMatchElement):

LayoutTests:

Location:
trunk
Files:
6 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r284859 r284865  
     12021-10-26  Antti Koivisto  <antti@apple.com>
     2
     3        Fix ::part(foo):hover
     4        https://bugs.webkit.org/show_bug.cgi?id=232301
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * TestExpectations:
     9
    1102021-10-26  Antti Koivisto  <antti@apple.com>
    211
  • trunk/LayoutTests/TestExpectations

    r284859 r284865  
    51925192# IPC test failing in Debug mode due to assert.
    51935193[ Debug ] ipc/send-invalid-message.html [ Skip ]
     5194
     5195imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html [ ImageOnlyFailure ]
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r284863 r284865  
     12021-10-26  Antti Koivisto  <antti@apple.com>
     2
     3        Fix ::part(foo):hover
     4        https://bugs.webkit.org/show_bug.cgi?id=232301
     5
     6        Reviewed by Alan Bujtas.
     7
     8        * web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html: Added.
     9        * web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html: Added.
     10        * web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.txt: Added.
     11        * web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html: Added.
     12        * web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html: Added.
     13        * web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html: Added.
     14        * web-platform-tests/css/css-shadow-parts/w3c-import.log:
     15
    1162021-10-26  Antti Koivisto  <antti@apple.com>
    217
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/w3c-import.log

    r264522 r284865  
    2727/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/idlharness.html
    2828/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/inner-host.html
     29/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class-expected.html
     30/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-nested-pseudo-class.html
    2931/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-placeholder-expected.html
    3032/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/interaction-with-placeholder.html
     
    3739/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-complex-selector-forward.html
    3840/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-complex-selector.html
     41/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo-expected.html
     42/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html
    3943/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/multiple-parts.html
    4044/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-name-idl.html
     45/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo-expected.html
     46/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/part-nested-pseudo.html
    4147/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/precedence-part-vs-part.html
    4248/LayoutTests/imported/w3c/web-platform-tests/css/css-shadow-parts/serialization.html
  • trunk/Source/WebCore/ChangeLog

    r284863 r284865  
     12021-10-26  Antti Koivisto  <antti@apple.com>
     2
     3        Fix ::part(foo):hover
     4        https://bugs.webkit.org/show_bug.cgi?id=232301
     5
     6        Reviewed by Alan Bujtas.
     7
     8        We fail to match on shadow tree border if the right side of ::part() has other selectors.
     9
     10        Tests: imported/w3c/web-platform-tests/css/css-shadow-parts/invalidation-part-pseudo.html
     11
     12        * css/CSSSelector.cpp:
     13        (WebCore::CSSSelector::selectorText const):
     14        * css/CSSSelector.h:
     15
     16        Add a new ShadowPartDescendant relation type that behaves like the existing ShadowDescendant relation
     17        except it is only used for ::part.
     18
     19        * css/SelectorChecker.cpp:
     20        (WebCore::SelectorChecker::matchRecursively const):
     21
     22        We can now identify the ::part case easily from the relation type.
     23
     24        (WebCore::canMatchHoverOrActiveInQuirksMode):
     25        * css/SelectorFilter.cpp:
     26        (WebCore::collectSelectorHashes):
     27        * css/parser/CSSParserSelector.h:
     28        (WebCore::CSSParserSelector::hasShadowDescendant const): Deleted.
     29        * css/parser/CSSSelectorParser.cpp:
     30        (WebCore::CSSSelectorParser::splitCompoundAtImplicitShadowCrossingCombinator):
     31
     32        Use ShadowPartDescendant as appropriate.
     33
     34        * cssjit/SelectorCompiler.cpp:
     35        (WebCore::SelectorCompiler::fragmentRelationForSelectorRelation):
     36        (WebCore::SelectorCompiler::constructFragmentsInternal):
     37        * style/RuleFeature.cpp:
     38        (WebCore::Style::RuleFeatureSet::computeNextMatchElement):
     39
    1402021-10-26  Antti Koivisto  <antti@apple.com>
    241
  • trunk/Source/WebCore/css/CSSSelector.cpp

    r284863 r284865  
    823823#endif
    824824        case CSSSelector::ShadowDescendant:
     825        case CSSSelector::ShadowPartDescendant:
    825826            builder.append(rightSide);
    826827            return tagHistory->selectorText(builder.toString());
  • trunk/Source/WebCore/css/CSSSelector.h

    r281503 r284865  
    8787            DirectAdjacent,
    8888            IndirectAdjacent,
    89             ShadowDescendant
     89            ShadowDescendant,
     90            ShadowPartDescendant
    9091        };
    9192
  • trunk/Source/WebCore/css/SelectorChecker.cpp

    r283851 r284865  
    7878    bool hasSelectionPseudo { false };
    7979    bool mayMatchHostPseudoClass { false };
    80 
    8180};
    8281
     
    410409        }
    411410    case CSSSelector::ShadowDescendant:
     411    case CSSSelector::ShadowPartDescendant:
    412412        {
    413413            // When matching foo::part(bar) we skip directly to the tree of element 'foo'.
    414             bool isPart = context.selector->match() == CSSSelector::PseudoElement && context.selector->pseudoElementType() == CSSSelector::PseudoElementPart;
    415             auto* shadowHost = isPart ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost();
     414            auto* shadowHost = relation == CSSSelector::ShadowPartDescendant ? checkingContext.shadowHostInPartRuleScope : context.element->shadowHost();
    416415            if (!shadowHost)
    417416                return MatchResult::fails(Match::SelectorFailsCompletely);
     
    425424        }
    426425    }
    427 
    428426
    429427    ASSERT_NOT_REACHED();
     
    600598
    601599        auto relation = selector->relation();
    602         if (relation == CSSSelector::ShadowDescendant)
     600        if (relation == CSSSelector::ShadowDescendant || relation == CSSSelector::ShadowPartDescendant)
    603601            return true;
    604602
  • trunk/Source/WebCore/css/SelectorFilter.cpp

    r284078 r284865  
    195195        case CSSSelector::IndirectAdjacent:
    196196        case CSSSelector::ShadowDescendant:
     197        case CSSSelector::ShadowPartDescendant:
    197198            skipOverSubselectors = true;
    198199            break;
  • trunk/Source/WebCore/css/parser/CSSParserSelector.h

    r281295 r284865  
    7272    bool isPseudoElementCueFunction() const;
    7373
    74     bool hasShadowDescendant() const;
    7574    bool matchesPseudoElement() const;
    7675
     
    9796};
    9897
    99 inline bool CSSParserSelector::hasShadowDescendant() const
    100 {
    101     return m_selector->relation() == CSSSelector::ShadowDescendant;
    102 }
    103 
    10498inline bool CSSParserSelector::needsImplicitShadowCombinatorForMatching() const
    10599{
  • trunk/Source/WebCore/css/parser/CSSSelectorParser.cpp

    r283254 r284865  
    10691069        secondCompound = splitAfter->releaseTagHistory();
    10701070
    1071     secondCompound->appendTagHistory(CSSSelector::ShadowDescendant, WTFMove(compoundSelector));
     1071    secondCompound->appendTagHistory(isPart ? CSSSelector::ShadowPartDescendant : CSSSelector::ShadowDescendant, WTFMove(compoundSelector));
    10721072    return secondCompound;
    10731073}
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r283970 r284865  
    501501    case CSSSelector::Subselector:
    502502    case CSSSelector::ShadowDescendant:
     503    case CSSSelector::ShadowPartDescendant:
    503504        ASSERT_NOT_REACHED();
    504505    }
     
    13231324            continue;
    13241325
    1325         if (relation == CSSSelector::ShadowDescendant && !selector->isLastInTagHistory())
     1326        if ((relation == CSSSelector::ShadowDescendant || relation == CSSSelector::ShadowPartDescendant) && !selector->isLastInTagHistory())
    13261327            return FunctionType::CannotCompile;
    13271328
  • trunk/Source/WebCore/style/RuleFeature.cpp

    r279365 r284865  
    8585            return matchElement == MatchElement::Subject ? MatchElement::DirectSibling : MatchElement::IndirectSibling;
    8686        case CSSSelector::ShadowDescendant:
     87        case CSSSelector::ShadowPartDescendant:
    8788            return MatchElement::Host;
    8889        };
     
    9899        return matchElement == MatchElement::Parent ? MatchElement::ParentSibling : MatchElement::AncestorSibling;
    99100    case CSSSelector::ShadowDescendant:
     101    case CSSSelector::ShadowPartDescendant:
    100102        return MatchElement::Host;
    101103    };
Note: See TracChangeset for help on using the changeset viewer.