WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-235881-20220131125259.patch (text/plain), 20.26 KB, created by
Antti Koivisto
on 2022-01-31 02:53:01 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2022-01-31 02:53:01 PST
Size:
20.26 KB
patch
obsolete
>Subversion Revision: 288791 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index aed670beaaf235f9357dfd529e3a65a87b28b8b8..34e7fbd3912c1660626b5808b77de3faef8df673 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,37 @@ >+2022-01-31 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Check for query containers when matching rules >+ https://bugs.webkit.org/show_bug.cgi?id=235881 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Skip rules inside container queries when there are no container ancestors. >+ >+ * style/ElementRuleCollector.cpp: >+ (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList): >+ (WebCore::Style::ElementRuleCollector::containerQueryMatches): >+ >+ Add the matching function. >+ >+ This patch doesn't yet do any actual container query matching, it just check >+ if we are inside a query container. >+ >+ * style/ElementRuleCollector.h: >+ * style/RuleSet.h: >+ (WebCore::Style::RuleSet::containerQueryFor const): >+ * style/SelectorMatchingState.h: >+ >+ Add container stack. >+ >+ * style/StyleTreeResolver.cpp: >+ (WebCore::Style::TreeResolver::popParent): >+ (WebCore::Style::TreeResolver::resolveComposedTree): >+ (WebCore::Style::TreeResolver::updateQueryContainer): >+ >+ Maintain the container stack. >+ >+ * style/StyleTreeResolver.h: >+ > 2022-01-29 Tyler Wilcock <tyler_w@apple.com> > > AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes >diff --git a/Source/WebCore/style/ElementRuleCollector.cpp b/Source/WebCore/style/ElementRuleCollector.cpp >index fefa485cafbf4bbc84be95f459a799e2768d65f5..ce6cce2966c8a75063b6bb37cf640508e2df1023 100644 >--- a/Source/WebCore/style/ElementRuleCollector.cpp >+++ b/Source/WebCore/style/ElementRuleCollector.cpp >@@ -73,12 +73,12 @@ static const StyleProperties& rightToLeftDeclaration() > > class MatchRequest { > public: >- MatchRequest(const RuleSet* ruleSet, ScopeOrdinal styleScopeOrdinal = ScopeOrdinal::Element) >+ MatchRequest(const RuleSet& ruleSet, ScopeOrdinal styleScopeOrdinal = ScopeOrdinal::Element) > : ruleSet(ruleSet) > , styleScopeOrdinal(styleScopeOrdinal) > { > } >- const RuleSet* ruleSet; >+ const RuleSet& ruleSet; > ScopeOrdinal styleScopeOrdinal; > }; > >@@ -114,7 +114,7 @@ const Vector<RefPtr<const StyleRule>>& ElementRuleCollector::matchedRuleList() c > > inline void ElementRuleCollector::addMatchedRule(const RuleData& ruleData, unsigned specificity, const MatchRequest& matchRequest) > { >- auto cascadeLayerPriority = matchRequest.ruleSet ? matchRequest.ruleSet->cascadeLayerPriorityFor(ruleData) : RuleSet::cascadeLayerPriorityForUnlayered; >+ auto cascadeLayerPriority = matchRequest.ruleSet.cascadeLayerPriorityFor(ruleData); > m_matchedRules.append({ &ruleData, specificity, matchRequest.styleScopeOrdinal, cascadeLayerPriority }); > } > >@@ -139,7 +139,6 @@ inline void ElementRuleCollector::addElementStyleProperties(const StylePropertie > > void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest) > { >- ASSERT(matchRequest.ruleSet); > ASSERT_WITH_MESSAGE(!(m_mode == SelectorChecker::Mode::CollectingRulesIgnoringVirtualPseudoElements && m_pseudoElementRequest.pseudoId != PseudoId::None), "When in StyleInvalidation or SharingRules, SelectorChecker does not try to match the pseudo ID. While ElementRuleCollector supports matching a particular pseudoId in this case, this would indicate a error at the call site since matching a particular element should be unnecessary."); > > auto* shadowRoot = element().containingShadowRoot(); >@@ -150,18 +149,18 @@ void ElementRuleCollector::collectMatchingRules(const MatchRequest& matchRequest > // then sort the buffer. > auto& id = element().idForStyleResolution(); > if (!id.isNull()) >- collectMatchingRulesForList(matchRequest.ruleSet->idRules(id), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.idRules(id), matchRequest); > if (element().hasClass()) { > for (size_t i = 0; i < element().classNames().size(); ++i) >- collectMatchingRulesForList(matchRequest.ruleSet->classRules(element().classNames()[i]), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.classRules(element().classNames()[i]), matchRequest); > } > > if (element().isLink()) >- collectMatchingRulesForList(matchRequest.ruleSet->linkPseudoClassRules(), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.linkPseudoClassRules(), matchRequest); > if (matchesFocusPseudoClass(element())) >- collectMatchingRulesForList(matchRequest.ruleSet->focusPseudoClassRules(), matchRequest); >- collectMatchingRulesForList(matchRequest.ruleSet->tagRules(element().localName(), element().isHTMLElement() && element().document().isHTMLDocument()), matchRequest); >- collectMatchingRulesForList(matchRequest.ruleSet->universalRules(), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.focusPseudoClassRules(), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.tagRules(element().localName(), element().isHTMLElement() && element().document().isHTMLDocument()), matchRequest); >+ collectMatchingRulesForList(matchRequest.ruleSet.universalRules(), matchRequest); > } > > >@@ -234,7 +233,7 @@ bool ElementRuleCollector::matchesAnyAuthorRules() > void ElementRuleCollector::collectMatchingAuthorRules() > { > { >- MatchRequest matchRequest(m_authorStyle.ptr()); >+ MatchRequest matchRequest(m_authorStyle); > collectMatchingRules(matchRequest); > } > >@@ -259,7 +258,7 @@ void ElementRuleCollector::matchAuthorShadowPseudoElementRules() > return; > // Look up shadow pseudo elements also from the host scope author style as they are web-exposed. > auto& hostAuthorRules = Scope::forNode(*shadowRoot.host()).resolver().ruleSets().authorStyle(); >- MatchRequest hostAuthorRequest { &hostAuthorRules, ScopeOrdinal::ContainingHost }; >+ MatchRequest hostAuthorRequest { hostAuthorRules, ScopeOrdinal::ContainingHost }; > collectMatchingShadowPseudoElementRules(hostAuthorRequest); > } > >@@ -272,7 +271,7 @@ void ElementRuleCollector::matchHostPseudoClassRules() > if (shadowHostRules.isEmpty()) > return; > >- MatchRequest hostMatchRequest { nullptr, ScopeOrdinal::Shadow }; >+ MatchRequest hostMatchRequest { shadowAuthorStyle, ScopeOrdinal::Shadow }; > collectMatchingRulesForList(&shadowHostRules, hostMatchRequest); > } > >@@ -288,7 +287,7 @@ void ElementRuleCollector::matchSlottedPseudoElementRules() > > auto& scopeAuthorRules = styleScope.resolver().ruleSets().authorStyle(); > >- MatchRequest scopeMatchRequest(&scopeAuthorRules, styleScopeOrdinal); >+ MatchRequest scopeMatchRequest(scopeAuthorRules, styleScopeOrdinal); > collectMatchingRulesForList(&scopeAuthorRules.slottedPseudoElementRules(), scopeMatchRequest); > > if (styleScopeOrdinal == ScopeOrdinal::SlotLimit) >@@ -321,7 +320,7 @@ void ElementRuleCollector::matchPartPseudoElementRulesForScope(const Element& pa > > auto& hostAuthorRules = styleScope.resolver().ruleSets().authorStyle(); > >- MatchRequest scopeMatchRequest(&hostAuthorRules, styleScopeOrdinal); >+ MatchRequest scopeMatchRequest(hostAuthorRules, styleScopeOrdinal); > collectMatchingRulesForList(&hostAuthorRules.partPseudoElementRules(), scopeMatchRequest); > > // Element may only be exposed to styling from enclosing scopes via exportparts attributes. >@@ -335,10 +334,9 @@ void ElementRuleCollector::matchPartPseudoElementRulesForScope(const Element& pa > > void ElementRuleCollector::collectMatchingShadowPseudoElementRules(const MatchRequest& matchRequest) > { >- ASSERT(matchRequest.ruleSet); > ASSERT(element().containingShadowRoot()->mode() == ShadowRootMode::UserAgent); > >- auto& rules = *matchRequest.ruleSet; >+ auto& rules = matchRequest.ruleSet; > #if ENABLE(VIDEO) > // FXIME: WebVTT should not be done by styling UA shadow trees like this. > if (element().isWebVTTElement()) >@@ -356,7 +354,7 @@ void ElementRuleCollector::matchUserRules() > > clearMatchedRules(); > >- MatchRequest matchRequest(m_userStyle.get()); >+ MatchRequest matchRequest(*m_userStyle); > collectMatchingRules(matchRequest); > > sortAndTransferMatchedRules(DeclarationOrigin::User); >@@ -381,7 +379,7 @@ void ElementRuleCollector::matchUARules(const RuleSet& rules) > { > clearMatchedRules(); > >- collectMatchingRules(MatchRequest(&rules)); >+ collectMatchingRules(MatchRequest(rules)); > > sortAndTransferMatchedRules(DeclarationOrigin::UserAgent); > } >@@ -486,6 +484,11 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe > if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes())) > continue; > >+ if (auto* containerQuery = matchRequest.ruleSet.containerQueryFor(ruleData)) { >+ if (!containerQueryMatches(*containerQuery)) >+ continue; >+ } >+ > auto& rule = ruleData.styleRule(); > > // If the rule has no properties to apply, then ignore it in the non-debug mode. >@@ -501,6 +504,14 @@ void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe > } > } > >+bool ElementRuleCollector::containerQueryMatches(const ContainerQuery&) >+{ >+ if (!m_selectorMatchingState) >+ return true; >+ // FIXME: The actual matching. >+ return !m_selectorMatchingState->queryContainers.isEmpty(); >+} >+ > static inline bool compareRules(MatchedRule r1, MatchedRule r2) > { > // For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade. >@@ -578,7 +589,7 @@ void ElementRuleCollector::addElementInlineStyleProperties(bool includeSMILPrope > addElementStyleProperties(downcast<SVGElement>(element()).animatedSMILStyleProperties(), false /* isCacheable */); > } > >-bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet* ruleSet) >+bool ElementRuleCollector::hasAnyMatchingRules(const RuleSet& ruleSet) > { > clearMatchedRules(); > >diff --git a/Source/WebCore/style/ElementRuleCollector.h b/Source/WebCore/style/ElementRuleCollector.h >index 1af4fb0087ca9c89bae5bf0d0d7fce6deb218f65..4ba3344e096c770cda6219400158637a7a8be41f 100644 >--- a/Source/WebCore/style/ElementRuleCollector.h >+++ b/Source/WebCore/style/ElementRuleCollector.h >@@ -82,7 +82,7 @@ public: > void setPseudoElementRequest(const PseudoElementRequest& request) { m_pseudoElementRequest = request; } > void setMedium(const MediaQueryEvaluator* medium) { m_isPrintStyle = medium->mediaTypeMatchSpecific("print"); } > >- bool hasAnyMatchingRules(const RuleSet*); >+ bool hasAnyMatchingRules(const RuleSet&); > > const MatchResult& matchResult() const; > const Vector<RefPtr<const StyleRule>>& matchedRuleList() const; >@@ -112,6 +112,7 @@ private: > void collectMatchingRules(const MatchRequest&); > void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&); > bool ruleMatches(const RuleData&, unsigned& specificity, ScopeOrdinal); >+ bool containerQueryMatches(const ContainerQuery&); > > void sortMatchedRules(); > >diff --git a/Source/WebCore/style/RuleSet.h b/Source/WebCore/style/RuleSet.h >index 5efaa4b3e5820fa34805c4f546a969d2f323b2e8..64e452f9ff57085606933caff6e7ad1cb2116bab 100644 >--- a/Source/WebCore/style/RuleSet.h >+++ b/Source/WebCore/style/RuleSet.h >@@ -108,6 +108,7 @@ public: > static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max(); > > CascadeLayerPriority cascadeLayerPriorityFor(const RuleData&) const; >+ const ContainerQuery* containerQueryFor(const RuleData&) const; > > private: > friend class RuleSetBuilder; >@@ -220,5 +221,18 @@ inline CascadeLayerPriority RuleSet::cascadeLayerPriorityFor(const RuleData& rul > return cascadeLayerPriorityForIdentifier(identifier); > } > >+inline const ContainerQuery* RuleSet::containerQueryFor(const RuleData& ruleData) const >+{ >+ if (m_containerQueryIdentifierForRulePosition.size() <= ruleData.position()) >+ return nullptr; >+ >+ auto identifier = m_containerQueryIdentifierForRulePosition[ruleData.position()]; >+ if (!identifier) >+ return nullptr; >+ >+ return &m_containerQueries[identifier - 1].query; >+} >+ >+ > } // namespace Style > } // namespace WebCore >diff --git a/Source/WebCore/style/SelectorMatchingState.h b/Source/WebCore/style/SelectorMatchingState.h >index 2b53cd3babf648b3e7ecda296e7b9b2f42538982..9e0e1b4bd58f02afdcbdd9f85cb097b1a1ff7816 100644 >--- a/Source/WebCore/style/SelectorMatchingState.h >+++ b/Source/WebCore/style/SelectorMatchingState.h >@@ -38,6 +38,8 @@ enum class HasPseudoClassMatch : uint8_t { None, Matches, Fails, FailsSubtree }; > struct SelectorMatchingState { > SelectorFilter selectorFilter; > >+ Vector<Ref<const Element>> queryContainers; >+ > HashMap<HasPseudoClassCacheKey, HasPseudoClassMatch> hasPseudoClassMatchCache; > HashMap<HasPseudoClassFilterKey, std::unique_ptr<HasSelectorFilter>> hasPseudoClassSelectorFilters; > }; >diff --git a/Source/WebCore/style/StyleSharingResolver.cpp b/Source/WebCore/style/StyleSharingResolver.cpp >index dc3479207fd156060b44a5be253430d2d48685ef..c8ed841bced9e5d714aefcd48e141b58d7f16570 100644 >--- a/Source/WebCore/style/StyleSharingResolver.cpp >+++ b/Source/WebCore/style/StyleSharingResolver.cpp >@@ -330,7 +330,7 @@ bool SharingResolver::styleSharingCandidateMatchesRuleSet(const StyledElement& e > return false; > > ElementRuleCollector collector(element, m_ruleSets, &m_selectorMatchingState); >- return collector.hasAnyMatchingRules(ruleSet); >+ return collector.hasAnyMatchingRules(*ruleSet); > } > > bool SharingResolver::sharingCandidateHasIdenticalStyleAffectingAttributes(const Context& context, const StyledElement& sharingCandidate) const >diff --git a/Source/WebCore/style/StyleTreeResolver.cpp b/Source/WebCore/style/StyleTreeResolver.cpp >index 20e2e3d6573c4867a5d93f9e8fdfe18be0bfecb9..2d2366ae438b89fba57e524a7f85e78e00f75306 100644 >--- a/Source/WebCore/style/StyleTreeResolver.cpp >+++ b/Source/WebCore/style/StyleTreeResolver.cpp >@@ -426,6 +426,10 @@ void TreeResolver::popParent() > > scope().selectorMatchingState.selectorFilter.popParent(); > >+ auto& queryContainers = scope().selectorMatchingState.queryContainers; >+ if (!queryContainers.isEmpty() && queryContainers.last().ptr() == &parentElement) >+ queryContainers.removeLast(); >+ > m_parentStack.removeLast(); > } > >@@ -594,6 +598,9 @@ void TreeResolver::resolveComposedTree() > > bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None); > >+ if (shouldIterateChildren) >+ updateQueryContainer(element, *style); >+ > if (!m_didSeePendingStylesheet) > m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren); > >@@ -612,6 +619,16 @@ void TreeResolver::resolveComposedTree() > popParentsToDepth(1); > } > >+void TreeResolver::updateQueryContainer(const Element& element, const RenderStyle& style) >+{ >+ if (style.containerType() == ContainerType::None) >+ return; >+ >+ scope().selectorMatchingState.queryContainers.append(element); >+ >+ // FIXME: Skip the subtree and ensure the container is resolved by doing a layout if needed. >+} >+ > std::unique_ptr<Update> TreeResolver::resolve() > { > auto& renderView = *m_document.renderView(); >diff --git a/Source/WebCore/style/StyleTreeResolver.h b/Source/WebCore/style/StyleTreeResolver.h >index fa25a51549d40d87d055713825efeba046e6e0c7..af189a3a50b4f525731cd3aede563819740ef996 100644 >--- a/Source/WebCore/style/StyleTreeResolver.h >+++ b/Source/WebCore/style/StyleTreeResolver.h >@@ -59,6 +59,7 @@ private: > std::unique_ptr<RenderStyle> styleForStyleable(const Styleable&, const ResolutionContext&); > > void resolveComposedTree(); >+ void updateQueryContainer(const Element&, const RenderStyle&); > > ElementUpdates resolveElement(Element&); > >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index d57f32c923b088c73aaddeff21813e05f27309ff..93b7ccd0f0dd166631bd43485fe51773cfd9c8ce 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2022-01-31 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Check for query containers when matching rules >+ https://bugs.webkit.org/show_bug.cgi?id=235881 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestExpectations: >+ > 2022-01-29 Tyler Wilcock <tyler_w@apple.com> > > AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index 2aecfcc83e0efc1262902f94ba1adf168e90c3d3..be28b963c5115b9acdb935c98a0104981b742e12 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,12 @@ >+2022-01-31 Antti Koivisto <antti@apple.com> >+ >+ [CSS Container Queries] Check for query containers when matching rules >+ https://bugs.webkit.org/show_bug.cgi?id=235881 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt: >+ > 2022-01-28 Antoine Quint <graouts@webkit.org> > > css/css-backgrounds/animations/box-shadow-composition.html has failures >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index 4c2b997a84fabb6f4ac9f1650428f69ef96b0dbe..e47fdd2645feffce265a2fcb9b2cfce9371b1bb9 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -4747,15 +4747,8 @@ imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-003.html [ > imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-004.html [ ImageOnlyFailure ] > > # Container queries >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/change-display-in-container.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/counters-in-container-dynamic.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/counters-in-container.html [ ImageOnlyFailure ] > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/fieldset-legend-change.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/multicol-inside-container.html [ ImageOnlyFailure ] > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/resize-while-content-visibility-hidden.html [ ImageOnlyFailure ] >-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/top-layer-dialog-backdrop.html [ ImageOnlyFailure ] > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ] > webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/whitespace-update-after-removal.html [ ImageOnlyFailure ] > >diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt >index 7e1fbf1d22ca2b2b95f2ddef687258f9af058389..c351c237c78dcbf4f8e8f43ff942cc0cf9abb6a9 100644 >--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt >+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt >@@ -1,4 +1,4 @@ > Test > >-FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)" >+FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)" >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 235881
:
450390
|
450392
|
450405