Title: [285423] trunk
Revision
285423
Author
[email protected]
Date
2021-11-08 12:14:48 -0800 (Mon, 08 Nov 2021)

Log Message

Discrete animation of content property does not work
https://bugs.webkit.org/show_bug.cgi?id=183544
LayoutTests/imported/w3c:

<rdar://problem/38360395>

Reviewed by Antti Koivisto.

Add a new test to check that we can animate the "content" property using a discrete animation.

* web-platform-tests/css/css-content/content-animation-expected.txt: Added.
* web-platform-tests/css/css-content/content-animation.html: Added.

Source/WebCore:

Reviewed by Antti Koivisto.

Test: imported/w3c/web-platform-tests/css/css-content/content-animation.html

Add support for animating the "content" property.

* animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* rendering/style/RenderStyle.h:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285422 => 285423)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-08 19:57:03 UTC (rev 285422)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-08 20:14:48 UTC (rev 285423)
@@ -1,3 +1,16 @@
+2021-11-08  Antoine Quint  <[email protected]>
+
+        Discrete animation of content property does not work
+        https://bugs.webkit.org/show_bug.cgi?id=183544
+        <rdar://problem/38360395>
+
+        Reviewed by Antti Koivisto.
+
+        Add a new test to check that we can animate the "content" property using a discrete animation.
+
+        * web-platform-tests/css/css-content/content-animation-expected.txt: Added.
+        * web-platform-tests/css/css-content/content-animation.html: Added.
+
 2021-11-08  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r285408.

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation-expected.txt (0 => 285423)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation-expected.txt	2021-11-08 20:14:48 UTC (rev 285423)
@@ -0,0 +1,3 @@
+
+PASS The content property can be animated with a discrete animation type.
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation.html (0 => 285423)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-content/content-animation.html	2021-11-08 20:14:48 UTC (rev 285423)
@@ -0,0 +1,51 @@
+<!DOCTYPE html>
+<meta charset="UTF-8">
+<title>content animation</title>
+<link rel="help" href=""
+<meta name="test" content="box-shadow supports animation">
+<link rel="author" href="" title="Antoine Quint">
+<script src=""
+<script src=""
+<style>
+
+.target::after {
+  content: "default";
+}
+
+@keyframes content-animation {
+  from { content: "from" }
+  to   { content: "to" }
+}
+
+.target.animated::after {
+  animation: content-animation 1s paused linear forwards;
+}
+
+</style>
+<body>
+<div class="target"></div>
+<script>
+
+test(function() {
+  const target = document.querySelector(".target");
+  const style = getComputedStyle(target, "::after");
+
+  assert_equals(style.content, '"default"', "Before the animation is applied.");
+
+  target.classList.add("animated");
+  const animation = target.getAnimations({ subtree: true })[0];
+
+  const testContentAtTime = (time, expected) => {
+    animation.currentTime = time;
+    assert_equals(style.content, `"${expected}"`, `Check the animated value at time = ${time}ms`);
+  };
+
+  testContentAtTime(0, 'from');
+  testContentAtTime(499, 'from');
+  testContentAtTime(500, 'to');
+  testContentAtTime(999, 'to');
+  testContentAtTime(1000, 'to');
+}, "The content property can be animated with a discrete animation type.");
+
+</script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (285422 => 285423)


--- trunk/Source/WebCore/ChangeLog	2021-11-08 19:57:03 UTC (rev 285422)
+++ trunk/Source/WebCore/ChangeLog	2021-11-08 20:14:48 UTC (rev 285423)
@@ -1,3 +1,18 @@
+2021-11-08  Antoine Quint  <[email protected]>
+
+        Discrete animation of content property does not work
+        https://bugs.webkit.org/show_bug.cgi?id=183544
+
+        Reviewed by Antti Koivisto.
+
+        Test: imported/w3c/web-platform-tests/css/css-content/content-animation.html
+
+        Add support for animating the "content" property.
+
+        * animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
+        * rendering/style/RenderStyle.h:
+
 2021-11-08  Commit Queue  <[email protected]>
 
         Unreviewed, reverting r285408.

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (285422 => 285423)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-11-08 19:57:03 UTC (rev 285422)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-11-08 20:14:48 UTC (rev 285423)
@@ -42,6 +42,7 @@
 #include "CachedImage.h"
 #include "CalculationValue.h"
 #include "ColorBlending.h"
