Changeset 285100 in webkit


Ignore:
Timestamp:
Oct 31, 2021 11:20:41 PM (9 months ago)
Author:
Antti Koivisto
Message:

Fix :host invalidation when combined with pseudo classes in descendant position
https://bugs.webkit.org/show_bug.cgi?id=232544

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

  • web-platform-tests/css/css-scoping/host-functional-descendant-invalidation-expected.txt:

Source/WebCore:

  • style/RuleSet.cpp:

(WebCore::Style::isHostSelectorMatchingInShadowTree):

Make more readable and accurate.

(WebCore::Style::RuleSet::addRule):

Compute m_hasHostPseudoClassRulesMatchingInShadowTree before bailing out for pseudo elements.

Location:
trunk
Files:
4 edited

Legend:

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

    r285084 r285100  
     12021-10-31  Antti Koivisto  <antti@apple.com>
     2
     3        Fix :host invalidation when combined with pseudo classes in descendant position
     4        https://bugs.webkit.org/show_bug.cgi?id=232544
     5
     6        Reviewed by Simon Fraser.
     7
     8        * web-platform-tests/css/css-scoping/host-functional-descendant-invalidation-expected.txt:
     9
    1102021-10-30  Brandon Stewart  <brandonstewart@apple.com>
    211
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-scoping/host-functional-descendant-invalidation-expected.txt

    r232903 r285100  
    11
    2 FAIL CSS Test: element style is correctly updated for rule with :host(..) assert_equals: expected "rgb(0, 128, 0)" but got "rgb(255, 0, 0)"
     2PASS CSS Test: element style is correctly updated for rule with :host(..)
    33
  • trunk/Source/WebCore/ChangeLog

    r285099 r285100  
     12021-10-31  Antti Koivisto  <antti@apple.com>
     2
     3        Fix :host invalidation when combined with pseudo classes in descendant position
     4        https://bugs.webkit.org/show_bug.cgi?id=232544
     5
     6        Reviewed by Simon Fraser.
     7
     8        * style/RuleSet.cpp:
     9        (WebCore::Style::isHostSelectorMatchingInShadowTree):
     10
     11        Make more readable and accurate.
     12
     13        (WebCore::Style::RuleSet::addRule):
     14
     15        Compute m_hasHostPseudoClassRulesMatchingInShadowTree before bailing out for pseudo elements.
     16
    1172021-10-31  Fujii Hironori  <Hironori.Fujii@sony.com>
    218
  • trunk/Source/WebCore/style/RuleSet.cpp

    r283508 r285100  
    7272static bool isHostSelectorMatchingInShadowTree(const CSSSelector& startSelector)
    7373{
    74     auto* leftmostSelector = &startSelector;
    75     bool hasDescendantOrChildRelation = false;
    76     while (auto* previous = leftmostSelector->tagHistory()) {
    77         hasDescendantOrChildRelation = leftmostSelector->hasDescendantOrChildRelation();
    78         leftmostSelector = previous;
    79     }
    80     if (!hasDescendantOrChildRelation)
    81         return false;
    82 
    83     return leftmostSelector->match() == CSSSelector::PseudoClass && leftmostSelector->pseudoClassType() == CSSSelector::PseudoClassHost;
     74    bool hasOnlyOneCompound = true;
     75    bool hasHostInLastCompound = false;
     76    for (auto* selector = &startSelector; selector; selector = selector->tagHistory()) {
     77        if (selector->match() == CSSSelector::PseudoClass && selector->pseudoClassType() == CSSSelector::PseudoClassHost)
     78            hasHostInLastCompound = true;
     79        if (selector->tagHistory() && selector->relation() != CSSSelector::Subselector) {
     80            hasOnlyOneCompound = false;
     81            hasHostInLastCompound = false;
     82        }
     83    }
     84    return !hasOnlyOneCompound && hasHostInLastCompound;
    8485}
    8586
     
    198199    } while (selector);
    199200
     201    if (!m_hasHostPseudoClassRulesMatchingInShadowTree)
     202        m_hasHostPseudoClassRulesMatchingInShadowTree = isHostSelectorMatchingInShadowTree(*ruleData.selector());
     203
    200204#if ENABLE(VIDEO)
    201205    if (cuePseudoElementSelector) {
     
    233237        return;
    234238    }
    235 
    236     if (!m_hasHostPseudoClassRulesMatchingInShadowTree)
    237         m_hasHostPseudoClassRulesMatchingInShadowTree = isHostSelectorMatchingInShadowTree(*ruleData.selector());
    238239
    239240    if (hostPseudoClassSelector) {
Note: See TracChangeset for help on using the changeset viewer.