| Differences between
and this patch
- a/Source/WebCore/dom/Element.cpp -1 / +12 lines
Lines 2265-2274 void Element::invalidateStyleForSubtreeInternal() a/Source/WebCore/dom/Element.cpp_sec1
2265
    Node::invalidateStyle(Style::Validity::SubtreeInvalid);
2265
    Node::invalidateStyle(Style::Validity::SubtreeInvalid);
2266
}
2266
}
2267
2267
2268
void Element::invalidateForQueryContainerChange()
2268
void Element::invalidateForQueryContainerSizeChange()
2269
{
2269
{
2270
    // FIXME: Ideally we would just recompute things that are actually affected by containers queries within the subtree.
2270
    // FIXME: Ideally we would just recompute things that are actually affected by containers queries within the subtree.
2271
    Node::invalidateStyle(Style::Validity::SubtreeInvalid);
2271
    Node::invalidateStyle(Style::Validity::SubtreeInvalid);
2272
    setNodeFlag(NodeFlag::NeedsUpdateQueryContainerDependentStyle);
2273
}
2274
2275
bool Element::needsUpdateQueryContainerDependentStyle() const
2276
{
2277
    return hasNodeFlag(NodeFlag::NeedsUpdateQueryContainerDependentStyle);
2278
}
2279
2280
void Element::clearNeedsUpdateQueryContainerDependentStyle()
2281
{
2282
    clearNodeFlag(NodeFlag::NeedsUpdateQueryContainerDependentStyle);
2272
}
2283
}
2273
2284
2274
void Element::invalidateEventListenerRegions()
2285
void Element::invalidateEventListenerRegions()
- a/Source/WebCore/dom/Element.h -1 / +4 lines
Lines 639-645 public: a/Source/WebCore/dom/Element.h_sec1
639
639
640
    void invalidateStyleInternal();
640
    void invalidateStyleInternal();
641
    void invalidateStyleForSubtreeInternal();
641
    void invalidateStyleForSubtreeInternal();
642
    void invalidateForQueryContainerChange();
642
    void invalidateForQueryContainerSizeChange();
643
644
    bool needsUpdateQueryContainerDependentStyle() const;
645
    void clearNeedsUpdateQueryContainerDependentStyle();
643
646
644
    void invalidateEventListenerRegions();
647
    void invalidateEventListenerRegions();
645
648
- a/Source/WebCore/dom/Node.h -2 / +3 lines
Lines 582-590 protected: a/Source/WebCore/dom/Node.h_sec1
582
        IsComputedStyleInvalidFlag = 1 << 25,
582
        IsComputedStyleInvalidFlag = 1 << 25,
583
        HasShadowRootContainingSlots = 1 << 26,
583
        HasShadowRootContainingSlots = 1 << 26,
584
        IsInTopLayer = 1 << 27,
584
        IsInTopLayer = 1 << 27,
585
        NeedsSVGRendererUpdate = 1 << 28
585
        NeedsSVGRendererUpdate = 1 << 28,
586
        NeedsUpdateQueryContainerDependentStyle = 1 << 29,
586
587
587
        // Bits 29-31 are free.
588
        // Bits 30-31 are free.
588
    };
589
    };
589
590
590
    enum class TabIndexState : uint8_t {
591
    enum class TabIndexState : uint8_t {
- a/Source/WebCore/rendering/style/KeyframeList.cpp +10 lines
Lines 217-220 bool KeyframeList::containsAnimatableProperty() const a/Source/WebCore/rendering/style/KeyframeList.cpp_sec1
217
    return false;
217
    return false;
218
}
218
}
219
219
220
bool KeyframeList::usesContainerUnits() const
221
{
222
    for (auto& keyframe : m_keyframes) {
223
        if (keyframe.style()->usesContainerUnits())
224
            return true;
225
    }
226
    return false;
227
}
228
229
220
} // namespace WebCore
230
} // namespace WebCore
- a/Source/WebCore/rendering/style/KeyframeList.h +2 lines
Lines 105-110 public: a/Source/WebCore/rendering/style/KeyframeList.h_sec1
105
    auto begin() const { return m_keyframes.begin(); }
105
    auto begin() const { return m_keyframes.begin(); }
106
    auto end() const { return m_keyframes.end(); }
106
    auto end() const { return m_keyframes.end(); }
