Title: [285630] trunk/Source/WebCore
Revision
285630
Author
[email protected]
Date
2021-11-11 07:01:54 -0800 (Thu, 11 Nov 2021)

Log Message

Introduce SelectorMatchingState and move SelectorFilter there
https://bugs.webkit.org/show_bug.cgi?id=232994

Reviewed by Alan Bujtas.

It will be useful to have an extensible state struct available during style resolution.
Initially it will contain just the existing SelectorFilter.

* WebCore.xcodeproj/project.pbxproj:
* style/ElementRuleCollector.cpp:
(WebCore::Style::ElementRuleCollector::ElementRuleCollector):
(WebCore::Style::ElementRuleCollector::collectMatchingRulesForList):
* style/ElementRuleCollector.h:
* style/SelectorMatchingState.h: Added.
* style/StyleInvalidator.cpp:
(WebCore::Style::Invalidator::invalidateIfNeeded):
(WebCore::Style::Invalidator::invalidateStyleForTree):
(WebCore::Style::Invalidator::invalidateStyleForDescendants):
(WebCore::Style::Invalidator::invalidateStyle):
(WebCore::Style::Invalidator::invalidateStyleWithMatchElement):
* style/StyleInvalidator.h:
* style/StyleResolver.cpp:
(WebCore::Style::Resolver::styleForElement):
(WebCore::Style::Resolver::pseudoStyleForElement):
* style/StyleResolver.h:
* style/StyleSharingResolver.cpp:
(WebCore::Style::SharingResolver::SharingResolver):
(WebCore::Style::SharingResolver::styleSharingCandidateMatchesRuleSet const):
* style/StyleSharingResolver.h:
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::Scope::Scope):
(WebCore::Style::TreeResolver::makeResolutionContext):
(WebCore::Style::TreeResolver::makeResolutionContextForPseudoElement):
(WebCore::Style::TreeResolver::pushParent):
(WebCore::Style::TreeResolver::popParent):
* style/StyleTreeResolver.h:
* svg/SVGElement.cpp:
(WebCore::SVGElement::resolveCustomStyle):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285629 => 285630)


