CSS Animations with triggers should map scroll position to duration
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Mar 2015 04:47:20 +0000 (04:47 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 20 Mar 2015 04:47:20 +0000 (04:47 +0000)
commitb70815a32eeaa9f8851fbc0e769752466451a854
tree531458feca4073e45bde81308fae0938a4657d59
parentedf1232d742c54ed33cb44ba4107b49bb1d13547
CSS Animations with triggers should map scroll position to duration
https://bugs.webkit.org/show_bug.cgi?id=142870
<rdar://problem/20227244>

Reviewed by Simon Fraser.

Source/WebCore:

Expose a prototype implementation of what will eventually be called
animation-timebase, mapping the scroll location to the duration of an
animation. This only applies if the animation has a start and end
trigger.

Test: animations/trigger-container-scroll-boundaries.html
Test: animations/trigger-container-scroll-empty.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::createAnimationTriggerValue): Change to downcast.

* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapAnimationTrigger): Fix a bug where I wasn't
telling the ScrollAnimationTrigger object whether or not it had
an end value. This wasn't visible before because we were not using
the end value.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::fireAnimationEventsIfNeeded): Add a comment and
change to using a downcast.
(WebCore::AnimationBase::timeToNextService): Change to downcast.
(WebCore::AnimationBase::freezeAtTime): Whitespace cleanup.
(WebCore::AnimationBase::getElapsedTime): Calculate the elapsedTime based
on the scroll position relative to the start and end trigger spots.

* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::updateAnimations): Since this
can potentially call into beginAnimationUpdateTime, it should have
an update blocker. This fixes the assert we were seeing in tests.
(WebCore::AnimationControllerPrivate::scrollWasUpdated): Keep track of the scroll
position so we don't need to ask for it all the time.
* page/animation/AnimationControllerPrivate.h:
(WebCore::AnimationControllerPrivate::scrollPosition): New accessor.

* platform/animation/AnimationTrigger.h: Add downcast macros.
(WebCore::ScrollAnimationTrigger::create): Calculate hasEndValue from the passed
parameters rather than a separate value.
(WebCore::ScrollAnimationTrigger::hasEndValue):
(WebCore::ScrollAnimationTrigger::ScrollAnimationTrigger):
(WebCore::ScrollAnimationTrigger::setHasEndValue): Deleted.

* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::animationCanBeAccelerated): If we have an
animation of this sort, we can't use a CAAnimation.

LayoutTests:

Add a new test that exercises an animation trigger over a scroll
region, and a test of the boundary condition. Also, unskip a test that
was failing due to a bug fixed in this patch.

* animations/trigger-container-scroll-boundaries-expected.txt: Added.
* animations/trigger-container-scroll-boundaries.html: Added.
* animations/trigger-container-scroll-empty-expected.txt: Added.
* animations/trigger-container-scroll-empty.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181778 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/trigger-container-scroll-boundaries-expected.txt [new file with mode: 0644]
LayoutTests/animations/trigger-container-scroll-boundaries.html [new file with mode: 0644]
LayoutTests/animations/trigger-container-scroll-empty-expected.txt [new file with mode: 0644]
LayoutTests/animations/trigger-container-scroll-empty.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/page/animation/AnimationBase.cpp
Source/WebCore/page/animation/AnimationController.cpp
Source/WebCore/page/animation/AnimationControllerPrivate.h
Source/WebCore/platform/animation/AnimationTrigger.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp