Changeset 228412 in webkit


Ignore:
Timestamp:
Feb 12, 2018 5:28:27 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[Web Animations] Support the copy constructors for KeyframeEffectReadOnly and KeyframeEffect
https://bugs.webkit.org/show_bug.cgi?id=182712

Patch by Antoine Quint <Antoine Quint> on 2018-02-12
Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Update test expectations for tests relevant to the copy constructors.

  • web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt:
  • web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt:

Source/WebCore:

We now support the variants for the KeyframeEffectReadOnly and KeyframeEffect constructors where
another KeyframeEffectReadOnly is provided as a source. All timing, keyframe and target properties
of that source are copied on the newly-constructed KeyframeEffect.

To support copying properties, we add new copyPropertiesFromSource() methods to
AnimationEffectTimingReadOnly and KeyframeEffectReadOnly to encapsulate copying various
member variables in the relevant classes. Copying properties of the backing KeyframeList
is performed in KeyframeEffectReadOnly::copyPropertiesFromSource() via public KeyframeList
methods.

  • animation/AnimationEffectTimingReadOnly.cpp:

(WebCore::AnimationEffectTimingReadOnly::copyPropertiesFromSource):

  • animation/AnimationEffectTimingReadOnly.h:
  • animation/KeyframeEffect.cpp:

(WebCore::KeyframeEffect::create):

  • animation/KeyframeEffect.h:
  • animation/KeyframeEffect.idl:
  • animation/KeyframeEffectOptions.idl:
  • animation/KeyframeEffectReadOnly.cpp:

