| Differences between
and this patch
- a/Source/WebCore/dom/Document.cpp -7 / +9 lines
Lines 2095-2107 void Document::resolveStyle(ResolveStyleType type) a/Source/WebCore/dom/Document.cpp_sec1
2095
        Style::TreeResolver resolver(*this, WTFMove(m_pendingRenderTreeUpdate));
2095
        Style::TreeResolver resolver(*this, WTFMove(m_pendingRenderTreeUpdate));
2096
        auto styleUpdate = resolver.resolve();
2096
        auto styleUpdate = resolver.resolve();
2097
2097
2098
        while (resolver.hasUnresolvedQueryContainers() && styleUpdate) {
2098
        while (resolver.hasUnresolvedQueryContainers()) {
2099
            SetForScope resolvingContainerQueriesScope(m_isResolvingContainerQueries, true);
2099
            if (styleUpdate) {
2100
2100
                SetForScope resolvingContainerQueriesScope(m_isResolvingContainerQueries, true);
2101
            updateRenderTree(WTFMove(styleUpdate));
2101
                
2102
2102
                updateRenderTree(WTFMove(styleUpdate));
2103
            if (frameView.layoutContext().needsLayout())
2103
2104
                frameView.layoutContext().layout();
2104
                if (frameView.layoutContext().needsLayout())
2105
                    frameView.layoutContext().layout();
2106
            }
2105
2107
2106
            styleUpdate = resolver.resolve();
2108
            styleUpdate = resolver.resolve();
2107
        }
2109
        }
- a/Source/WebCore/dom/Element.cpp -2 / +2 lines
Lines 2267-2274 void Element::invalidateStyleForSubtreeInternal() a/Source/WebCore/dom/Element.cpp_sec1
2267
2267
2268
void Element::invalidateForQueryContainerChange()
2268
void Element::invalidateForQueryContainerChange()
2269
{
2269
{
2270
    // FIXME: This doesn't really need to recompute the element style.
2270
    // FIXME: Ideally we would just recompute things that are actually affected by containers queries within the subtree.
2271
    Node::invalidateStyle(Style::Validity::ElementInvalid);
2271
    Node::invalidateStyle(Style::Validity::SubtreeInvalid);
2272
}
2272
}
2273
2273
2274
void Element::invalidateEventListenerRegions()
2274
void Element::invalidateEventListenerRegions()
- a/Source/WebCore/style/StyleChange.cpp -3 / +3 lines
Lines 57-67 Change determineChange(const RenderStyle& s1, const RenderStyle& s2) a/Source/WebCore/style/StyleChange.cpp_sec1
57
    if (s1.hasTextCombine() != s2.hasTextCombine())
57
    if (s1.hasTextCombine() != s2.hasTextCombine())
58
        return Change::Renderer;
58
        return Change::Renderer;
59
59
60
    if (!s1.descendantAffectingNonInheritedPropertiesEqual(s2))
61
        return Change::Inherited;
62
63
    // Query container changes affect descendant style.
60
    // Query container changes affect descendant style.
64
    if (s1.containerType() != s2.containerType() || s1.containerNames() != s2.containerNames())
61
    if (s1.containerType() != s2.containerType() || s1.containerNames() != s2.containerNames())
62
        return Change::Descendants;
63
64
    if (!s1.descendantAffectingNonInheritedPropertiesEqual(s2))
65
        return Change::Inherited;
65
        return Change::Inherited;
66
66
67
    if (!s1.nonFastPathInheritedEqual(s2))
67
    if (!s1.nonFastPathInheritedEqual(s2))
- a/Source/WebCore/style/StyleChange.h +1 lines
Lines 36-41 enum class Change : uint8_t { a/Source/WebCore/style/StyleChange.h_sec1
36
    NonInherited,
36
    NonInherited,
37
    FastPathInherited,
37
    FastPathInherited,
38
    Inherited,
38
    Inherited,
39
    Descendants,
39
    Renderer
40
    Renderer
40
};
41
};
41
42
- a/Source/WebCore/style/StyleTreeResolver.cpp -21 / +32 lines
Lines 199-204 auto TreeResolver::computeDescendantsToResolve(Change change, Validity validity, a/Source/WebCore/style/StyleTreeResolver.cpp_sec1
199
    case Change::FastPathInherited:
199
    case Change::FastPathInherited:
200
    case Change::Inherited:
200
    case Change::Inherited:
201
        return DescendantsToResolve::Children;
201
        return DescendantsToResolve::Children;
202
    case Change::Descendants:
202
    case Change::Renderer:
203
    case Change::Renderer:
203
        return DescendantsToResolve::All;
204
        return DescendantsToResolve::All;
204
    };
