Diff
Modified: trunk/LayoutTests/ChangeLog (290122 => 290123)
--- trunk/LayoutTests/ChangeLog 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/LayoutTests/ChangeLog 2022-02-18 15:38:23 UTC (rev 290123)
@@ -1,5 +1,15 @@
2022-02-18 Antoine Quint <grao...@webkit.org>
+ [frame-rate] allow setting frameRate as an option passed to Element.animate()
+ https://bugs.webkit.org/show_bug.cgi?id=236830
+
+ Reviewed by Dean Jackson.
+
+ * webanimations/frame-rate/animation-frame-rate-expected.txt:
+ * webanimations/frame-rate/animation-frame-rate.html:
+
+2022-02-18 Antoine Quint <grao...@webkit.org>
+
[custom-effect] Animations associated with a custom effect should appear in document.getAnimations() result
https://bugs.webkit.org/show_bug.cgi?id=236828
Modified: trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt (290122 => 290123)
--- trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt 2022-02-18 15:38:23 UTC (rev 290123)
@@ -1,4 +1,5 @@
PASS Valid animation.frameRate values
PASS Invalid animation.frameRate values
+PASS Calling element.animate() allows setting animation.frameRate
Modified: trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html (290122 => 290123)
--- trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html 2022-02-18 15:38:23 UTC (rev 290123)
@@ -8,6 +8,9 @@
<script>
'use strict';
+const presets = ["low", "high", "highest", "auto"];
+const invalidValues = ["default", "120", null, [], {}];
+
test(t => {
const animation = new Animation;
@@ -14,7 +17,7 @@
assert_equals(animation.frameRate, "auto", "The default value for frameRate is 'auto'");
// AnimationFrameRatePreset values.
- for (let value of ["low", "high", "highest", "auto"]) {
+ for (let value of presets) {
animation.frameRate = value;
assert_equals(animation.frameRate, value, `The value "${value}" can be set`);
}
@@ -26,11 +29,27 @@
test(t => {
const animation = new Animation;
- for (let value of ["default", "120", null, undefined, [], {}]) {
+ for (let value of invalidValues.concat(undefined)) {
assert_throws_js(TypeError, () => animation.frameRate = value, `Setting the value ${value} throws`);
assert_equals(animation.frameRate, "auto", `Setting the invalid value "${value}" does not change the value`);
}
}, "Invalid animation.frameRate values");
+test(t => {
+ const target = document.createElement("div");
+ const animation = frameRate => target.animate(null, { 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 element.animate() allows setting animation.frameRate");
+
</script>
</body>
Modified: trunk/Source/WebCore/ChangeLog (290122 => 290123)
--- trunk/Source/WebCore/ChangeLog 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/Source/WebCore/ChangeLog 2022-02-18 15:38:23 UTC (rev 290123)
@@ -1,5 +1,17 @@
2022-02-18 Antoine Quint <grao...@webkit.org>
+ [frame-rate] allow setting frameRate as an option passed to Element.animate()
+ https://bugs.webkit.org/show_bug.cgi?id=236830
+
+ Reviewed by Dean Jackson.
+
+ * animation/KeyframeAnimationOptions.h:
+ * animation/KeyframeAnimationOptions.idl:
+ * dom/Element.cpp:
+ (WebCore::Element::animate):
+
+2022-02-18 Antoine Quint <grao...@webkit.org>
+
[custom-effect] Animations associated with a custom effect should appear in document.getAnimations() result
https://bugs.webkit.org/show_bug.cgi?id=236828
Modified: trunk/Source/WebCore/animation/KeyframeAnimationOptions.h (290122 => 290123)
--- trunk/Source/WebCore/animation/KeyframeAnimationOptions.h 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/Source/WebCore/animation/KeyframeAnimationOptions.h 2022-02-18 15:38:23 UTC (rev 290123)
@@ -25,6 +25,8 @@
#pragma once
+#include "AnimationFrameRate.h"
+#include "AnimationFrameRatePreset.h"
#include "KeyframeEffectOptions.h"
namespace WebCore {
@@ -31,6 +33,7 @@
struct KeyframeAnimationOptions : KeyframeEffectOptions {
String id;
+ std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/animation/KeyframeAnimationOptions.idl (290122 => 290123)
--- trunk/Source/WebCore/animation/KeyframeAnimationOptions.idl 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/Source/WebCore/animation/KeyframeAnimationOptions.idl 2022-02-18 15:38:23 UTC (rev 290123)
@@ -23,6 +23,9 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+typedef unsigned long FramesPerSecond;
+
dictionary KeyframeAnimationOptions : KeyframeEffectOptions {
DOMString id = "";
+ [EnabledBySetting=WebAnimationsCustomFrameRateEnabled] (FramesPerSecond or AnimationFrameRatePreset) frameRate = "auto";
};
Modified: trunk/Source/WebCore/dom/Element.cpp (290122 => 290123)
--- trunk/Source/WebCore/dom/Element.cpp 2022-02-18 15:35:59 UTC (rev 290122)
+++ trunk/Source/WebCore/dom/Element.cpp 2022-02-18 15:38:23 UTC (rev 290123)
@@ -4686,6 +4686,7 @@
ExceptionOr<Ref<WebAnimation>> Element::animate(JSC::JSGlobalObject& lexicalGlobalObject, JSC::Strong<JSC::JSObject>&& keyframes, std::optional<std::variant<double, KeyframeAnimationOptions>>&& options)
{
String id = "";
+ std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate = AnimationFrameRatePreset::Auto;
std::optional<std::variant<double, KeyframeEffectOptions>> keyframeEffectOptions;
if (options) {
auto optionsValue = options.value();
@@ -4695,6 +4696,7 @@
else {
auto keyframeEffectOptions = std::get<KeyframeAnimationOptions>(optionsValue);
id = keyframeEffectOptions.id;
+ frameRate = keyframeEffectOptions.frameRate;
keyframeEffectOptionsVariant = WTFMove(keyframeEffectOptions);
}
keyframeEffectOptions = keyframeEffectOptionsVariant;
@@ -4706,6 +4708,7 @@
auto animation = WebAnimation::create(document(), &keyframeEffectResult.returnValue().get());
animation->setId(id);
+ animation->setBindingsFrameRate(WTFMove(frameRate));
auto animationPlayResult = animation->play();
if (animationPlayResult.hasException())