107
107
108
    bool usesContainerUnits() const;
109
108
private:
110
private:
109
    AtomString m_animationName;
111
    AtomString m_animationName;
110
    Vector<KeyframeValue> m_keyframes; // Kept sorted by key.
112
    Vector<KeyframeValue> m_keyframes; // Kept sorted by key.
- a/Source/WebCore/style/StyleScope.cpp -1 / +1 lines
Lines 829-835 bool Scope::updateQueryContainerState(QueryContainerUpdateContext& context) a/Source/WebCore/style/StyleScope.cpp_sec1
829
    }
829
    }
830
830
831
    for (auto* toInvalidate : containersToInvalidate)
831
    for (auto* toInvalidate : containersToInvalidate)
832
        toInvalidate->invalidateForQueryContainerChange();
832
        toInvalidate->invalidateForQueryContainerSizeChange();
833
833
834
    return !containersToInvalidate.isEmpty();
834
    return !containersToInvalidate.isEmpty();
835
}
835
}
- a/Source/WebCore/style/StyleTreeResolver.cpp -1 / +8 lines
Lines 577-583 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderSt a/Source/WebCore/style/StyleTreeResolver.cpp_sec1
577
    auto& document = element.document();
577
    auto& document = element.document();
578
    auto* oldStyle = element.renderOrDisplayContentsStyle(styleable.pseudoId);
578
    auto* oldStyle = element.renderOrDisplayContentsStyle(styleable.pseudoId);
579
579
580
    OptionSet<AnimationImpact> animationImpact;
580
    // FIXME: Something like this is also needed for viewport units.
581
    if (oldStyle && parent().needsUpdateQueryContainerDependentStyle)
582
        styleable.queryContainerDidChange();
581
583
582
    // First, we need to make sure that any new CSS animation occuring on this element has a matching WebAnimation
584
    // First, we need to make sure that any new CSS animation occuring on this element has a matching WebAnimation
583
    // on the document timeline.
585
    // on the document timeline.
Lines 592-597 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderSt a/Source/WebCore/style/StyleTreeResolver.cpp_sec2
592
            styleable.updateCSSAnimations(oldStyle, *newStyle, resolutionContext);
594
            styleable.updateCSSAnimations(oldStyle, *newStyle, resolutionContext);
593
    }
595
    }
594
596
597
    OptionSet<AnimationImpact> animationImpact;
598
595
    // Now we can update all Web animations, which will include CSS Animations as well
599
    // Now we can update all Web animations, which will include CSS Animations as well
596
    // as animations created via the JS API.
600
    // as animations created via the JS API.
597
    if (styleable.hasKeyframeEffects()) {
601
    if (styleable.hasKeyframeEffects()) {
Lines 640-645 void TreeResolver::pushParent(Element& element, const RenderStyle& style, Change a/Source/WebCore/style/StyleTreeResolver.cpp_sec3
640
        parent.didPushScope = true;
644
        parent.didPushScope = true;
641
    }
645
    }
642
646
647
    parent.needsUpdateQueryContainerDependentStyle = m_parentStack.last().needsUpdateQueryContainerDependentStyle || element.needsUpdateQueryContainerDependentStyle();
648
    element.clearNeedsUpdateQueryContainerDependentStyle();
649
643
    m_parentStack.append(WTFMove(parent));
650
    m_parentStack.append(WTFMove(parent));
644
}
651
}
645
652
- a/Source/WebCore/style/StyleTreeResolver.h -1 / +2 lines
Lines 69-75 private: a/Source/WebCore/style/StyleTreeResolver.h_sec1
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);
71
71
72
    static ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change, const ResolutionContext&);
72
    ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change, const ResolutionContext&);
73
    std::optional<ElementUpdate> resolvePseudoElement(Element&, PseudoId, const ElementUpdate&);
73
    std::optional<ElementUpdate> resolvePseudoElement(Element&, PseudoId, const ElementUpdate&);
74
    std::optional<ElementUpdate> resolveAncestorPseudoElement(Element&, PseudoId, const ElementUpdate&);
74
    std::optional<ElementUpdate> resolveAncestorPseudoElement(Element&, PseudoId, const ElementUpdate&);
75
    std::unique_ptr<RenderStyle> resolveAncestorFirstLinePseudoElement(Element&, const ElementUpdate&);