205
    };
Lines 625-630 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderSt a/Source/WebCore/style/StyleTreeResolver.cpp_sec2
625
void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change change, DescendantsToResolve descendantsToResolve)
626
void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change change, DescendantsToResolve descendantsToResolve)
626
{
627
{
627
    scope().selectorMatchingState.selectorFilter.pushParent(&element);
628
    scope().selectorMatchingState.selectorFilter.pushParent(&element);
629
    if (style.containerType() != ContainerType::None)
630
        scope().selectorMatchingState.queryContainers.append(element);
628
631
629
    Parent parent(element, style, change, descendantsToResolve);
632
    Parent parent(element, style, change, descendantsToResolve);
630
633
Lines 645-651 void TreeResolver::popParent() a/Source/WebCore/style/StyleTreeResolver.cpp_sec3
645
    auto& parentElement = *parent().element;
648
    auto& parentElement = *parent().element;
646
649
647
    parentElement.setHasValidStyle();
650
    parentElement.setHasValidStyle();
648
    parentElement.clearChildNeedsStyleRecalc();
651
    // Don't clear the child flag if the are unresolved containers because we are going to resume the style resolution.
652
    if (m_unresolvedQueryContainers.isEmpty())
653
        parentElement.clearChildNeedsStyleRecalc();
649
654
650
    if (parent().didPushScope)
655
    if (parent().didPushScope)
651
        popScope();
656
        popScope();
Lines 834-843 void TreeResolver::resolveComposedTree() a/Source/WebCore/style/StyleTreeResolver.cpp_sec4
834
        if (!style)
839
        if (!style)
835
            resetStyleForNonRenderedDescendants(element);
840
            resetStyleForNonRenderedDescendants(element);
836
841
837
        bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None);
842
        auto queryContainerAction = determineQueryContainerAction(element, style, previousContainerType);
843
844
        bool shouldIterateChildren = [&] {
845
            // display::none, no need to resolve descendants.
846
            if (!style)
847
                return false;
848
            // Style resolution will be resumed after the container has been resolved.
849
            if (queryContainerAction == QueryContainerAction::Resolve)
850
                return false;
851
            return element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None;
852
        }();
838
853
839
        if (style && updateQueryContainer(element, *style, previousContainerType) == QueryContainerAction::Layout)
854
        // Ensure we respect DescendantsToResolve::All after resuming the style resolution.
840
            shouldIterateChildren = false;
855
        if (queryContainerAction == QueryContainerAction::Resolve && descendantsToResolve == DescendantsToResolve::All)
856
            element.invalidateStyleForSubtreeInternal();
841
857
842
        if (!m_didSeePendingStylesheet)
858
        if (!m_didSeePendingStylesheet)
843
            m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren);
859
            m_didSeePendingStylesheet = hasLoadingStylesheet(m_document.styleScope(), element, !shouldIterateChildren);
Lines 860-898 void TreeResolver::resolveComposedTree() a/Source/WebCore/style/StyleTreeResolver.cpp_sec5
860
    popParentsToDepth(1);
876
    popParentsToDepth(1);
