| Differences between
and this patch
- a/Source/WebCore/ChangeLog +34 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2022-01-31  Antti Koivisto  <antti@apple.com>
2
3
        [CSS Container Queries] Check for query containers when matching rules
4
        https://bugs.webkit.org/show_bug.cgi?id=235881
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        Skip rules inside container queries when there are no container ancestors.
9
10
        * style/ElementRuleCollector.cpp:
11
        (WebCore::Style::ElementRuleCollector::collectMatchingRulesForList):
12
        (WebCore::Style::ElementRuleCollector::containerQueryMatches):
13
14
        Add the matching function.
15
        
16
        This patch doesn't yet do any actual container query matching, it just check
17
        if we are inside a query container.
18
19
        * style/ElementRuleCollector.h:
20
        * style/RuleSet.h:
21
        (WebCore::Style::RuleSet::containerQueryFor const):
22
        * style/SelectorMatchingState.h:
23
24
        Add container stack.
25
26
        * style/StyleTreeResolver.cpp:
27
        (WebCore::Style::TreeResolver::popParent):
28
        (WebCore::Style::TreeResolver::resolveComposedTree):
29
        (WebCore::Style::TreeResolver::updateQueryContainer):
30
31
        Maintain the container stack.
32
33
        * style/StyleTreeResolver.h:
34
1
2022-01-29  Tyler Wilcock  <tyler_w@apple.com>
35
2022-01-29  Tyler Wilcock  <tyler_w@apple.com>
2
36
3
        AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes
37
        AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes
- a/Source/WebCore/style/ElementRuleCollector.cpp +13 lines
Lines 486-491 void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe a/Source/WebCore/style/ElementRuleCollector.cpp_sec1
486
        if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes()))
486
        if (m_selectorMatchingState && m_selectorMatchingState->selectorFilter.fastRejectSelector(ruleData.descendantSelectorIdentifierHashes()))
487
            continue;
487
            continue;
488
488
489
        if (auto* containerQuery = matchRequest.ruleSet->containerQueryFor(ruleData)) {
490
            if (!containerQueryMatches(*containerQuery))
491
                continue;
492
        }
493
489
        auto& rule = ruleData.styleRule();
494
        auto& rule = ruleData.styleRule();
490
495
491
        // If the rule has no properties to apply, then ignore it in the non-debug mode.
496
        // If the rule has no properties to apply, then ignore it in the non-debug mode.
Lines 501-506 void ElementRuleCollector::collectMatchingRulesForList(const RuleSet::RuleDataVe a/Source/WebCore/style/ElementRuleCollector.cpp_sec2
501
    }
506
    }
