Title: [285269] trunk/Source/WebCore
Revision
285269
Author
an...@apple.com
Date
2021-11-04 11:06:22 -0700 (Thu, 04 Nov 2021)

Log Message

Remove isMatchingHostPseudoClass state from ElementRuleCollector
https://bugs.webkit.org/show_bug.cgi?id=232715

Reviewed by Simon Fraser.

Style scope ordinal that we already pass to SelectorChecker contains the same information.

* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::match const):

Check the ordinal.

(WebCore::SelectorChecker::matchHostPseudoClass const):

Just check for shadow root as it is hard to reason why the assert is correct.

* css/SelectorChecker.h:
* style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::matchHostPseudoClassRules):
(WebCore::Style::ElementRuleCollector::ruleMatches):
* style/ElementRuleCollector.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285268 => 285269)


--- trunk/Source/WebCore/ChangeLog	2021-11-04 17:53:07 UTC (rev 285268)
+++ trunk/Source/WebCore/ChangeLog	2021-11-04 18:06:22 UTC (rev 285269)
@@ -1,5 +1,29 @@
 2021-11-04  Antti Koivisto  <an...@apple.com>
 
+        Remove isMatchingHostPseudoClass state from ElementRuleCollector
+        https://bugs.webkit.org/show_bug.cgi?id=232715
+
+        Reviewed by Simon Fraser.
+
+        Style scope ordinal that we already pass to SelectorChecker contains the same information.
+
+        * css/SelectorChecker.cpp:
+        (WebCore::SelectorChecker::match const):
+
+        Check the ordinal.
+
+        (WebCore::SelectorChecker::matchHostPseudoClass const):
+
+        Just check for shadow root as it is hard to reason why the assert is correct.
+
+        * css/SelectorChecker.h:
+        * style/ElementRuleCollector.cpp:
+        (WebCore::Style::ElementRuleCollector::matchHostPseudoClassRules):
+        (WebCore::Style::ElementRuleCollector::ruleMatches):
+        * style/ElementRuleCollector.h:
+
+2021-11-04  Antti Koivisto  <an...@apple.com>
+
         :host::part(foo) selector does not select elements inside shadow roots
         https://bugs.webkit.org/show_bug.cgi?id=232261
         <rdar://problem/84894922>

Modified: trunk/Source/WebCore/css/SelectorChecker.cpp (285268 => 285269)


--- trunk/Source/WebCore/css/SelectorChecker.cpp	2021-11-04 17:53:07 UTC (rev 285268)
+++ trunk/Source/WebCore/css/SelectorChecker.cpp	2021-11-04 18:06:22 UTC (rev 285269)
@@ -175,8 +175,9 @@
 {
     LocalContext context(selector, element, checkingContext.resolvingMode == SelectorChecker::Mode::QueryingRules ? VisitedMatchType::Disabled : VisitedMatchType::Enabled, checkingContext.pseudoId);
 
-    if (checkingContext.isMatchingHostPseudoClass) {
+    if (checkingContext.styleScopeOrdinal == Style::ScopeOrdinal::Shadow) {
         ASSERT(element.shadowRoot());
+        // Rules coming from the element's shadow tree must match :host pseudo class.
         context.mustMatchHostPseudoClass = true;
     }
 
@@ -201,8 +202,8 @@
 
 bool SelectorChecker::matchHostPseudoClass(const CSSSelector& selector, const Element& element, CheckingContext& checkingContext) const
 {
-    ASSERT(element.shadowRoot());
-    ASSERT(selector.match() == CSSSelector::PseudoClass && selector.pseudoClassType() == CSSSelector::PseudoClassHost);
+    if (!element.shadowRoot())
+        return false;
 
     if (auto* selectorList = selector.selectorList()) {
         LocalContext context(*selectorList->first(), element, VisitedMatchType::Enabled, PseudoId::None);

Modified: trunk/Source/WebCore/css/SelectorChecker.h (285268 => 285269)


--- trunk/Source/WebCore/css/SelectorChecker.h	2021-11-04 17:53:07 UTC (rev 285268)
+++ trunk/Source/WebCore/css/SelectorChecker.h	2021-11-04 18:06:22 UTC (rev 285269)
@@ -94,7 +94,6 @@
         std::optional<StyleScrollbarState> scrollbarState;
         AtomString nameForHightlightPseudoElement;
         const ContainerNode* scope { nullptr };
-        bool isMatchingHostPseudoClass { false };
         Style::ScopeOrdinal styleScopeOrdinal { Style::ScopeOrdinal::Element };
 
         // FIXME: It would be nicer to have a separate object for return values. This requires some more work in the selector compiler.

Modified: trunk/Source/WebCore/style/ElementRuleCollector.cpp (285268 => 285269)


--- trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-04 17:53:07 UTC (rev 285268)
+++ trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-04 18:06:22 UTC (rev 285269)
@@ -268,8 +268,6 @@
     if (shadowHostRules.isEmpty())
         return;
 
-    SetForScope<bool> change(m_isMatchingHostPseudoClass, true);
-
     MatchRequest hostMatchRequest { nullptr, ScopeOrdinal::Shadow };
     collectMatchingRulesForList(&shadowHostRules, hostMatchRequest);
 }
@@ -432,7 +430,6 @@
     context.pseudoId = m_pseudoElementRequest.pseudoId;
     context.scrollbarState = m_pseudoElementRequest.scrollbarState;
     context.nameForHightlightPseudoElement = m_pseudoElementRequest.highlightName;
-    context.isMatchingHostPseudoClass = m_isMatchingHostPseudoClass;
     context.styleScopeOrdinal = styleScopeOrdinal;
 
     bool selectorMatches;

Modified: trunk/Source/WebCore/style/ElementRuleCollector.h (285268 => 285269)


--- trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-04 17:53:07 UTC (rev 285268)
+++ trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-04 18:06:22 UTC (rev 285269)
@@ -162,7 +162,6 @@
     bool m_isPrintStyle { false };
     PseudoElementRequest m_pseudoElementRequest { PseudoId::None };
     SelectorChecker::Mode m_mode { SelectorChecker::Mode::ResolvingStyle };
-    bool m_isMatchingHostPseudoClass { false };
 
     Vector<MatchedRule, 64> m_matchedRules;
     size_t m_matchedRuleTransferIndex { 0 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to