Title: [290730] trunk
Revision
290730
Author
[email protected]
Date
2022-03-02 07:27:56 -0800 (Wed, 02 Mar 2022)

Log Message

[web-animations] changes to font-size should recompute keyframes
https://bugs.webkit.org/show_bug.cgi?id=237357

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt:
* web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt:
* web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-filling-expected.txt:
* web-platform-tests/web-animations/responsive/fontSize-expected.txt:
* web-platform-tests/web-animations/responsive/perspective-expected.txt:
* web-platform-tests/web-animations/responsive/textIndent-expected.txt:
* web-platform-tests/web-animations/responsive/to-style-change-expected.txt:

Source/WebCore:

When we compute keyframes, it's possible that some values are specified using "em" units
and thus dependent on the current value for font-size. If the font-size changes over time,
we must recompute keyframes to ensure that any such value is updated.

To ensure that we correctly determine when the font-size changed, we pass a pointer to the
style seen when we last udpated animations so that we only consider a change in font-size
provided we've ever resolved animations.

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::propertyAffectingKeyframeResolutionDidChange):
(WebCore::KeyframeEffect::propertyAffectingLogicalPropertiesDidChange): Deleted.
* animation/KeyframeEffect.h:
* animation/KeyframeEffectStack.cpp:
(WebCore::KeyframeEffectStack::applyKeyframeEffects):
* animation/KeyframeEffectStack.h:
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):
* style/Styleable.h:
(WebCore::Styleable::applyKeyframeEffects const):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,3 +1,18 @@
+2022-03-02  Antoine Quint  <[email protected]>
+
+        [web-animations] changes to font-size should recompute keyframes
+        https://bugs.webkit.org/show_bug.cgi?id=237357
+
+        Reviewed by Antti Koivisto.
+
+        * web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt:
+        * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt:
+        * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-filling-expected.txt:
+        * web-platform-tests/web-animations/responsive/fontSize-expected.txt:
+        * web-platform-tests/web-animations/responsive/perspective-expected.txt:
+        * web-platform-tests/web-animations/responsive/textIndent-expected.txt:
+        * web-platform-tests/web-animations/responsive/to-style-change-expected.txt:
+
 2022-03-01  Martin Robinson  <[email protected]>
 
         When interpolating between transform lists partial prefix matches should not use matrix interpolation

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/responsive/column-width-001-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,5 +1,5 @@
 
-FAIL column-width responds to font-size changes assert_equals: expected "80px" but got "40px"
-FAIL column-width clamps to 0px assert_equals: expected "0px" but got "30px"
+PASS column-width responds to font-size changes
+FAIL column-width clamps to 0px assert_equals: expected "0px" but got "20px"
 FAIL column-width responds to inherited changes assert_equals: expected "auto" but got "30px"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,7 +1,7 @@
 
-FAIL Effect values reflect changes to font-size on element assert_equals: Effect value after updating font-size expected "300px" but got "150px"
+PASS Effect values reflect changes to font-size on element
 FAIL Effect values reflect changes to font-size on parent element assert_equals: Effect value after updating font-size on parent element expected "300px" but got "150px"
 PASS Effect values reflect changes to font-size when computed style is not immediately flushed
-FAIL Effect values reflect changes to font-size from reparenting assert_equals: Effect value after attaching to font-size:20px parent expected "300px" but got "150px"
+PASS Effect values reflect changes to font-size from reparenting
 PASS Effect values reflect changes to target element
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-filling-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-filling-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-context-filling-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,5 +1,5 @@
 
-FAIL Filling effect values reflect changes to font-size on element assert_equals: Effect value after updating font-size expected "400px" but got "200px"
+PASS Filling effect values reflect changes to font-size on element
 FAIL Filling effect values reflect changes to font-size on parent element assert_equals: Effect value after updating font-size on parent element expected "400px" but got "200px"
 FAIL Filling effect values reflect changes to variables on element assert_equals: Effect value after updating variable expected "200px" but got "100px"
 FAIL Filling effect values reflect changes to variables on parent element assert_equals: Effect value after updating variable expected "400px" but got "200px"

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/fontSize-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/fontSize-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/fontSize-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,6 +1,6 @@
 
-FAIL Relative font size larger responsive to style changes assert_not_equals: got disallowed value "15.6px"
-FAIL Relative font size smaller responsive to style changes assert_not_equals: got disallowed value "14.999999px"
-FAIL Font size medium responsive to style changes assert_not_equals: got disallowed value "16px"
-FAIL Font size initial responsive to style changes assert_not_equals: got disallowed value "13px"
+PASS Relative font size larger responsive to style changes
+PASS Relative font size smaller responsive to style changes
+PASS Font size medium responsive to style changes
+PASS Font size initial responsive to style changes
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/perspective-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/perspective-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/perspective-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,5 +1,5 @@
 
 PASS perspective responsive to style changes