+#include "ContentData.h"
 #include "FloatConversion.h"
 #include "FontCascade.h"
 #include "FontSelectionAlgorithm.h"
@@ -2366,6 +2367,45 @@
     }
 };
 
+class PropertyWrapperContent final : public AnimationPropertyWrapperBase {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    PropertyWrapperContent()
+        : AnimationPropertyWrapperBase(CSSPropertyContent)
+    {
+    }
+
+    bool canInterpolate(const RenderStyle&, const RenderStyle&, CompositeOperation) const final { return false; }
+
+    bool equals(const RenderStyle& a, const RenderStyle& b) const final
+    {
+        if (!a.hasContent() && !b.hasContent())
+            return true;
+        if (a.hasContent() && b.hasContent())
+            return *a.contentData() == *b.contentData();
+        return false;
+    }
+
+#if !LOG_DISABLED
+    void logBlend(const RenderStyle&, const RenderStyle&, const RenderStyle&, double progress) const final
+    {
+        LOG_WITH_STREAM(Animations, stream << " blending content at " << TextStream::FormatNumberRespectingIntegers(progress) << ".");
+    }
+#endif
+
+    void blend(RenderStyle& destination, const RenderStyle& from, const RenderStyle& to, const CSSPropertyBlendingContext& context) const final
+    {
+        ASSERT(context.isDiscrete);
+        ASSERT(!context.progress || context.progress == 1);
+
+        auto& style = context.progress ? to : from;
+        if (auto* content = style.contentData())
+            destination.setContent(content->clone(), false);
+        else
+            destination.clearContent();
+    }
+};
+
 class CSSPropertyAnimationWrapperMap final {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -2684,7 +2724,8 @@
         new PathOperationPropertyWrapper(CSSPropertyOffsetPath, &RenderStyle::offsetPath, &RenderStyle::setOffsetPath),
         new LengthPropertyWrapper(CSSPropertyOffsetDistance, &RenderStyle::offsetDistance, &RenderStyle::setOffsetDistance, LengthPropertyWrapper::Flags::IsLengthPercentage),
         new LengthPointOrAutoPropertyWrapper(CSSPropertyOffsetPosition, &RenderStyle::offsetPosition, &RenderStyle::setOffsetPosition),
-        new LengthPointOrAutoPropertyWrapper(CSSPropertyOffsetAnchor, &RenderStyle::offsetAnchor, &RenderStyle::setOffsetAnchor)
+        new LengthPointOrAutoPropertyWrapper(CSSPropertyOffsetAnchor, &RenderStyle::offsetAnchor, &RenderStyle::setOffsetAnchor),
+        new PropertyWrapperContent
     };
     const unsigned animatableLonghandPropertiesCount = WTF_ARRAY_LENGTH(animatableLonghandPropertyWrappers);
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (285422 => 285423)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-11-08 19:57:03 UTC (rev 285422)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-11-08 20:14:48 UTC (rev 285423)
@@ -1474,6 +1474,7 @@
 
     bool hasContent() const { return contentData(); }
     const ContentData* contentData() const { return m_rareNonInheritedData->content.get(); }
+    void setContent(std::unique_ptr<ContentData>, bool add);
     bool contentDataEquivalent(const RenderStyle* otherStyle) const { return const_cast<RenderStyle*>(this)->m_rareNonInheritedData->contentDataEquivalent(*const_cast<RenderStyle*>(otherStyle)->m_rareNonInheritedData); }
     void clearContent();
     void setHasExplicitlyClearedContent(bool v) { m_nonInheritedFlags.hasExplicitlyClearedContent = v; }
@@ -1995,8 +1996,6 @@
     bool hasAutoLeftAndRight() const { return left().isAuto() && right().isAuto(); }
     bool hasAutoTopAndBottom() const { return top().isAuto() && bottom().isAuto(); }
 
-    void setContent(std::unique_ptr<ContentData>, bool add);
-
     static bool isDisplayReplacedType(DisplayType);
     static bool isDisplayInlineType(DisplayType);
     static bool isDisplayFlexibleBox(DisplayType);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to