502
}
507
}
503
508
509
bool ElementRuleCollector::containerQueryMatches(const ContainerQuery&)
510
{
511
    if (!m_selectorMatchingState)
512
        return true;
513
    // FIXME: The actual matching.
514
    return !m_selectorMatchingState->queryContainers.isEmpty();
515
}
516
504
static inline bool compareRules(MatchedRule r1, MatchedRule r2)
517
static inline bool compareRules(MatchedRule r1, MatchedRule r2)
505
{
518
{
506
    // For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade.
519
    // For normal properties the earlier scope wins. This may be reversed by !important which is handled when resolving cascade.
- a/Source/WebCore/style/ElementRuleCollector.h +1 lines
Lines 112-117 private: a/Source/WebCore/style/ElementRuleCollector.h_sec1
112
    void collectMatchingRules(const MatchRequest&);
112
    void collectMatchingRules(const MatchRequest&);
113
    void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&);
113
    void collectMatchingRulesForList(const RuleSet::RuleDataVector*, const MatchRequest&);
114
    bool ruleMatches(const RuleData&, unsigned& specificity, ScopeOrdinal);
114
    bool ruleMatches(const RuleData&, unsigned& specificity, ScopeOrdinal);
115
    bool containerQueryMatches(const ContainerQuery&);
115
116
116
    void sortMatchedRules();
117
    void sortMatchedRules();
117
118
- a/Source/WebCore/style/RuleSet.h +14 lines
Lines 108-113 public: a/Source/WebCore/style/RuleSet.h_sec1
108
    static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max();
108
    static constexpr auto cascadeLayerPriorityForUnlayered = std::numeric_limits<CascadeLayerPriority>::max();
109
109
110
    CascadeLayerPriority cascadeLayerPriorityFor(const RuleData&) const;
110
    CascadeLayerPriority cascadeLayerPriorityFor(const RuleData&) const;
111
    const ContainerQuery* containerQueryFor(const RuleData&) const;
111
112
112
private:
113
private:
113
    friend class RuleSetBuilder;
114
    friend class RuleSetBuilder;
Lines 220-224 inline CascadeLayerPriority RuleSet::cascadeLayerPriorityFor(const RuleData& rul a/Source/WebCore/style/RuleSet.h_sec2
220
    return cascadeLayerPriorityForIdentifier(identifier);
221
    return cascadeLayerPriorityForIdentifier(identifier);
221
}
222
}
222
223
224
inline const ContainerQuery* RuleSet::containerQueryFor(const RuleData& ruleData) const
225
{
226
    if (m_containerQueryIdentifierForRulePosition.size() <= ruleData.position())
227
        return nullptr;
228
229
    auto identifier = m_containerQueryIdentifierForRulePosition[ruleData.position()];
230
    if (!identifier)
231
        return nullptr;
232
233
    return &m_containerQueries[identifier - 1].query;
234
}
235
236
223
} // namespace Style
237
} // namespace Style
224
} // namespace WebCore
238
} // namespace WebCore
- a/Source/WebCore/style/SelectorMatchingState.h +2 lines
Lines 38-43 enum class HasPseudoClassMatch : uint8_t { None, Matches, Fails, FailsSubtree }; a/Source/WebCore/style/SelectorMatchingState.h_sec1
38
struct SelectorMatchingState {
38
struct SelectorMatchingState {
39
    SelectorFilter selectorFilter;
39
    SelectorFilter selectorFilter;
40
40
41
    Vector<Ref<const Element>> queryContainers;
42
41
    HashMap<HasPseudoClassCacheKey, HasPseudoClassMatch> hasPseudoClassMatchCache;
43
    HashMap<HasPseudoClassCacheKey, HasPseudoClassMatch> hasPseudoClassMatchCache;
42
    HashMap<HasPseudoClassFilterKey, std::unique_ptr<HasSelectorFilter>> hasPseudoClassSelectorFilters;
44
    HashMap<HasPseudoClassFilterKey, std::unique_ptr<HasSelectorFilter>> hasPseudoClassSelectorFilters;
43
};
45
};
- a/Source/WebCore/style/StyleTreeResolver.cpp +17 lines
Lines 426-431 void TreeResolver::popParent() a/Source/WebCore/style/StyleTreeResolver.cpp_sec1
426
426
427
    scope().selectorMatchingState.selectorFilter.popParent();
427
    scope().selectorMatchingState.selectorFilter.popParent();
428
428
429
    auto& queryContainers = scope().selectorMatchingState.queryContainers;
430
    if (!queryContainers.isEmpty() && queryContainers.last().ptr() == &parentElement)
431
        queryContainers.removeLast();
432
429
    m_parentStack.removeLast();
433
    m_parentStack.removeLast();
430
}
434
}
431
435
Lines 594-599 void TreeResolver::resolveComposedTree() a/Source/WebCore/style/StyleTreeResolver.cpp_sec2
594
598
595
        bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None);
599
        bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None);
596
600
601
        if (shouldIterateChildren)
602
            updateQueryContainer(element, *style);
603
597
        if (!m_didSeePendingStylesheet)
604
        if (!m_didSeePendingStylesheet)
598
            m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren);
605
            m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren);
599
606
Lines 612-617 void TreeResolver::resolveComposedTree() a/Source/WebCore/style/StyleTreeResolver.cpp_sec3
612
    popParentsToDepth(1);
619
    popParentsToDepth(1);
