Title: [290125] trunk
Revision
290125
Author
grao...@webkit.org
Date
2022-02-18 07:44:59 -0800 (Fri, 18 Feb 2022)

Log Message

[frame-rate] [custom-effect] allow setting frameRate as an option passed to document.timeline.animate()
https://bugs.webkit.org/show_bug.cgi?id=236831

Reviewed by Dean Jackson.

Source/WebCore:

* animation/CustomAnimationOptions.h:
* animation/CustomAnimationOptions.idl:
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::animate):

LayoutTests:

* webanimations/frame-rate/animation-frame-rate-expected.txt:
* webanimations/frame-rate/animation-frame-rate.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290124 => 290125)


--- trunk/LayoutTests/ChangeLog	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/LayoutTests/ChangeLog	2022-02-18 15:44:59 UTC (rev 290125)
@@ -1,3 +1,13 @@
+2022-02-18  Antoine Quint  <grao...@webkit.org>
+
+        [frame-rate] [custom-effect] allow setting frameRate as an option passed to document.timeline.animate()
+        https://bugs.webkit.org/show_bug.cgi?id=236831
+
+        Reviewed by Dean Jackson.
+
+        * webanimations/frame-rate/animation-frame-rate-expected.txt:
+        * webanimations/frame-rate/animation-frame-rate.html:
+
 2022-02-18  Ziran Sun  <z...@igalia.com>
 
         [InputElement] Return empty string for an invalid floating-point number that ends with "."

Modified: trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt (290124 => 290125)


--- trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt	2022-02-18 15:44:59 UTC (rev 290125)
@@ -2,4 +2,5 @@
 PASS Valid animation.frameRate values
 PASS Invalid animation.frameRate values
 PASS Calling element.animate() allows setting animation.frameRate
+PASS Calling document.timeline.animate() allows setting animation.frameRate
 

Modified: trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html (290124 => 290125)


--- trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html	2022-02-18 15:44:59 UTC (rev 290125)
@@ -51,5 +51,20 @@
         assert_throws_js(TypeError, () => animation(value), `providing the invalid value "${value}" throws`);
 }, "Calling element.animate() allows setting animation.frameRate");
 
+test(t => {
+    const animation = frameRate => document.timeline.animate(() => { }, { frameRate });
+
+    // Numeric value.
+    assert_equals(animation(30).frameRate, 30, "frameRate can be set to a numeric value");
+
+    // Presets.
+    for (let value of presets)
+        assert_equals(animation(value).frameRate, value, "frameRate can be set to a preset value");
+
+    // Invalid values.
+    for (let value of invalidValues)
+        assert_throws_js(TypeError, () => animation(value), `providing the invalid value "${value}" throws`);
+}, "Calling document.timeline.animate() allows setting animation.frameRate");
+
 </script>
 </body>

Modified: trunk/Source/WebCore/ChangeLog (290124 => 290125)


--- trunk/Source/WebCore/ChangeLog	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/Source/WebCore/ChangeLog	2022-02-18 15:44:59 UTC (rev 290125)
@@ -1,3 +1,15 @@
+2022-02-18  Antoine Quint  <grao...@webkit.org>
+
+        [frame-rate] [custom-effect] allow setting frameRate as an option passed to document.timeline.animate()
+        https://bugs.webkit.org/show_bug.cgi?id=236831
+
+        Reviewed by Dean Jackson.
+
+        * animation/CustomAnimationOptions.h:
+        * animation/CustomAnimationOptions.idl:
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::animate):
+
 2022-02-18  Ziran Sun  <z...@igalia.com>
 
         [InputElement] Return empty string for an invalid floating-point number that ends with "."

Modified: trunk/Source/WebCore/animation/CustomAnimationOptions.h (290124 => 290125)


--- trunk/Source/WebCore/animation/CustomAnimationOptions.h	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/Source/WebCore/animation/CustomAnimationOptions.h	2022-02-18 15:44:59 UTC (rev 290125)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#include "AnimationFrameRate.h"
+#include "AnimationFrameRatePreset.h"
 #include "EffectTiming.h"
 
 namespace WebCore {
@@ -31,6 +33,7 @@
 
 struct CustomAnimationOptions : EffectTiming {
     String id;
+    std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/CustomAnimationOptions.idl (290124 => 290125)


--- trunk/Source/WebCore/animation/CustomAnimationOptions.idl	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/Source/WebCore/animation/CustomAnimationOptions.idl	2022-02-18 15:44:59 UTC (rev 290125)
@@ -23,7 +23,10 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+typedef unsigned long FramesPerSecond;
+
 dictionary CustomAnimationOptions : EffectTiming {
     DOMString id = "";
+    [EnabledBySetting=WebAnimationsCustomFrameRateEnabled] (FramesPerSecond or AnimationFrameRatePreset) frameRate = "auto";
 };
 

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (290124 => 290125)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2022-02-18 15:39:39 UTC (rev 290124)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2022-02-18 15:44:59 UTC (rev 290125)
@@ -453,6 +453,7 @@
         return Exception { InvalidStateError };
 
     String id = "";
+    std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate = AnimationFrameRatePreset::Auto;
     std::optional<std::variant<double, EffectTiming>> customEffectOptions;
 
     if (options) {
@@ -462,6 +463,7 @@
         else {
             auto customEffectOptions = std::get<CustomAnimationOptions>(*options);
             id = customEffectOptions.id;
+            frameRate = customEffectOptions.frameRate;
             customEffectOptionsVariant = WTFMove(customEffectOptions);
         }
         customEffectOptions = customEffectOptionsVariant;
@@ -473,6 +475,7 @@
 
     auto animation = WebAnimation::create(*document(), &customEffectResult.returnValue().get());
     animation->setId(id);
+    animation->setBindingsFrameRate(WTFMove(frameRate));
 
     auto animationPlayResult = animation->play();
     if (animationPlayResult.hasException())
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to