--- trunk/Source/WebCore/ChangeLog	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/ChangeLog	2021-11-11 15:01:54 UTC (rev 285630)
@@ -1,3 +1,44 @@
+2021-11-11  Antti Koivisto  <[email protected]>
+
+        Introduce SelectorMatchingState and move SelectorFilter there
+        https://bugs.webkit.org/show_bug.cgi?id=232994
+
+        Reviewed by Alan Bujtas.
+
+        It will be useful to have an extensible state struct available during style resolution.
+        Initially it will contain just the existing SelectorFilter.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * style/ElementRuleCollector.cpp:
+        (WebCore::Style::ElementRuleCollector::ElementRuleCollector):
+        (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList):
+        * style/ElementRuleCollector.h:
+        * style/SelectorMatchingState.h: Added.
+        * style/StyleInvalidator.cpp:
+        (WebCore::Style::Invalidator::invalidateIfNeeded):
+        (WebCore::Style::Invalidator::invalidateStyleForTree):
+        (WebCore::Style::Invalidator::invalidateStyleForDescendants):
+        (WebCore::Style::Invalidator::invalidateStyle):
+        (WebCore::Style::Invalidator::invalidateStyleWithMatchElement):
+        * style/StyleInvalidator.h:
+        * style/StyleResolver.cpp:
+        (WebCore::Style::Resolver::styleForElement):
+        (WebCore::Style::Resolver::pseudoStyleForElement):
+        * style/StyleResolver.h:
+        * style/StyleSharingResolver.cpp:
+        (WebCore::Style::SharingResolver::SharingResolver):
+        (WebCore::Style::SharingResolver::styleSharingCandidateMatchesRuleSet const):
+        * style/StyleSharingResolver.h:
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::Scope::Scope):
+        (WebCore::Style::TreeResolver::makeResolutionContext):
+        (WebCore::Style::TreeResolver::makeResolutionContextForPseudoElement):
+        (WebCore::Style::TreeResolver::pushParent):
+        (WebCore::Style::TreeResolver::popParent):
+        * style/StyleTreeResolver.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::resolveCustomStyle):
+
 2021-11-11  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Do not set prior context on the line-break iterator when when crossing layout box boundary

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (285629 => 285630)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2021-11-11 15:01:54 UTC (rev 285630)
@@ -5281,6 +5281,7 @@
 		E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */ = {isa = PBXBuildFile; fileRef = E461802C1C8DD2900026C02C /* StyleRelations.h */; };
 		E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* StyleScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		E464328A273D2E7C005B756B /* SelectorMatchingState.h in Headers */ = {isa = PBXBuildFile; fileRef = E4643288273D2E7C005B756B /* SelectorMatchingState.h */; };
 		E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		E46B41F91CB24E70008F11DE /* ScriptDisallowedScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E46B41F81CB24E70008F11DE /* ScriptDisallowedScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -16900,6 +16901,7 @@
 		E461D65C1BB0C7F000CB5645 /* StyleScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleScope.cpp; sourceTree = "<group>"; };
 		E461D65E1BB0C80D00CB5645 /* StyleScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleScope.h; sourceTree = "<group>"; };
 		E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = "<group>"; };
+		E4643288273D2E7C005B756B /* SelectorMatchingState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SelectorMatchingState.h; sourceTree = "<group>"; };
 		E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = "<group>"; };
 		E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = "<group>"; };
 		E46B41F81CB24E70008F11DE /* ScriptDisallowedScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDisallowedScope.h; sourceTree = "<group>"; };
@@ -18920,11 +18922,11 @@
 		1A569CC40D7E2B60007C3983 /* bridge */ = {
 			isa = PBXGroup;
 			children = (
-				59B5977111086556007159E8 /* jsc */,
 				1A569CE20D7E2B82007C3983 /* objc */,
 				599E758F11055A1F00D904FA /* Bridge.h */,
 				1A71D5790F33819000F9CE4E /* IdentifierRep.cpp */,
 				1A71D57A0F33819000F9CE4E /* IdentifierRep.h */,
+				59B5977111086556007159E8 /* jsc */,
 				1A569CEF0D7E2B82007C3983 /* runtime_array.cpp */,
 				1A569CF00D7E2B82007C3983 /* runtime_array.h */,
 				1A569CF10D7E2B82007C3983 /* runtime_method.cpp */,
@@ -30227,6 +30229,7 @@
 				A79BADA0161E7F3F00C2E652 /* RuleSet.h */,
 				E47CEBEB2709DFDC00B8D8F5 /* RuleSetBuilder.cpp */,
 				E47CEBE82709DFD000B8D8F5 /* RuleSetBuilder.h */,
+				E4643288273D2E7C005B756B /* SelectorMatchingState.h */,
 				7173DEBD2614DF040097DF32 /* Styleable.cpp */,
 				713922BC2518AB70005DB3C2 /* Styleable.h */,
 				E45BA6B22376227E004DFC07 /* StyleAdjuster.cpp */,
@@ -35966,6 +35969,7 @@
 				432D3FE818A8658400D7DC03 /* SelectorCheckerTestFunctions.h in Headers */,
 				26B999971804D54200D01121 /* SelectorCompiler.h in Headers */,
 				415071581685067300C3C7B3 /* SelectorFilter.h in Headers */,
+				E464328A273D2E7C005B756B /* SelectorMatchingState.h in Headers */,
 				43107BE218CC19DE00CC18E8 /* SelectorPseudoTypeMap.h in Headers */,
 				E45322AC140CE267005A0F92 /* SelectorQuery.h in Headers */,
 				F4D43D662188038B00ECECAC /* SerializedAttachmentData.h in Headers */,

Modified: trunk/Source/WebCore/style/ElementRuleCollector.cpp (285629 => 285630)


--- trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/ElementRuleCollector.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -38,7 +38,7 @@
 #include "SVGElement.h"
 #include "SelectorCheckerTestFunctions.h"
 #include "SelectorCompiler.h"
-#include "SelectorFilter.h"
+#include "SelectorMatchingState.h"
 #include "ShadowRoot.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
@@ -82,22 +82,22 @@
     ScopeOrdinal styleScopeOrdinal;
 };
 
-ElementRuleCollector::ElementRuleCollector(const Element& element, const ScopeRuleSets& ruleSets, const SelectorFilter* selectorFilter)
+ElementRuleCollector::ElementRuleCollector(const Element& element, const ScopeRuleSets& ruleSets, SelectorMatchingState* selectorMatchingState)
     : m_element(element)
     , m_authorStyle(ruleSets.authorStyle())
     , m_userStyle(ruleSets.userStyle())
     , m_userAgentMediaQueryStyle(ruleSets.userAgentMediaQueryStyle())
-    , m_selectorFilter(selectorFilter)
+    , m_selectorMatchingState(selectorMatchingState)
 {
-    ASSERT(!m_selectorFilter || m_selectorFilter->parentStackIsConsistent(element.parentNode()));
+    ASSERT(!m_selectorMatchingState || m_selectorMatchingState->selectorFilter.parentStackIsConsistent(element.parentNode()));
 }
 
-ElementRuleCollector::ElementRuleCollector(const Element& element, const RuleSet& authorStyle, const SelectorFilter* selectorFilter)
+ElementRuleCollector::ElementRuleCollector(const Element& element, const RuleSet& authorStyle, SelectorMatchingState* selectorMatchingState)
     : m_element(element)
     , m_authorStyle(authorStyle)
-    , m_selectorFilter(selectorFilter)
+    , m_selectorMatchingState(selectorMatchingState)
 {
-    ASSERT(!m_selectorFilter || m_selectorFilter->parentStackIsConsistent(element.parentNode()));
+    ASSERT(!m_selectorMatchingState || m_selectorMatchingState->selectorFilter.parentStackIsConsistent(element.parentNode()));
 }
 
 const MatchResult& ElementRuleCollector::matchResult() const
@@ -482,7 +482,7 @@
         if (!ruleData.canMatchPseudoElement() && m_pseudoElementRequest.pseudoId != PseudoId::None)
             continue;
 
-        if (m_selectorFilter && m_selectorFilter->fastRejectSelector(ruleData.descendantSelectorIdentifierHashes()))
+        if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes()))
             continue;
 
         auto& rule = ruleData.styleRule();