613
}
620
}
614
621
622
void TreeResolver::updateQueryContainer(const Element& element, const RenderStyle& style)
623
{
624
    if (style.containerType() == ContainerType::None)
625
        return;
626
627
    scope().selectorMatchingState.queryContainers.append(element);
628
629
    // FIXME: Skip the subtree and ensure the container is resolved by doing a layout if needed.
630
}
631
615
std::unique_ptr<Update> TreeResolver::resolve()
632
std::unique_ptr<Update> TreeResolver::resolve()
616
{
633
{
617
    auto& renderView = *m_document.renderView();
634
    auto& renderView = *m_document.renderView();
- a/Source/WebCore/style/StyleTreeResolver.h +1 lines
Lines 59-64 private: a/Source/WebCore/style/StyleTreeResolver.h_sec1
59
    std::unique_ptr<RenderStyle> styleForStyleable(const Styleable&, const ResolutionContext&);
59
    std::unique_ptr<RenderStyle> styleForStyleable(const Styleable&, const ResolutionContext&);
60
60
61
    void resolveComposedTree();
61
    void resolveComposedTree();
62
    void updateQueryContainer(const Element&, const RenderStyle&);
62
63
63
    ElementUpdates resolveElement(Element&);
64
    ElementUpdates resolveElement(Element&);
64
65
- a/LayoutTests/ChangeLog +9 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2022-01-31  Antti Koivisto  <antti@apple.com>
2
3
        [CSS Container Queries] Check for query containers when matching rules
4
        https://bugs.webkit.org/show_bug.cgi?id=235881
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * TestExpectations:
9
1
2022-01-29  Tyler Wilcock  <tyler_w@apple.com>
10
2022-01-29  Tyler Wilcock  <tyler_w@apple.com>
2
11
3
        AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes
12
        AX: Isolated tree objects don't update their AXPropertyName::ElementRect or AXPropertyName::BoundingBoxRect in response to dynamic page changes
- a/LayoutTests/imported/w3c/ChangeLog +9 lines
Lines 1-3 a/LayoutTests/imported/w3c/ChangeLog_sec1
1
2022-01-31  Antti Koivisto  <antti@apple.com>
2
3
        [CSS Container Queries] Check for query containers when matching rules
4
        https://bugs.webkit.org/show_bug.cgi?id=235881
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        * web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt:
9
1
2022-01-28  Antoine Quint  <graouts@webkit.org>
10
2022-01-28  Antoine Quint  <graouts@webkit.org>
2
11
3
        css/css-backgrounds/animations/box-shadow-composition.html has failures
12
        css/css-backgrounds/animations/box-shadow-composition.html has failures
- a/LayoutTests/TestExpectations -7 lines
Lines 4747-4761 imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-003.html [ a/LayoutTests/TestExpectations_sec1
4747
imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-004.html [ ImageOnlyFailure ]
4747
imported/w3c/web-platform-tests/css/css-contain/contain-html-overflow-004.html [ ImageOnlyFailure ]
4748
4748
4749
# Container queries
4749
# Container queries
4750
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/change-display-in-container.html [ ImageOnlyFailure ]
4751
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/counters-in-container-dynamic.html [ ImageOnlyFailure ]
4752
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/counters-in-container.html [ ImageOnlyFailure ]
4753
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ]
4750
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ]
4754
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/fieldset-legend-change.html [ ImageOnlyFailure ]
4755
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/multicol-inside-container.html [ ImageOnlyFailure ]
4756
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ]
4751
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ]
4757
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/resize-while-content-visibility-hidden.html [ ImageOnlyFailure ]
4758
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/top-layer-dialog-backdrop.html [ ImageOnlyFailure ]
4759
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
4752
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
4760
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/whitespace-update-after-removal.html [ ImageOnlyFailure ]
4753
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/whitespace-update-after-removal.html [ ImageOnlyFailure ]
4761
4754
- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt -1 / +1 lines
Lines 1-4 a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt_sec1
1
Test
1
Test
2
2
3
FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)"
3
FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 128, 0)" but got "rgb(0, 0, 0)"
4
4

Return to Bug 235881