-FAIL perspective clamped to 0px assert_equals: expected "0px" but got "60px"
+FAIL perspective clamped to 0px assert_equals: expected "0px" but got "100px"
 FAIL perspective responsive to inherited changes assert_equals: expected "80px" but got "none"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/textIndent-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/textIndent-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/textIndent-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,4 +1,4 @@
 
-FAIL textIndent responsive to style changes assert_not_equals: got disallowed value "100px hanging"
+PASS textIndent responsive to style changes
 FAIL textIndent responsive to inherited textIndent changes assert_equals: expected "200px hanging each-line" but got "150px hanging each-line"
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/to-style-change-expected.txt (290729 => 290730)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/to-style-change-expected.txt	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/responsive/to-style-change-expected.txt	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,5 +1,5 @@
 
-FAIL Lengths responsive to style changes assert_equals: expected "calc(40% + 150px)" but got "calc(40% + 100px)"
+PASS Lengths responsive to style changes
 PASS Percentages responsive to width style changes
 PASS Numbers responsive to style changes
 

Modified: trunk/Source/WebCore/ChangeLog (290729 => 290730)


--- trunk/Source/WebCore/ChangeLog	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/ChangeLog	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1,3 +1,30 @@
+2022-03-02  Antoine Quint  <[email protected]>
+
+        [web-animations] changes to font-size should recompute keyframes
+        https://bugs.webkit.org/show_bug.cgi?id=237357
+
+        Reviewed by Antti Koivisto.
+
+        When we compute keyframes, it's possible that some values are specified using "em" units
+        and thus dependent on the current value for font-size. If the font-size changes over time,
+        we must recompute keyframes to ensure that any such value is updated.
+
+        To ensure that we correctly determine when the font-size changed, we pass a pointer to the
+        style seen when we last udpated animations so that we only consider a change in font-size
+        provided we've ever resolved animations.
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::propertyAffectingKeyframeResolutionDidChange):
+        (WebCore::KeyframeEffect::propertyAffectingLogicalPropertiesDidChange): Deleted.
+        * animation/KeyframeEffect.h:
+        * animation/KeyframeEffectStack.cpp:
+        (WebCore::KeyframeEffectStack::applyKeyframeEffects):
+        * animation/KeyframeEffectStack.h:
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
+        * style/Styleable.h:
+        (WebCore::Styleable::applyKeyframeEffects const):
+
 2022-03-02  Oriol Brufau  <[email protected]>
 
         [css-cascade] Support 'revert-layer' in @keyframes

Modified: trunk/Source/WebCore/animation/KeyframeEffect.cpp (290729 => 290730)


--- trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/animation/KeyframeEffect.cpp	2022-03-02 15:27:56 UTC (rev 290730)
@@ -1682,7 +1682,7 @@
     addPendingAcceleratedAction(AcceleratedAction::TransformChange);
 }
 