Modified: trunk/Source/WebCore/style/ElementRuleCollector.h (285629 => 285630)


--- trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/ElementRuleCollector.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -31,14 +31,11 @@
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
-namespace WebCore {
+namespace WebCore::Style {
 
-class SelectorFilter;
-
-namespace Style {
-
 class MatchRequest;
 class ScopeRuleSets;
+struct SelectorMatchingState;
 
 class PseudoElementRequest {
 public:
@@ -69,8 +66,8 @@
 
 class ElementRuleCollector {
 public:
-    ElementRuleCollector(const Element&, const ScopeRuleSets&, const SelectorFilter*);
-    ElementRuleCollector(const Element&, const RuleSet& authorStyle, const SelectorFilter*);
+    ElementRuleCollector(const Element&, const ScopeRuleSets&, SelectorMatchingState*);
+    ElementRuleCollector(const Element&, const RuleSet& authorStyle, SelectorMatchingState*);
 
     void setIncludeEmptyRules(bool value) { m_shouldIncludeEmptyRules = value; }
 
@@ -132,7 +129,7 @@
     Ref<const RuleSet> m_authorStyle;
     RefPtr<const RuleSet> m_userStyle;
     RefPtr<const RuleSet> m_userAgentMediaQueryStyle;
-    const SelectorFilter* m_selectorFilter;
+    SelectorMatchingState* m_selectorMatchingState;
 
     bool m_shouldIncludeEmptyRules { false };
     bool m_isPrintStyle { false };
@@ -150,5 +147,4 @@
     PseudoIdSet m_matchedPseudoElementIds;
 };
 
-} // namespace Style
-} // namespace WebCore
+}

Added: trunk/Source/WebCore/style/SelectorMatchingState.h (0 => 285630)


--- trunk/Source/WebCore/style/SelectorMatchingState.h	                        (rev 0)
+++ trunk/Source/WebCore/style/SelectorMatchingState.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "SelectorFilter.h"
+
+namespace WebCore::Style {
+
+struct SelectorMatchingState {
+    SelectorFilter selectorFilter;
+};
+
+}

Modified: trunk/Source/WebCore/style/StyleInvalidator.cpp (285629 => 285630)


--- trunk/Source/WebCore/style/StyleInvalidator.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleInvalidator.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -33,7 +33,7 @@
 #include "HTMLSlotElement.h"
 #include "RuleSetBuilder.h"
 #include "RuntimeEnabledFeatures.h"
-#include "SelectorFilter.h"
+#include "SelectorMatchingState.h"
 #include "ShadowRoot.h"
 #include "StyleResolver.h"
 #include "StyleRuleImport.h"
@@ -144,7 +144,7 @@
     }
 }
 
-Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, const SelectorFilter* filter)
+Invalidator::CheckDescendants Invalidator::invalidateIfNeeded(Element& element, SelectorMatchingState* selectorMatchingState)
 {
     invalidateInShadowTreeIfNeeded(element);
 
@@ -154,7 +154,7 @@
     switch (element.styleValidity()) {
     case Style::Validity::Valid: {
         for (auto& ruleSet : m_ruleSets) {
-            ElementRuleCollector ruleCollector(element, *ruleSet, filter);
+            ElementRuleCollector ruleCollector(element, *ruleSet, selectorMatchingState);
             ruleCollector.setMode(SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements);
 
             if (ruleCollector.matchesAnyAuthorRules()) {
@@ -175,14 +175,14 @@
     return CheckDescendants::Yes;
 }
 
-void Invalidator::invalidateStyleForTree(Element& root, SelectorFilter* filter)
+void Invalidator::invalidateStyleForTree(Element& root, SelectorMatchingState* selectorMatchingState)
 {
-    if (invalidateIfNeeded(root, filter) == CheckDescendants::No)
+    if (invalidateIfNeeded(root, selectorMatchingState) == CheckDescendants::No)
         return;
-    invalidateStyleForDescendants(root, filter);
+    invalidateStyleForDescendants(root, selectorMatchingState);
 }
 
-void Invalidator::invalidateStyleForDescendants(Element& root, SelectorFilter* filter)
+void Invalidator::invalidateStyleForDescendants(Element& root, SelectorMatchingState* selectorMatchingState)
 {
     Vector<Element*, 20> parentStack;
     Element* previousElement = &root;
@@ -192,19 +192,19 @@
         if (parentStack.isEmpty() || parentStack.last() != parent) {
             if (parent == previousElement) {
                 parentStack.append(parent);
-                if (filter)
-                    filter->pushParentInitializingIfNeeded(*parent);
+                if (selectorMatchingState)
+                    selectorMatchingState->selectorFilter.pushParentInitializingIfNeeded(*parent);
             } else {
                 while (parentStack.last() != parent) {
                     parentStack.removeLast();
-                    if (filter)
-                        filter->popParent();
+                    if (selectorMatchingState)
+                        selectorMatchingState->selectorFilter.popParent();
                 }
             }
         }
         previousElement = &descendant;
 
-        if (invalidateIfNeeded(descendant, filter) == CheckDescendants::Yes)
+        if (invalidateIfNeeded(descendant, selectorMatchingState) == CheckDescendants::Yes)
             it.traverseNext();
         else
             it.traverseNextSkippingChildren();
@@ -219,8 +219,8 @@
     if (!documentElement)
         return;
 
-    SelectorFilter filter;
-    invalidateStyleForTree(*documentElement, &filter);
+    SelectorMatchingState selectorMatchingState;
+    invalidateStyleForTree(*documentElement, &selectorMatchingState);
 }
 
 void Invalidator::invalidateStyle(Scope& scope)
@@ -246,8 +246,8 @@
         shadowRoot.host()->invalidateStyleInternal();
 
     for (auto& child : childrenOfType<Element>(shadowRoot)) {
-        SelectorFilter filter;
-        invalidateStyleForTree(child, &filter);
+        SelectorMatchingState selectorMatchingState;
+        invalidateStyleForTree(child, &selectorMatchingState);
     }
 }
 
@@ -273,8 +273,8 @@
         break;
     }
     case MatchElement::Ancestor: {
-        SelectorFilter filter;
-        invalidateStyleForDescendants(element, &filter);
+        SelectorMatchingState selectorMatchingState;
+        invalidateStyleForDescendants(element, &selectorMatchingState);
         break;
     }
     case MatchElement::DirectSibling:
@@ -297,10 +297,10 @@
         }
         break;
     case MatchElement::AncestorSibling: {
-        SelectorFilter filter;
+        SelectorMatchingState selectorMatchingState;
         for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) {
-            filter.popParentsUntil(element.parentElement());
-            invalidateStyleForDescendants(*sibling, &filter);
+            selectorMatchingState.selectorFilter.popParentsUntil(element.parentElement());
+            invalidateStyleForDescendants(*sibling, &selectorMatchingState);
         }
         break;
     }

Modified: trunk/Source/WebCore/style/StyleInvalidator.h (285629 => 285630)


--- trunk/Source/WebCore/style/StyleInvalidator.h	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleInvalidator.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -35,7 +35,6 @@
 class Document;
 class Element;
 class MediaQueryEvaluator;
-class SelectorFilter;
 class ShadowRoot;
 class StyleSheetContents;
 
@@ -44,6 +43,7 @@
 class Scope;
 
 struct InvalidationRuleSet;