(WebCore::KeyframeEffectReadOnly::create):
(WebCore::KeyframeEffectReadOnly::copyPropertiesFromSource):

  • animation/KeyframeEffectReadOnly.h:
  • animation/KeyframeEffectReadOnly.idl:
Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r228333 r228412  
     12018-02-12  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Support the copy constructors for KeyframeEffectReadOnly and KeyframeEffect
     4        https://bugs.webkit.org/show_bug.cgi?id=182712
     5
     6        Reviewed by Dean Jackson.
     7
     8        Update test expectations for tests relevant to the copy constructors.
     9
     10        * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt:
     11        * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt:
     12
    1132018-02-08  Antoine Quint  <graouts@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt

    r228333 r228412  
    11
    2 FAIL Copied KeyframeEffectReadOnly has the same target Not enough arguments
    3 FAIL Copied KeyframeEffectReadOnly has the same keyframes Not enough arguments
    4 FAIL Copied KeyframeEffectReadOnly has the same KeyframeEffectOptions Not enough arguments
    5 FAIL Copied KeyframeEffectReadOnly has the same timing content Not enough arguments
    6 FAIL KeyframeEffect constructed from a KeyframeEffectReadOnly is mutable Not enough arguments
     2PASS Copied KeyframeEffectReadOnly has the same target
     3PASS Copied KeyframeEffectReadOnly has the same keyframes
     4PASS Copied KeyframeEffectReadOnly has the same KeyframeEffectOptions
     5PASS Copied KeyframeEffectReadOnly has the same timing content
     6PASS KeyframeEffect constructed from a KeyframeEffectReadOnly is mutable
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt

    r228333 r228412  
    88PASS AnimationEffectReadOnly interface: operation getComputedTiming()
    99PASS KeyframeEffectReadOnly interface: existence and properties of interface object
    10 FAIL KeyframeEffectReadOnly interface object length assert_equals: wrong value for KeyframeEffectReadOnly.length expected 1 but got 2
     10PASS KeyframeEffectReadOnly interface object length
    1111PASS KeyframeEffectReadOnly interface object name
    1212PASS KeyframeEffectReadOnly interface: existence and properties of interface prototype object
     
    2525PASS AnimationEffectReadOnly interface: new KeyframeEffectReadOnly(null, null) must inherit property "getComputedTiming()" with the proper type
    2626PASS KeyframeEffect interface: existence and properties of interface object
    27 FAIL KeyframeEffect interface object length assert_equals: wrong value for KeyframeEffect.length expected 1 but got 2
     27PASS KeyframeEffect interface object length
    2828PASS KeyframeEffect interface object name
    2929PASS KeyframeEffect interface: existence and properties of interface prototype object
  • trunk/Source/WebCore/ChangeLog

    r228400 r228412  
     12018-02-12  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Support the copy constructors for KeyframeEffectReadOnly and KeyframeEffect
     4        https://bugs.webkit.org/show_bug.cgi?id=182712
     5
     6        Reviewed by Dean Jackson.
     7
     8        We now support the variants for the KeyframeEffectReadOnly and KeyframeEffect constructors where
     9        another KeyframeEffectReadOnly is provided as a source. All timing, keyframe and target properties
     10        of that source are copied on the newly-constructed KeyframeEffect.
     11
     12        To support copying properties, we add new copyPropertiesFromSource() methods to
     13        AnimationEffectTimingReadOnly and KeyframeEffectReadOnly to encapsulate copying various
     14        member variables in the relevant classes. Copying properties of the backing KeyframeList
     15        is performed in KeyframeEffectReadOnly::copyPropertiesFromSource() via public KeyframeList
     16        methods.
     17
     18        * animation/AnimationEffectTimingReadOnly.cpp:
     19        (WebCore::AnimationEffectTimingReadOnly::copyPropertiesFromSource):
     20        * animation/AnimationEffectTimingReadOnly.h:
     21        * animation/KeyframeEffect.cpp:
     22        (WebCore::KeyframeEffect::create):
     23        * animation/KeyframeEffect.h:
     24        * animation/KeyframeEffect.idl:
     25        * animation/KeyframeEffectOptions.idl:
     26        * animation/KeyframeEffectReadOnly.cpp:
     27        (WebCore::KeyframeEffectReadOnly::create):
     28        (WebCore::KeyframeEffectReadOnly::copyPropertiesFromSource):
     29        * animation/KeyframeEffectReadOnly.h:
     30        * animation/KeyframeEffectReadOnly.idl:
     31
    1322018-02-12  Zalan Bujtas  <zalan@apple.com>
    233
  • trunk/Source/WebCore/animation/AnimationEffectTimingReadOnly.cpp

    r228333 r228412  
    7979
    8080    return { };
     81}
     82
     83void AnimationEffectTimingReadOnly::copyPropertiesFromSource(AnimationEffectTimingReadOnly* source)
     84{
     85    m_fill = source->m_fill;
     86    m_delay = source->m_delay;
     87    m_endDelay = source->m_endDelay;
     88    m_direction = source->m_direction;
     89    m_iterations = source->m_iterations;
     90    m_timingFunction = source->m_timingFunction;
     91    m_iterationStart = source->m_iterationStart;
     92    m_iterationDuration = source->m_iterationDuration;
    8193}
    8294
  • trunk/Source/WebCore/animation/AnimationEffectTimingReadOnly.h

    r228333 r228412  
    4949
    5050    ExceptionOr<void> setProperties(std::optional<Variant<double, KeyframeEffectOptions>>&&);
     51    void copyPropertiesFromSource(AnimationEffectTimingReadOnly*);
    5152
    5253    double bindingsDelay() const { return secondsToWebAnimationsAPITime(m_delay); }
  • trunk/Source/WebCore/animation/KeyframeEffect.cpp

    r228333 r228412  
    4545}
    4646
     47ExceptionOr<Ref<KeyframeEffect>> KeyframeEffect::create(JSC::ExecState&, Ref<KeyframeEffectReadOnly>&& source)
     48{
     49    auto keyframeEffect = adoptRef(*new KeyframeEffect(AnimationEffectTiming::create(), nullptr));
     50    keyframeEffect->copyPropertiesFromSource(WTFMove(source));
     51    return WTFMove(keyframeEffect);
     52}
     53
    4754KeyframeEffect::KeyframeEffect(Ref<AnimationEffectTimingReadOnly>&& timing, Element* target)
    4855    : KeyframeEffectReadOnly(KeyframeEffectClass, WTFMove(timing), target)
  • trunk/Source/WebCore/animation/KeyframeEffect.h

    r228333 r228412  
    3939public:
    4040    static ExceptionOr<Ref<KeyframeEffect>> create(JSC::ExecState&, Element*, JSC::Strong<JSC::JSObject>&&, std::optional<Variant<double, KeyframeEffectOptions>>&&);
     41    static ExceptionOr<Ref<KeyframeEffect>> create(JSC::ExecState&, Ref<KeyframeEffectReadOnly>&&);
    4142    ~KeyframeEffect() { }
    4243
  • trunk/Source/WebCore/animation/KeyframeEffect.idl

    r228333 r228412  
    2929    ConstructorMayThrowException,
    3030    ConstructorCallWith=ScriptState,
    31     Constructor(Element? target, object? keyframes, optional (unrestricted double or KeyframeEffectOptions) options)
     31    Constructor(Element? target, object? keyframes, optional (unrestricted double or KeyframeEffectOptions) options),
     32    Constructor(KeyframeEffectReadOnly source)
    3233] interface KeyframeEffect : KeyframeEffectReadOnly {
    3334    inherit attribute IterationCompositeOperation iterationComposite;
  • trunk/Source/WebCore/animation/KeyframeEffectOptions.idl

    r226289 r228412  
     1/*
     2 * Copyright (C) 2018 Apple Inc. All rights reserved.
     3 *
     4 * Redistribution and use in source and binary forms, with or without
     5 * modification, are permitted provided that the following conditions
     6 * are met:
     7 * 1. Redistributions of source code must retain the above copyright
     8 *    notice, this list of conditions and the following disclaimer.
     9 * 2. Redistributions in binary form must reproduce the above copyright
     10 *    notice, this list of conditions and the following disclaimer in the
     11 *    documentation and/or other materials provided with the distribution.
     12 *
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
     14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
     17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24 */
    125
    226dictionary KeyframeEffectOptions : AnimationEffectTimingProperties {
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp

    r228333 r228412  
    400400}
    401401
     402ExceptionOr<Ref<KeyframeEffectReadOnly>> KeyframeEffectReadOnly::create(JSC::ExecState&, Ref<KeyframeEffectReadOnly>&& source)
     403{
     404    auto keyframeEffect = adoptRef(*new KeyframeEffectReadOnly(KeyframeEffectReadOnlyClass, AnimationEffectTimingReadOnly::create(), nullptr));
     405    keyframeEffect->copyPropertiesFromSource(WTFMove(source));
     406    return WTFMove(keyframeEffect);
     407}
     408
    402409KeyframeEffectReadOnly::KeyframeEffectReadOnly(ClassType classType, Ref<AnimationEffectTimingReadOnly>&& timing, Element* target)
    403410    : AnimationEffectReadOnly(classType, WTFMove(timing))
     
    405412    , m_keyframes(emptyString())
    406413{
     414}
     415
     416void KeyframeEffectReadOnly::copyPropertiesFromSource(Ref<KeyframeEffectReadOnly>&& source)
     417{
     418    m_target = source->m_target;
     419    m_offsets = source->m_offsets;
     420    m_timingFunctions = source->m_timingFunctions;
     421    m_compositeOperation = source->m_compositeOperation;
     422    m_compositeOperations = source->m_compositeOperations;
     423    m_iterationCompositeOperation = source->m_iterationCompositeOperation;
     424
     425    timing()->copyPropertiesFromSource(source->timing());
     426
     427    KeyframeList keyframeList("keyframe-effect-" + createCanonicalUUIDString());
     428    for (auto& keyframe : source->m_keyframes.keyframes()) {
     429        KeyframeValue keyframeValue(keyframe.key(), RenderStyle::clonePtr(*keyframe.style()));
     430        for (auto propertyId : keyframe.properties())
     431            keyframeValue.addProperty(propertyId);
     432        keyframeList.insert(WTFMove(keyframeValue));
     433    }
     434    m_keyframes = WTFMove(keyframeList);
    407435}
    408436
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h

    r228333 r228412  
    4545public:
    4646    static ExceptionOr<Ref<KeyframeEffectReadOnly>> create(JSC::ExecState&, Element*, JSC::Strong<JSC::JSObject>&&, std::optional<Variant<double, KeyframeEffectOptions>>&&);
     47    static ExceptionOr<Ref<KeyframeEffectReadOnly>> create(JSC::ExecState&, Ref<KeyframeEffectReadOnly>&&);
    4748    ~KeyframeEffectReadOnly() { }
    4849
     
    99100
    100101protected:
     102    void copyPropertiesFromSource(Ref<KeyframeEffectReadOnly>&&);
    101103    ExceptionOr<void> processKeyframes(JSC::ExecState&, JSC::Strong<JSC::JSObject>&&);
     104
    102105    IterationCompositeOperation m_iterationCompositeOperation { IterationCompositeOperation::Replace };
    103106    CompositeOperation m_compositeOperation { CompositeOperation::Replace };
  • trunk/Source/WebCore/animation/KeyframeEffectReadOnly.idl

    r228333 r228412  
    2727    EnabledAtRuntime=WebAnimations,
    2828    Exposed=Window,
     29    JSGenerateToNativeObject,
    2930    ConstructorMayThrowException,
    3031    ConstructorCallWith=ScriptState,
    31     Constructor(Element? target, object? keyframes, optional (unrestricted double or KeyframeEffectOptions) options)
     32    Constructor(Element? target, object? keyframes, optional (unrestricted double or KeyframeEffectOptions) options),
     33    Constructor(KeyframeEffectReadOnly source)
    3234] interface KeyframeEffectReadOnly : AnimationEffectReadOnly {
    3335    readonly attribute Element? target;
Note: See TracChangeset for help on using the changeset viewer.