haikuwebkit/LayoutTests/webanimations/css-animations.html

227 lines
13 KiB
HTML
Raw Permalink Normal View History

Remove the legacy animation code https://bugs.webkit.org/show_bug.cgi?id=216608 Reviewed by Dean Jackson. Source/WebCore: We remove the legacy animation code found in Source/WebCore/page/animation/, save for CSSPropertyAnimation which is also used by the new Web Animations engine and now moved to Source/WebCore/animation/. Since we now have a single animation engine, the runtime flags to optionally enable the Web Animations engine are not needed anymore and removed as well. We also remove some testing utilities and some RenderLayerBacking methods specific to accelerated transitions which the new animation engine does not use. * CMakeLists.txt: * Headers.cmake: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/Animatable.idl: * animation/AnimationEffect.idl: * animation/AnimationPlaybackEvent.idl: * animation/AnimationPlaybackEventInit.idl: * animation/AnimationTimeline.idl: * animation/CSSAnimation.idl: * animation/CSSPropertyAnimation.cpp: Renamed from Source/WebCore/page/animation/CSSPropertyAnimation.cpp. (WebCore::PropertyWrapperVisitedAffectedColor::PropertyWrapperVisitedAffectedColor): * animation/CSSPropertyAnimation.h: Renamed from Source/WebCore/page/animation/CSSPropertyAnimation.h. * animation/CSSTransition.idl: * animation/DocumentAnimations.idl: * animation/DocumentOrShadowRootAnimations.idl: * animation/DocumentTimeline.idl: * animation/KeyframeEffect.idl: * animation/WebAnimation.idl: * animation/WebAnimationTypes.h: * css/CSSComputedStyleDeclaration.cpp: (WebCore::computeRenderStyleForProperty): * dom/Document.cpp: (WebCore::Document::resolveStyle): (WebCore::Document::didBecomeCurrentDocumentInFrame): (WebCore::Document::willBeRemovedFromFrame): (WebCore::Document::implicitClose): (WebCore::Document::resume): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): * history/CachedFrame.cpp: (WebCore::CachedFrame::destroy): * page/Frame.cpp: (WebCore::Frame::Frame): (WebCore::Frame::clearTimers): (WebCore::Frame::resumeActiveDOMObjectsAndAnimations): * page/Frame.h: * page/FrameView.cpp: (WebCore::FrameView::didDestroyRenderTree): (WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive): * page/FrameViewLayoutContext.cpp: (WebCore::FrameViewLayoutContext::layout): * page/Page.cpp: (WebCore::Page::handleLowModePowerChange): (WebCore::Page::setIsVisibleInternal): (WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged): * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::setWebAnimationsEnabled): Deleted. (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Deleted. (WebCore::RuntimeEnabledFeatures::setWebAnimationsCSSIntegrationEnabled): Deleted. (WebCore::RuntimeEnabledFeatures::webAnimationsCSSIntegrationEnabled const): Deleted. * page/animation/AnimationBase.cpp: Removed. * page/animation/AnimationBase.h: Removed. * page/animation/CSSAnimationController.cpp: Removed. * page/animation/CSSAnimationController.h: Removed. * page/animation/CSSAnimationControllerPrivate.h: Removed. * page/animation/CompositeAnimation.cpp: Removed. * page/animation/CompositeAnimation.h: Removed. * page/animation/ImplicitAnimation.cpp: Removed. * page/animation/ImplicitAnimation.h: Removed. * page/animation/KeyframeAnimation.cpp: Removed. * page/animation/KeyframeAnimation.h: Removed. * platform/graphics/GraphicsLayer.h: * platform/graphics/ca/GraphicsLayerCA.cpp: (WebCore::isKeyframe): (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes): * rendering/RenderElement.cpp: (WebCore::RenderElement::animatedStyle): * rendering/RenderElement.h: (WebCore::RenderElement::startTransition): Deleted. (WebCore::RenderElement::transitionPaused): Deleted. (WebCore::RenderElement::transitionFinished): Deleted. * rendering/RenderLayer.cpp: (WebCore::RenderLayer::currentTransform const): (WebCore::RenderLayer::calculateClipRects const): * rendering/RenderLayerBacking.cpp: (WebCore::RenderLayerBacking::updateGeometry): (WebCore::RenderLayerBacking::notifyAnimationStarted): (WebCore::RenderLayerBacking::startTransition): Deleted. (WebCore::RenderLayerBacking::transitionPaused): Deleted. (WebCore::RenderLayerBacking::transitionFinished): Deleted. * rendering/RenderLayerBacking.h: * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::flushPendingLayerChanges): (WebCore::RenderLayerCompositor::updateCompositingLayers): (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/RenderLayerModelObject.cpp: (WebCore::RenderLayerModelObject::startTransition): Deleted. (WebCore::RenderLayerModelObject::transitionPaused): Deleted. (WebCore::RenderLayerModelObject::transitionFinished): Deleted. * rendering/RenderLayerModelObject.h: * rendering/RenderObject.h: (WebCore::RenderObject::legacyAnimation const): Deleted. * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleAdjuster.cpp: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * testing/InternalSettings.cpp: (WebCore::InternalSettings::webAnimationsCSSIntegrationEnabled): Deleted. * testing/InternalSettings.h: * testing/InternalSettings.idl: * testing/Internals.cpp: (WebCore::Internals::numberOfActiveAnimations const): (WebCore::Internals::animationsAreSuspended const): (WebCore::Internals::animationsInterval const): (WebCore::Internals::suspendAnimations const): (WebCore::Internals::resumeAnimations const): (WebCore::Internals::acceleratedAnimationsForElement): (WebCore::Internals::numberOfAnimationTimelineInvalidations const): (WebCore::Internals::pauseAnimationAtTimeOnElement): Deleted. (WebCore::Internals::pauseAnimationAtTimeOnPseudoElement): Deleted. (WebCore::Internals::pauseTransitionAtTimeOnElement): Deleted. (WebCore::Internals::pauseTransitionAtTimeOnPseudoElement): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Since we now have a single animation engine, the runtime flags to optionally enable the Web Animations engine are not needed anymore and are now removed. * Shared/WebPreferencesExperimental.yaml: * UIProcess/API/C/WKPreferences.cpp: (WKPreferencesSetWebAnimationsEnabled): Deleted. (WKPreferencesGetWebAnimationsEnabled): Deleted. (WKPreferencesSetWebAnimationsCSSIntegrationEnabled): Deleted. (WKPreferencesGetWebAnimationsCSSIntegrationEnabled): Deleted. * UIProcess/API/C/WKPreferencesRefPrivate.h: * UIProcess/API/Cocoa/WKPreferences.mm: (-[WKPreferences _setWebAnimationsCSSIntegrationEnabled:]): Deleted. (-[WKPreferences _webAnimationsCSSIntegrationEnabled]): Deleted. * UIProcess/API/Cocoa/WKPreferencesPrivate.h: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): Deleted. (WebKit::InjectedBundle::setWebAnimationsCSSIntegrationEnabled): Deleted. * WebProcess/InjectedBundle/InjectedBundle.h: Source/WebKitLegacy/mac: Since we now have a single animation engine, the runtime flags to optionally enable the Web Animations engine are not needed anymore and are now removed. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences webAnimationsEnabled]): Deleted. (-[WebPreferences setWebAnimationsEnabled:]): Deleted. (-[WebPreferences webAnimationsCSSIntegrationEnabled]): Deleted. (-[WebPreferences setWebAnimationsCSSIntegrationEnabled:]): Deleted. * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Since we now have a single animation engine, the runtime flags to optionally enable the Web Animations engine are not needed anymore and are now removed. * Interfaces/IWebFramePrivate.idl: * Interfaces/IWebPreferencesPrivate.idl: * WebFrame.cpp: (WebFrame::resumeAnimations): Deleted. (WebFrame::suspendAnimations): Deleted. (WebFrame::pauseAnimation): Deleted. (WebFrame::pauseTransition): Deleted. (WebFrame::numberOfActiveAnimations): Deleted. * WebFrame.h: * WebPreferenceKeysPrivate.h: * WebPreferences.cpp: (WebPreferences::initializeDefaultSettings): (WebPreferences::webAnimationsCSSIntegrationEnabled): Deleted. (WebPreferences::setWebAnimationsCSSIntegrationEnabled): Deleted. (WebPreferences::setWebAnimationsEnabled): Deleted. (WebPreferences::webAnimationsEnabled): Deleted. * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Since we now have a single animation engine, the runtime flags to optionally enable the Web Animations engine are not needed anymore and are now removed. * DumpRenderTree/TestOptions.cpp: (TestOptions::TestOptions): (TestOptions::webViewIsCompatibleWithOptions const): * DumpRenderTree/TestOptions.h: * DumpRenderTree/mac/DumpRenderTree.mm: (enableExperimentalFeatures): (setWebPreferencesForTestOptions): * DumpRenderTree/win/DumpRenderTree.cpp: (enableExperimentalFeatures): (setWebPreferencesForTestOptions): LayoutTests: Remove any use of now-removed testing methods and some runtime flags from layout tests. * animations/legacy-encoding-timing-function.html: * animations/resources/animation-test-helpers.js: (pauseAnimationAtTimeOnElement): * http/tests/contentextensions/css-display-none-keyframe.html: * imported/blink/transitions/resources/opacity-transform-transitions-inside-iframe-inner.html: Removed. * transitions/background-position-transitions.html: * transitions/background-transitions.html: * transitions/blendmode-transitions.html: * transitions/border-radius-transition.html: * transitions/clip-path-path-transitions.html: * transitions/clip-path-transitions.html: * transitions/clip-transition.html: * transitions/color-transition-all.html: * transitions/color-transition-premultiplied.html: * transitions/color-transition-rounding.html: * transitions/cross-fade-background-image.html: * transitions/cross-fade-border-image.html: * transitions/cubic-bezier-overflow-color.html: * transitions/cubic-bezier-overflow-length.html: * transitions/cubic-bezier-overflow-shadow.html: * transitions/cubic-bezier-overflow-svg-length.html: * transitions/cubic-bezier-overflow-transform.html: * transitions/default-timing-function.html: * transitions/delay.html: * transitions/flex-transitions.html: * transitions/font-family-during-transition.html: * transitions/frames-timing-function.html: * transitions/interrupted-all-transition.html: * transitions/longhand-vs-shorthand-initial.html: * transitions/mask-transitions.html: * transitions/min-max-width-height-transitions.html: * transitions/mismatched-shadow-styles.html: * transitions/mismatched-shadow-transitions.html: * transitions/mixed-type.html: * transitions/move-after-transition.html: * transitions/multiple-background-size-transitions.html: * transitions/multiple-background-transitions.html: * transitions/multiple-mask-transitions.html: * transitions/multiple-shadow-transitions.html: * transitions/negative-delay.html: * transitions/opacity-transition-zindex.html: * transitions/resources/transition-test-helpers.js: * transitions/shape-outside-transitions.html: * transitions/shorthand-border-transitions.html: * transitions/shorthand-transitions.html: * transitions/steps-timing-function.html: * transitions/svg-layout-transition.html: * transitions/svg-text-shadow-transition.html: * transitions/svg-transitions.html: * transitions/text-indent-transition.html: * transitions/transform-op-list-match.html: * transitions/transform-op-list-no-match.html: * transitions/transition-end-event-rendering.html: * transitions/transition-hit-test-transform.html: * transitions/transition-hit-test.html: * transitions/transition-in-delay-phase.html: * transitions/transition-on-element-with-content.html: * transitions/transition-shorthand-delay.html: * transitions/transition-timing-function.html: * transitions/transition-to-from-auto.html: * transitions/transition-to-from-undefined.html: * transitions/visited-link-color.html: * transitions/zero-duration-in-list.html: * transitions/zero-duration-with-non-zero-delay-start.html: * webanimations/accelerated-animation-interruption-display-none.html: * webanimations/accelerated-animation-removal-upon-transition-completion.html: * webanimations/accelerated-animation-suspension.html: * webanimations/accelerated-transition-by-removing-property.html: * webanimations/accessing-current-time-after-clearing-css-animation-effect.html: * webanimations/accessing-current-time-after-finished-css-animation-target-removal.html: * webanimations/css-animation-effect-target-change-and-animation-removal-crash.html: * webanimations/css-animation-effect-target-change-and-get-keyframes-crash.html: * webanimations/css-animations.html: * webanimations/css-transition-in-flight-reversal-accelerated.html: * webanimations/empty-keyframes-crash.html: * webanimations/partly-accelerated-transition-by-removing-property.html: * webanimations/setting-css-animation-none-after-clearing-effect.html: * webanimations/setting-css-animation-timing-property-via-style-after-clearing-effect.html: Canonical link: https://commits.webkit.org/229462@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267188 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-17 12:39:28 +00:00
<!DOCTYPE html>
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
<meta charset=utf-8>
<title>CSS Animations</title>
<style type="text/css" media="screen">
@keyframes animation {
from { left: 50px; }
to { left: 100px; }
}
@keyframes animation-top {
from { top: 50px; }
to { top: 100px; }
}
</style>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script>
'use strict';
function targetTest(testCallback, description)
{
test(() => {
const target = document.body.appendChild(document.createElement("div"));
testCallback(target);
target.remove();
}, description);
}
targetTest(target => {
assert_array_equals(target.getAnimations(), [], "An element should not have any animations initially.");
target.style.animationDelay = "-3s";
target.style.animationDuration = "2s";
target.style.animationTimingFunction = "linear";
target.style.animationFillMode = "forwards";
target.style.animationDirection = "alternate";
target.style.animationIterationCount = "2";
target.style.animationName = "animation";
const animation = target.getAnimations()[0];
assert_true(animation instanceof Animation, "The animation is an Animation.");
assert_true(animation instanceof CSSAnimation, "The animation is a CSSAnimation.");
assert_equals(animation.timeline, target.ownerDocument.timeline, "The animation's timeline is set to the element's document timeline.");
assert_equals(animation.playState, "running", "The animation is running as soon as it's created.");
assert_equals(animation.animationName, "animation", "The animation's animationName is set.");
const effect = animation.effect;
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_true(effect instanceof KeyframeEffect, "The animation's effect is a KeyframeEffect.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
assert_equals(effect.target, target, "The animation's effect is targeting the target.");
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
const timing = animation.effect.getTiming();
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
assert_equals(timing.fill, "forwards", "The animation's fill property matches the animation-fill-mode property.");
assert_equals(timing.delay, -3000, "The animation's delay property matches the animation-delay property.");
assert_equals(timing.duration, 2000, "The animation's duration property matches the animation-duration property.");
assert_equals(timing.iterations, 2, "The animation's iterations property matches the animation-iteration-count property.");
assert_equals(timing.direction, "alternate", "The animation's direction property matches the animation-direction property.");
const computedTiming = animation.effect.getComputedTiming();
assert_equals(computedTiming.activeDuration, 4000, "The animations's computed timing activeDuration property matches the properties set by CSS");
assert_equals(computedTiming.currentIteration, 1, "The animations's computed timing currentIteration property matches the properties set by CSS");
assert_equals(computedTiming.delay, -3000, "The animations's computed timing delay property matches the properties set by CSS");
assert_equals(computedTiming.duration, 2000, "The animations's computed timing duration property matches the properties set by CSS");
assert_equals(computedTiming.endDelay, 0, "The animations's computed timing endDelay property matches the properties set by CSS");
assert_equals(computedTiming.endTime, 1000, "The animations's computed timing endTime property matches the properties set by CSS");
assert_equals(computedTiming.iterationStart, 0, "The animations's computed timing iterationStart property matches the properties set by CSS");
assert_equals(computedTiming.iterations, 2, "The animations's computed timing iterations property matches the properties set by CSS");
assert_equals(computedTiming.localTime, 0, "The animations's computed timing localTime property matches the properties set by CSS");
assert_equals(computedTiming.progress, 0.5, "The animations's computed timing progress property matches the properties set by CSS");
assert_equals(computedTiming.fill, "forwards", "The animations's computed timing fill property matches the properties set by CSS");
assert_equals(computedTiming.easing, "linear", "The animations's computed timing easing property matches the properties set by CSS");
assert_equals(computedTiming.direction, "alternate", "The animations's computed timing direction property matches the properties set by CSS");
const keyframes = animation.effect.getKeyframes();
assert_equals(keyframes.length, 2, "The animation's effect has two keyframes.");
assert_equals(keyframes[0].offset, 0, "The animation's effect's first keyframe has a 0 offset.");
assert_equals(keyframes[0].left, "50px", "The animation's effect's first keyframe has its left property set to 50px.");
assert_equals(keyframes[1].offset, 1, "The animation's effect's first keyframe has a 1 offset.");
assert_equals(keyframes[1].left, "100px", "The animation's effect's first keyframe has its left property set to 100px.");
assert_equals(getComputedStyle(effect.target).left, "75px", "The animation's target's computed style reflects the animation state.");
}, "A CSS Animation should be reflected entirely as a CSSAnimation object on the timeline.");
targetTest(target => {
target.style.animationDelay = "-1s";
target.style.animationDuration = "2s";
target.style.animationName = "animation";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().delay, -1000, "The animation's delay matches the initial animation-delay property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
CSS Transitions and CSS Animations properties should treat unitless 0 as an invalid value for times https://bugs.webkit.org/show_bug.cgi?id=203484 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Mark WPT progressions. * web-platform-tests/css/css-animations/parsing/animation-delay-invalid-expected.txt: * web-platform-tests/css/css-animations/parsing/animation-duration-invalid-expected.txt: * web-platform-tests/css/css-transitions/parsing/transition-delay-invalid-expected.txt: Source/WebCore: The CSS specification does not allow for "0" as a valid time (https://drafts.csswg.org/css-values-3/#time). We change the way we parse time values to only allow for "0" if the UnitlessQuirk is set to Allow, which is only the case for the -webkit-marquee-speed property. * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeTime): Source/WebInspectorUI: Use 0s instead of 0 in places where unitless times were used but shouldn't have been. * UserInterface/Views/FindBanner.css: (.no-find-banner-transition:matches(.find-banner, .supports-find-banner)): * UserInterface/Views/TabBar.css: (.tab-bar > .item > .close): LayoutTests: Use 0s instead of 0 in places where unitless times were used but shouldn't have been. * animations/fill-mode-forwards-zero-duration.html: * compositing/animation/keyframe-order.html: * css1/units/zero-duration-without-units.html: * legacy-animation-engine/animations/fill-mode-forwards-zero-duration.html: * legacy-animation-engine/compositing/animation/keyframe-order.html: * legacy-animation-engine/css1/units/zero-duration-without-units.html: * legacy-animation-engine/transitions/zero-duration-in-list.html: * legacy-animation-engine/transitions/zero-duration-without-units.html: * transitions/zero-duration-in-list.html: * transitions/zero-duration-without-units.html: * webanimations/css-animations-expected.txt: * webanimations/css-animations.html: Canonical link: https://commits.webkit.org/216885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251658 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-28 17:01:55 +00:00
target.style.animationDelay = "0s";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().delay, 0, "The animation's delay matches the updated animation-delay property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}, "Web Animations should reflect the animation-delay property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationName = "animation";
for (let direction of ["reverse", "alternate", "normal", "alternate-reverse"]) {
target.style.animationDirection = direction;
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().direction, direction, `The animation's direction matches the "${direction}" CSS value.`);
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}
target.style.removeProperty("animation-direction");
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().direction, "normal", "The animation's easing matches the default animation-direction value when the property is not set.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}, "Web Animations should reflect the animation-direction property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationName = "animation";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().duration, 2000, "The animation's duration matches the initial animation-duration property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
target.style.animationDuration = "1s";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().duration, 1000, "The animation's duration matches the updated animation-duration property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}, "Web Animations should reflect the animation-duration property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationName = "animation";
for (let fillMode of ["forwards", "backwards", "none", "both"]) {
target.style.animationFillMode = fillMode;
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().fill, fillMode, `The animation's fill mode matches the "${fillMode}" CSS value.`);
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}
target.style.removeProperty("animation-fill-mode");
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().fill, "none", "The animation's easing matches the default animation-fill-mode value when the property is not set.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
}, "Web Animations should reflect the animation-fill-mode property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationName = "animation";
target.style.animationIterationCount = 2;
const initialAnimation = target.getAnimations()[0];
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().iterations, 2, "The animation's duration matches the initial animation-iteration-count property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
target.style.animationIterationCount = 1;
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().iterations, 1, "The animation's duration matches the updated animation-iteration-count property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
assert_equals(target.getAnimations()[0], initialAnimation, "The animation object remained the same instance throughout the test.");
}, "Web Animations should reflect the animation-iteration-count property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationName = "animation";
const initialAnimation = target.getAnimations()[0];
assert_equals(target.getAnimations()[0].animationName, "animation", "The animation's name matches the initial animation-name CSS property.");
const initialKeyframes = initialAnimation.effect.getKeyframes();
assert_equals(initialKeyframes.length, 2);
assert_equals(initialKeyframes[0].offset, 0);
assert_equals(initialKeyframes[0].left, "50px");
assert_equals(initialKeyframes[1].offset, 1);
assert_equals(initialKeyframes[1].left, "100px");
target.style.animationName = "animation-top";
const updatedAnimation = target.getAnimations()[0];
assert_not_equals(updatedAnimation, initialAnimation, "Changing the animation-name property generates a different CSSAnimation object.");
assert_equals(updatedAnimation.animationName, "animation-top", "The animation's name matches the updated animation-name CSS property.");
const updatedKeyframes = updatedAnimation.effect.getKeyframes();
assert_equals(updatedKeyframes.length, 2);
assert_equals(updatedKeyframes[0].offset, 0);
assert_equals(updatedKeyframes[0].top, "50px");
assert_equals(updatedKeyframes[1].offset, 1);
assert_equals(updatedKeyframes[1].top, "100px");
}, "Web Animations should reflect the animation-name property.");
targetTest(target => {
target.style.animationDelay = "-1s";
target.style.animationDuration = "2s";
target.style.animationName = "animation";
const initialAnimation = target.getAnimations()[0];
assert_equals(target.getAnimations()[0].playState, "running", "Setting animation-play-state to running should resume the animation.");
target.style.animationPlayState = "paused";
assert_equals(target.getAnimations()[0].playState, "paused", "Setting animation-play-state back to paused should pause the animation.");
target.style.removeProperty("animation-play-state");
assert_equals(target.getAnimations()[0].playState, "running", "Removing the animation-play-state property should resume the animation.");
assert_equals(target.getAnimations()[0], initialAnimation, "The animation object remained the same instance throughout the test.");
}, "Web Animations should reflect the animation-play-state property.");
targetTest(target => {
target.style.animationDuration = "2s";
target.style.animationTimingFunction = "ease-out";
target.style.animationName = "animation";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().easing, "linear", "The animation's easing does not match the initial animation-timing-function property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
target.style.animationTimingFunction = "ease-in";
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().easing, "linear", "The animation's easing does not match the updated animation-timing-function property.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
target.style.removeProperty("animation-timing-function");
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
assert_equals(target.getAnimations()[0].effect.getTiming().easing, "linear", "The animation's easing does not match the default animation-timing-function value when the property is not set.");
[Web Animations] Correctly handle timing functions specified by CSS Animations and CSS Transitions https://bugs.webkit.org/show_bug.cgi?id=183935 Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Record progressions of Mozilla tests. * css-animations/test_animation-computed-timing-expected.txt: * css-transitions/test_animation-computed-timing-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: Source/WebCore: We were incorrectly reflecting the animation-timing-function and transition-timing-function values on the generated DeclarativeAnimation effect timing "easing" property. In fact, those values should only be represented on the keyframes. In the case of a CSS Animation, the animation-timing-function property set on the element's style serves as the default value used for all keyframes, and individual keyframes can specify an overriding animation-timing-function. For a CSS Transition, the transition-timing-function property set on the element's style serves as the timing function of the from keyframe. To correctly reflect this, we provide a new timingFunctionForKeyframeAtIndex() function on KeyframeEffectReadOnly which will return the right TimingFunction object at a given index, regardless of the animation type. In the case of getKeyframes(), we manually return "linear" for the "to" keyframe since timingFunctionForKeyframeAtIndex() would otherwise return the same timing function as the "from" keyframe. This avoids creating an extra LinearTimingFunction object. As a result, a number of Mozilla imported tests progress since we have correct information on the "easing" property of objects returned by getKeyframes() and the "progress" reported by getComputedTiming() now always uses a linear timing function. * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): The timing function of the backing Animation should not be reflected on the effect's timing object. * animation/KeyframeEffectReadOnly.cpp: (WebCore::KeyframeEffectReadOnly::getKeyframes): Return the correct timing function for a keyframe, and use a "linear" value for the "to" keyframe of a CSS Transition. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): (WebCore::KeyframeEffectReadOnly::timingFunctionForKeyframeAtIndex): * animation/KeyframeEffectReadOnly.h: LayoutTests: We now pass 2 additional Mozilla tests completely, so they no longer need to be marked as flaky failures or timeouts. We also update tests that we wrote ourselves and which incorrectly assumed that the effect's timing would reflect the timing function set by CSS. * TestExpectations: * webanimations/css-animations-expected.txt: * webanimations/css-animations.html: * webanimations/css-transitions-expected.txt: * webanimations/css-transitions.html: Canonical link: https://commits.webkit.org/199613@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229981 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-26 19:08:01 +00:00
}, "Web Animations should not reflect the animation-timing-function property on the effect's timing.");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
function runAnimationCompletionTest(finalAssertionCallback, description)
{
targetTest(target => {
target.style.animationName = "animation";
assert_array_equals(target.getAnimations(), [], "Seting the animation-name property alone does not yield a CSSAnimation.");
target.style.animationDuration = "1s";
assert_equals(target.getAnimations().length, 1, "Seting the animation-duration property on top of the animation-name yields a CSSAnimation.");
assert_equals(target.getAnimations()[0].playState, "running", "Seting the animation-duration property on top of the animation-name yields a running CSSAnimation.");
finalAssertionCallback(target.getAnimations()[0]);
assert_array_equals(target.getAnimations(), [], `${description} no longer lists the animation.`);
}, `${description} no longer lists the animation after it has been running.`);
}
runAnimationCompletionTest(animation => animation.finish(), "Calling finish() on the animation");
[Web Animations] Update all tests to match the latest API changes https://bugs.webkit.org/show_bug.cgi?id=191302 <rdar://problem/41000438> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: * css-animations/test_animation-computed-timing.html: * css-animations/test_effect-target.html: * css-animations/test_keyframeeffect-getkeyframes-expected.txt: * css-animations/test_keyframeeffect-getkeyframes.html: * css-animations/test_pseudoElement-get-animations.html: * css-transitions/test_effect-target.html: * css-transitions/test_keyframeeffect-getkeyframes-expected.txt: * css-transitions/test_keyframeeffect-getkeyframes.html: LayoutTests/imported/w3c: * web-platform-tests/css-timing-1/cubic-bezier-timing-functions-output.html: * web-platform-tests/web-animations/META.yml: Added. * web-platform-tests/web-animations/README.md: Added. * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/addition-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property.html: * web-platform-tests/web-animations/animation-model/animation-types/property-list.js: * web-platform-tests/web-animations/animation-model/animation-types/property-types.js: * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result-expected.txt: Added. * web-platform-tests/web-animations/animation-model/combining-effects/applying-the-composited-result.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance-expected.txt: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-interval-distance.html: Added. * web-platform-tests/web-animations/animation-model/keyframe-effects/effect-value-iteration-composite-operation.html: * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/animate.html: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html: * web-platform-tests/web-animations/interfaces/Animation/cancel.html: * web-platform-tests/web-animations/interfaces/Animation/constructor.html: * web-platform-tests/web-animations/interfaces/Animation/effect.html: * web-platform-tests/web-animations/interfaces/Animation/finish-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/finish.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/finished.html: * web-platform-tests/web-animations/interfaces/Animation/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Animation/onfinish.html: * web-platform-tests/web-animations/interfaces/Animation/playbackRate-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/Animation/playbackRate.html: Removed. * web-platform-tests/web-animations/interfaces/Animation/ready.html: * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming-expected.txt. * web-platform-tests/web-animations/interfaces/AnimationEffect/getComputedTiming.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/AnimationEffectTiming/getComputedTiming.html. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming-expected.txt: Added. * web-platform-tests/web-animations/interfaces/AnimationEffect/updateTiming.html: Added. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/delay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/direction.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/duration.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/easing.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/endDelay.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/fill.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterationStart.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationEffectTiming/iterations.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/AnimationPlaybackEvent/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations.html: * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/DocumentTimeline/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/composite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/copy-constructor.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness-expected.txt: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.html: Removed. * web-platform-tests/web-animations/interfaces/KeyframeEffect/idlharness.window.js: Added. * web-platform-tests/web-animations/interfaces/KeyframeEffect/iterationComposite.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/processing-a-keyframes-argument-001.html: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes-expected.txt: * web-platform-tests/web-animations/interfaces/KeyframeEffect/setKeyframes.html: * web-platform-tests/web-animations/resources/keyframe-tests.js: * web-platform-tests/web-animations/resources/timing-tests.js: Added. * web-platform-tests/web-animations/resources/timing-utils.js: Added. * web-platform-tests/web-animations/testcommon.js: * web-platform-tests/web-animations/timing-model/animation-effects/phases-and-states.html: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/canceling-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/finishing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/pausing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/play-states-expected.txt: * web-platform-tests/web-animations/timing-model/animations/play-states.html: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/playing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation-expected.txt: * web-platform-tests/web-animations/timing-model/animations/reversing-an-animation.html: * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/seamlessly-updating-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-current-time-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation-expected.txt: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-playback-rate-of-an-animation.html: Added. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-start-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-animation-start-time.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-target-effect-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-target-effect-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation-expected.txt. * web-platform-tests/web-animations/timing-model/animations/setting-the-timeline-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/set-the-timeline-of-an-animation.html. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation-expected.txt: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt. * web-platform-tests/web-animations/timing-model/animations/the-current-time-of-an-animation.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/animations/current-time.html. * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state.html: * web-platform-tests/web-animations/timing-model/timelines/document-timelines.html: * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-expected.txt: Added. * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events.html: Added. LayoutTests: * TestExpectations: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/ios/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac-sierra/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/accumulation-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/addition-per-property-expected.txt: * platform/mac/imported/w3c/web-platform-tests/web-animations/animation-model/animation-types/interpolation-per-property-expected.txt: * webanimations/css-animations.html: * webanimations/left-and-opacity-animation-yields-no-compositing.html: * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/width-and-opacity-separate-animation-yields-no-compositing.html: Canonical link: https://commits.webkit.org/206106@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237857 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:16:48 +00:00
runAnimationCompletionTest(animation => animation.currentTime = animation.effect.getTiming().duration, "Seeking the animation to its end time");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
runAnimationCompletionTest(animation => animation.effect.target.style.animationName = "none", "Setting the target's animation-name to none");
CSS Transitions and CSS Animations properties should treat unitless 0 as an invalid value for times https://bugs.webkit.org/show_bug.cgi?id=203484 Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Mark WPT progressions. * web-platform-tests/css/css-animations/parsing/animation-delay-invalid-expected.txt: * web-platform-tests/css/css-animations/parsing/animation-duration-invalid-expected.txt: * web-platform-tests/css/css-transitions/parsing/transition-delay-invalid-expected.txt: Source/WebCore: The CSS specification does not allow for "0" as a valid time (https://drafts.csswg.org/css-values-3/#time). We change the way we parse time values to only allow for "0" if the UnitlessQuirk is set to Allow, which is only the case for the -webkit-marquee-speed property. * css/parser/CSSPropertyParserHelpers.cpp: (WebCore::CSSPropertyParserHelpers::consumeTime): Source/WebInspectorUI: Use 0s instead of 0 in places where unitless times were used but shouldn't have been. * UserInterface/Views/FindBanner.css: (.no-find-banner-transition:matches(.find-banner, .supports-find-banner)): * UserInterface/Views/TabBar.css: (.tab-bar > .item > .close): LayoutTests: Use 0s instead of 0 in places where unitless times were used but shouldn't have been. * animations/fill-mode-forwards-zero-duration.html: * compositing/animation/keyframe-order.html: * css1/units/zero-duration-without-units.html: * legacy-animation-engine/animations/fill-mode-forwards-zero-duration.html: * legacy-animation-engine/compositing/animation/keyframe-order.html: * legacy-animation-engine/css1/units/zero-duration-without-units.html: * legacy-animation-engine/transitions/zero-duration-in-list.html: * legacy-animation-engine/transitions/zero-duration-without-units.html: * transitions/zero-duration-in-list.html: * transitions/zero-duration-without-units.html: * webanimations/css-animations-expected.txt: * webanimations/css-animations.html: Canonical link: https://commits.webkit.org/216885@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@251658 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-10-28 17:01:55 +00:00
runAnimationCompletionTest(animation => animation.effect.target.style.animationDuration = "0s", "Setting the target's animation-duration to 0s");
[Web Animations] Implement CSS Animations and CSS Transitions as Web Animations https://bugs.webkit.org/show_bug.cgi?id=183504 <rdar://problem/38372965> LayoutTests/imported/w3c: Reviewed by Dean Jackson and Jon Lee. Since we've improved our implementation of getAnimations() we updated the expectations to mark the progressions. Both tests for getAnimations() now pass 100%. Another test now fails at a later stage and needed its expectation updated. * web-platform-tests/web-animations/interfaces/Animatable/animate-expected.txt: * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-expected.txt: * web-platform-tests/web-animations/interfaces/Document/getAnimations-expected.txt: Source/WebCore: Reviewed by Dean Jackson and Jon Lee. Tests: webanimations/css-animations.html webanimations/css-transitions.html This patch implements CSS Animations and CSS Transitions as Web Animations. The main changes are: * StyleTreeResolver: StyleTreeResolver now has a code path to add CSSAnimation and CSSTransition objects onto the DocumentTimeline to be picked up by the Web Animations engine. The previous CSSAnimationController code path is preserved if the runtime flag is disabled. * AnimationTimeline: we add two new methods, updateCSSAnimationsForElement() and updateCSSTransitionsForElement() which are called from TreeResolver::createAnimatedElementUpdate(). These look at the AnimationList for the old and new RenderStyle objects and create, update and remove matching CSSAnimation and CSSTransition instances. * DeclarativeAnimation: a new superclass to both CSSAnimation and CSSTransition which introduces the concept of a backingAnimation(), which is an Animation held by the RenderStyle objects, and two virtual methods with base implementations, initialize() which is called upon creating by create() methods in subclasses, and syncPropertiesWithBackingAnimation() which ensures that properties on the DeclarativeAnimation objects (Web Animations side) match the backing animation (CSS side). * KeyframeEffectReadOnly: two new important methods to create blending keyframes (KeyframeList) based on backing Animation objects, computeCSSAnimationBlendingKeyframes() and computeCSSTransitionBlendingKeyframes(). * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffectReadOnly.h: (WebCore::AnimationEffectReadOnly::isKeyframeEffectReadOnly const): We fix this method such that calling it on a KeyframeEffect, which is a subclass of KeyframeEffectReadOnly, returns true. * animation/AnimationEffectTimingReadOnly.cpp: In order for DeclarativeAnimation::syncPropertiesWithBackingAnimation() to set the timing function for a declarative animation's effect, we need a public method to set an effect's timing function outside of just the "easing" property setter exposed via the JS API. So we introduce a setTimingFunction() method and call it from setEasing(). (WebCore::AnimationEffectTimingReadOnly::setEasing): (WebCore::AnimationEffectTimingReadOnly::setTimingFunction): * animation/AnimationEffectTimingReadOnly.h: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::~AnimationTimeline): Clear all maps and sets containing WebAnimation references to ensure these get destructed when the AnimationTimeline is being destructed and should no longer hold a reference to them. (WebCore::AnimationTimeline::relevantMapForAnimation): We store various subclasses of WebAnimation in dedicated maps so we can composite animations in the correct order when animating. This function returns the correct map for a given animation such that animationWasAddedToElement() and animationWasRemovedFromElement() mutate the right map. (WebCore::AnimationTimeline::animationWasAddedToElement): (WebCore::AnimationTimeline::animationWasRemovedFromElement): (WebCore::AnimationTimeline::animationsForElement): Make sure to look for animations in the lists of CSS Animations and CSS Transitions as well as Web Animations. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): This method is called by TreeResolver::createAnimatedElementUpdate() during style resolution. It compares the AnimationList of the previous style and the new style for a given element, checks that animations with a given name that were not present in the old AnimationList have a new matching CSSAnimation object for them added to the AnimationTimeline, that animations with a given name that are no longer present in the new AnimationList have their matching CSSAnimation object removed from the AnimationTimeline, and that animations with a given name that are present in both the old and new AnimationList have their matching CSSAnimation updated to match the current state of the animation in the AnimationList. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Similarly to updateCSSAnimationsForElement(), this method is called during style resolution by TreeResolver::createAnimatedElementUpdate(). Its role is to create or remove CSSTransition objects based on the AnimationList found in the old and new styles for a given element. It follows a slightly different logic than updateCSSAnimationsForElement() since for CSS Transitions, there is no need to update CSSTransition objects for a CSS property existing in both the old and new AnimationList, since when a CSS transitions property is changed, a whole new transition is initiated. However, it's important to check that different Animation objects and styles would actually result in different timing properties and blending keyframes, so check for this as well before creating new CSSTransition objects. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::animations const): Change the m_animations type from HashSet to ListHashSet to guarantee we preserve the insertion order which is required by getAnimations(). (WebCore::AnimationTimeline::hasElementAnimations const): Indicates to DocumentTimeline::updateAnimations() that there are animations targeting the provided element. (WebCore::AnimationTimeline::elementToAnimationsMap): (WebCore::AnimationTimeline::elementToCSSAnimationsMap): (WebCore::AnimationTimeline::elementToCSSTransitionsMap): * animation/CSSAnimation.cpp: CSSAnimation is now a subclass of DeclarativeAnimation and subclasses initialize() and syncPropertiesWithBackingAnimation() to perform work specific to CSS Animations. (WebCore::CSSAnimation::create): Set the animationName property based on the provided backing animation. (WebCore::CSSAnimation::CSSAnimation): (WebCore::CSSAnimation::initialize): Create the blending keyframes for this CSSAnimation. (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): Reflect the animation-fill-mode, animation-direction, animation-iteration-count and animation-play-state CSS properties on the AnimationEffectTimingReadOnly object associated with this CSSAnimation. * animation/CSSAnimation.h: * animation/CSSTransition.cpp: CSSTransition is now a subclass of DeclarativeAnimation. (WebCore::CSSTransition::create): Set the transitionProperty property based on the provided backing animation. (WebCore::CSSTransition::CSSTransition): (WebCore::CSSTransition::matchesBackingAnimationAndStyles const): (WebCore::CSSTransition::canBeListed const): Subclass this method such that we also check that we have blending keyframes for a CSSTransition to be listed by calls to getAnimations(). * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: Added. This new WebAnimation subclass now is the common base class for both CSSAnimation and CSSTransition. It establishes a relationship with a "backing animation", which is an Animation obtained from a style's AnimationList while resolving styles. These backing animations contain all of the parsed CSS styles related to CSS Animations and CSS Transitions and we use those to set matching properties of the Web Animations timing model in the new syncPropertiesWithBackingAnimation() virtual method, which subclasses can override to perform further work that is specific to a given declarative animation type. The initialize() method is called during create() methods to perform common animation setup work. Note that while both initialize() and syncPropertiesWithBackingAnimation() are called, we suspend invalidation to that animation's effect since these methods are meant to be called during style invalidation and we would hit an assertion if we followed the usual route of calling updateStyleIfNeeded() on the target's document during invalidation. (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::setBackingAnimation): (WebCore::DeclarativeAnimation::initialize): Create a KeyframeEffectReadOnly for this animation and set the provided element as its target, set that element's document's timeline and play the animation if the backing animation's play state is playing. (WebCore::DeclarativeAnimation::syncPropertiesWithBackingAnimation): Reflect the {animation|transition}-delay, {animation|transition}-duration and {animation|transition}-timing-function properties as set on the backing animation. * animation/DeclarativeAnimation.h: Added. (WebCore::DeclarativeAnimation::backingAnimation const): * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::updateAnimations): Trigger style invalidation for elements targeted not just by WebAnimation instances, but also by any of the DeclarativeAnimation subclasses. We also remove the call to updateFinishedState() which should have been removed when we implemented correct support for asynchronous WebAnimation operations. (WebCore::DocumentTimeline::animatedStyleForRenderer): Declarative animations are backed by KeyframeEffectReadOnly effects, so make sure we check for KeyframeEffectReadOnly or one of its subclasses and not just KeyframeEffect since there now are animation types that use the ReadOnly variant. (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated): Same as for animatedStyleForRenderer, check for KeyframeEffectReadOnly and not simply KeyframeEffect. * animation/KeyframeEffectReadOnly.cpp: (WebCore::invalidateElement): Stop forcing a style resolution as we invalidate element, marking them as dirty is sufficient. Calls to getAnimations() already force a style resolution as needed. (WebCore::KeyframeEffectReadOnly::create): Add a new create() method that only provides a target and which is used by DeclarativeAnimation::initialize(). (WebCore::KeyframeEffectReadOnly::getKeyframes): The previous implementation of getKeyframes() used the ParsedKeyframe list held as m_parsedKeyframes to compute keyframes. In the case of declarative animations, there are no ParsedKeyframe since the JS API was not involved, so we use the blending keyframes to look for keyframe data. (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Called by CSSAnimation::initialize(), this function creates blending keyframes by looking up the keyframes date obtained from the @keyframes rule with this backing animation's name. (WebCore::KeyframeEffectReadOnly::computeCSSTransitionBlendingKeyframes): Called by CSSTransition::create(), this function creates blending keyframes by creating a 0-offset keyframe with the old style and a 1-offset keyframe with the new style as provided during TreeResolver::createAnimatedElementUpdate(). (WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Called by AnimationTimeline::updateCSSTransitionsForElement() to check that a provided backing Animation and a pair of old and new RenderStyles that may be different objects actually would yield different timing properties and keyframe CSS values for a given CSS transition to avoid the deletion and creation of CSSTransition objects. (WebCore::KeyframeEffectReadOnly::shouldRunAccelerated): We mistakenly assumed we always had blending keyframes, which is not always the case with a CSSTransition where the transition style itself might be set first, but the target value after. So we should only run accelerated provided there are blending keyframes at least, the function already returning false if it finds a blending keyframe animating a non-accelerated CSS property. (WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): Check that there actually is a matching ParsedKeyframe to read the timing function from. * animation/KeyframeEffectReadOnly.h: (WebCore::KeyframeEffectReadOnly::hasBlendingKeyframes const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::~WebAnimation): We used to do something very wrong when a WebAnimation was destroyed which uncovered crashes when dealing with declarative animations. In AnimationTimeline's updateCSSAnimationsForElement() and updateCSSTransitionsForElement(), when we identify that a DeclarativeAnimation no longer matches an Animation from the current style's AnimationList, we set that DeclarativeAnimation's effect to null and call removeAnimation() on the timeline. This removes all references from AnimationTimeline to this DeclarativeAnimation and leads to ~WebAnimation being called. Calling removeAnimation() again in the destructor means that we'd hit ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun) in ref(). It was also meaningless to perform this work in the WebAnimation destructor since an animation could never be destroyed if it were still registered on a timeline. (WebCore::WebAnimation::suspendEffectInvalidation): DeclarativeAnimation instances have their timing model properties set during style invalidation, so we need a mechanism to allow the usual effect invalidation to be suspended in this case. We now maintain a simple m_suspendCount count that increases and decreases with calls to this method and unsuspendEffectInvalidation() and a isEffectInvalidationSuspended() method returning true whenever that count is positive. (WebCore::WebAnimation::unsuspendEffectInvalidation): (WebCore::WebAnimation::timingModelDidChange): Check that effect invalidation is not suspended before proceeding with invalidating the effect. (WebCore::WebAnimation::setEffect): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::setTimeline): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::scheduleMicrotaskIfNeeded): Ensure that the WebAnimation's lifecycle is extended at least to the completion of the scheduled microtask. This would otherwise cause crashes after declarative animations were destroyed when they were no longer applied. (WebCore::WebAnimation::runPendingPlayTask): Only fulfill the "ready" promise if it hasn't already been, which might have been the case if multiple calls to play() are made as a result of updating the animation play state in CSSAnimation::syncPropertiesWithBackingAnimation(). (WebCore::WebAnimation::runPendingPauseTask): Same as above but with multiple pause() calls. (WebCore::WebAnimation::startOrStopAccelerated): Check for KeyframeEffectReadOnly and not just KeyframeEffect since declarative animations have ReadOnly effects. (WebCore::WebAnimation::canBeListed const): This new method is called by {Document|Element}::getAnimations() to check that an animation is in the correct state to be listed. The Web Animations spec explains that only animations "that have an associated target effect which is current or in effect" can be listed. We implement this behavior as specified. * animation/WebAnimation.h: (WebCore::WebAnimation::isDeclarativeAnimation const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * dom/Document.cpp: (WebCore::Document::getAnimations): Ensure that the document's pending styles are resolved before returning animations to ensure that any pending declarative animations are created. Additionally, we ensure that we only list qualifying animations that have effects targeting elements that are children of thi document. * dom/Element.cpp: (WebCore::Element::getAnimations): Same as Document::getAnimations(). * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): When resolving styles, call into the AnimationTimeline if the runtime flag to enable CSS Animations and CSS Transitions as Web Animations is on. Otherwise, use CSSAnimationController. Source/WebKitLegacy/mac: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * WebView/WebPreferenceKeysPrivate.h: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): (-[WebPreferences setModernMediaControlsEnabled:]): (-[WebPreferences cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled]): (-[WebPreferences setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled:]): * WebView/WebPreferencesPrivate.h: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Reviewed by Dean Jackson and Jon Lee. Add the missing WebKitLegacy support the cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled flag which is required for the matching <!-- webkit-test-runner --> flag to work in DumpRenderTree. * Interfaces/IWebPreferencesPrivate.idl: * WebPreferences.cpp: (WebPreferences::cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): (WebPreferences::setCSSAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled): * WebPreferenceKeysPrivate.h * WebPreferences.h: * WebView.cpp: (WebView::notifyPreferencesChanged): Tools: Reviewed by Jon Lee. Add a new <!-- webkit-test-runner --> flag to enable the CSS Animations and CSS Transitions as Web Animations runtime flag in the new tests we've created for this feature. * DumpRenderTree/TestOptions.h: * DumpRenderTree/TestOptions.mm: (TestOptions::TestOptions): * DumpRenderTree/mac/DumpRenderTree.mm: (setWebPreferencesForTestOptions): * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetPreferencesToConsistentValues): (WTR::updateTestOptionsFromTestHeader): * WebKitTestRunner/TestOptions.h: (WTR::TestOptions::hasSameInitializationOptions const): LayoutTests: Reviewed by Dean Jackson and Jon Lee. Add a series of new tests to check CSSAnimation and CSSTransition objects are correctly created as CSS animation-* and CSS transition-* properties are used. We also update some existing tests to use a more concise API since we've implement Element.animate() since their creation. * webanimations/animation-opacity-animation-crash.html: * webanimations/css-animations-expected.txt: Added. * webanimations/css-animations.html: Added. * webanimations/css-transitions-expected.txt: Added. * webanimations/css-transitions.html: Added. * webanimations/opacity-animation-no-longer-composited-upon-completion.html: * webanimations/opacity-animation-yields-compositing.html: Canonical link: https://commits.webkit.org/199224@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@229530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-03-12 12:56:14 +00:00
</script>
</body>