+struct SelectorMatchingState;
 
 class Invalidator {
 public:
@@ -68,9 +68,9 @@
 
 private:
     enum class CheckDescendants { Yes, No };
-    CheckDescendants invalidateIfNeeded(Element&, const SelectorFilter*);
-    void invalidateStyleForTree(Element&, SelectorFilter*);
-    void invalidateStyleForDescendants(Element&, SelectorFilter*);
+    CheckDescendants invalidateIfNeeded(Element&, SelectorMatchingState*);
+    void invalidateStyleForTree(Element&, SelectorMatchingState*);
+    void invalidateStyleForDescendants(Element&, SelectorMatchingState*);
     void invalidateInShadowTreeIfNeeded(Element&);
     void invalidateShadowPseudoElements(ShadowRoot&);
     void invalidateStyleWithMatchElement(Element&, MatchElement);

Modified: trunk/Source/WebCore/style/StyleResolver.cpp (285629 => 285630)


--- trunk/Source/WebCore/style/StyleResolver.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleResolver.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -245,7 +245,7 @@
 
     UserAgentStyle::ensureDefaultStyleSheetsForElement(element);
 
-    ElementRuleCollector collector(element, m_ruleSets, context.selectorFilter);
+    ElementRuleCollector collector(element, m_ruleSets, context.selectorMatchingState);
     collector.setMedium(&m_mediaQueryEvaluator);
 
     if (matchingBehavior == RuleMatchingBehavior::MatchOnlyUserAgentRules)
@@ -392,7 +392,7 @@
         state.setParentStyle(RenderStyle::clonePtr(*state.style()));
     }
 
-    ElementRuleCollector collector(element, m_ruleSets, context.selectorFilter);
+    ElementRuleCollector collector(element, m_ruleSets, context.selectorMatchingState);
     collector.setPseudoElementRequest(pseudoElementRequest);
     collector.setMedium(&m_mediaQueryEvaluator);
     collector.matchUARules();

Modified: trunk/Source/WebCore/style/StyleResolver.h (285629 => 285630)


--- trunk/Source/WebCore/style/StyleResolver.h	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleResolver.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -70,6 +70,8 @@
 
 namespace Style {
 
+struct SelectorMatchingState;
+
 struct ElementStyle {
     ElementStyle(std::unique_ptr<RenderStyle> renderStyle, std::unique_ptr<Relations> relations = { })
         : renderStyle(WTFMove(renderStyle))
@@ -85,7 +87,7 @@
     const RenderStyle* parentBoxStyle { nullptr };
     // This needs to be provided during style resolution when up-to-date document element style is not available via DOM.
     const RenderStyle* documentElementStyle { nullptr };
-    const SelectorFilter* selectorFilter { nullptr };
+    SelectorMatchingState* selectorMatchingState { nullptr };
 };
 
 class Resolver : public RefCounted<Resolver> {

Modified: trunk/Source/WebCore/style/StyleSharingResolver.cpp (285629 => 285630)


--- trunk/Source/WebCore/style/StyleSharingResolver.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleSharingResolver.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -57,10 +57,10 @@
     InsideLink elementLinkState;
 };
 
-SharingResolver::SharingResolver(const Document& document, const ScopeRuleSets& ruleSets, const SelectorFilter& selectorFilter)
+SharingResolver::SharingResolver(const Document& document, const ScopeRuleSets& ruleSets, SelectorMatchingState& selectorMatchingState)
     : m_document(document)
     , m_ruleSets(ruleSets)
-    , m_selectorFilter(selectorFilter)
+    , m_selectorMatchingState(selectorMatchingState)
 {
 }
 
@@ -326,7 +326,7 @@
     if (!ruleSet)
         return false;
 
-    ElementRuleCollector collector(const_cast<StyledElement&>(element), m_ruleSets, &m_selectorFilter);
+    ElementRuleCollector collector(element, m_ruleSets, &m_selectorMatchingState);
     return collector.hasAnyMatchingRules(ruleSet);
 }
 

Modified: trunk/Source/WebCore/style/StyleSharingResolver.h (285629 => 285630)


--- trunk/Source/WebCore/style/StyleSharingResolver.h	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleSharingResolver.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -34,7 +34,6 @@
 class Element;
 class Node;
 class RenderStyle;
-class SelectorFilter;
 class SpaceSplitString;
 class StyledElement;
 
@@ -43,10 +42,11 @@
 class RuleSet;
 class ScopeRuleSets;
 class Update;
