haikuwebkit/Source/WebCore/animation/IterationCompositeOperation.h

33 lines
1.4 KiB
C
Raw Permalink Normal View History

[Web Animations] Implement Element.animate() https://bugs.webkit.org/show_bug.cgi?id=180402 <rdar://problem/35851353> Reviewed by Dean Jackson. LayoutTests/imported/w3c: Rebaselining a few tests using Element.animate(). They still fail, but no longer on the Element.animate() calls. * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output-expected.txt: * web-platform-tests/css-timing-1/frames-timing-functions-output-expected.txt: * web-platform-tests/css-timing-1/step-timing-functions-output-expected.txt: Source/WebCore: Now that we have added support for play() (webkit.org/b/178932) on Animation and parsing of multiple keyframes (webkit.org/b/179708), we can add support Element.animate(). To support this simple task, we must add a series of new IDL interfaces to support option parameters for Element.animate() (KeyframeAnimationOptions), AnimationEffect (AnimationEffectTimingProperties), KeyframeEffect (KeyframeEffectOptions) and supporting types CompositeOperation, FillMode, IterationCompositeOperation and PlaybackDirection. While we do not support most parameters of those types, we at least define them for future support. To support the most used form of the Element.animate() constructor across the WPT tests, we add support for specifying the duration of an animation when constructing both a KeyframeEffect and calling Element.animate(), either via a property on an options dictionary or as a double value. The implementation of Element.animate() itself is relatively straightforward, we just need to create a supporting KeyframeEffect based on the options provided, then an Animation with that effect set on it, and finally call play(). We also fix one crash that came up in WPT tests where we would try to access the DOMWindow when none was available in http/wpt/web-animations/interfaces/Animatable/animate-no-browsing-context.html. * CMakeLists.txt: Add new IDL files. * DerivedSources.make: Add new IDL files. * Sources.txt: Add new generated JS bindings. * WebCore.xcodeproj/project.pbxproj: Add new IDL, header and C++ files. * animation/Animatable.idl: Expose the animate() method. * animation/AnimationEffectTiming.cpp: (WebCore::AnimationEffectTiming::setBindingsDuration): Make the duration property spec-compliant and expect the right kind of type (unrestricted double or DOMString). * animation/AnimationEffectTiming.h: * animation/AnimationEffectTiming.idl: * animation/AnimationEffectTimingProperties.h: Added. * animation/AnimationEffectTimingProperties.idl: Added. * animation/CompositeOperation.h: Added. * animation/CompositeOperation.idl: Added. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::currentTime): Check that there is DOMWindow before proceeding to querying the current time through it, fixes a newly-apparent crash. * animation/FillMode.h: Added. * animation/FillMode.idl: Added. * animation/IterationCompositeOperation.h: Added. * animation/IterationCompositeOperation.idl: Added. * animation/KeyframeAnimationOptions.h: Added. * animation/KeyframeAnimationOptions.idl: Added. * animation/KeyframeEffect.cpp: Update types that are no longer defined under KeyframeEffect. (WebCore::processIterableKeyframes): (WebCore::processPropertyIndexedKeyframes): (WebCore::KeyframeEffect::create): Add support for duration provided either directly as a double or through KeyframeEffectOptions. * animation/KeyframeEffect.h: * animation/KeyframeEffect.idl: * animation/KeyframeEffectOptions.h: Added. * animation/KeyframeEffectOptions.idl: Added. * animation/PlaybackDirection.h: Added. * animation/PlaybackDirection.idl: Added. * dom/Element.cpp: (WebCore::Element::animate): Implement Element.animate(). * dom/Element.h: LayoutTests: Turning on Element.animate() means that a ton of WPT tests that would immediately fail when Element.animate() was used now progressed to either PASS, FAIL or TIMEOUT. We update the output to match the updated behavior and TestExpectations for some cases of flaky outputs due to incomplete implementations that had not surfaced until now. We're also removing a Blink test that uses Web Animations to animate a bogus "rotate" property. * TestExpectations: * http/wpt/web-animations/animation-model/animation-types/discrete-animation-expected.txt: * http/wpt/web-animations/animation-model/combining-effects/effect-composition-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-overlapping-keyframes-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-transformed-distance-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-visibility-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-no-browsing-context-expected.txt: * http/wpt/web-animations/interfaces/Animatable/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/Animation/cancel-expected.txt: * http/wpt/web-animations/interfaces/Animation/effect-expected.txt: * http/wpt/web-animations/interfaces/Animation/finish-expected.txt: * http/wpt/web-animations/interfaces/Animation/finished-expected.txt: * http/wpt/web-animations/interfaces/Animation/id-expected.txt: * http/wpt/web-animations/interfaces/Animation/oncancel-expected.txt: * http/wpt/web-animations/interfaces/Animation/onfinish-expected.txt: * http/wpt/web-animations/interfaces/Animation/pause-expected.txt: * http/wpt/web-animations/interfaces/Animation/play-expected.txt: * http/wpt/web-animations/interfaces/Animation/playState-expected.txt: * http/wpt/web-animations/interfaces/Animation/playbackRate-expected.txt: * http/wpt/web-animations/interfaces/Animation/ready-expected.txt: * http/wpt/web-animations/interfaces/Animation/startTime-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/getComputedStyle-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: * http/wpt/web-animations/interfaces/AnimationTimeline/document-timeline-expected.txt: * http/wpt/web-animations/interfaces/Document/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/composite-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/iterationComposite-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/setTarget-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/active-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/current-iteration-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/local-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/phases-and-states-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/simple-iteration-progress-expected.txt: * http/wpt/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/playing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * http/wpt/web-animations/timing-model/time-transformations/transformed-progress-expected.txt: * imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees-expected.html: Removed. * imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html: Removed. Canonical link: https://commits.webkit.org/197013@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-24 13:57:42 +00:00
/*
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
namespace WebCore {
[Web Animations] Audit Web Animations classes for memory reduction https://bugs.webkit.org/show_bug.cgi?id=193195 Reviewed by Simon Fraser and Yusuke Suzuki. The classes, enums and structs added to support Web Animations were not as memory-efficient as they could be. We now order members in a way that reduces padding, use Markable<T, Traits> instead of Optional<T> where applicable, declare enums as uint8_t and removed unnecessary members. As a result, classes and structs have shrunk as follows: WebAnimation: 256 > 216 DeclarativeAnimation: 392 > 344 CSSAnimation: 416 > 368 CSSTransition: 440 > 392 AnimationEffect: 88 > 72 KeyframeEffect: 208 > 184 AnimationPlaybackEvent: 104 > 88 EffectTiming: 72 > 64 ComputedEffectTiming: 136 > 112 AnimationTimeline: 264 > 248 DocumentTimeline: 496 > 464 OptionalEffectTiming: 112 > 80 BaseKeyframe: 32 > 24 ParsedKeyframe: 80 > 72 BaseComputedKeyframe: 40 > 32 * animation/AnimationEffect.h: Order members in decreasing size, except for m_fill and m_direction, which we put at the top to save 8 bytes (2 bytes of padding instead of 4 before m_animation and saving 6 bytes of padding at the end). * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::AnimationPlaybackEvent): * animation/AnimationPlaybackEvent.h: * animation/AnimationPlaybackEventInit.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::updateCSSTransitionsForElement): * animation/AnimationTimeline.h: We remove the m_classType member and instead make isDocumentTimeline() virtual. (WebCore::AnimationTimeline::isDocumentTimeline const): (): Deleted. (WebCore::AnimationTimeline::classType const): Deleted. * animation/CompositeOperation.h: * animation/CompositeOperationOrAuto.h: * animation/ComputedEffectTiming.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::invalidateDOMEvents): * animation/DeclarativeAnimation.h: We keep m_wasPending and m_previousPhase at the top to save some padding at the end. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: * animation/EffectTiming.h: * animation/FillMode.h: * animation/IterationCompositeOperation.h: * animation/KeyframeEffect.cpp: (WebCore::computeMissingKeyframeOffsets): (WebCore::KeyframeEffect::create): (WebCore::KeyframeEffect::KeyframeEffect): * animation/KeyframeEffect.h: * animation/OptionalEffectTiming.h: * animation/PlaybackDirection.h: * animation/WebAnimation.h: * animation/WebAnimationUtilities.h: (WebCore::WebAnimationsMarkableDoubleTraits::isEmptyValue): (WebCore::WebAnimationsMarkableDoubleTraits::emptyValue): Canonical link: https://commits.webkit.org/207806@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239820 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-01-10 08:19:39 +00:00
enum class IterationCompositeOperation : uint8_t { Replace, Accumulate };
[Web Animations] Implement Element.animate() https://bugs.webkit.org/show_bug.cgi?id=180402 <rdar://problem/35851353> Reviewed by Dean Jackson. LayoutTests/imported/w3c: Rebaselining a few tests using Element.animate(). They still fail, but no longer on the Element.animate() calls. * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output-expected.txt: * web-platform-tests/css-timing-1/frames-timing-functions-output-expected.txt: * web-platform-tests/css-timing-1/step-timing-functions-output-expected.txt: Source/WebCore: Now that we have added support for play() (webkit.org/b/178932) on Animation and parsing of multiple keyframes (webkit.org/b/179708), we can add support Element.animate(). To support this simple task, we must add a series of new IDL interfaces to support option parameters for Element.animate() (KeyframeAnimationOptions), AnimationEffect (AnimationEffectTimingProperties), KeyframeEffect (KeyframeEffectOptions) and supporting types CompositeOperation, FillMode, IterationCompositeOperation and PlaybackDirection. While we do not support most parameters of those types, we at least define them for future support. To support the most used form of the Element.animate() constructor across the WPT tests, we add support for specifying the duration of an animation when constructing both a KeyframeEffect and calling Element.animate(), either via a property on an options dictionary or as a double value. The implementation of Element.animate() itself is relatively straightforward, we just need to create a supporting KeyframeEffect based on the options provided, then an Animation with that effect set on it, and finally call play(). We also fix one crash that came up in WPT tests where we would try to access the DOMWindow when none was available in http/wpt/web-animations/interfaces/Animatable/animate-no-browsing-context.html. * CMakeLists.txt: Add new IDL files. * DerivedSources.make: Add new IDL files. * Sources.txt: Add new generated JS bindings. * WebCore.xcodeproj/project.pbxproj: Add new IDL, header and C++ files. * animation/Animatable.idl: Expose the animate() method. * animation/AnimationEffectTiming.cpp: (WebCore::AnimationEffectTiming::setBindingsDuration): Make the duration property spec-compliant and expect the right kind of type (unrestricted double or DOMString). * animation/AnimationEffectTiming.h: * animation/AnimationEffectTiming.idl: * animation/AnimationEffectTimingProperties.h: Added. * animation/AnimationEffectTimingProperties.idl: Added. * animation/CompositeOperation.h: Added. * animation/CompositeOperation.idl: Added. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::currentTime): Check that there is DOMWindow before proceeding to querying the current time through it, fixes a newly-apparent crash. * animation/FillMode.h: Added. * animation/FillMode.idl: Added. * animation/IterationCompositeOperation.h: Added. * animation/IterationCompositeOperation.idl: Added. * animation/KeyframeAnimationOptions.h: Added. * animation/KeyframeAnimationOptions.idl: Added. * animation/KeyframeEffect.cpp: Update types that are no longer defined under KeyframeEffect. (WebCore::processIterableKeyframes): (WebCore::processPropertyIndexedKeyframes): (WebCore::KeyframeEffect::create): Add support for duration provided either directly as a double or through KeyframeEffectOptions. * animation/KeyframeEffect.h: * animation/KeyframeEffect.idl: * animation/KeyframeEffectOptions.h: Added. * animation/KeyframeEffectOptions.idl: Added. * animation/PlaybackDirection.h: Added. * animation/PlaybackDirection.idl: Added. * dom/Element.cpp: (WebCore::Element::animate): Implement Element.animate(). * dom/Element.h: LayoutTests: Turning on Element.animate() means that a ton of WPT tests that would immediately fail when Element.animate() was used now progressed to either PASS, FAIL or TIMEOUT. We update the output to match the updated behavior and TestExpectations for some cases of flaky outputs due to incomplete implementations that had not surfaced until now. We're also removing a Blink test that uses Web Animations to animate a bogus "rotate" property. * TestExpectations: * http/wpt/web-animations/animation-model/animation-types/discrete-animation-expected.txt: * http/wpt/web-animations/animation-model/combining-effects/effect-composition-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-context-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-overlapping-keyframes-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-transformed-distance-expected.txt: * http/wpt/web-animations/animation-model/keyframe-effects/effect-value-visibility-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-no-browsing-context-expected.txt: * http/wpt/web-animations/interfaces/Animatable/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/Animation/cancel-expected.txt: * http/wpt/web-animations/interfaces/Animation/effect-expected.txt: * http/wpt/web-animations/interfaces/Animation/finish-expected.txt: * http/wpt/web-animations/interfaces/Animation/finished-expected.txt: * http/wpt/web-animations/interfaces/Animation/id-expected.txt: * http/wpt/web-animations/interfaces/Animation/oncancel-expected.txt: * http/wpt/web-animations/interfaces/Animation/onfinish-expected.txt: * http/wpt/web-animations/interfaces/Animation/pause-expected.txt: * http/wpt/web-animations/interfaces/Animation/play-expected.txt: * http/wpt/web-animations/interfaces/Animation/playState-expected.txt: * http/wpt/web-animations/interfaces/Animation/playbackRate-expected.txt: * http/wpt/web-animations/interfaces/Animation/ready-expected.txt: * http/wpt/web-animations/interfaces/Animation/startTime-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/getComputedStyle-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: * http/wpt/web-animations/interfaces/AnimationTimeline/document-timeline-expected.txt: * http/wpt/web-animations/interfaces/Document/getAnimations-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/composite-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/iterationComposite-expected.txt: * http/wpt/web-animations/interfaces/KeyframeEffect/setTarget-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/active-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/current-iteration-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/local-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/phases-and-states-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/simple-iteration-progress-expected.txt: * http/wpt/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/playing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * http/wpt/web-animations/timing-model/time-transformations/transformed-progress-expected.txt: * imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees-expected.html: Removed. * imported/blink/virtual/threaded/animations/compositor-rotate-zero-degrees.html: Removed. Canonical link: https://commits.webkit.org/197013@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226289 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-12-24 13:57:42 +00:00
} // namespace WebCore