75
    std::unique_ptr<RenderStyle> resolveAncestorFirstLinePseudoElement(Element&, const ElementUpdate&);
Lines 95-100 private: a/Source/WebCore/style/StyleTreeResolver.h_sec2
95
        DescendantsToResolve descendantsToResolve { DescendantsToResolve::None };
95
        DescendantsToResolve descendantsToResolve { DescendantsToResolve::None };
96
        bool didPushScope { false };
96
        bool didPushScope { false };
97
        bool resolvedFirstLineAndLetterChild { false };
97
        bool resolvedFirstLineAndLetterChild { false };
98
        bool needsUpdateQueryContainerDependentStyle { false };
98
99
99
        Parent(Document&);
100
        Parent(Document&);
100
        Parent(Element&, const RenderStyle&, Change, DescendantsToResolve);
101
        Parent(Element&, const RenderStyle&, Change, DescendantsToResolve);
- a/Source/WebCore/style/Styleable.cpp +15 lines
Lines 625-628 void Styleable::updateCSSTransitions(const RenderStyle& currentStyle, const Rend a/Source/WebCore/style/Styleable.cpp_sec1
625
        updateCSSTransitionsForStyleableAndProperty(*this, property, currentStyle, newStyle, generationTime);
625
        updateCSSTransitionsForStyleableAndProperty(*this, property, currentStyle, newStyle, generationTime);
626
}
626
}
627
627
628
void Styleable::queryContainerDidChange() const
629
{
630
    auto* animations = this->animations();
631
    if (!animations)
632
        return;
633
    for (auto animation : *animations) {
634
        auto* cssAnimation = dynamicDowncast<CSSAnimation>(animation.get());
635
        if (!cssAnimation)
636
            continue;
637
        auto* keyframeEffect = dynamicDowncast<KeyframeEffect>(cssAnimation->effect());
638
        if (keyframeEffect && keyframeEffect->blendingKeyframes().usesContainerUnits())
639
            cssAnimation->keyframesRuleDidChange();
640
    }
641
}
642
628
} // namespace WebCore
643
} // namespace WebCore
- a/Source/WebCore/style/Styleable.h +2 lines
Lines 161-166 struct Styleable { a/Source/WebCore/style/Styleable.h_sec1
161
        element.keyframesRuleDidChange(pseudoId);
161
        element.keyframesRuleDidChange(pseudoId);
162
    }
162
    }
163
163
164
    void queryContainerDidChange() const;
165
164
    bool animationListContainsNewlyValidAnimation(const AnimationList&) const;
166
    bool animationListContainsNewlyValidAnimation(const AnimationList&) const;
165
167
166
    void elementWasRemoved() const;
168
    void elementWasRemoved() const;
- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-animation-expected.txt -6 / +6 lines
Lines 1-14 a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-animation-expected.txt_sec1
1
1
2
PASS Animation using cqw unit
2
PASS Animation using cqw unit
3
FAIL Animation using cqw unit responds to changing container size assert_equals: expected "90px" but got "60px"
3
PASS Animation using cqw unit responds to changing container size
4
PASS Animation using cqh unit
4
PASS Animation using cqh unit
5
FAIL Animation using cqh unit responds to changing container size assert_equals: expected "90px" but got "60px"
5
PASS Animation using cqh unit responds to changing container size
6
PASS Animation using cqi unit
6
PASS Animation using cqi unit
7
FAIL Animation using cqi unit responds to changing container size assert_equals: expected "90px" but got "60px"
7
PASS Animation using cqi unit responds to changing container size
8
PASS Animation using cqb unit
8
PASS Animation using cqb unit
9
FAIL Animation using cqb unit responds to changing container size assert_equals: expected "90px" but got "60px"
9
PASS Animation using cqb unit responds to changing container size
10
PASS Animation using cqmin unit
10
PASS Animation using cqmin unit
11
FAIL Animation using cqmin unit responds to changing container size assert_equals: expected "90px" but got "60px"
11
PASS Animation using cqmin unit responds to changing container size
12
PASS Animation using cqmax unit
12
PASS Animation using cqmax unit
13
FAIL Animation using cqmax unit responds to changing container size assert_equals: expected "90px" but got "60px"
13
PASS Animation using cqmax unit responds to changing container size
14
14

Return to Bug 241546