Changeset 290123 in webkit


Ignore:
Timestamp:
Feb 18, 2022 7:38:23 AM (5 months ago)
Author:
graouts@webkit.org
Message:

[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.

Source/WebCore:

  • animation/KeyframeAnimationOptions.h:
  • animation/KeyframeAnimationOptions.idl:
  • dom/Element.cpp:

(WebCore::Element::animate):

LayoutTests:

  • webanimations/frame-rate/animation-frame-rate-expected.txt:
  • webanimations/frame-rate/animation-frame-rate.html:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r290122 r290123  
     12022-02-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [frame-rate] allow setting frameRate as an option passed to Element.animate()
     4        https://bugs.webkit.org/show_bug.cgi?id=236830
     5
     6        Reviewed by Dean Jackson.
     7
     8        * webanimations/frame-rate/animation-frame-rate-expected.txt:
     9        * webanimations/frame-rate/animation-frame-rate.html:
     10
    1112022-02-18  Antoine Quint  <graouts@webkit.org>
    212
  • trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate-expected.txt

    r286915 r290123  
    22PASS Valid animation.frameRate values
    33PASS Invalid animation.frameRate values
     4PASS Calling element.animate() allows setting animation.frameRate
    45
  • trunk/LayoutTests/webanimations/frame-rate/animation-frame-rate.html

    r288806 r290123  
    99'use strict';
    1010
     11const presets = ["low", "high", "highest", "auto"];
     12const invalidValues = ["default", "120", null, [], {}];
     13
    1114test(t => {
    1215    const animation = new Animation;
     
    1518
    1619    // AnimationFrameRatePreset values.
    17     for (let value of ["low", "high", "highest", "auto"]) {
     20    for (let value of presets) {
    1821        animation.frameRate = value;
    1922        assert_equals(animation.frameRate, value, `The value "${value}" can be set`);
     
    2730test(t => {
    2831    const animation = new Animation;
    29     for (let value of ["default", "120", null, undefined, [], {}]) {
     32    for (let value of invalidValues.concat(undefined)) {
    3033        assert_throws_js(TypeError, () => animation.frameRate = value, `Setting the value ${value} throws`);
    3134        assert_equals(animation.frameRate, "auto", `Setting the invalid value "${value}" does not change the value`);
     
    3336}, "Invalid animation.frameRate values");
    3437
     38test(t => {
     39    const target = document.createElement("div");
     40    const animation = frameRate => target.animate(null, { frameRate });
     41
     42    // Numeric value.
     43    assert_equals(animation(30).frameRate, 30, "frameRate can be set to a numeric value");
     44
     45    // Presets.
     46    for (let value of presets)
     47        assert_equals(animation(value).frameRate, value, "frameRate can be set to a preset value");
     48
     49    // Invalid values.
     50    for (let value of invalidValues)
     51        assert_throws_js(TypeError, () => animation(value), `providing the invalid value "${value}" throws`);
     52}, "Calling element.animate() allows setting animation.frameRate");
     53
    3554</script>
    3655</body>
  • trunk/Source/WebCore/ChangeLog

    r290122 r290123  
     12022-02-18  Antoine Quint  <graouts@webkit.org>
     2
     3        [frame-rate] allow setting frameRate as an option passed to Element.animate()
     4        https://bugs.webkit.org/show_bug.cgi?id=236830
     5
     6        Reviewed by Dean Jackson.
     7
     8        * animation/KeyframeAnimationOptions.h:
     9        * animation/KeyframeAnimationOptions.idl:
     10        * dom/Element.cpp:
     11        (WebCore::Element::animate):
     12
    1132022-02-18  Antoine Quint  <graouts@webkit.org>
    214
  • trunk/Source/WebCore/animation/KeyframeAnimationOptions.h

    r226289 r290123  
    2626#pragma once
    2727
     28#include "AnimationFrameRate.h"
     29#include "AnimationFrameRatePreset.h"
    2830#include "KeyframeEffectOptions.h"
    2931
     
    3234struct KeyframeAnimationOptions : KeyframeEffectOptions {
    3335    String id;
     36    std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate;
    3437};
    3538
  • trunk/Source/WebCore/animation/KeyframeAnimationOptions.idl

    r226289 r290123  
    2424 */
    2525
     26typedef unsigned long FramesPerSecond;
     27
    2628dictionary KeyframeAnimationOptions : KeyframeEffectOptions {
    2729    DOMString id = "";
     30    [EnabledBySetting=WebAnimationsCustomFrameRateEnabled] (FramesPerSecond or AnimationFrameRatePreset) frameRate = "auto";
    2831};
  • trunk/Source/WebCore/dom/Element.cpp

    r289682 r290123  
    46874687{
    46884688    String id = "";
     4689    std::variant<FramesPerSecond, AnimationFrameRatePreset> frameRate = AnimationFrameRatePreset::Auto;
    46894690    std::optional<std::variant<double, KeyframeEffectOptions>> keyframeEffectOptions;
    46904691    if (options) {
     
    46964697            auto keyframeEffectOptions = std::get<KeyframeAnimationOptions>(optionsValue);
    46974698            id = keyframeEffectOptions.id;
     4699            frameRate = keyframeEffectOptions.frameRate;
    46984700            keyframeEffectOptionsVariant = WTFMove(keyframeEffectOptions);
    46994701        }
     
    47074709    auto animation = WebAnimation::create(document(), &keyframeEffectResult.returnValue().get());
    47084710    animation->setId(id);
     4711    animation->setBindingsFrameRate(WTFMove(frameRate));
    47094712
    47104713    auto animationPlayResult = animation->play();
Note: See TracChangeset for help on using the changeset viewer.