861
}
877
}
862
878
863
auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style, ContainerType previousContainerType) -> QueryContainerAction
879
auto TreeResolver::determineQueryContainerAction(Element& element, const RenderStyle* style, ContainerType previousContainerType) -> QueryContainerAction
864
{
880
{
865
    if (style.containerType() != ContainerType::None)
881
    if (!style)
866
        scope().selectorMatchingState.queryContainers.append(element);
882
        return QueryContainerAction::None;
867
868
    if (m_unresolvedQueryContainers.remove(&element))
869
        return QueryContainerAction::Continue;
870
883
871
    // Render tree needs to be updated before proceeding to children also if we have a former query container
884
    // FIXME: Render tree needs to be updated before proceeding to children also if we have a former query container
872
    // because container query resolution for descendants relies on it being up-to-date.
885
    // because container unit resolution for descendants relies on it being up-to-date.
873
    if (style.containerType() == ContainerType::None && previousContainerType == ContainerType::None)
886
    if (style->containerType() == ContainerType::None && previousContainerType == ContainerType::None)
874
        return QueryContainerAction::None;
887
        return QueryContainerAction::None;
875
888
876
    if (m_update->isEmpty())
889
    if (m_resolvedQueryContainers.contains(&element))
877
        return QueryContainerAction::Continue;
890
        return QueryContainerAction::None;
878
891
879
    // Bail out from TreeResolver to build a render tree and do a layout. Resolution continues after.
880
    m_unresolvedQueryContainers.add(&element);
892
    m_unresolvedQueryContainers.add(&element);
881
    return QueryContainerAction::Layout;
893
    return QueryContainerAction::Resolve;
882
}
894
}
883
895
884
std::unique_ptr<Update> TreeResolver::resolve()
896
std::unique_ptr<Update> TreeResolver::resolve()
885
{
897
{
898
    m_resolvedQueryContainers.add(m_unresolvedQueryContainers.begin(), m_unresolvedQueryContainers.end());
899
    m_unresolvedQueryContainers.clear();
900
886
    Element* documentElement = m_document.documentElement();
901
    Element* documentElement = m_document.documentElement();
887
    if (!documentElement) {
902
    if (!documentElement) {
888
        m_document.styleScope().resolver();
903
        m_document.styleScope().resolver();
889
        return nullptr;
904
        return nullptr;
890
    }
905
    }
891
906
892
    // FIXME: Just need to restore the ancestor marking.
893
    for (auto& queryContainer : m_unresolvedQueryContainers)
894
        queryContainer->invalidateStyleForSubtreeInternal();
895
896
    if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
907
    if (!documentElement->childNeedsStyleRecalc() && !documentElement->needsStyleRecalc())
897
        return WTFMove(m_update);
908
        return WTFMove(m_update);
898
909
- a/Source/WebCore/style/StyleTreeResolver.h -2 / +3 lines
Lines 63-70 private: a/Source/WebCore/style/StyleTreeResolver.h_sec1
63
63
64
    void resolveComposedTree();
64
    void resolveComposedTree();
65
65
66
    enum class QueryContainerAction : uint8_t { None, Continue, Layout };
66
    enum class QueryContainerAction : uint8_t { None, Resolve };
67
    QueryContainerAction updateQueryContainer(Element&, const RenderStyle&, ContainerType previousContainerType);
67
    QueryContainerAction determineQueryContainerAction(Element&, const RenderStyle*, ContainerType previousContainerType);
68
68
69
    enum class DescendantsToResolve : uint8_t { None, ChildrenWithExplicitInherit, Children, All };
69
    enum class DescendantsToResolve : uint8_t { None, ChildrenWithExplicitInherit, Children, All };
70
    std::pair<ElementUpdate, DescendantsToResolve> resolveElement(Element&, ResolutionType);
70
    std::pair<ElementUpdate, DescendantsToResolve> resolveElement(Element&, ResolutionType);
Lines 130-135 private: a/Source/WebCore/style/StyleTreeResolver.h_sec2
130
    bool m_didSeePendingStylesheet { false };
130
    bool m_didSeePendingStylesheet { false };
131
131
132
    HashSet<RefPtr<Element>> m_unresolvedQueryContainers;
132
    HashSet<RefPtr<Element>> m_unresolvedQueryContainers;
133
    HashSet<RefPtr<Element>> m_resolvedQueryContainers;
133
134
134
    std::unique_ptr<Update> m_update;
135
    std::unique_ptr<Update> m_update;
135
};
136
};
- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/sibling-layout-dependency-expected.txt -5 / +4 lines
Lines 1-7 a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/sibling-layout-dependency-expected.txt_sec1
1
XXXX
1
XXXX
2
2
3
FAIL Sibling style mutation assert_equals: expected "10" but got "20"
3
PASS Sibling style mutation
4
FAIL Sibling style mutation, parent is affected assert_equals: expected "10" but got "20"
4
PASS Sibling style mutation, parent is affected
5
FAIL Sibling style mutation, ancestor is affected assert_equals: expected "10" but got "20"
5
PASS Sibling style mutation, ancestor is affected
6
FAIL Sibling text mutation assert_equals: expected "10" but got "20"
6
PASS Sibling text mutation
7
7
8
- 

Return to Bug 241457