haikuwebkit/Source/WebCore/animation/AnimationTimeline.cpp

86 lines
3.1 KiB
C++
Raw Permalink Normal View History

[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
/*
* Copyright (C) Canon Inc. 2016
* Copyright (C) 2017 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "AnimationTimeline.h"
[Web Animations] Update the Web Animations API to remove all the ReadOnly interfaces https://bugs.webkit.org/show_bug.cgi?id=186512 <rdar://problem/41000691> Reviewed by Dean Jackson. The Web Animations API has been simplified by removing its various ReadOnly interfaces. In this patch, we make the following changes, not adding code but merely merging and renaming files: - AnimationEffectReadOnly and AnimationEffect are now a single AnimationEffect interface - KeyframeEffectReadOnly and KeyframeEffect are now a single KeyframeEffect interface - ComputedTimingProperties is now named ComputedEffectTiming - AnimationEffectTimingProperties is now named EffectTiming * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.cpp: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.cpp. (WebCore::AnimationEffect::~AnimationEffect): (WebCore::AnimationEffect::timingDidChange): (WebCore::AnimationEffect::localTime const): (WebCore::AnimationEffect::phase const): (WebCore::AnimationEffect::activeTime const): (WebCore::AnimationEffect::overallProgress const): (WebCore::AnimationEffect::simpleIterationProgress const): (WebCore::AnimationEffect::currentIteration const): (WebCore::AnimationEffect::currentDirection const): (WebCore::AnimationEffect::directedProgress const): (WebCore::AnimationEffect::transformedProgress const): (WebCore::AnimationEffect::iterationProgress const): (WebCore::AnimationEffect::getComputedTiming): * animation/AnimationEffect.h: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.h. (WebCore::AnimationEffect::isKeyframeEffect const): * animation/AnimationEffect.idl: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.idl. * animation/AnimationEffectTimingReadOnly.cpp: * animation/AnimationEffectTimingReadOnly.h: (WebCore::AnimationEffectTimingReadOnly::setEffect): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::cssAnimationForElementAndProperty): * animation/CSSTransition.cpp: * animation/ComputedEffectTiming.h: Renamed from Source/WebCore/animation/ComputedTimingProperties.h. * animation/ComputedEffectTiming.idl: Renamed from Source/WebCore/animation/ComputedTimingProperties.idl. * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::flushPendingStyleChanges const): (WebCore::DeclarativeAnimation::phaseWithoutEffect const): (WebCore::DeclarativeAnimation::invalidateDOMEvents): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::getAnimations const): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::animationAcceleratedRunningStateDidChange): (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): (WebCore::DocumentTimeline::applyPendingAcceleratedAnimations): (WebCore::DocumentTimeline::resolveAnimationsForElement): * animation/EffectTiming.h: Renamed from Source/WebCore/animation/AnimationEffectTimingProperties.h. * animation/EffectTiming.idl: Renamed from Source/WebCore/animation/AnimationEffectTimingProperties.idl. * animation/KeyframeEffect.cpp: (WebCore::invalidateElement): (WebCore::CSSPropertyIDToIDLAttributeName): (WebCore::IDLAttributeNameToAnimationPropertyName): (WebCore::computeMissingKeyframeOffsets): (WebCore::processKeyframeLikeObject): (WebCore::processIterableKeyframes): (WebCore::processPropertyIndexedKeyframes): (WebCore::KeyframeEffect::create): (WebCore::KeyframeEffect::KeyframeEffect): (WebCore::KeyframeEffect::copyPropertiesFromSource): (WebCore::KeyframeEffect::getKeyframes): (WebCore::KeyframeEffect::processKeyframes): (WebCore::KeyframeEffect::updateBlendingKeyframes): (WebCore::KeyframeEffect::forceLayoutIfNeeded): (WebCore::KeyframeEffect::setBlendingKeyframes): (WebCore::KeyframeEffect::checkForMatchingTransformFunctionLists): (WebCore::KeyframeEffect::checkForMatchingFilterFunctionLists const): (WebCore::KeyframeEffect::checkForMatchingFilterFunctionLists): (WebCore::KeyframeEffect::checkForMatchingBackdropFilterFunctionLists): (WebCore::KeyframeEffect::checkForMatchingColorFilterFunctionLists): (WebCore::KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes): (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes): (WebCore::KeyframeEffect::computeCSSTransitionBlendingKeyframes): (WebCore::KeyframeEffect::computedNeedsForcedLayout): (WebCore::KeyframeEffect::computeStackingContextImpact): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::apply): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::computeShouldRunAccelerated): (WebCore::KeyframeEffect::getAnimatedStyle): (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): (WebCore::KeyframeEffect::timingFunctionForKeyframeAtIndex): (WebCore::KeyframeEffect::updateAcceleratedAnimationState): (WebCore::KeyframeEffect::addPendingAcceleratedAction): (WebCore::KeyframeEffect::animationDidSeek): (WebCore::KeyframeEffect::animationSuspensionStateDidChange): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::backingAnimationForCompositedRenderer const): (WebCore::KeyframeEffect::renderer const): (WebCore::KeyframeEffect::currentStyle const): (WebCore::KeyframeEffect::computeExtentOfTransformAnimation const): (WebCore::containsRotation): (WebCore::KeyframeEffect::computeTransformedExtentViaTransformList const): (WebCore::KeyframeEffect::computeTransformedExtentViaMatrix const): * animation/KeyframeEffect.h: (WebCore::KeyframeEffect::ParsedKeyframe::ParsedKeyframe): (WebCore::KeyframeEffect::target const): (WebCore::KeyframeEffect::iterationComposite const): (WebCore::KeyframeEffect::composite const): (WebCore::KeyframeEffect::isRunningAccelerated const): (WebCore::KeyframeEffect::hasPendingAcceleratedAction const): (WebCore::KeyframeEffect::hasBlendingKeyframes const): (WebCore::KeyframeEffect::animatedProperties const): * animation/KeyframeEffect.idl: * animation/KeyframeEffectOptions.h: * animation/KeyframeEffectOptions.idl: * animation/KeyframeEffectReadOnly.cpp: Removed. * animation/KeyframeEffectReadOnly.h: Removed. * animation/KeyframeEffectReadOnly.idl: Removed. * animation/WebAnimation.cpp: (WebCore::WebAnimation::create): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::applyPendingAcceleratedActions): (WebCore::WebAnimation::computeRelevance): * animation/WebAnimation.h: (WebCore::WebAnimation::effect const): * animation/WebAnimation.idl: * bindings/js/JSAnimationEffectCustom.cpp: Renamed from Source/WebCore/bindings/js/JSAnimationEffectReadOnlyCustom.cpp. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/JSWebAnimationCustom.cpp: (WebCore::constructJSWebAnimation): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: Canonical link: https://commits.webkit.org/206101@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:15:15 +00:00
#include "KeyframeEffect.h"
[Web Animations] Use a keyframe effect stack to resolve animations on an element https://bugs.webkit.org/show_bug.cgi?id=204010 Reviewed by Dean Jackson. Until now, when resolving animations for an element, we would call animationsForElement() during each resolution which means doing several hash table lookups to locate the various classes of animations for that given element, sorting each of those animations and inserting them into a new Vector. We now use a KeyframeEffectStack which keeps a list of KeyframeEffect objects that apply to a given target, provided the effect also has a valid animation and that animation has a valid timeline, all pre-conditions for that effect to produce an animated value. Any time one of those pre-conditions change, we update the membership of that effect in the stack. The KeyframeEffectStack is a new member of ElementRareData. Now, each time we resolve an animation for an element, we iterate over the KeyframeEffect objects returned by calling sortEffects() on the KeyframeEffectStack which will sort the stack's effects only if a new effect had been added since the last iteration, which means that simple animations that are not mutated will require sorting of the stack just once, and the addition of several animations in a single animation frame will require sorting just once as well. It was also found while doing this work that Style::TreeResolver::createAnimatedElementUpdate would call RenderStyle::clonePtr() for any element that was part of a document containing a timeline, regardless of whether that element had any animations. Now we check whether that element's KeyframeEffectStack contains any effects prior to cloning the style. No tests or changes to existed test expectations as this should not yield any change in behavior. * Sources.txt: Add the new KeyframeEffectStack. * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.h: (WebCore::AnimationEffect::setAnimation): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Since we need to know the order of CSS @keyframes rules listed in animation-name when sorting effects, we must compile the ordered list of those @keyframe rules as we update CSS animations for an element and store it on its KeyframeEffectStack. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::resolveAnimationsForElement): Deleted. Replaced by Element::applyKeyframeEffects(). * animation/DocumentTimeline.h: * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::setAnimation): (WebCore::KeyframeEffect::setTarget): * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: Added. (WebCore::KeyframeEffectStack::KeyframeEffectStack): (WebCore::KeyframeEffectStack::~KeyframeEffectStack): (WebCore::KeyframeEffectStack::addEffect): (WebCore::KeyframeEffectStack::removeEffect): (WebCore::KeyframeEffectStack::sortedEffects): (WebCore::KeyframeEffectStack::ensureEffectsAreSorted): (WebCore::KeyframeEffectStack::setCSSAnimationNames): * animation/KeyframeEffectStack.h: Added. (WebCore::KeyframeEffectStack::hasEffects const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::persist): * dom/Element.cpp: (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::keyframeEffectStack): (WebCore::ElementRareData::setKeyframeEffectStack): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Canonical link: https://commits.webkit.org/217343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-08 20:40:57 +00:00
#include "KeyframeEffectStack.h"
Flaky crash in AnimationTimeline::cancelOrRemoveDeclarativeAnimation https://bugs.webkit.org/show_bug.cgi?id=187530 <rdar://problem/42095186> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Mark a WPT progression now that we correctly ignore animation names that have no matching @keyframes rule. * css-animations/test_element-get-animations-expected.txt: Source/WebCore: We would crash in cancelOrRemoveDeclarativeAnimation() because updateCSSAnimationsForElement() would pass nullptr values due to the return value of cssAnimationsByName.take(nameOfAnimationToRemove). This is because we would create animations for animation names that may be empty or not match an existing @keyframes rule. Not only was that wasteful, but it was also non-compliant, and as a result of fixing this we're actually seeing a progression in the CSS Animations WPT tests. * animation/AnimationTimeline.cpp: (WebCore::shouldConsiderAnimation): New function that performs all required steps to see if a provided animation is valid and has a name that is not "none", not the empty string and matches the name of a @keyframes rule. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): * animation/KeyframeEffectReadOnly.cpp: (WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): We no longer need to check whether we have an empty animation name since we're no longer creating CSSAnimation objects in that circumstance. * css/StyleResolver.cpp: (WebCore::StyleResolver::isAnimationNameValid): Add a new method that checks whether the provided animation name a known @keyframes rule. * css/StyleResolver.h: LayoutTests: Adjust an existing test which assumes an animation might be running when it's not really, so we test the animation is not running using an alternate method. * animations/keyframes-dynamic-expected.txt: * animations/keyframes-dynamic.html: Canonical link: https://commits.webkit.org/203023@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234017 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-07-20 00:06:10 +00:00
#include "StyleResolver.h"
Reduce the reliance on PseudoElement in the animation code https://bugs.webkit.org/show_bug.cgi?id=216931 LayoutTests/imported/w3c: Reviewed by Antti Koivisto. Mark a WPT test progression. * web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt: Source/WebCore: <rdar://problem/69511682> Reviewed by Antti Koivisto. We have so far relied on PseudoElement as a foundation for supporting animations of pseudo-elements. This is not a great choice since PseudoElement is currently limited to ::before and ::after pseudo-elements only. This patch refactors animation-related code to rely on PseudoElement as little as possible without making changes outside of the animation code, as a first step towards supporting animation of more pseudo-elements. This patch introduces a new struct Styleable which combines an Element& and PseudoId. We use this struct instead of Element objects wherever necessary in the animation code. On top of that, we add a PseudoId parameter to all the Element methods wrapping access to ElementAnimationRareData and use a HashMap<PseudoId, std::unique_ptr<ElementAnimationRareData>> to be able to separate animation data per pseudo-element. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::animationWasAddedToStyleable): (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::willChangeRendererForStyleable): (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): (WebCore::shouldConsiderAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): (WebCore::keyframeEffectForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): (WebCore::AnimationTimeline::animationWasAddedToElement): Deleted. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Deleted. (WebCore::AnimationTimeline::willChangeRendererForElement): Deleted. (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::create): (WebCore::CSSAnimation::CSSAnimation): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::create): (WebCore::CSSTransition::CSSTransition): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::owningElement const): (WebCore::DeclarativeAnimation::disassociateFromOwningElement): (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animationCanBeRemoved): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): Deleted. * animation/DocumentTimeline.h: * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::ElementAnimationRareData): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::pseudoId const): * animation/KeyframeEffect.cpp: (WebCore::elementOrPseudoElementForStyleable): (WebCore::invalidateElement): (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::targetStyleable const): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::setPseudoElement): (WebCore::KeyframeEffect::didChangeTargetStyleable): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::didChangeTargetElementOrPseudoElement): Deleted. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::effectTargetDidChange): (WebCore::WebAnimation::persist): (WebCore::WebAnimation::commitStyles): * animation/WebAnimation.h: * animation/WebAnimationUtilities.cpp: (WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder): (WebCore::compareCSSTransitions): (WebCore::compareCSSAnimations): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): (WebCore::Element::animationRareData const): (WebCore::Element::ensureAnimationRareData): (WebCore::Element::keyframeEffectStack const): (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): (WebCore::Element::animations const): (WebCore::Element::hasCompletedTransitionsForProperty const): (WebCore::Element::hasRunningTransitionsForProperty const): (WebCore::Element::hasRunningTransitions const): (WebCore::Element::ensureAnimations): (WebCore::Element::animationsCreatedByMarkup): (WebCore::Element::setAnimationsCreatedByMarkup): (WebCore::Element::ensureCompletedTransitionsByProperty): (WebCore::Element::ensureRunningTransitionsByProperty): (WebCore::Element::lastStyleChangeEventStyle const): (WebCore::Element::setLastStyleChangeEventStyle): (WebCore::Element::getAnimations): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::useTypes const): (WebCore::ElementRareData::animationRareData const): (WebCore::ElementRareData::ensureAnimationRareData): (WebCore::ElementRareData::elementAnimationRareData): Deleted. * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): (WebCore::PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement): * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/RenderStyleConstants.cpp: (WebCore::operator<<): * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): (WebCore::Style::TreeResolver::resolvePseudoStyle): (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * style/StyleTreeResolver.h: * style/Styleable.h: Added. (WebCore::Styleable::Styleable): (WebCore::Styleable::fromElement): (WebCore::Styleable::fromRenderer): (WebCore::Styleable::operator== const): (WebCore::Styleable::operator!= const): (WebCore::Styleable::keyframeEffectStack const): (WebCore::Styleable::ensureKeyframeEffectStack const): (WebCore::Styleable::hasKeyframeEffects const): (WebCore::Styleable::applyKeyframeEffects const): (WebCore::Styleable::animations const): (WebCore::Styleable::hasCompletedTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitions const): (WebCore::Styleable::ensureAnimations const): (WebCore::Styleable::ensureCompletedTransitionsByProperty const): (WebCore::Styleable::ensureRunningTransitionsByProperty const): (WebCore::Styleable::animationsCreatedByMarkup const): (WebCore::Styleable::setAnimationsCreatedByMarkup const): (WebCore::Styleable::lastStyleChangeEventStyle const): (WebCore::Styleable::setLastStyleChangeEventStyle const): LayoutTests: <rdar://problem/69511682> Reviewed by Antti Koivisto. Update a couple of tests which relied on an internals method to get a pseudo element and instead use the Web Animations API to determine whether a given animation targets a pseudo-element. This has the added benefit of having the same code run in a testing environment as in a regular browser. * fast/css-generated-content/pseudo-animation.html: * fast/css-generated-content/pseudo-transition.html: Canonical link: https://commits.webkit.org/229750@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267571 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 15:22:00 +00:00
#include "Styleable.h"
[Web Animations] Expose timing properties (delay, endDelay, fill, iterationStart, iterations, direction) and getComputedTiming() https://bugs.webkit.org/show_bug.cgi?id=181857 <rdar://problem/36660081> Reviewed by Dean Jackson. Source/WebCore: We start the work to implement the rest of the Web Animations timing and animation model by exposing more properties on AnimationEffectTiming to control delay (delay, endDelay), looping (iterationStart, iterations), fill and direction. Additionally, we expose the getComputedTiming() method on AnimationEffect, although it currently lacks some computed properties that will come in later patch as we implement various processes defined by the spec. We also update the existing duration() method on AnimationEffectTiming to be called iterationDuration() to match the terms used in the specification. Finally, we make all new properties, and update existing ones, that expose a time value go through the new utility function secondsToWebAnimationsAPITime() to guarantee rounded values with microseconds precision, as advised by the Web Animations specification. * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.cpp: (WebCore::AnimationEffect::localTime const): (WebCore::AnimationEffect::getComputedTiming): * animation/AnimationEffect.h: * animation/AnimationEffect.idl: * animation/AnimationEffectTiming.cpp: (WebCore::AnimationEffectTiming::AnimationEffectTiming): (WebCore::AnimationEffectTiming::setIterationStart): (WebCore::AnimationEffectTiming::setIterations): (WebCore::AnimationEffectTiming::bindingsDuration const): (WebCore::AnimationEffectTiming::setBindingsDuration): (WebCore::AnimationEffectTiming::endTime const): (WebCore::AnimationEffectTiming::activeDuration const): * animation/AnimationEffectTiming.h: * animation/AnimationEffectTiming.idl: * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::bindingsCurrentTime const): (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::bindingsCurrentTime): * animation/ComputedTimingProperties.h: Added. * animation/ComputedTimingProperties.idl: Added. We set nullable double values to a default value of "null" since otherwise setting those properties to a null value would not set the properties in the converted JS dictionary. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::create): Handle new timing properties passed in the KeyframeEffectOptions dictionary. (WebCore::KeyframeEffect::applyAtLocalTime): (WebCore::KeyframeEffect::getAnimatedStyle): (WebCore::KeyframeEffect::startOrStopAccelerated): * animation/WebAnimation.cpp: (WebCore::WebAnimation::bindingsStartTime const): (WebCore::WebAnimation::bindingsCurrentTime const): (WebCore::WebAnimation::effectEndTime const): (WebCore::WebAnimation::timeToNextRequiredTick const): * animation/WebAnimationUtilities.h: Added. (WebCore::secondsToWebAnimationsAPITime): LayoutTests: Update expectations with progressions and new failure points now we expose more of the API. * http/wpt/web-animations/animation-model/animation-types/discrete-animation-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-expected.txt: * http/wpt/web-animations/interfaces/Animation/finish-expected.txt: * http/wpt/web-animations/interfaces/Animation/finished-expected.txt: * http/wpt/web-animations/interfaces/Animation/pause-expected.txt: * http/wpt/web-animations/interfaces/Animation/play-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: * http/wpt/web-animations/interfaces/AnimationTimeline/document-timeline-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/active-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/current-iteration-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/local-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/phases-and-states-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/simple-iteration-progress-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/time-transformations/transformed-progress-expected.txt: * http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html: Canonical link: https://commits.webkit.org/197684@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-19 17:56:53 +00:00
#include "WebAnimationUtilities.h"
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
namespace WebCore {
AnimationTimeline::AnimationTimeline() = default;
AnimationTimeline::~AnimationTimeline() = default;
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
void AnimationTimeline::forgetAnimation(WebAnimation* animation)
{
m_allAnimations.removeFirst(animation);
}
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
void AnimationTimeline::animationTimingDidChange(WebAnimation& animation)
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
{
REGRESSION(r252455): imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html fails on iOS and WK1 https://bugs.webkit.org/show_bug.cgi?id=204272 <rdar://problem/57253742> Reviewed by Dean Jackson. Source/WebCore: Events for declarative animations are dispatched using a MainThreadGenericEventQueue which dispatches enqueued events asynchronously. When a declarative animation would be canceled, AnimationTimeline::cancelDeclarativeAnimation() would be called and would enqueue a "transitioncancel" or "animationcancel" event (depending on the animation type) by virtue of calling DeclarativeAnimation::cancelFromStyle(), and would also call AnimationTimeline::removeAnimation() right after. However, calling AnimationTimeline::removeAnimation() could have the side effect of removing the last reference to the DeclarativeAnimation object, which would destroy its attached MainThreadGenericEventQueue before it had the time to dispatch the queued "transitioncancel" or "animationcancel" event. The call to AnimationTimeline::removeAnimation() in AnimationTimeline::cancelDeclarativeAnimation() is actually unnecessary. Simply canceling the animation via DeclarativeAnimation::cancelFromStyle() will end up calling AnimationTimeline::removeAnimation() the next time animations are updated, which will leave time for the cancel events to be dispatched. So all we need to do is remove AnimationTimeline::cancelDeclarativeAnimation() and replace its call sites with simple calls to DeclarativeAnimation::cancelFromStyle(). Making this change broke a test however: imported/w3c/web-platform-tests/css/css-animations/Document-getAnimations.tentative.html. We actually passed that test by chance without implementing the feature required to make it work. We now implement the correct way to track a global position for an animation by only setting one for declarative animations once they are disassociated with their owning element and have a non-idle play state. And a few other tests broke: animations/animation-shorthand-name-order.html, imported/w3c/web-platform-tests/css/css-animations/animationevent-types.html and webanimations/css-animations.html. The reason for those tests being broken was that not calling AnimationTimeline::removeAnimation() instantly as CSS Animations were canceled also meant that the KeyframeEffectStack for the targeted element wasn't updated. To solve this, we added the animationTimingDidChange() method on KeyframeEffect which is called whenever timing on the owning Animation changes, so for instance when cancel() is called as we cancel a CSS Animation. That way we ensure we add and remove KeyframeEffect instances from the KeyframeEffectStack as the animation becomes relevant, which is now an added condition checked by KeyframeEffectStack::addEffect(). Finally, this revealed an issue in KeyframeEffectStack::ensureEffectsAreSorted() where we would consider CSSTransition and CSSAnimation objects to be representative of a CSS Transition or CSS Animation even after the relationship with their owning element had been severed. We now correctly check that relationship is intact and otherwise consider those animations just like any other animation. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): (WebCore::AnimationTimeline::updateGlobalPosition): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForElement): (WebCore::AnimationTimeline::cancelDeclarativeAnimation): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): * animation/CSSTransition.cpp: (WebCore::CSSTransition::setTimingProperties): * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::canHaveGlobalPosition): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::getAnimations const): * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::animationTimingDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::setAnimation): (WebCore::KeyframeEffect::setTarget): * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): (WebCore::KeyframeEffectStack::ensureEffectsAreSorted): * animation/KeyframeEffectStack.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::timingDidChange): * animation/WebAnimation.h: (WebCore::WebAnimation::canHaveGlobalPosition): LayoutTests: Removing this specific expectation for WK1 since it now behaves just like the other configurations. * platform/mac-wk1/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt: Removed. Canonical link: https://commits.webkit.org/217884@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252911 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-27 19:38:43 +00:00
updateGlobalPosition(animation);
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
if (m_animations.add(&animation)) {
m_allAnimations.append(makeWeakPtr(&animation));
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
auto* timeline = animation.timeline();
if (timeline && timeline != this)
timeline->removeAnimation(animation);
}
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
}
REGRESSION(r252455): imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements.html fails on iOS and WK1 https://bugs.webkit.org/show_bug.cgi?id=204272 <rdar://problem/57253742> Reviewed by Dean Jackson. Source/WebCore: Events for declarative animations are dispatched using a MainThreadGenericEventQueue which dispatches enqueued events asynchronously. When a declarative animation would be canceled, AnimationTimeline::cancelDeclarativeAnimation() would be called and would enqueue a "transitioncancel" or "animationcancel" event (depending on the animation type) by virtue of calling DeclarativeAnimation::cancelFromStyle(), and would also call AnimationTimeline::removeAnimation() right after. However, calling AnimationTimeline::removeAnimation() could have the side effect of removing the last reference to the DeclarativeAnimation object, which would destroy its attached MainThreadGenericEventQueue before it had the time to dispatch the queued "transitioncancel" or "animationcancel" event. The call to AnimationTimeline::removeAnimation() in AnimationTimeline::cancelDeclarativeAnimation() is actually unnecessary. Simply canceling the animation via DeclarativeAnimation::cancelFromStyle() will end up calling AnimationTimeline::removeAnimation() the next time animations are updated, which will leave time for the cancel events to be dispatched. So all we need to do is remove AnimationTimeline::cancelDeclarativeAnimation() and replace its call sites with simple calls to DeclarativeAnimation::cancelFromStyle(). Making this change broke a test however: imported/w3c/web-platform-tests/css/css-animations/Document-getAnimations.tentative.html. We actually passed that test by chance without implementing the feature required to make it work. We now implement the correct way to track a global position for an animation by only setting one for declarative animations once they are disassociated with their owning element and have a non-idle play state. And a few other tests broke: animations/animation-shorthand-name-order.html, imported/w3c/web-platform-tests/css/css-animations/animationevent-types.html and webanimations/css-animations.html. The reason for those tests being broken was that not calling AnimationTimeline::removeAnimation() instantly as CSS Animations were canceled also meant that the KeyframeEffectStack for the targeted element wasn't updated. To solve this, we added the animationTimingDidChange() method on KeyframeEffect which is called whenever timing on the owning Animation changes, so for instance when cancel() is called as we cancel a CSS Animation. That way we ensure we add and remove KeyframeEffect instances from the KeyframeEffectStack as the animation becomes relevant, which is now an added condition checked by KeyframeEffectStack::addEffect(). Finally, this revealed an issue in KeyframeEffectStack::ensureEffectsAreSorted() where we would consider CSSTransition and CSSAnimation objects to be representative of a CSS Transition or CSS Animation even after the relationship with their owning element had been severed. We now correctly check that relationship is intact and otherwise consider those animations just like any other animation. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): (WebCore::AnimationTimeline::updateGlobalPosition): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForElement): (WebCore::AnimationTimeline::cancelDeclarativeAnimation): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::syncPropertiesWithBackingAnimation): * animation/CSSTransition.cpp: (WebCore::CSSTransition::setTimingProperties): * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::canHaveGlobalPosition): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::getAnimations const): * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::animationTimingDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::setAnimation): (WebCore::KeyframeEffect::setTarget): * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): (WebCore::KeyframeEffectStack::ensureEffectsAreSorted): * animation/KeyframeEffectStack.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::timingDidChange): * animation/WebAnimation.h: (WebCore::WebAnimation::canHaveGlobalPosition): LayoutTests: Removing this specific expectation for WK1 since it now behaves just like the other configurations. * platform/mac-wk1/imported/w3c/web-platform-tests/dom/events/Event-dispatch-on-disabled-elements-expected.txt: Removed. Canonical link: https://commits.webkit.org/217884@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252911 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-27 19:38:43 +00:00
void AnimationTimeline::updateGlobalPosition(WebAnimation& animation)
{
static uint64_t s_globalPosition = 0;
if (!animation.globalPosition() && animation.canHaveGlobalPosition())
animation.setGlobalPosition(++s_globalPosition);
}
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
void AnimationTimeline::removeAnimation(WebAnimation& animation)
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
{
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
ASSERT(!animation.timeline() || animation.timeline() == this);
m_animations.remove(&animation);
[Web Animations] Update the Web Animations API to remove all the ReadOnly interfaces https://bugs.webkit.org/show_bug.cgi?id=186512 <rdar://problem/41000691> Reviewed by Dean Jackson. The Web Animations API has been simplified by removing its various ReadOnly interfaces. In this patch, we make the following changes, not adding code but merely merging and renaming files: - AnimationEffectReadOnly and AnimationEffect are now a single AnimationEffect interface - KeyframeEffectReadOnly and KeyframeEffect are now a single KeyframeEffect interface - ComputedTimingProperties is now named ComputedEffectTiming - AnimationEffectTimingProperties is now named EffectTiming * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.cpp: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.cpp. (WebCore::AnimationEffect::~AnimationEffect): (WebCore::AnimationEffect::timingDidChange): (WebCore::AnimationEffect::localTime const): (WebCore::AnimationEffect::phase const): (WebCore::AnimationEffect::activeTime const): (WebCore::AnimationEffect::overallProgress const): (WebCore::AnimationEffect::simpleIterationProgress const): (WebCore::AnimationEffect::currentIteration const): (WebCore::AnimationEffect::currentDirection const): (WebCore::AnimationEffect::directedProgress const): (WebCore::AnimationEffect::transformedProgress const): (WebCore::AnimationEffect::iterationProgress const): (WebCore::AnimationEffect::getComputedTiming): * animation/AnimationEffect.h: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.h. (WebCore::AnimationEffect::isKeyframeEffect const): * animation/AnimationEffect.idl: Renamed from Source/WebCore/animation/AnimationEffectReadOnly.idl. * animation/AnimationEffectTimingReadOnly.cpp: * animation/AnimationEffectTimingReadOnly.h: (WebCore::AnimationEffectTimingReadOnly::setEffect): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::cssAnimationForElementAndProperty): * animation/CSSTransition.cpp: * animation/ComputedEffectTiming.h: Renamed from Source/WebCore/animation/ComputedTimingProperties.h. * animation/ComputedEffectTiming.idl: Renamed from Source/WebCore/animation/ComputedTimingProperties.idl. * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::flushPendingStyleChanges const): (WebCore::DeclarativeAnimation::phaseWithoutEffect const): (WebCore::DeclarativeAnimation::invalidateDOMEvents): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::getAnimations const): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::animationAcceleratedRunningStateDidChange): (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): (WebCore::DocumentTimeline::applyPendingAcceleratedAnimations): (WebCore::DocumentTimeline::resolveAnimationsForElement): * animation/EffectTiming.h: Renamed from Source/WebCore/animation/AnimationEffectTimingProperties.h. * animation/EffectTiming.idl: Renamed from Source/WebCore/animation/AnimationEffectTimingProperties.idl. * animation/KeyframeEffect.cpp: (WebCore::invalidateElement): (WebCore::CSSPropertyIDToIDLAttributeName): (WebCore::IDLAttributeNameToAnimationPropertyName): (WebCore::computeMissingKeyframeOffsets): (WebCore::processKeyframeLikeObject): (WebCore::processIterableKeyframes): (WebCore::processPropertyIndexedKeyframes): (WebCore::KeyframeEffect::create): (WebCore::KeyframeEffect::KeyframeEffect): (WebCore::KeyframeEffect::copyPropertiesFromSource): (WebCore::KeyframeEffect::getKeyframes): (WebCore::KeyframeEffect::processKeyframes): (WebCore::KeyframeEffect::updateBlendingKeyframes): (WebCore::KeyframeEffect::forceLayoutIfNeeded): (WebCore::KeyframeEffect::setBlendingKeyframes): (WebCore::KeyframeEffect::checkForMatchingTransformFunctionLists): (WebCore::KeyframeEffect::checkForMatchingFilterFunctionLists const): (WebCore::KeyframeEffect::checkForMatchingFilterFunctionLists): (WebCore::KeyframeEffect::checkForMatchingBackdropFilterFunctionLists): (WebCore::KeyframeEffect::checkForMatchingColorFilterFunctionLists): (WebCore::KeyframeEffect::computeDeclarativeAnimationBlendingKeyframes): (WebCore::KeyframeEffect::computeCSSAnimationBlendingKeyframes): (WebCore::KeyframeEffect::computeCSSTransitionBlendingKeyframes): (WebCore::KeyframeEffect::computedNeedsForcedLayout): (WebCore::KeyframeEffect::computeStackingContextImpact): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::apply): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::computeShouldRunAccelerated): (WebCore::KeyframeEffect::getAnimatedStyle): (WebCore::KeyframeEffect::setAnimatedPropertiesInStyle): (WebCore::KeyframeEffect::timingFunctionForKeyframeAtIndex): (WebCore::KeyframeEffect::updateAcceleratedAnimationState): (WebCore::KeyframeEffect::addPendingAcceleratedAction): (WebCore::KeyframeEffect::animationDidSeek): (WebCore::KeyframeEffect::animationSuspensionStateDidChange): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::backingAnimationForCompositedRenderer const): (WebCore::KeyframeEffect::renderer const): (WebCore::KeyframeEffect::currentStyle const): (WebCore::KeyframeEffect::computeExtentOfTransformAnimation const): (WebCore::containsRotation): (WebCore::KeyframeEffect::computeTransformedExtentViaTransformList const): (WebCore::KeyframeEffect::computeTransformedExtentViaMatrix const): * animation/KeyframeEffect.h: (WebCore::KeyframeEffect::ParsedKeyframe::ParsedKeyframe): (WebCore::KeyframeEffect::target const): (WebCore::KeyframeEffect::iterationComposite const): (WebCore::KeyframeEffect::composite const): (WebCore::KeyframeEffect::isRunningAccelerated const): (WebCore::KeyframeEffect::hasPendingAcceleratedAction const): (WebCore::KeyframeEffect::hasBlendingKeyframes const): (WebCore::KeyframeEffect::animatedProperties const): * animation/KeyframeEffect.idl: * animation/KeyframeEffectOptions.h: * animation/KeyframeEffectOptions.idl: * animation/KeyframeEffectReadOnly.cpp: Removed. * animation/KeyframeEffectReadOnly.h: Removed. * animation/KeyframeEffectReadOnly.idl: Removed. * animation/WebAnimation.cpp: (WebCore::WebAnimation::create): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::applyPendingAcceleratedActions): (WebCore::WebAnimation::computeRelevance): * animation/WebAnimation.h: (WebCore::WebAnimation::effect const): * animation/WebAnimation.idl: * bindings/js/JSAnimationEffectCustom.cpp: Renamed from Source/WebCore/bindings/js/JSAnimationEffectReadOnlyCustom.cpp. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/JSWebAnimationCustom.cpp: (WebCore::constructJSWebAnimation): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: Canonical link: https://commits.webkit.org/206101@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237852 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-11-06 11:15:15 +00:00
if (is<KeyframeEffect>(animation.effect())) {
Reduce the reliance on PseudoElement in the animation code https://bugs.webkit.org/show_bug.cgi?id=216931 LayoutTests/imported/w3c: Reviewed by Antti Koivisto. Mark a WPT test progression. * web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt: Source/WebCore: <rdar://problem/69511682> Reviewed by Antti Koivisto. We have so far relied on PseudoElement as a foundation for supporting animations of pseudo-elements. This is not a great choice since PseudoElement is currently limited to ::before and ::after pseudo-elements only. This patch refactors animation-related code to rely on PseudoElement as little as possible without making changes outside of the animation code, as a first step towards supporting animation of more pseudo-elements. This patch introduces a new struct Styleable which combines an Element& and PseudoId. We use this struct instead of Element objects wherever necessary in the animation code. On top of that, we add a PseudoId parameter to all the Element methods wrapping access to ElementAnimationRareData and use a HashMap<PseudoId, std::unique_ptr<ElementAnimationRareData>> to be able to separate animation data per pseudo-element. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::animationWasAddedToStyleable): (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::willChangeRendererForStyleable): (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): (WebCore::shouldConsiderAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): (WebCore::keyframeEffectForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): (WebCore::AnimationTimeline::animationWasAddedToElement): Deleted. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Deleted. (WebCore::AnimationTimeline::willChangeRendererForElement): Deleted. (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::create): (WebCore::CSSAnimation::CSSAnimation): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::create): (WebCore::CSSTransition::CSSTransition): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::owningElement const): (WebCore::DeclarativeAnimation::disassociateFromOwningElement): (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animationCanBeRemoved): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): Deleted. * animation/DocumentTimeline.h: * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::ElementAnimationRareData): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::pseudoId const): * animation/KeyframeEffect.cpp: (WebCore::elementOrPseudoElementForStyleable): (WebCore::invalidateElement): (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::targetStyleable const): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::setPseudoElement): (WebCore::KeyframeEffect::didChangeTargetStyleable): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::didChangeTargetElementOrPseudoElement): Deleted. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::effectTargetDidChange): (WebCore::WebAnimation::persist): (WebCore::WebAnimation::commitStyles): * animation/WebAnimation.h: * animation/WebAnimationUtilities.cpp: (WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder): (WebCore::compareCSSTransitions): (WebCore::compareCSSAnimations): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): (WebCore::Element::animationRareData const): (WebCore::Element::ensureAnimationRareData): (WebCore::Element::keyframeEffectStack const): (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): (WebCore::Element::animations const): (WebCore::Element::hasCompletedTransitionsForProperty const): (WebCore::Element::hasRunningTransitionsForProperty const): (WebCore::Element::hasRunningTransitions const): (WebCore::Element::ensureAnimations): (WebCore::Element::animationsCreatedByMarkup): (WebCore::Element::setAnimationsCreatedByMarkup): (WebCore::Element::ensureCompletedTransitionsByProperty): (WebCore::Element::ensureRunningTransitionsByProperty): (WebCore::Element::lastStyleChangeEventStyle const): (WebCore::Element::setLastStyleChangeEventStyle): (WebCore::Element::getAnimations): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::useTypes const): (WebCore::ElementRareData::animationRareData const): (WebCore::ElementRareData::ensureAnimationRareData): (WebCore::ElementRareData::elementAnimationRareData): Deleted. * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): (WebCore::PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement): * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/RenderStyleConstants.cpp: (WebCore::operator<<): * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): (WebCore::Style::TreeResolver::resolvePseudoStyle): (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * style/StyleTreeResolver.h: * style/Styleable.h: Added. (WebCore::Styleable::Styleable): (WebCore::Styleable::fromElement): (WebCore::Styleable::fromRenderer): (WebCore::Styleable::operator== const): (WebCore::Styleable::operator!= const): (WebCore::Styleable::keyframeEffectStack const): (WebCore::Styleable::ensureKeyframeEffectStack const): (WebCore::Styleable::hasKeyframeEffects const): (WebCore::Styleable::applyKeyframeEffects const): (WebCore::Styleable::animations const): (WebCore::Styleable::hasCompletedTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitions const): (WebCore::Styleable::ensureAnimations const): (WebCore::Styleable::ensureCompletedTransitionsByProperty const): (WebCore::Styleable::ensureRunningTransitionsByProperty const): (WebCore::Styleable::animationsCreatedByMarkup const): (WebCore::Styleable::setAnimationsCreatedByMarkup const): (WebCore::Styleable::lastStyleChangeEventStyle const): (WebCore::Styleable::setLastStyleChangeEventStyle const): LayoutTests: <rdar://problem/69511682> Reviewed by Antti Koivisto. Update a couple of tests which relied on an internals method to get a pseudo element and instead use the Web Animations API to determine whether a given animation targets a pseudo-element. This has the added benefit of having the same code run in a testing environment as in a regular browser. * fast/css-generated-content/pseudo-animation.html: * fast/css-generated-content/pseudo-transition.html: Canonical link: https://commits.webkit.org/229750@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267571 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 15:22:00 +00:00
if (auto styleable = downcast<KeyframeEffect>(animation.effect())->targetStyleable()) {
Move AnimationTimeline methods related to Styleable to Styleable https://bugs.webkit.org/show_bug.cgi?id=224012 Reviewed by Dean Jackson. A number of public methods on AnimationTimeline make no use of any AnimationTimeline instance variables and instead call into Styleable: void elementWasRemoved(const Styleable&); void willChangeRendererForStyleable(const Styleable&); void cancelDeclarativeAnimationsForStyleable(const Styleable&); void animationWasAddedToStyleable(WebAnimation&, const Styleable&); void animationWasRemovedFromStyleable(WebAnimation&, const Styleable&); void removeDeclarativeAnimationFromListsForOwningElement(WebAnimation&, const Styleable&); void updateCSSAnimationsForStyleable(const Styleable&, const RenderStyle* currentStyle, const RenderStyle& afterChangeStyle, const RenderStyle* parentElementStyle); void updateCSSTransitionsForStyleable(const Styleable&, const RenderStyle& currentStyle, const RenderStyle& newStyle); These really belong on Styleable so we move them all over to that class with a new .cpp class for these non-trivial methods. * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::animationWasAddedToStyleable): Deleted. (WebCore::removeCSSTransitionFromMap): Deleted. (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): Deleted. (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): Deleted. (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): Deleted. (WebCore::AnimationTimeline::elementWasRemoved): Deleted. (WebCore::AnimationTimeline::willChangeRendererForStyleable): Deleted. (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): Deleted. (WebCore::shouldConsiderAnimation): Deleted. (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): Deleted. (WebCore::keyframeEffectForElementAndProperty): Deleted. (WebCore::propertyInStyleMatchesValueForTransitionInMap): Deleted. (WebCore::transitionCombinedDuration): Deleted. (WebCore::transitionMatchesProperty): Deleted. (WebCore::compileTransitionPropertiesInStyle): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): Deleted. * animation/AnimationTimeline.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::disassociateFromOwningElement): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::effectTargetDidChange): (WebCore::WebAnimation::persist): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * style/Styleable.cpp: Copied from Source/WebCore/animation/AnimationTimeline.cpp. (WebCore::Styleable::animationWasAdded const): (WebCore::removeCSSTransitionFromMap): (WebCore::Styleable::removeDeclarativeAnimationFromListsForOwningElement const): (WebCore::Styleable::animationWasRemoved const): (WebCore::removeCSSAnimationCreatedByMarkup): (WebCore::Styleable::elementWasRemoved const): (WebCore::Styleable::willChangeRenderer const): (WebCore::Styleable::cancelDeclarativeAnimations const): (WebCore::shouldConsiderAnimation): (WebCore::Styleable::updateCSSAnimations const): (WebCore::keyframeEffectForElementAndProperty): (WebCore::propertyInStyleMatchesValueForTransitionInMap): (WebCore::transitionCombinedDuration): (WebCore::transitionMatchesProperty): (WebCore::compileTransitionPropertiesInStyle): (WebCore::updateCSSTransitionsForStyleableAndProperty): (WebCore::Styleable::updateCSSTransitions const): * style/Styleable.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@275346 268f45cc-cd09-0410-ab3c-d52691b4dbfc Canonical link: https://commits.webkit.org/236017@main
2021-04-01 06:33:21 +00:00
styleable->animationWasRemoved(animation);
Reduce the reliance on PseudoElement in the animation code https://bugs.webkit.org/show_bug.cgi?id=216931 LayoutTests/imported/w3c: Reviewed by Antti Koivisto. Mark a WPT test progression. * web-platform-tests/css/css-transitions/non-rendered-element-002-expected.txt: Source/WebCore: <rdar://problem/69511682> Reviewed by Antti Koivisto. We have so far relied on PseudoElement as a foundation for supporting animations of pseudo-elements. This is not a great choice since PseudoElement is currently limited to ::before and ::after pseudo-elements only. This patch refactors animation-related code to rely on PseudoElement as little as possible without making changes outside of the animation code, as a first step towards supporting animation of more pseudo-elements. This patch introduces a new struct Styleable which combines an Element& and PseudoId. We use this struct instead of Element objects wherever necessary in the animation code. On top of that, we add a PseudoId parameter to all the Element methods wrapping access to ElementAnimationRareData and use a HashMap<PseudoId, std::unique_ptr<ElementAnimationRareData>> to be able to separate animation data per pseudo-element. * Headers.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::animationWasAddedToStyleable): (WebCore::AnimationTimeline::animationWasRemovedFromStyleable): (WebCore::AnimationTimeline::removeDeclarativeAnimationFromListsForOwningElement): (WebCore::AnimationTimeline::removeCSSAnimationCreatedByMarkup): (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::willChangeRendererForStyleable): (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForStyleable): (WebCore::shouldConsiderAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForStyleable): (WebCore::keyframeEffectForElementAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleableAndProperty): (WebCore::AnimationTimeline::updateCSSTransitionsForStyleable): (WebCore::AnimationTimeline::animationWasAddedToElement): Deleted. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Deleted. (WebCore::AnimationTimeline::willChangeRendererForElement): Deleted. (WebCore::AnimationTimeline::cancelDeclarativeAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElementAndProperty): Deleted. (WebCore::AnimationTimeline::updateCSSTransitionsForElement): Deleted. * animation/AnimationTimeline.h: * animation/CSSAnimation.cpp: (WebCore::CSSAnimation::create): (WebCore::CSSAnimation::CSSAnimation): * animation/CSSAnimation.h: * animation/CSSTransition.cpp: (WebCore::CSSTransition::create): (WebCore::CSSTransition::CSSTransition): * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::DeclarativeAnimation): (WebCore::DeclarativeAnimation::owningElement const): (WebCore::DeclarativeAnimation::disassociateFromOwningElement): (WebCore::DeclarativeAnimation::initialize): (WebCore::DeclarativeAnimation::enqueueDOMEvent): * animation/DeclarativeAnimation.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::animationCanBeRemoved): (WebCore::DocumentTimeline::transitionDidComplete): (WebCore::DocumentTimeline::computeExtentOfAnimation const): (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): (WebCore::DocumentTimeline::animatedStyleForRenderer): (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): (WebCore::DocumentTimeline::runningAnimationsForElementAreAllAccelerated const): Deleted. * animation/DocumentTimeline.h: * animation/ElementAnimationRareData.cpp: (WebCore::ElementAnimationRareData::ElementAnimationRareData): * animation/ElementAnimationRareData.h: (WebCore::ElementAnimationRareData::pseudoId const): * animation/KeyframeEffect.cpp: (WebCore::elementOrPseudoElementForStyleable): (WebCore::invalidateElement): (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::updateEffectStackMembership): (WebCore::KeyframeEffect::targetStyleable const): (WebCore::KeyframeEffect::setTarget): (WebCore::KeyframeEffect::setPseudoElement): (WebCore::KeyframeEffect::didChangeTargetStyleable): (WebCore::KeyframeEffect::invalidate): (WebCore::KeyframeEffect::applyPendingAcceleratedActions): (WebCore::KeyframeEffect::didChangeTargetElementOrPseudoElement): Deleted. * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: (WebCore::KeyframeEffectStack::addEffect): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::effectTargetDidChange): (WebCore::WebAnimation::persist): (WebCore::WebAnimation::commitStyles): * animation/WebAnimation.h: * animation/WebAnimationUtilities.cpp: (WebCore::compareDeclarativeAnimationOwningElementPositionsInDocumentTreeOrder): (WebCore::compareCSSTransitions): (WebCore::compareCSSAnimations): * dom/Element.cpp: (WebCore::Element::removedFromAncestor): (WebCore::Element::animationRareData const): (WebCore::Element::ensureAnimationRareData): (WebCore::Element::keyframeEffectStack const): (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): (WebCore::Element::animations const): (WebCore::Element::hasCompletedTransitionsForProperty const): (WebCore::Element::hasRunningTransitionsForProperty const): (WebCore::Element::hasRunningTransitions const): (WebCore::Element::ensureAnimations): (WebCore::Element::animationsCreatedByMarkup): (WebCore::Element::setAnimationsCreatedByMarkup): (WebCore::Element::ensureCompletedTransitionsByProperty): (WebCore::Element::ensureRunningTransitionsByProperty): (WebCore::Element::lastStyleChangeEventStyle const): (WebCore::Element::setLastStyleChangeEventStyle): (WebCore::Element::getAnimations): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::useTypes const): (WebCore::ElementRareData::animationRareData const): (WebCore::ElementRareData::ensureAnimationRareData): (WebCore::ElementRareData::elementAnimationRareData): Deleted. * dom/PseudoElement.cpp: (WebCore::PseudoElement::clearHostElement): (WebCore::PseudoElement::isTargetedByKeyframeEffectRequiringPseudoElement): * rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const): * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const): (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): * rendering/style/RenderStyleConstants.cpp: (WebCore::operator<<): * rendering/updating/RenderTreeUpdater.cpp: (WebCore::RenderTreeUpdater::tearDownRenderers): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::resolveElement): (WebCore::Style::TreeResolver::resolvePseudoStyle): (WebCore::Style::TreeResolver::createAnimatedElementUpdate): * style/StyleTreeResolver.h: * style/Styleable.h: Added. (WebCore::Styleable::Styleable): (WebCore::Styleable::fromElement): (WebCore::Styleable::fromRenderer): (WebCore::Styleable::operator== const): (WebCore::Styleable::operator!= const): (WebCore::Styleable::keyframeEffectStack const): (WebCore::Styleable::ensureKeyframeEffectStack const): (WebCore::Styleable::hasKeyframeEffects const): (WebCore::Styleable::applyKeyframeEffects const): (WebCore::Styleable::animations const): (WebCore::Styleable::hasCompletedTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitionsForProperty const): (WebCore::Styleable::hasRunningTransitions const): (WebCore::Styleable::ensureAnimations const): (WebCore::Styleable::ensureCompletedTransitionsByProperty const): (WebCore::Styleable::ensureRunningTransitionsByProperty const): (WebCore::Styleable::animationsCreatedByMarkup const): (WebCore::Styleable::setAnimationsCreatedByMarkup const): (WebCore::Styleable::lastStyleChangeEventStyle const): (WebCore::Styleable::setLastStyleChangeEventStyle const): LayoutTests: <rdar://problem/69511682> Reviewed by Antti Koivisto. Update a couple of tests which relied on an internals method to get a pseudo element and instead use the Web Animations API to determine whether a given animation targets a pseudo-element. This has the added benefit of having the same code run in a testing environment as in a regular browser. * fast/css-generated-content/pseudo-animation.html: * fast/css-generated-content/pseudo-transition.html: Canonical link: https://commits.webkit.org/229750@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267571 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-09-25 15:22:00 +00:00
styleable->ensureKeyframeEffectStack().removeEffect(*downcast<KeyframeEffect>(animation.effect()));
[Web Animations] Use a keyframe effect stack to resolve animations on an element https://bugs.webkit.org/show_bug.cgi?id=204010 Reviewed by Dean Jackson. Until now, when resolving animations for an element, we would call animationsForElement() during each resolution which means doing several hash table lookups to locate the various classes of animations for that given element, sorting each of those animations and inserting them into a new Vector. We now use a KeyframeEffectStack which keeps a list of KeyframeEffect objects that apply to a given target, provided the effect also has a valid animation and that animation has a valid timeline, all pre-conditions for that effect to produce an animated value. Any time one of those pre-conditions change, we update the membership of that effect in the stack. The KeyframeEffectStack is a new member of ElementRareData. Now, each time we resolve an animation for an element, we iterate over the KeyframeEffect objects returned by calling sortEffects() on the KeyframeEffectStack which will sort the stack's effects only if a new effect had been added since the last iteration, which means that simple animations that are not mutated will require sorting of the stack just once, and the addition of several animations in a single animation frame will require sorting just once as well. It was also found while doing this work that Style::TreeResolver::createAnimatedElementUpdate would call RenderStyle::clonePtr() for any element that was part of a document containing a timeline, regardless of whether that element had any animations. Now we check whether that element's KeyframeEffectStack contains any effects prior to cloning the style. No tests or changes to existed test expectations as this should not yield any change in behavior. * Sources.txt: Add the new KeyframeEffectStack. * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.h: (WebCore::AnimationEffect::setAnimation): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::removeAnimation): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Since we need to know the order of CSS @keyframes rules listed in animation-name when sorting effects, we must compile the ordered list of those @keyframe rules as we update CSS animations for an element and store it on its KeyframeEffectStack. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::resolveAnimationsForElement): Deleted. Replaced by Element::applyKeyframeEffects(). * animation/DocumentTimeline.h: * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::animationTimelineDidChange): (WebCore::KeyframeEffect::setAnimation): (WebCore::KeyframeEffect::setTarget): * animation/KeyframeEffect.h: * animation/KeyframeEffectStack.cpp: Added. (WebCore::KeyframeEffectStack::KeyframeEffectStack): (WebCore::KeyframeEffectStack::~KeyframeEffectStack): (WebCore::KeyframeEffectStack::addEffect): (WebCore::KeyframeEffectStack::removeEffect): (WebCore::KeyframeEffectStack::sortedEffects): (WebCore::KeyframeEffectStack::ensureEffectsAreSorted): (WebCore::KeyframeEffectStack::setCSSAnimationNames): * animation/KeyframeEffectStack.h: Added. (WebCore::KeyframeEffectStack::hasEffects const): * animation/WebAnimation.cpp: (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::persist): * dom/Element.cpp: (WebCore::Element::ensureKeyframeEffectStack): (WebCore::Element::hasKeyframeEffects const): (WebCore::Element::applyKeyframeEffects): * dom/Element.h: * dom/ElementRareData.cpp: * dom/ElementRareData.h: (WebCore::ElementRareData::keyframeEffectStack): (WebCore::ElementRareData::setKeyframeEffectStack): * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): Canonical link: https://commits.webkit.org/217343@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-11-08 20:40:57 +00:00
}
[Web Animations] Implement the update animations and send events procedure https://bugs.webkit.org/show_bug.cgi?id=191013 <rdar://problem/45620495> Reviewed by Dean Jackson. LayoutTests/imported/mozilla: Progression in a couple of getAnimations() tests for CSS Animations. * css-animations/test_document-get-animations-expected.txt: LayoutTests/imported/w3c: Progressions in a couple of Web Animations Web Platform Tests. * web-platform-tests/web-animations/timing-model/animations/current-time-expected.txt: * web-platform-tests/web-animations/timing-model/animations/updating-the-finished-state-expected.txt: Source/WebCore: While we implemented the various parts of what the Web Animations specification refers to as the "update animations and send events" procedure, we did not implement it as one function and in the correct order, specifically updating animations and sending events in two separate tasks. We now have a single method on DocumentTimeline which runs as the DisplayRefreshMonitor fires to update each "relevant" animation with the current time, perform a microtask checkpoint and dispatch events. Implementing this procedure allowed us to make several enhancements: 1. We introduce the concept of a "relevant" animation, which is essentially an animation that is either pending or playing. All animations in a different state are no longer owned by the DocumentTimeline and can thus be destroyed if the developer doesn't hold references in JS. Maintaining such a list guarantees that we're only updating animations that would have changed state since the last time the "update animations and send events" procedure was run. Note that DeclarativeAnimation instances are also considered to be relevant if they have queued DOM events to dispatch as they could otherwise be destroyed before they can fully dispatch them. 2. We no longer conflate the timing model and effects. Until now the way we would update animations was to go through all elements for which we had a registered animation, invalidate their style and finally forcing a style update on the document. We had a separate data structure where we help animations without targets so we update these as well in a separate pass, in order to make sure that promises and events would fire for them as expected. We now let the "update animations and send events" procedure update the timing of all relevant animations and let individual animation effects invalidate their style as needed, the document style invalidation happening naturally without DocumentTimeline forcing it. 3. We use a single step to schedule the update of animations, which is to register for a display refresh monitor update provided a "relevant" animation is known since the previous update. Until now we first had an "timing model invalidation" task scheduled upon any change of an animation's timing model, which would then create a timer to the earliest moment any listed animation would require an update, finally registering a display refresh monitor update, which used at least GenericTaskQueue<Timer> and potentially two, whereas we use none right now. 4. We allow for a display refresh monitor update to be canceled should the number of "relevant" animations since the last update goes back to 0. To facilitate all of this, we have changed the m_animations ListHashSet to contain only the "relevant" animations, and no longer every animation created that has this DocumentTimeline set as their "timeline" property. To keep this list current, every single change that changes a given animation's timing ends up calling AnimationTimeline::animationTimingDidChange() passing the animation as the sole parameter and adding this animation to m_animations. We immediately schedule a display refresh monitor update if one wasn't already scheduled. Then, when running the "update animations and send events" procedure, we call a new WebAnimation::tick() method on each of those animations, which updates this animation's effect and relevance, using the newly computed relevance to identify whether this animation should be kept in the m_animations ListHashSet. This is only the first step towards a more efficient update and ownership model of animations by the document timeline since animations created as CSS Animations and CSS Transitions are committed through CSS have dedicated data structures that are not updated in this particular patch, but this will be addressed in a followup to keep this already significant patch smaller. Another issue that will be addressed later is the ability to not schedule display refresh monitor udpates when only accelerated animations are running. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::animationTimingDidChange): Called by animations when any aspect of their timing model changes. The provided animation is then added to the m_animations list unless its timeline is no longer this timeline. (WebCore::AnimationTimeline::removeAnimation): Remove the provided animation from m_animations and remove any animation registered on the element-specific animation lists if this animation has an effect with a target. (WebCore::AnimationTimeline::animationWasAddedToElement): We no longer need to worry about the m_animationsWithoutTarget data structure since we removed it. (WebCore::removeCSSTransitionFromMap): Fix a bug where we would remove any CSSTransition in the provided map that had a matching transition-property instead of checking the CSSTransition registered for this transition-property was indeed the provided CSSTransition. The other code changes in this patch made this code now cause regressions in the Web Platform Tests. (WebCore::AnimationTimeline::animationWasRemovedFromElement): Stop updating m_animationsWithoutTarget since it no longer exists. (WebCore::AnimationTimeline::elementWasRemoved): (WebCore::AnimationTimeline::updateCSSAnimationsForElement): Fix a small error that caused a regression in the Web Platform Tests where we could attempt to call setBackingAnimation() on a nullptr instead of a valid CSSAnimation. (WebCore::AnimationTimeline::cancelOrRemoveDeclarativeAnimation): (WebCore::AnimationTimeline::addAnimation): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::hasElementAnimations const): Deleted. (WebCore::AnimationTimeline:: const): Deleted. (WebCore::AnimationTimeline::elementToAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSAnimationsMap): Deleted. (WebCore::AnimationTimeline::elementToCSSTransitionsMap): Deleted. * animation/CSSTransition.cpp: (WebCore::CSSTransition::canBeListed const): Deleted. * animation/CSSTransition.h: * animation/DeclarativeAnimation.cpp: (WebCore::DeclarativeAnimation::tick): Call the superclass's method and queue any necessary DOM events reflecting the timing model changes. (WebCore::DeclarativeAnimation::needsTick const): Call the superclass's method and return true also if we have pending events since otherwise this animation could be removed from m_animations on its AnimationTimeline and potentially destroyed before the GenericEventQueue had a chance to dispatch all events. (WebCore::DeclarativeAnimation::startTime const): We removed the custom binding for this IDL property and renamed the method from bindingsStartTime to startTime. (WebCore::DeclarativeAnimation::setStartTime): We removed the custom binding for this IDL property and renamed the method from setBindingsStartTime to setStartTime. (WebCore::DeclarativeAnimation::bindingsStartTime const): Deleted. (WebCore::DeclarativeAnimation::setBindingsStartTime): Deleted. * animation/DeclarativeAnimation.h: * animation/DocumentAnimationScheduler.cpp: (WebCore::DocumentAnimationScheduler::unscheduleWebAnimationsResolution): Add a method to mark that we no longer need a display refresh monitor update for this document's animation timeline. This is called when m_animations becomes empty. * animation/DocumentAnimationScheduler.h: * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::DocumentTimeline): (WebCore::DocumentTimeline::detachFromDocument): Stop clearing two task queues and a timer that no longer exist and instead only clear the task queue to clear the cached current time, which we queue any time we generate a new one (see DocumentTimeline::currentTime). (WebCore::DocumentTimeline::getAnimations const): Use isRelevant() instead of canBeListed(). (WebCore::DocumentTimeline::updateThrottlingState): (WebCore::DocumentTimeline::suspendAnimations): (WebCore::DocumentTimeline::resumeAnimations): (WebCore::DocumentTimeline::numberOfActiveAnimationsForTesting const): (WebCore::DocumentTimeline::currentTime): Queue a task in the new m_currentTimeClearingTaskQueue task queue to clear the current time that we've generated and cached in the next run loop (provided all pending JS execution has also completed). (WebCore::DocumentTimeline::maybeClearCachedCurrentTime): (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Schedule a display refresh monitor update if we are not suspended and have "relevant" animations. (WebCore::DocumentTimeline::animationTimingDidChange): Call scheduleAnimationResolutionIfNeeded() after calling the superclass's implementation. (WebCore::DocumentTimeline::removeAnimation): Call unscheduleAnimationResolution() if the list of "relevant" animations is now empty. (WebCore::DocumentTimeline::unscheduleAnimationResolution): Unschedule a pending display refresh monitor update. (WebCore::DocumentTimeline::animationResolutionTimerFired): (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): Implement the "update animations and send events" procedure as specified by the Web Animations spec. During this procedure, we call tick() on all animations listed in m_animations and create a list of animations to remove from that list if this animation is no longer relevant following the call to tick(). (WebCore::DocumentTimeline::enqueueAnimationPlaybackEvent): (WebCore::DocumentTimeline::timingModelDidChange): Deleted. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Deleted. (WebCore::DocumentTimeline::performInvalidationTask): Deleted. (WebCore::DocumentTimeline::updateAnimationSchedule): Deleted. (WebCore::DocumentTimeline::animationScheduleTimerFired): Deleted. (WebCore::DocumentTimeline::updateAnimations): Deleted. (WebCore::compareAnimationPlaybackEvents): Deleted. (WebCore::DocumentTimeline::performEventDispatchTask): Deleted. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: The majority of the changes to this class is that we call the new timingDidChange() method when any code that modifies the timing model is run. We also remove methods to set the pending play and pause tasks as well as the animation's start time and hold time since any time we're changing these instance variables, we later already have a call to update the timing model and we were doing more work than needed. As a result we no longer need an internal method to set the start time and can stop requiring a custom IDL binding for the "startTime" property. (WebCore::WebAnimation::effectTimingPropertiesDidChange): (WebCore::WebAnimation::setEffect): (WebCore::WebAnimation::setEffectInternal): (WebCore::WebAnimation::setTimeline): (WebCore::WebAnimation::setTimelineInternal): (WebCore::WebAnimation::startTime const): (WebCore::WebAnimation::setStartTime): (WebCore::WebAnimation::silentlySetCurrentTime): (WebCore::WebAnimation::setCurrentTime): (WebCore::WebAnimation::setPlaybackRate): (WebCore::WebAnimation::cancel): (WebCore::WebAnimation::resetPendingTasks): (WebCore::WebAnimation::finish): (WebCore::WebAnimation::timingDidChange): New method called any time a timing property changed where we run the "update the finished state" procedure and notify the animation's timeline that its timing changed so that it can be considered the next time the "update animations and send events" procedure runs. (WebCore::WebAnimation::invalidateEffect): (WebCore::WebAnimation::updateFinishedState): Update the animation's relevance after running the procedure as specified. (WebCore::WebAnimation::play): (WebCore::WebAnimation::runPendingPlayTask): (WebCore::WebAnimation::pause): (WebCore::WebAnimation::runPendingPauseTask): (WebCore::WebAnimation::needsTick const): (WebCore::WebAnimation::tick): New method called during the "update animations and send events" procedure where we run the "update the finished state" procedure and run the pending play and pause tasks. (WebCore::WebAnimation::resolve): (WebCore::WebAnimation::updateRelevance): (WebCore::WebAnimation::computeRelevance): (WebCore::WebAnimation::timingModelDidChange): Deleted. (WebCore::WebAnimation::setHoldTime): Deleted. (WebCore::WebAnimation::bindingsStartTime const): Deleted. (WebCore::WebAnimation::setBindingsStartTime): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPlayTask): Deleted. (WebCore::WebAnimation::setTimeToRunPendingPauseTask): Deleted. (WebCore::WebAnimation::updatePendingTasks): Deleted. (WebCore::WebAnimation::timeToNextRequiredTick const): Deleted. (WebCore::WebAnimation::runPendingTasks): Deleted. (WebCore::WebAnimation::canBeListed const): Deleted. * animation/WebAnimation.h: (WebCore::WebAnimation::isRelevant const): (WebCore::WebAnimation::hasPendingPlayTask const): (WebCore::WebAnimation::isEffectInvalidationSuspended): * animation/WebAnimation.idl: * dom/Element.cpp: (WebCore::Element::getAnimations): Use isRelevant() instead of canBeListed(). LayoutTests: Several tests that broke when turning Web Animations CSS Integration on by default are now passing. In the case of one test, we had to ensure that the final animation frame had been committed before terminating the test or there would be a tiny image reference issue. * TestExpectations: * fast/layers/no-clipping-overflow-hidden-added-after-transform.html: Canonical link: https://commits.webkit.org/205875@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-10-30 09:30:03 +00:00
}
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
}
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
std::optional<double> AnimationTimeline::bindingsCurrentTime()
{
[Web Animations] Schedule animations registered on the document timeline https://bugs.webkit.org/show_bug.cgi?id=179236 <rdar://problem/35332669> Reviewed by Dean Jackson. Source/WebCore: We now schedule animations contained in the document timeline using a three-step approach. 1. Each time an object that is part of the timing model changes one of its timing properties, we call animationTimingModelDidChange() on the document timeline. This schedules performInvalidationTask() to be called when the current run loop completes, such that we invalidate the timing model just once per run loop. 2. Once performInvalidationTask() is called, the timing model is invalidated in updateAnimationSchedule(). We iterate over the registered animations on the timineline and identify the shortest interval between the current time and the next moment one of the animations requires a tick to update its value. If we find a value below 15ms, we schedule animations to be resolved with scheduleAnimationResolution() right away. If the value is above 15ms, and not inifinity, we schedule a one-shot timer for that interval to call scheduleAnimationResolution(). 3. Once scheduleAnimationResolution() is called, we call scheduleAnimation() on the shared DisplayRefreshMonitorManager to be notified when the next display refresh occurs to actually resolve animations with resolveAnimations(). Note that, in this patch, resolveAnimations() does nothing, we will add support for interpolating values in a future patch. Another important thing to note is that every time the document timeline's current time is requested, we cache it for the duration of the run loop such that the timing model always uses the same value during a given run loop. Finally, to support tests where we check the state of the timing model by manually advancing time, we expose a new pause() method on AnimationTimeline for tests to call to avoid the timeline to self-advance. * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::addAnimation): Mark that the timing model changed as a result of adding an animation. (WebCore::AnimationTimeline::removeAnimation): Mark that the timing model changed as a result of removing an animation. (WebCore::AnimationTimeline::bindingsCurrentTime): Update the method signature to no longer be const and call into currentTime() instead of reading directly from the m_currentTime member variable since a subclass, like DocumentTimeline, may have a custom currentTime() implementation. (WebCore::AnimationTimeline::setCurrentTime): Mark that the timing model changed as a result of the timeline current time changing. (WebCore::AnimationTimeline::bindingsCurrentTime const): Deleted. * animation/AnimationTimeline.h: (WebCore::AnimationTimeline::currentTime): Change both methods signatures to no longer be const so that DocumentTimeline's implementation of currentTime() may cache the current time in a member variable, enqueuing a callback when the run loop completes for this member variable to be reset, and updating some states. (WebCore::AnimationTimeline::pause): To be implemented by subclasses. (WebCore::AnimationTimeline::animationTimingModelDidChange): Add a new virtual method to indicate that the timing model needs invalidating. (WebCore::AnimationTimeline::animations const): Add an accessor to allow animations to be accessed by a subclass. * animation/DocumentTimeline.cpp: (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): Update the constructor signature to receive a Document and a PlatformDisplayID since we need a reference to the Document to get at the nowTime() and a PlatformDisplayID to create the DisplayRefreshMonitor. (WebCore::DocumentTimeline::~DocumentTimeline): Close the task queue when the timeline gets destroyed. (WebCore::DocumentTimeline::currentTime): If we don't have a current cahed current time, compute one and schedule the invalidation task if needed so that we may reset the cached value as the run loop completes. (WebCore::DocumentTimeline::pause): Allows the timeline not to self-advance, for testing purposes only. (WebCore::DocumentTimeline::animationTimingModelDidChange): If we haven't already done so, mark that we need to update our animation schedule in the invalidation task and schedule that task if not scheduled yet. (WebCore::DocumentTimeline::scheduleInvalidationTaskIfNeeded): Schedule the invalidation task to run as the run loop completes if we haven't already done so. (WebCore::DocumentTimeline::performInvalidationTask): Update the animation schedule if needed and reset the cached current time value. (WebCore::DocumentTimeline::updateAnimationSchedule): Iterate over registed animations and find the shortest interval until one of them needs to update their animation. If the shortest interval is below 15ms, schedule the animation resolution right away. If the shortest inverval is finite and above 15ms, then schedule a one-shot timer for that interval to perform the animation resolution then. (WebCore::DocumentTimeline::animationScheduleTimerFired): The one-shot timer to perform the animation resolution has fired, we call scheduleAnimationResolution(). (WebCore::DocumentTimeline::scheduleAnimationResolution): We call scheduleAnimation() on the shared DisplayRefreshMonitorManager so that we may resolve animations on the next display refresh, or start a timer if the DisplayRefreshMonitorManager is not available. (WebCore::DocumentTimeline::displayRefreshFired): The display is about to refresh, we call resolveAnimations(). (WebCore::DocumentTimeline::animationResolutionTimerFired): The fallback animation resolution timer has fired, we call resolveAnimations(). (WebCore::DocumentTimeline::resolveAnimations): Currently do nothing, this is where we'll iterate over registered animations to update them with the current time. (WebCore::DocumentTimeline::windowScreenDidChange): Notify the shared DisplayRefreshMonitorManager that the PlatformDisplayID changed. (WebCore::DocumentTimeline::createDisplayRefreshMonitor const): Provide a DisplayRefreshMonitor as part of the DisplayRefreshMonitorClient protocol. * animation/DocumentTimeline.h: * animation/WebAnimation.cpp: (WebCore::WebAnimation::create): Remove extra white space. (WebCore::WebAnimation::setStartTime): Mark that the timing model changed as a result of changing this animation's start time. (WebCore::WebAnimation::timeToNextRequiredTick const): Compute the interval until the next time we need to resolve this animation. If the provided current time is before this animation's start time, compute the delay until the start time. If the current time is after the animation's start time but before the animation's end time, indicate that we want to resolve the animation again right away and return 0ms. In any other case, return an infinite interval to indicate that we don't need to be refreshed after the provided time. * animation/WebAnimation.h: * dom/Document.cpp: (WebCore::Document::windowScreenDidChange): Notify the document timeline that the PlatformDisplayID changed. (WebCore::Document::timeline): Provide the Document and the PlatformDisplayID to the DocumentTimeline. * testing/Internals.cpp: (WebCore::Internals::pauseTimeline): * testing/Internals.h: * testing/Internals.idl: LayoutTests: Adopt the new internals.pauseTimeline() method to ensure that the existing tests do not have a self-advancing timeline since we're interested in checking the timing model state based on manually setting the timeline current time. Also update some WPT expectations with some progressions. * TestExpectations: Mark two tests as flaky due to the sample time being logged in the failure. * http/wpt/web-animations/interfaces/AnimationTimeline/document-timeline-expected.txt: * http/wpt/web-animations/timing-model/animations/current-time-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt: * http/wpt/wk-web-animations/timing-model/animation-creation-basic.html: * http/wpt/wk-web-animations/timing-model/animation-current-time.html: * http/wpt/wk-web-animations/timing-model/animation-effect-timing.html: * http/wpt/wk-web-animations/timing-model/animation-effect.html: * http/wpt/wk-web-animations/timing-model/animation-interface-effect-property.html: * http/wpt/wk-web-animations/timing-model/animation-interface-start-time-property.html: * http/wpt/wk-web-animations/timing-model/animation-playback-rate.html: * http/wpt/wk-web-animations/timing-model/document-timeline.html: * http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html: * http/wpt/wk-web-animations/timing-model/keyframe-effect.html: * http/wpt/wk-web-animations/timing-model/timeline-current-time.html: Canonical link: https://commits.webkit.org/195397@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224472 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-05 22:34:10 +00:00
auto time = currentTime();
if (!time)
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
return std::nullopt;
[Web Animations] Expose timing properties (delay, endDelay, fill, iterationStart, iterations, direction) and getComputedTiming() https://bugs.webkit.org/show_bug.cgi?id=181857 <rdar://problem/36660081> Reviewed by Dean Jackson. Source/WebCore: We start the work to implement the rest of the Web Animations timing and animation model by exposing more properties on AnimationEffectTiming to control delay (delay, endDelay), looping (iterationStart, iterations), fill and direction. Additionally, we expose the getComputedTiming() method on AnimationEffect, although it currently lacks some computed properties that will come in later patch as we implement various processes defined by the spec. We also update the existing duration() method on AnimationEffectTiming to be called iterationDuration() to match the terms used in the specification. Finally, we make all new properties, and update existing ones, that expose a time value go through the new utility function secondsToWebAnimationsAPITime() to guarantee rounded values with microseconds precision, as advised by the Web Animations specification. * CMakeLists.txt: * DerivedSources.make: * Sources.txt: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationEffect.cpp: (WebCore::AnimationEffect::localTime const): (WebCore::AnimationEffect::getComputedTiming): * animation/AnimationEffect.h: * animation/AnimationEffect.idl: * animation/AnimationEffectTiming.cpp: (WebCore::AnimationEffectTiming::AnimationEffectTiming): (WebCore::AnimationEffectTiming::setIterationStart): (WebCore::AnimationEffectTiming::setIterations): (WebCore::AnimationEffectTiming::bindingsDuration const): (WebCore::AnimationEffectTiming::setBindingsDuration): (WebCore::AnimationEffectTiming::endTime const): (WebCore::AnimationEffectTiming::activeDuration const): * animation/AnimationEffectTiming.h: * animation/AnimationEffectTiming.idl: * animation/AnimationPlaybackEvent.cpp: (WebCore::AnimationPlaybackEvent::bindingsCurrentTime const): (WebCore::AnimationPlaybackEvent::bindingsTimelineTime const): * animation/AnimationTimeline.cpp: (WebCore::AnimationTimeline::bindingsCurrentTime): * animation/ComputedTimingProperties.h: Added. * animation/ComputedTimingProperties.idl: Added. We set nullable double values to a default value of "null" since otherwise setting those properties to a null value would not set the properties in the converted JS dictionary. * animation/KeyframeEffect.cpp: (WebCore::KeyframeEffect::create): Handle new timing properties passed in the KeyframeEffectOptions dictionary. (WebCore::KeyframeEffect::applyAtLocalTime): (WebCore::KeyframeEffect::getAnimatedStyle): (WebCore::KeyframeEffect::startOrStopAccelerated): * animation/WebAnimation.cpp: (WebCore::WebAnimation::bindingsStartTime const): (WebCore::WebAnimation::bindingsCurrentTime const): (WebCore::WebAnimation::effectEndTime const): (WebCore::WebAnimation::timeToNextRequiredTick const): * animation/WebAnimationUtilities.h: Added. (WebCore::secondsToWebAnimationsAPITime): LayoutTests: Update expectations with progressions and new failure points now we expose more of the API. * http/wpt/web-animations/animation-model/animation-types/discrete-animation-expected.txt: * http/wpt/web-animations/interfaces/Animatable/animate-expected.txt: * http/wpt/web-animations/interfaces/Animation/finish-expected.txt: * http/wpt/web-animations/interfaces/Animation/finished-expected.txt: * http/wpt/web-animations/interfaces/Animation/pause-expected.txt: * http/wpt/web-animations/interfaces/Animation/play-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/delay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/direction-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/duration-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/easing-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/endDelay-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/fill-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterationStart-expected.txt: * http/wpt/web-animations/interfaces/AnimationEffectTiming/iterations-expected.txt: * http/wpt/web-animations/interfaces/AnimationTimeline/document-timeline-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/active-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/current-iteration-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/local-time-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/phases-and-states-expected.txt: * http/wpt/web-animations/timing-model/animation-effects/simple-iteration-progress-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-animation-start-time-expected.txt: * http/wpt/web-animations/timing-model/animations/set-the-target-effect-of-an-animation-expected.txt: * http/wpt/web-animations/timing-model/time-transformations/transformed-progress-expected.txt: * http/wpt/wk-web-animations/timing-model/keyframe-effect-interface-timing-duration.html: Canonical link: https://commits.webkit.org/197684@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-01-19 17:56:53 +00:00
return secondsToWebAnimationsAPITime(*time);
}
[Web Animations] Provide basic timeline and animation interfaces https://bugs.webkit.org/show_bug.cgi?id=178526 Patch by Antoine Quint <graouts@apple.com> on 2017-10-20 Reviewed by Dean Jackson. .: Remove the WEB_ANIMATIONS compile-time flag. * Source/cmake/OptionsWPE.cmake: * Source/cmake/OptionsWin.cmake: * Source/cmake/WebKitFeatures.cmake: * Source/cmake/tools/vsprops/FeatureDefines.props: * Source/cmake/tools/vsprops/FeatureDefinesCairo.props: Source/JavaScriptCore: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebCore: We're getting Web Animations work started by implementing a very minimal codebase which provides a DocumentTimeline class which has an instance created for each Document. The parent class, AnimationTimeline, allows for animations to be added and removed, and animations can be created using the Animation class, with an optional timeline as parameter. Tests: webanimations/animation-creation-basic.html webanimations/document-timeline.html * CMakeLists.txt: * Configurations/FeatureDefines.xcconfig: * DerivedSources.make: * PlatformWin.cmake: * WebCore.xcodeproj/project.pbxproj: * animation/AnimationTimeline.cpp: Added. (WebCore::AnimationTimeline::AnimationTimeline): (WebCore::AnimationTimeline::~AnimationTimeline): (WebCore::AnimationTimeline::addAnimation): (WebCore::AnimationTimeline::removeAnimation): * animation/AnimationTimeline.h: Added. (WebCore::AnimationTimeline::isDocumentTimeline const): (WebCore::AnimationTimeline::classType const): * animation/AnimationTimeline.idl: Added. * animation/DocumentTimeline.cpp: Added. (WebCore::DocumentTimeline::create): (WebCore::DocumentTimeline::DocumentTimeline): * animation/DocumentTimeline.h: Added. * animation/DocumentTimeline.idl: Added. * animation/WebAnimation.cpp: Added. (WebCore::WebAnimation::create): (WebCore::WebAnimation::WebAnimation): (WebCore::WebAnimation::~WebAnimation): * animation/WebAnimation.h: Added. * animation/WebAnimation.idl: Added. * bindings/js/JSAnimationTimelineCustom.cpp: Added. (WebCore::toJSNewlyCreated): (WebCore::toJS): * bindings/js/WebCoreBuiltinNames.h: * dom/Document.cpp: (WebCore::Document::timeline): * dom/Document.h: * dom/Document.idl: * page/RuntimeEnabledFeatures.h: (WebCore::RuntimeEnabledFeatures::webAnimationsEnabled const): Source/WebCore/PAL: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: Source/WebKit: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebProcess/InjectedBundle/InjectedBundle.cpp: (WebKit::InjectedBundle::overrideBoolPreferenceForTestRunner): (WebKit::InjectedBundle::setWebAnimationsEnabled): * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::updatePreferences): Source/WebKitLegacy/mac: Remove the WEB_ANIMATIONS compile-time flag. * Configurations/FeatureDefines.xcconfig: * WebView/WebPreferences.mm: (+[WebPreferences initialize]): * WebView/WebView.mm: (-[WebView _preferencesChanged:]): Source/WebKitLegacy/win: Remove the WEB_ANIMATIONS compile-time flag. * WebView.cpp: (WebView::notifyPreferencesChanged): Source/WTF: Remove the WEB_ANIMATIONS compile-time flag. * wtf/FeatureDefines.h: Tools: Remove the WEB_ANIMATIONS compile-time flag. * TestWebKitAPI/Configurations/FeatureDefines.xcconfig: LayoutTests: Basic test coverage to check that we are exposing a DocumentTimeline instance on the Document and that we can construct Animations, optionally associated with a timeline. * platform/mac-elcapitan/TestExpectations: * webanimations/animation-creation-basic-expected.txt: Added. * webanimations/animation-creation-basic.html: Added. * webanimations/document-timeline-expected.txt: Added. * webanimations/document-timeline.html: Added. Canonical link: https://commits.webkit.org/194785@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-10-20 18:41:23 +00:00
} // namespace WebCore