+struct SelectorMatchingState;
 
 class SharingResolver {
 public:
-    SharingResolver(const Document&, const ScopeRuleSets&, const SelectorFilter&);
+    SharingResolver(const Document&, const ScopeRuleSets&, SelectorMatchingState&);
 
     std::unique_ptr<RenderStyle> resolve(const Styleable&, const Update&);
 
@@ -62,7 +62,7 @@
 
     const Document& m_document;
     const ScopeRuleSets& m_ruleSets;
-    const SelectorFilter& m_selectorFilter;
+    SelectorMatchingState& m_selectorMatchingState;
 
     // FIXME: Use WeakHashMap or HashMap<CheckedPtr, CheckedPtr>.
     HashMap<const Element*, const Element*> m_elementsSharingStyle;

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (285629 => 285630)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -73,7 +73,7 @@
 
 TreeResolver::Scope::Scope(Document& document)
     : resolver(document.styleScope().resolver())
-    , sharingResolver(document, resolver->ruleSets(), selectorFilter)
+    , sharingResolver(document, resolver->ruleSets(), selectorMatchingState)
 {
     document.setIsResolvingTreeStyle(true);
 
@@ -84,7 +84,7 @@
 
 TreeResolver::Scope::Scope(ShadowRoot& shadowRoot, Scope& enclosingScope)
     : resolver(shadowRoot.styleScope().resolver())
-    , sharingResolver(shadowRoot.documentScope(), resolver->ruleSets(), selectorFilter)
+    , sharingResolver(shadowRoot.documentScope(), resolver->ruleSets(), selectorMatchingState)
     , shadowRoot(&shadowRoot)
     , enclosingScope(&enclosingScope)
 {
@@ -303,7 +303,7 @@
         &parent().style,
         parentBoxStyle(),
         m_documentElementStyle.get(),
-        &scope().selectorFilter
+        &scope().selectorMatchingState
     };
 }
 
@@ -313,7 +313,7 @@
         elementUpdate.style.get(),
         parentBoxStyleForPseudoElement(elementUpdate),
         m_documentElementStyle.get(),
-        &scope().selectorFilter
+        &scope().selectorMatchingState
     };
 }
 
@@ -398,7 +398,7 @@
 
 void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change change, DescendantsToResolve descendantsToResolve)
 {
-    scope().selectorFilter.pushParent(&element);
+    scope().selectorMatchingState.selectorFilter.pushParent(&element);
 
     Parent parent(element, style, change, descendantsToResolve);
 
@@ -424,7 +424,7 @@
     if (parent().didPushScope)
         popScope();
 
-    scope().selectorFilter.popParent();
+    scope().selectorMatchingState.selectorFilter.popParent();
 
     m_parentStack.removeLast();
 }

Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (285629 => 285630)


--- trunk/Source/WebCore/style/StyleTreeResolver.h	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h	2021-11-11 15:01:54 UTC (rev 285630)
@@ -26,7 +26,7 @@
 #pragma once
 
 #include "SelectorChecker.h"
-#include "SelectorFilter.h"
+#include "SelectorMatchingState.h"
 #include "StyleChange.h"
 #include "StyleSharingResolver.h"
 #include "StyleUpdate.h"
@@ -68,7 +68,7 @@
     struct Scope : RefCounted<Scope> {
         WTF_MAKE_STRUCT_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(TreeResolverScope);
         Ref<Resolver> resolver;
-        SelectorFilter selectorFilter;
+        SelectorMatchingState selectorMatchingState;
         SharingResolver sharingResolver;
         RefPtr<ShadowRoot> shadowRoot;
         RefPtr<Scope> enclosingScope;

Modified: trunk/Source/WebCore/svg/SVGElement.cpp (285629 => 285630)


--- trunk/Source/WebCore/svg/SVGElement.cpp	2021-11-11 14:57:22 UTC (rev 285629)
+++ trunk/Source/WebCore/svg/SVGElement.cpp	2021-11-11 15:01:54 UTC (rev 285630)
@@ -643,8 +643,8 @@
     // If the element is in a <use> tree we get the style from the definition tree.
     if (RefPtr styleElement = this->correspondingElement()) {
         auto styleElementResolutionContext = resolutionContext;
-        // Can't use the selector filter since we are going to another part of the tree.
-        styleElementResolutionContext.selectorFilter = nullptr;
+        // Can't use the state since we are going to another part of the tree.
+        styleElementResolutionContext.selectorMatchingState = nullptr;
         auto style = styleElement->resolveStyle(styleElementResolutionContext);
         Style::Adjuster::adjustSVGElementStyle(*style.renderStyle, *this);
         return style;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to