-void KeyframeEffect::propertyAffectingLogicalPropertiesDidChange(RenderStyle& unanimatedStyle, const Style::ResolutionContext& resolutionContext)
+void KeyframeEffect::propertyAffectingKeyframeResolutionDidChange(RenderStyle& unanimatedStyle, const Style::ResolutionContext& resolutionContext)
 {
     switch (m_blendingKeyframesSource) {
     case BlendingKeyframesSource::CSSTransition:

Modified: trunk/Source/WebCore/animation/KeyframeEffect.h (290729 => 290730)


--- trunk/Source/WebCore/animation/KeyframeEffect.h	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/animation/KeyframeEffect.h	2022-03-02 15:27:56 UTC (rev 290730)
@@ -126,7 +126,7 @@
 
     void animationTimingDidChange();
     void transformRelatedPropertyDidChange();
-    void propertyAffectingLogicalPropertiesDidChange(RenderStyle&, const Style::ResolutionContext&);
+    void propertyAffectingKeyframeResolutionDidChange(RenderStyle&, const Style::ResolutionContext&);
     OptionSet<AcceleratedActionApplicationResult> applyPendingAcceleratedActions();
 
     void willChangeRenderer();

Modified: trunk/Source/WebCore/animation/KeyframeEffectStack.cpp (290729 => 290730)


--- trunk/Source/WebCore/animation/KeyframeEffectStack.cpp	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/animation/KeyframeEffectStack.cpp	2022-03-02 15:27:56 UTC (rev 290730)
@@ -122,19 +122,21 @@
     m_isSorted = false;
 }
 
-OptionSet<AnimationImpact> KeyframeEffectStack::applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext)
+OptionSet<AnimationImpact> KeyframeEffectStack::applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle* previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext)
 {
     OptionSet<AnimationImpact> impact;
 
+    auto& previousStyle = previousLastStyleChangeEventStyle ? *previousLastStyleChangeEventStyle : RenderStyle::defaultStyle();
+
     auto transformRelatedPropertyChanged = [&]() -> bool {
-        return !arePointingToEqualData(targetStyle.translate(), previousLastStyleChangeEventStyle.translate())
-            || !arePointingToEqualData(targetStyle.scale(), previousLastStyleChangeEventStyle.scale())
-            || !arePointingToEqualData(targetStyle.rotate(), previousLastStyleChangeEventStyle.rotate())
-            || targetStyle.transform() != previousLastStyleChangeEventStyle.transform();
+        return !arePointingToEqualData(targetStyle.translate(), previousStyle.translate())
+            || !arePointingToEqualData(targetStyle.scale(), previousStyle.scale())
+            || !arePointingToEqualData(targetStyle.rotate(), previousStyle.rotate())
+            || targetStyle.transform() != previousStyle.transform();
     }();
 
-    auto propertyAffectingLogicalPropertiesChanged = previousLastStyleChangeEventStyle.direction() != targetStyle.direction()
-        || previousLastStyleChangeEventStyle.writingMode() != targetStyle.writingMode();
+    auto fontSizeChanged = previousLastStyleChangeEventStyle && previousLastStyleChangeEventStyle->computedFontSize() != targetStyle.computedFontSize();
+    auto propertyAffectingLogicalPropertiesChanged = previousLastStyleChangeEventStyle && (previousLastStyleChangeEventStyle->direction() != targetStyle.direction() || previousLastStyleChangeEventStyle->writingMode() != targetStyle.writingMode());
 
     auto unanimatedStyle = RenderStyle::clone(targetStyle);
 
@@ -141,8 +143,8 @@
     for (const auto& effect : sortedEffects()) {
         ASSERT(effect->animation());
 
-        if (propertyAffectingLogicalPropertiesChanged)
-            effect->propertyAffectingLogicalPropertiesDidChange(unanimatedStyle, resolutionContext);
+        if (propertyAffectingLogicalPropertiesChanged || fontSizeChanged)
+            effect->propertyAffectingKeyframeResolutionDidChange(unanimatedStyle, resolutionContext);
 
         effect->animation()->resolve(targetStyle, resolutionContext);
 

Modified: trunk/Source/WebCore/animation/KeyframeEffectStack.h (290729 => 290730)


--- trunk/Source/WebCore/animation/KeyframeEffectStack.h	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/animation/KeyframeEffectStack.h	2022-03-02 15:27:56 UTC (rev 290730)
@@ -54,7 +54,7 @@
     void setCSSAnimationList(RefPtr<const AnimationList>&&);
     bool isCurrentlyAffectingProperty(CSSPropertyID) const;
     bool requiresPseudoElement() const;
-    OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext&);
+    OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle* previousLastStyleChangeEventStyle, const Style::ResolutionContext&);
     bool hasEffectWithImplicitKeyframes() const;
 
     bool containsEffectThatPreventsAccelerationOfEffect(const KeyframeEffect&);

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (290729 => 290730)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-02 15:27:56 UTC (rev 290730)
@@ -366,12 +366,12 @@
     // Now we can update all Web animations, which will include CSS Animations as well
     // as animations created via the JS API.
     if (styleable.hasKeyframeEffects()) {
-        auto previousLastStyleChangeEventStyle = styleable.lastStyleChangeEventStyle() ? RenderStyle::clonePtr(*styleable.lastStyleChangeEventStyle()) : RenderStyle::createPtr();
+        auto previousLastStyleChangeEventStyle = styleable.lastStyleChangeEventStyle() ? RenderStyle::clonePtr(*styleable.lastStyleChangeEventStyle()) : nullptr;
         // Record the style prior to applying animations for this style change event.
         styleable.setLastStyleChangeEventStyle(RenderStyle::clonePtr(*newStyle));
         // Apply all keyframe effects to the new style.
         auto animatedStyle = RenderStyle::clonePtr(*newStyle);
-        animationImpact = styleable.applyKeyframeEffects(*animatedStyle, *previousLastStyleChangeEventStyle, resolutionContext);
+        animationImpact = styleable.applyKeyframeEffects(*animatedStyle, previousLastStyleChangeEventStyle.get(), resolutionContext);
         newStyle = WTFMove(animatedStyle);
 
         Adjuster adjuster(document, *resolutionContext.parentStyle, resolutionContext.parentBoxStyle, styleable.pseudoId == PseudoId::None ? &element : nullptr);

Modified: trunk/Source/WebCore/style/Styleable.h (290729 => 290730)


--- trunk/Source/WebCore/style/Styleable.h	2022-03-02 15:23:29 UTC (rev 290729)
+++ trunk/Source/WebCore/style/Styleable.h	2022-03-02 15:27:56 UTC (rev 290730)
@@ -96,7 +96,7 @@
         return element.hasKeyframeEffects(pseudoId);
     }
 
-    OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle& previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext) const
+    OptionSet<AnimationImpact> applyKeyframeEffects(RenderStyle& targetStyle, const RenderStyle* previousLastStyleChangeEventStyle, const Style::ResolutionContext& resolutionContext) const
     {
         return element.ensureKeyframeEffectStack(pseudoId).applyKeyframeEffects(targetStyle, previousLastStyleChangeEventStyle, resolutionContext);
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to