[Web Animations] Fix a host of small CSS Animations and CSS Transitions issues
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2018 21:25:56 +0000 (21:25 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Apr 2018 21:25:56 +0000 (21:25 +0000)
commit2d648ea4d3a6a2cab24238a1acbeee914af24c99
tree1c851ad629e4ce3158f335b1942deefe83dfc882
parent677bac4710e173d8894a094c2eeaade1bb4d5549
[Web Animations] Fix a host of small CSS Animations and CSS Transitions issues
https://bugs.webkit.org/show_bug.cgi?id=184555

Reviewed by Dean Jackson.

Source/WebCore:

A series of small and intertwined issues were preventing a number of CSS Animations and CSS Trantions
tests to fail when expressed as Web Animations.

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::updateCSSAnimationsForElement): Pass the old and new RenderStyles to CSSAnimation::create()
since we're refactoring DeclarativeAnimation to create blending keyframes in initialize(), no longer requiring each subclass
to create them.
(WebCore::AnimationTimeline::cssAnimationForElementAndProperty): Return the animation, if any, for a property animated by
a CSS animation, so that we can determine if a property is already being animated when running a CSS Transition.
(WebCore::AnimationTimeline::updateCSSTransitionsForElement): Since a property can be specified twice in a "transition" property,
once via "all" and once explicitly, ensure we look at all currently running transitions for the currently-processed property to
see if we need to cancel this transition. Previously, we used to only see if it had been transitioned in the old style. We also
start transitions even if the duration is 0 provided the delay is a positive, non-zero value. Then, if there is a CSS Animation
for this property already running, use that animation's original unanimated style as the from value.
* animation/AnimationTimeline.h:
* animation/CSSAnimation.cpp:
(WebCore::CSSAnimation::create): The animation name is now set in the CSSAnimation constructor.
(WebCore::CSSAnimation::CSSAnimation): Set the animation name and keep a copy of the unanimated style such that we can
get it when a CSS Transition is created and takes precedence over this CSS Animation.
(WebCore::CSSAnimation::initialize): Deleted.
* animation/CSSAnimation.h:
* animation/CSSTransition.cpp:
(WebCore::CSSTransition::create):
(WebCore::CSSTransition::initialize):
* animation/CSSTransition.h:
* animation/DeclarativeAnimation.cpp:
(WebCore::DeclarativeAnimation::initialize): Call the new computeDeclarativeAnimationBlendingKeyframes() on the KeyframeEffect
directly in this method so that subclasses don't need to create it manually, but most important so that keyframes are created
before timing properties are set based on the backing animation.
* animation/DeclarativeAnimation.h:
* animation/KeyframeEffectReadOnly.cpp:
(WebCore::KeyframeEffectReadOnly::getKeyframes): Ensure we have a CSSValue before trying to serialize it.
(WebCore::KeyframeEffectReadOnly::computeDeclarativeAnimationBlendingKeyframes):
(WebCore::KeyframeEffectReadOnly::computeCSSAnimationBlendingKeyframes): Use the animation's unanimated style to compute keyframes,
instead of a default RenderStyle which would not use the right values for implicit keyframes.
(WebCore::KeyframeEffectReadOnly::stylesWouldYieldNewCSSTransitionsBlendingKeyframes const): Look at the property used to create
the transition rather than that specified on the backing Animation object since it can be CSSPropertyInvalid in the case of
"transition: all".
(WebCore::KeyframeEffectReadOnly::setAnimatedPropertiesInStyle): If we're dealing with a CSS animation, we consider the first and
last keyframes to always have the property listed since the underlying style was provided and should be captured.
* animation/KeyframeEffectReadOnly.h:
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::createAnimatedElementUpdate): Apply CSS Animations after CSS Trasitions since they take precedence.

LayoutTests:

Mark more tests as passing when the CSS Animations and CSS Transitions as Web Animations flag is on.

* animations/animation-border-overflow.html:
* animations/lineheight-animation.html:
* animations/missing-from-to-transforms.html:
* animations/missing-values-first-keyframe.html:
* animations/missing-values-last-keyframe.html:
* animations/transition-and-animation-1.html:
* animations/transition-and-animation-2.html:
* animations/transition-and-animation-3.html:
* animations/width-using-ems.html:
* compositing/layer-creation/mismatched-rotated-transform-animation-overlap.html:
* compositing/layer-creation/multiple-keyframes-animation-overlap.html:
* compositing/layer-creation/scale-rotation-animation-overlap.html:
* compositing/layer-creation/translate-scale-animation-overlap.html:
* css3/filters/filter-animation-from-none-hw.html:
* css3/filters/filter-animation-from-none-multi-hw.html:
* css3/filters/filter-animation-from-none-multi.html:
* css3/filters/filter-animation-from-none.html:
* imported/blink/transitions/unprefixed-transform.html:
* transitions/interrupted-all-transition.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230595 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/animation-border-overflow.html
LayoutTests/animations/lineheight-animation.html
LayoutTests/animations/missing-from-to-transforms.html
LayoutTests/animations/missing-values-first-keyframe.html
LayoutTests/animations/missing-values-last-keyframe.html
LayoutTests/animations/transition-and-animation-1.html
LayoutTests/animations/transition-and-animation-2.html
LayoutTests/animations/transition-and-animation-3.html
LayoutTests/animations/width-using-ems.html
LayoutTests/compositing/layer-creation/mismatched-rotated-transform-animation-overlap.html
LayoutTests/compositing/layer-creation/multiple-keyframes-animation-overlap.html
LayoutTests/compositing/layer-creation/scale-rotation-animation-overlap.html
LayoutTests/compositing/layer-creation/translate-scale-animation-overlap.html
LayoutTests/css3/filters/filter-animation-from-none-hw.html
LayoutTests/css3/filters/filter-animation-from-none-multi-hw.html
LayoutTests/css3/filters/filter-animation-from-none-multi.html
LayoutTests/css3/filters/filter-animation-from-none.html
LayoutTests/imported/blink/transitions/unprefixed-transform.html
LayoutTests/transitions/interrupted-all-transition.html
Source/WebCore/ChangeLog
Source/WebCore/animation/AnimationTimeline.cpp
Source/WebCore/animation/AnimationTimeline.h
Source/WebCore/animation/CSSAnimation.cpp
Source/WebCore/animation/CSSAnimation.h
Source/WebCore/animation/CSSTransition.cpp
Source/WebCore/animation/CSSTransition.h
Source/WebCore/animation/DeclarativeAnimation.cpp
Source/WebCore/animation/DeclarativeAnimation.h
Source/WebCore/animation/KeyframeEffectReadOnly.cpp
Source/WebCore/animation/KeyframeEffectReadOnly.h
Source/WebCore/style/StyleTreeResolver.cpp