summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordstockwell@chromium.org <dstockwell@chromium.org>2015-05-06 04:49:49 +0000
committerdstockwell@chromium.org <dstockwell@chromium.org>2015-05-06 04:49:49 +0000
commit5d4375dd23951f07259d66136a655dddb1783aa0 (patch)
tree9d6a61473a40eec03e461abd16cf884d32a43748
parent4c4ec02ff4a89aeed1b2df84fc4be76967a0f18c (diff)
downloadchromium_src-5d4375dd23951f07259d66136a655dddb1783aa0.zip
chromium_src-5d4375dd23951f07259d66136a655dddb1783aa0.tar.gz
chromium_src-5d4375dd23951f07259d66136a655dddb1783aa0.tar.bz2
Web Animations: Update naming to reflect spec changes
KeyframeEffect -> KeyframeEffectModel (internal) Animation -> KeyframeEffect AnimationEffect -> EffectModel AnimationNode -> AnimationEffect (internal), AnimationEffectReadOnly (idl) AnimationPlayer -> Animation Timing (internal), AnimationNodeTiming (idl), -> AnimationEffectTiming Note, this does not rename: * the WebCompositor* interfaces (for @loyso) * or the devtools protocol (for @samli) Follow on changes: * remove EffectModel from idl, to be replaced by SharedKeyframeList * rename InertAnimation to InertEffect * expose other *ReadOnly interfaces and add support for treating AnimationEffect as a read only instance BUG=483272 Review URL: https://codereview.chromium.org/1113173003 git-svn-id: svn://svn.chromium.org/blink/trunk@194961 bbb929c8-8fbe-4397-9dbb-9b2b20218538
-rw-r--r--third_party/WebKit/LayoutTests/animations/resources/animation-test-helpers.js4
-rw-r--r--third_party/WebKit/LayoutTests/transitions/interrupted-immediately.html2
-rw-r--r--third_party/WebKit/LayoutTests/transitions/repeated-firing-background-color.html2
-rw-r--r--third_party/WebKit/LayoutTests/transitions/transition-currentcolor.html4
-rw-r--r--third_party/WebKit/LayoutTests/transitions/webkit-clip-path-equality.html4
-rw-r--r--third_party/WebKit/LayoutTests/virtual/stable/webexposed/web-animations-api-expected.txt2
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/animation-constructor.html32
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/partial-keyframes.html46
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timed-item-expected.txt10
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-getters.html12
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-setters.html3
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timed-item.html82
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timeline-play-animation.html4
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/timeline-updates-players.html6
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/transitions-replay.html10
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/w3c/get-animation-players.html160
-rw-r--r--third_party/WebKit/LayoutTests/web-animations-api/w3c/get-css-players.html24
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt4
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt54
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/web-animations-api-expected.txt14
-rw-r--r--third_party/WebKit/LayoutTests/webexposed/web-animations-api.html4
-rw-r--r--third_party/WebKit/Source/core/animation/Animation.cpp1093
-rw-r--r--third_party/WebKit/Source/core/animation/Animation.h269
-rw-r--r--third_party/WebKit/Source/core/animation/Animation.idl32
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffect.cpp (renamed from third_party/WebKit/Source/core/animation/AnimationNode.cpp)58
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffect.h129
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.idl (renamed from third_party/WebKit/Source/core/animation/AnimationNode.idl)9
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffectTest.cpp (renamed from third_party/WebKit/Source/core/animation/AnimationNodeTest.cpp)181
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp (renamed from third_party/WebKit/Source/core/animation/AnimationNodeTiming.cpp)50
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffectTiming.h (renamed from third_party/WebKit/Source/core/animation/AnimationNodeTiming.h)14
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl (renamed from third_party/WebKit/Source/core/animation/Timing.idl)11
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationNode.h172
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationPlayer.cpp1032
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationPlayer.h288
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationPlayerTest.cpp882
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationStack.cpp20
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationStack.h7
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationStackTest.cpp56
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationTest.cpp1076
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationTimeline.cpp98
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationTimeline.h30
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationTimeline.idl4
-rw-r--r--third_party/WebKit/Source/core/animation/AnimationTimelineTest.cpp44
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorAnimations.cpp110
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorAnimations.h20
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h6
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp114
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp64
-rw-r--r--third_party/WebKit/Source/core/animation/CompositorPendingAnimations.h8
-rw-r--r--third_party/WebKit/Source/core/animation/ComputedTimingProperties.idl2
-rw-r--r--third_party/WebKit/Source/core/animation/DocumentAnimations.cpp6
-rw-r--r--third_party/WebKit/Source/core/animation/DocumentAnimations.h2
-rw-r--r--third_party/WebKit/Source/core/animation/EffectInput.cpp10
-rw-r--r--third_party/WebKit/Source/core/animation/EffectInput.h10
-rw-r--r--third_party/WebKit/Source/core/animation/EffectInputTest.cpp4
-rw-r--r--third_party/WebKit/Source/core/animation/EffectModel.h (renamed from third_party/WebKit/Source/core/animation/AnimationPlayer.idl)62
-rw-r--r--third_party/WebKit/Source/core/animation/EffectModel.idl (renamed from third_party/WebKit/Source/core/animation/AnimationEffect.idl)2
-rw-r--r--third_party/WebKit/Source/core/animation/ElementAnimation.h36
-rw-r--r--third_party/WebKit/Source/core/animation/ElementAnimation.idl8
-rw-r--r--third_party/WebKit/Source/core/animation/ElementAnimations.cpp28
-rw-r--r--third_party/WebKit/Source/core/animation/ElementAnimations.h18
-rw-r--r--third_party/WebKit/Source/core/animation/InertAnimation.cpp8
-rw-r--r--third_party/WebKit/Source/core/animation/InertAnimation.h12
-rw-r--r--third_party/WebKit/Source/core/animation/Keyframe.h18
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffect.cpp341
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffect.h123
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffect.idl41
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp10
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffectModel.h16
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp42
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffectOptions.idl (renamed from third_party/WebKit/Source/core/animation/AnimationTimingProperties.idl)2
-rw-r--r--third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp464
-rw-r--r--third_party/WebKit/Source/core/animation/SampledEffect.cpp14
-rw-r--r--third_party/WebKit/Source/core/animation/SampledEffect.h16
-rw-r--r--third_party/WebKit/Source/core/animation/StringKeyframe.cpp12
-rw-r--r--third_party/WebKit/Source/core/animation/StringKeyframe.h4
-rw-r--r--third_party/WebKit/Source/core/animation/TimingCalculations.h30
-rw-r--r--third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp28
-rw-r--r--third_party/WebKit/Source/core/animation/TimingInput.cpp4
-rw-r--r--third_party/WebKit/Source/core/animation/TimingInput.h4
-rw-r--r--third_party/WebKit/Source/core/animation/TimingInputTest.cpp14
-rw-r--r--third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.cpp6
-rw-r--r--third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.h2
-rw-r--r--third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h68
-rw-r--r--third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp172
-rw-r--r--third_party/WebKit/Source/core/animation/css/CSSAnimations.h42
-rw-r--r--third_party/WebKit/Source/core/core.gypi38
-rw-r--r--third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp2
-rw-r--r--third_party/WebKit/Source/core/dom/Document.cpp4
-rw-r--r--third_party/WebKit/Source/core/frame/UseCounter.h30
-rw-r--r--third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp70
-rw-r--r--third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h18
-rw-r--r--third_party/WebKit/Source/core/inspector/InspectorInstrumentation.idl4
-rw-r--r--third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp10
-rw-r--r--third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h6
-rw-r--r--third_party/WebKit/Source/core/style/KeyframeList.cpp2
96 files changed, 4106 insertions, 4119 deletions
diff --git a/third_party/WebKit/LayoutTests/animations/resources/animation-test-helpers.js b/third_party/WebKit/LayoutTests/animations/resources/animation-test-helpers.js
index 823d445..ba84169 100644
--- a/third_party/WebKit/LayoutTests/animations/resources/animation-test-helpers.js
+++ b/third_party/WebKit/LayoutTests/animations/resources/animation-test-helpers.js
@@ -205,7 +205,7 @@ function runChecksWithRAF(checks)
function runChecksWithPauseAPI(checks) {
for (var k in checks) {
var timeMs = Number(k);
- log('Pausing at time: ' + timeMs + ', current players: ' + document.timeline.getAnimationPlayers().length);
+ log('Pausing at time: ' + timeMs + ', current animations: ' + document.timeline.getAnimations().length);
internals.pauseAnimations(timeMs / 1000);
checks[k].forEach(function(check) { check(); });
}
@@ -236,7 +236,7 @@ function log(message)
function waitForAnimationsToStart(callback)
{
- if (document.timeline.getAnimationPlayers().length > 0) {
+ if (document.timeline.getAnimations().length > 0) {
callback();
} else {
setTimeout(waitForAnimationsToStart.bind(this, callback), 0);
diff --git a/third_party/WebKit/LayoutTests/transitions/interrupted-immediately.html b/third_party/WebKit/LayoutTests/transitions/interrupted-immediately.html
index cef0469..92b58e8 100644
--- a/third_party/WebKit/LayoutTests/transitions/interrupted-immediately.html
+++ b/third_party/WebKit/LayoutTests/transitions/interrupted-immediately.html
@@ -40,7 +40,7 @@
// Force at least one timing update and recalc after the interruption.
id = requestAnimationFrame(function() {
cancelAnimationFrame(id);
- var current = document.timeline.getAnimationPlayers().length;
+ var current = document.timeline.getAnimations().length;
document.getElementById('result').innerHTML = (current == 0) ? "PASS" : "FAIL";
if (window.testRunner)
testRunner.notifyDone();
diff --git a/third_party/WebKit/LayoutTests/transitions/repeated-firing-background-color.html b/third_party/WebKit/LayoutTests/transitions/repeated-firing-background-color.html
index 2591435..a14fa20 100644
--- a/third_party/WebKit/LayoutTests/transitions/repeated-firing-background-color.html
+++ b/third_party/WebKit/LayoutTests/transitions/repeated-firing-background-color.html
@@ -11,7 +11,7 @@
<script>
function checkRunning()
{
- var current = document.timeline.getAnimationPlayers().length;
+ var current = document.timeline.getAnimations().length;
if (current == 0)
document.getElementById('result').innerHTML = "PASS: Number of active transitions is (0) as expected";
else
diff --git a/third_party/WebKit/LayoutTests/transitions/transition-currentcolor.html b/third_party/WebKit/LayoutTests/transitions/transition-currentcolor.html
index 1a67741..a8f453a 100644
--- a/third_party/WebKit/LayoutTests/transitions/transition-currentcolor.html
+++ b/third_party/WebKit/LayoutTests/transitions/transition-currentcolor.html
@@ -18,8 +18,8 @@ requestAnimationFrame(function() {
target2.style.borderLeftColor = "orange";
requestAnimationFrame(function() {
// Only 'color' should transition
- test1.step(function() { assert_equals(target1.getAnimationPlayers().length, 1); });
- test2.step(function() { assert_equals(target2.getAnimationPlayers().length, 1); });
+ test1.step(function() { assert_equals(target1.getAnimations().length, 1); });
+ test2.step(function() { assert_equals(target2.getAnimations().length, 1); });
test1.done();
test2.done();
});
diff --git a/third_party/WebKit/LayoutTests/transitions/webkit-clip-path-equality.html b/third_party/WebKit/LayoutTests/transitions/webkit-clip-path-equality.html
index 13a19a6..f0c2375 100644
--- a/third_party/WebKit/LayoutTests/transitions/webkit-clip-path-equality.html
+++ b/third_party/WebKit/LayoutTests/transitions/webkit-clip-path-equality.html
@@ -20,14 +20,14 @@ onload = function() {
};
function step1() {
target.offsetTop;
- result = document.timeline.getAnimationPlayers().length == 0 ?
+ result = document.timeline.getAnimations().length == 0 ?
'PASS - No transition started.' :
'FAIL - Unexpected transition started.';
target.style.webkitClipPath = 'circle(200px at 0px 0px)';
requestAnimationFrame(step2);
}
function step2() {
- result += document.timeline.getAnimationPlayers().length == 1 ?
+ result += document.timeline.getAnimations().length == 1 ?
'\nPASS - Transition started.' :
'\nFAIL - Transition did not start.';
document.documentElement.style.whiteSpace = 'pre';
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/web-animations-api-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/web-animations-api-expected.txt
index b32a957..7bfb48a 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/web-animations-api-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/web-animations-api-expected.txt
@@ -1,6 +1,6 @@
This is a testharness.js-based test.
PASS Element.animate() should be exposed.
-PASS Element.getAnimationPlayers() should not be exposed without experimental web platform features enabled.
+PASS Element.getAnimations() should not be exposed without experimental web platform features enabled.
This test is expected to fail in LayoutTests/webexposed.
PASS Animation constructor should not be exposed without experimental web platform features enabled.
This test is expected to fail in LayoutTests/webexposed.
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/animation-constructor.html b/third_party/WebKit/LayoutTests/web-animations-api/animation-constructor.html
index 6f44b72..6c131ee 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/animation-constructor.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/animation-constructor.html
@@ -11,26 +11,26 @@ var keyframes = [{opacity: '1'}, {opacity: '0'}];
var timingObject = {duration: 2, iterations: 5};
test(function() {
- var animation = new Animation(element, keyframes, timingObject);
- assert_not_equals(animation, undefined);
- assert_equals(animation.constructor, Animation);
-}, 'Calling new Animation() with a timing object input should create an animation.');
+ var keyframeEffect = new KeyframeEffect(element, keyframes, timingObject);
+ assert_not_equals(keyframeEffect, undefined);
+ assert_equals(keyframeEffect.constructor, KeyframeEffect);
+}, 'Calling new KeyframeEffect() with a timing object input should create an keyframeEffect.');
test(function() {
- var animation = new Animation(element, keyframes, 2);
- assert_not_equals(animation, undefined);
- assert_equals(animation.constructor, Animation);
-}, 'Calling new Animation() with a duration input should create an animation.');
+ var keyframeEffect = new KeyframeEffect(element, keyframes, 2);
+ assert_not_equals(keyframeEffect, undefined);
+ assert_equals(keyframeEffect.constructor, KeyframeEffect);
+}, 'Calling new KeyframeEffect() with a duration input should create an keyframeEffect.');
test(function() {
- var animation = new Animation(element, keyframes);
- assert_not_equals(animation, undefined);
- assert_equals(animation.constructor, Animation);
-}, 'Calling new Animation() with no timing input should create an animation.');
+ var keyframeEffect = new KeyframeEffect(element, keyframes);
+ assert_not_equals(keyframeEffect, undefined);
+ assert_equals(keyframeEffect.constructor, KeyframeEffect);
+}, 'Calling new KeyframeEffect() with no timing input should create an keyframeEffect.');
test(function() {
- var animation = new Animation(null, keyframes);
- assert_not_equals(animation, undefined);
- assert_equals(animation.constructor, Animation);
-}, 'Calling new Animation() with no target should create an animation.');
+ var keyframeEffect = new KeyframeEffect(null, keyframes);
+ assert_not_equals(keyframeEffect, undefined);
+ assert_equals(keyframeEffect.constructor, KeyframeEffect);
+}, 'Calling new KeyframeEffect() with no target should create an keyframeEffect.');
</script>
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/partial-keyframes.html b/third_party/WebKit/LayoutTests/web-animations-api/partial-keyframes.html
index 9e3fe3df..ca573a6 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/partial-keyframes.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/partial-keyframes.html
@@ -27,11 +27,11 @@ test(function() {
{opacity: '0', color: 'red'}
];
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes3); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes4); });
-}, 'Calling new Animation() with a mismatched keyframe property should throw a NotSupportedError.');
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes1); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes2); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes3); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes4); });
+}, 'Calling new KeyframeEffect() with a mismatched keyframe property should throw a NotSupportedError.');
test(function() {
var validKeyframes1 = [
@@ -45,9 +45,9 @@ test(function() {
{width: '10px', height: '10px', offset: 1}
];
- assert_not_equals(new Animation(element, validKeyframes1), undefined);
- assert_not_equals(new Animation(element, validKeyframes2), undefined);
-}, 'Calling new Animation() with no offset specified for the first keyframe should create and animation.');
+ assert_not_equals(new KeyframeEffect(element, validKeyframes1), undefined);
+ assert_not_equals(new KeyframeEffect(element, validKeyframes2), undefined);
+}, 'Calling new KeyframeEffect() with no offset specified for the first keyframe should create and animation.');
test(function() {
var partialKeyframes1 = [
@@ -59,9 +59,9 @@ test(function() {
{opacity: '0'}
];
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
-}, 'Calling new Animation() with the offset of the first keyframe specified but not equal to 0 should throw a NotSupportedError.');
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes1); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes2); });
+}, 'Calling new KeyframeEffect() with the offset of the first keyframe specified but not equal to 0 should throw a NotSupportedError.');
test(function() {
var validKeyframes1 = [
@@ -75,9 +75,9 @@ test(function() {
{width: '10px'}
];
- assert_not_equals(new Animation(element, validKeyframes1), undefined);
- assert_not_equals(new Animation(element, validKeyframes2), undefined);
-}, 'Calling new Animation() with no offset specified for the last keyframe should create an animation.');
+ assert_not_equals(new KeyframeEffect(element, validKeyframes1), undefined);
+ assert_not_equals(new KeyframeEffect(element, validKeyframes2), undefined);
+}, 'Calling new KeyframeEffect() with no offset specified for the last keyframe should create an animation.');
test(function() {
var partialKeyframes1 = [
@@ -89,9 +89,9 @@ test(function() {
{opacity: '0', offset: 0.1}
];
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
-}, 'Calling new Animation() with the offset of the last keyframe specified but not equal to 1 should throw a NotSupportedError.');
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes1); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes2); });
+}, 'Calling new KeyframeEffect() with the offset of the last keyframe specified but not equal to 1 should throw a NotSupportedError.');
test(function() {
var partialKeyframes1 = [
@@ -106,9 +106,9 @@ test(function() {
];
// Height is missing keyframe at offset: 1
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
-}, 'Calling new Animation() with a keyframe that has no offset specified, is followed by other keyframes, ' +
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes1); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes2); });
+}, 'Calling new KeyframeEffect() with a keyframe that has no offset specified, is followed by other keyframes, ' +
'and is the last keyframe for a property, should throw a NotSupportedError.');
test(function() {
@@ -124,8 +124,8 @@ test(function() {
];
// Height is missing keyframe at offset: 0
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes1); });
- assert_throws('NOT_SUPPORTED_ERR', function() { new Animation(element, partialKeyframes2); });
-}, 'Calling new Animation() with a keyframe that has no offset specified, is preceded by other keyframes, ' +
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes1); });
+ assert_throws('NOT_SUPPORTED_ERR', function() { new KeyframeEffect(element, partialKeyframes2); });
+}, 'Calling new KeyframeEffect() with a keyframe that has no offset specified, is preceded by other keyframes, ' +
'and is the first keyframe for a property, should throw a NotSupportedError.');
</script>
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-expected.txt b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-expected.txt
index 3c09337..1c6d454 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-expected.txt
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-expected.txt
@@ -1,9 +1,9 @@
This is a testharness.js-based test.
-FAIL TimedItem.localTime and TimedItem.currentIteration are null when animation is not associated with a Player assert_equals: expected (object) null but got (undefined) undefined
-PASS TimedItem.localTime and TimedItem.currentIteration return reasonable values when an animation is in effect
-FAIL TimedItem.currentIteration is null when animation is not in effect assert_equals: expected (object) null but got (undefined) undefined
-PASS TimedItem startTime, endTime, duration, activeDuration are sensible for a simple animation
-PASS TimedItem startTime, endTime, duration, activeDuration are sensible for animations with delays and iterations
+FAIL localTime and currentIteration are null when the KeyframeEffect is not associated with an Animation assert_equals: expected (object) null but got (undefined) undefined
+PASS TimedItem.localTime and TimedItem.currentIteration return reasonable values when an keyframeEffect is in effect
+FAIL TimedItem.currentIteration is null when keyframeEffect is not in effect assert_equals: expected (object) null but got (undefined) undefined
+PASS TimedItem startTime, endTime, duration, activeDuration are sensible for a simple keyframeEffect
+PASS TimedItem startTime, endTime, duration, activeDuration are sensible for keyframeEffects with delays and iterations
PASS TimedItem duration is calculated when no duration is specified
PASS Restricted double attributes on the Timing interface throws for non-finite values.
Harness: the test ran to completion.
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-getters.html b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-getters.html
index ed57b7b..40952e0 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-getters.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-getters.html
@@ -10,15 +10,15 @@
var element = document.getElementById('e');
var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
-var animationBasic = new Animation(element, keyframes);
-var specifiedTimingBasic = animationBasic.timing;
+var keyframeEffectBasic = new KeyframeEffect(element, keyframes);
+var specifiedTimingBasic = keyframeEffectBasic.timing;
var timingNumberDuration = {duration: 2};
-var animationNumberDuration = new Animation(element, keyframes, timingNumberDuration);
+var animationNumberDuration = new KeyframeEffect(element, keyframes, timingNumberDuration);
var specifiedTimingNumberDuration = animationNumberDuration.timing;
var timingNoDuration = {iterations: 3};
-var animationNoDuration = new Animation(element, keyframes, timingNoDuration);
+var animationNoDuration = new KeyframeEffect(element, keyframes, timingNoDuration);
var specifiedTimingNoDuration = animationNoDuration.timing;
var timingAllFields = {
@@ -32,11 +32,11 @@ var timingAllFields = {
direction: 'reverse',
easing: 'step-start'
};
-var animationAllFields = new Animation(element, keyframes, timingAllFields);
+var animationAllFields = new KeyframeEffect(element, keyframes, timingAllFields);
var specifiedTimingAllFields = animationAllFields.timing;
test(function() {
- assert_equals(specifiedTimingBasic.constructor, Timing);
+ assert_equals(specifiedTimingBasic.constructor, AnimationEffectTiming);
assert_equals(specifiedTimingBasic.delay, 0);
assert_equals(specifiedTimingBasic.endDelay, 0);
assert_equals(specifiedTimingBasic.fill, 'auto');
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-setters.html b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-setters.html
index f955ab2..5d268a4 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-setters.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timed-item-specified-setters.html
@@ -10,8 +10,7 @@
var element = document.getElementById('e');
var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
-var animation = new Animation(element, keyframes);
-var specifiedTiming = animation.timing;
+var specifiedTiming = new KeyframeEffect(element, keyframes).timing;
test(function() {
specifiedTiming.delay = 2;
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timed-item.html b/third_party/WebKit/LayoutTests/web-animations-api/timed-item.html
index 3e41643..a4b3390 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timed-item.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timed-item.html
@@ -11,60 +11,60 @@ var element = document.getElementById('e');
var keyframes = [{opacity: '1', offset: 0}, {opacity: '0', offset: 1}];
test(function() {
- var animation = new Animation(element, keyframes);
- assert_equals(animation.computedTiming.localTime, null);
- assert_equals(animation.computedTiming.currentIteration, null);
-}, 'TimedItem.localTime and TimedItem.currentIteration are null when animation is not associated with a Player');
+ var keyframeEffect = new KeyframeEffect(element, keyframes);
+ assert_equals(keyframeEffect.computedTiming.localTime, null);
+ assert_equals(keyframeEffect.computedTiming.currentIteration, null);
+}, 'localTime and currentIteration are null when the KeyframeEffect is not associated with an Animation');
test(function() {
- var player = element.animate(keyframes, {fill: 'both', duration: 2000, iterations: 3});
- var animation = player.source;
- player.currentTime = -1000;
- assert_equals(animation.computedTiming.localTime, -1000, 'localTime');
- assert_equals(animation.computedTiming.currentIteration, 0);
- player.currentTime = 1000;
- assert_equals(animation.computedTiming.localTime, 1000);
- assert_equals(animation.computedTiming.currentIteration, 0);
- player.currentTime = 5000;
- assert_equals(animation.computedTiming.localTime, 5000);
- assert_equals(animation.computedTiming.currentIteration, 2);
- player.currentTime = 7000;
- assert_equals(animation.computedTiming.localTime, 7000);
- assert_equals(animation.computedTiming.currentIteration, 2);
-}, 'TimedItem.localTime and TimedItem.currentIteration return reasonable values when an animation is in effect');
+ var animation = element.animate(keyframes, {fill: 'both', duration: 2000, iterations: 3});
+ var keyframeEffect = animation.source;
+ animation.currentTime = -1000;
+ assert_equals(keyframeEffect.computedTiming.localTime, -1000, 'localTime');
+ assert_equals(keyframeEffect.computedTiming.currentIteration, 0);
+ animation.currentTime = 1000;
+ assert_equals(keyframeEffect.computedTiming.localTime, 1000);
+ assert_equals(keyframeEffect.computedTiming.currentIteration, 0);
+ animation.currentTime = 5000;
+ assert_equals(keyframeEffect.computedTiming.localTime, 5000);
+ assert_equals(keyframeEffect.computedTiming.currentIteration, 2);
+ animation.currentTime = 7000;
+ assert_equals(keyframeEffect.computedTiming.localTime, 7000);
+ assert_equals(keyframeEffect.computedTiming.currentIteration, 2);
+}, 'TimedItem.localTime and TimedItem.currentIteration return reasonable values when an keyframeEffect is in effect');
test(function() {
- var player = element.animate(keyframes);
- var animation = player.source;
- player.currentTime = -1;
- assert_equals(animation.computedTiming.currentIteration, null);
- player.currentTime = 1;
- assert_equals(animation.computedTiming.currentIteration, null);
-}, 'TimedItem.currentIteration is null when animation is not in effect');
+ var animation = element.animate(keyframes);
+ var keyframeEffect = animation.source;
+ animation.currentTime = -1;
+ assert_equals(keyframeEffect.computedTiming.currentIteration, null);
+ animation.currentTime = 1;
+ assert_equals(keyframeEffect.computedTiming.currentIteration, null);
+}, 'TimedItem.currentIteration is null when keyframeEffect is not in effect');
test(function() {
- var animation = new Animation(element, keyframes, 2);
- assert_equals(animation.computedTiming.startTime, 0);
- assert_equals(animation.computedTiming.endTime, 2);
- assert_equals(animation.computedTiming.duration, 2);
- assert_equals(animation.computedTiming.activeDuration, 2);
-}, 'TimedItem startTime, endTime, duration, activeDuration are sensible for a simple animation');
+ var keyframeEffect = new KeyframeEffect(element, keyframes, 2);
+ assert_equals(keyframeEffect.computedTiming.startTime, 0);
+ assert_equals(keyframeEffect.computedTiming.endTime, 2);
+ assert_equals(keyframeEffect.computedTiming.duration, 2);
+ assert_equals(keyframeEffect.computedTiming.activeDuration, 2);
+}, 'TimedItem startTime, endTime, duration, activeDuration are sensible for a simple keyframeEffect');
test(function() {
- var animation = new Animation(element, keyframes, {duration: 3, iterations: 4, delay: 5});
- assert_equals(animation.computedTiming.startTime, 0);
- assert_equals(animation.computedTiming.endTime, 17);
- assert_equals(animation.computedTiming.duration, 3);
- assert_equals(animation.computedTiming.activeDuration, 12);
-}, 'TimedItem startTime, endTime, duration, activeDuration are sensible for animations with delays and iterations');
+ var keyframeEffect = new KeyframeEffect(element, keyframes, {duration: 3, iterations: 4, delay: 5});
+ assert_equals(keyframeEffect.computedTiming.startTime, 0);
+ assert_equals(keyframeEffect.computedTiming.endTime, 17);
+ assert_equals(keyframeEffect.computedTiming.duration, 3);
+ assert_equals(keyframeEffect.computedTiming.activeDuration, 12);
+}, 'TimedItem startTime, endTime, duration, activeDuration are sensible for keyframeEffects with delays and iterations');
test(function() {
- var animation = new Animation(element, keyframes, {delay: 1});
- assert_equals(animation.computedTiming.duration, 0);
+ var keyframeEffect = new KeyframeEffect(element, keyframes, {delay: 1});
+ assert_equals(keyframeEffect.computedTiming.duration, 0);
}, 'TimedItem duration is calculated when no duration is specified');
test(function() {
- var timing = new Animation(element, keyframes).timing;
+ var timing = new KeyframeEffect(element, keyframes).timing;
for (var attr of ['delay', 'endDelay', 'iterationStart', 'playbackRate']) {
assert_throws(new TypeError, function() { timing[attr] = NaN; }, attr);
assert_throws(new TypeError, function() { timing[attr] = Infinity; }, attr);
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timeline-play-animation.html b/third_party/WebKit/LayoutTests/web-animations-api/timeline-play-animation.html
index 0e6f993..0198419 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timeline-play-animation.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timeline-play-animation.html
@@ -11,13 +11,13 @@ var element = document.getElementById('e');
var style = getComputedStyle(element);
var duration = 1;
-var animation = new Animation(element,
+var keyframeEffect = new KeyframeEffect(element,
[{opacity: '1', offset: 0},
{opacity: '0', offset: 1}],
duration);
test(function() {
- var player = document.timeline.play(animation);
+ var player = document.timeline.play(keyframeEffect);
player.pause();
player.currentTime = duration / 2;
assert_equals(style.opacity, '0.5');
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/timeline-updates-players.html b/third_party/WebKit/LayoutTests/web-animations-api/timeline-updates-players.html
index f3b9e42..3cbc6b1 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/timeline-updates-players.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/timeline-updates-players.html
@@ -8,9 +8,9 @@
<script>
var element = document.getElementById('element');
-var animation = new Animation(element, [{left: '0px'}, {left: '100px'}], 10);
+var keyframeEffect = new KeyframeEffect(element, [{left: '0px'}, {left: '100px'}], 10);
test(function() {
- var player = document.timeline.play(animation);
+ var player = document.timeline.play(keyframeEffect);
player.finish();
assert_equals(getComputedStyle(element).left, 'auto');
@@ -21,7 +21,7 @@ test(function() {
}, 'Player updated after finish and play');
test(function() {
- var player = document.timeline.play(animation);
+ var player = document.timeline.play(keyframeEffect);
assert_equals(getComputedStyle(element).left, '0px');
var source = player.source
player.source = null;
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/transitions-replay.html b/third_party/WebKit/LayoutTests/web-animations-api/transitions-replay.html
index 8849de9..083b041 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/transitions-replay.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/transitions-replay.html
@@ -16,13 +16,13 @@ t.step(function() {
element.style.background = "green";
element.offsetTop; // Force recalc
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- var player = document.timeline.getAnimationPlayers()[0];
- player.onfinish = function() {
+ assert_equals(document.timeline.getAnimations().length, 1);
+ var animation = document.timeline.getAnimations()[0];
+ animation.onfinish = function() {
requestAnimationFrame(function() {
requestAnimationFrame(function() {
- player.startTime = document.timeline.currentTime - 10;
- player.onfinish = t.done.bind(t);
+ animation.startTime = document.timeline.currentTime - 10;
+ animation.onfinish = t.done.bind(t);
});
});
}
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-animation-players.html b/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-animation-players.html
index 4f267bd..8e340e8 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-animation-players.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-animation-players.html
@@ -11,98 +11,98 @@ var container = document.getElementById('container');
var element = document.getElementById('element');
test(function() {
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
- var player = element.animate([], 1000);
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
+ var animation = element.animate([], 1000);
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation);
- var player2 = container.animate([], 1000);
- assert_equals(document.timeline.getAnimationPlayers().length, 2);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
- assert_equals(document.timeline.getAnimationPlayers()[1], player2);
+ var animation2 = container.animate([], 1000);
+ assert_equals(document.timeline.getAnimations().length, 2);
+ assert_equals(document.timeline.getAnimations()[0], animation);
+ assert_equals(document.timeline.getAnimations()[1], animation2);
- player.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player2);
+ animation.finish();
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation2);
- player2.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
-}, 'Timeline getAnimationPlayers()');
+ animation2.finish();
+ assert_equals(document.timeline.getAnimations().length, 0);
+}, 'Timeline getAnimations()');
test(function() {
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
-
- var player = element.animate([], 1000);
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 1);
- assert_equals(element.getAnimationPlayers()[0], player);
-
- var player2 = container.animate([], 1000);
- assert_equals(document.timeline.getAnimationPlayers().length, 2);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
- assert_equals(document.timeline.getAnimationPlayers()[1], player2);
- assert_equals(container.getAnimationPlayers().length, 1);
- assert_equals(container.getAnimationPlayers()[0], player2);
- assert_equals(element.getAnimationPlayers().length, 1);
- assert_equals(element.getAnimationPlayers()[0], player);
-
- player.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player2);
- assert_equals(container.getAnimationPlayers().length, 1);
- assert_equals(container.getAnimationPlayers()[0], player2);
- assert_equals(element.getAnimationPlayers().length, 0);
-
- player2.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
-
-}, 'Animatable getAnimationPlayers()');
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
+
+ var animation = element.animate([], 1000);
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 1);
+ assert_equals(element.getAnimations()[0], animation);
+
+ var animation2 = container.animate([], 1000);
+ assert_equals(document.timeline.getAnimations().length, 2);
+ assert_equals(document.timeline.getAnimations()[0], animation);
+ assert_equals(document.timeline.getAnimations()[1], animation2);
+ assert_equals(container.getAnimations().length, 1);
+ assert_equals(container.getAnimations()[0], animation2);
+ assert_equals(element.getAnimations().length, 1);
+ assert_equals(element.getAnimations()[0], animation);
+
+ animation.finish();
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation2);
+ assert_equals(container.getAnimations().length, 1);
+ assert_equals(container.getAnimations()[0], animation2);
+ assert_equals(element.getAnimations().length, 0);
+
+ animation2.finish();
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
+
+}, 'Animatable getAnimations()');
test(function() {
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
- var player = element.animate([], {duration: 1000, delay: 500});
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 1);
- assert_equals(element.getAnimationPlayers()[0], player);
+ var animation = element.animate([], {duration: 1000, delay: 500});
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 1);
+ assert_equals(element.getAnimations()[0], animation);
- player.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
+ animation.finish();
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
-}, 'getAnimationPlayers() with delays');
+}, 'getAnimations() with delays');
test(function() {
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
-
- var player = element.animate([], {duration: 1000, delay: 500, fill: 'both'});
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- assert_equals(document.timeline.getAnimationPlayers()[0], player);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 1);
- assert_equals(element.getAnimationPlayers()[0], player);
-
- player.finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 1);
- // assert_equals(container.getAnimationPlayers().length, 1);
- // assert_equals(element.getAnimationPlayers().length, 1);
-
-}, 'getAnimationPlayers() - in effect animations');
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
+
+ var animation = element.animate([], {duration: 1000, delay: 500, fill: 'both'});
+ assert_equals(document.timeline.getAnimations().length, 1);
+ assert_equals(document.timeline.getAnimations()[0], animation);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 1);
+ assert_equals(element.getAnimations()[0], animation);
+
+ animation.finish();
+ assert_equals(document.timeline.getAnimations().length, 1);
+ // assert_equals(container.getAnimations().length, 1);
+ // assert_equals(element.getAnimations().length, 1);
+
+}, 'getAnimations() - in effect animations');
</script>
diff --git a/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-css-players.html b/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-css-players.html
index d4828bb..9340fc5 100644
--- a/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-css-players.html
+++ b/third_party/WebKit/LayoutTests/web-animations-api/w3c/get-css-players.html
@@ -15,25 +15,25 @@
<script>
async_test(function(t) {
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
element.className = 'cssAnimation';
onload = function () {
t.step(function() {
- var players = document.timeline.getAnimationPlayers();
- assert_equals(players.length, 1);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 1);
+ var animations = document.timeline.getAnimations();
+ assert_equals(animations.length, 1);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 1);
- players[0].finish();
- assert_equals(document.timeline.getAnimationPlayers().length, 0);
- assert_equals(container.getAnimationPlayers().length, 0);
- assert_equals(element.getAnimationPlayers().length, 0);
+ animations[0].finish();
+ assert_equals(document.timeline.getAnimations().length, 0);
+ assert_equals(container.getAnimations().length, 0);
+ assert_equals(element.getAnimations().length, 0);
t.done();
});
}
-}, 'getAnimationPlayers() with cssanimations');
+}, 'getAnimations() with cssanimations');
</script>
diff --git a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt
index 06442c7..9291d68 100644
--- a/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/element-instance-property-listing-expected.txt
@@ -57,7 +57,7 @@ namespace http://www.w3.org/1999/xhtml
property firstChild
property firstElementChild
property focus
- property getAnimationPlayers
+ property getAnimations
property getAttribute
property getAttributeNS
property getAttributeNode
@@ -1152,7 +1152,7 @@ namespace http://www.w3.org/2000/svg
property firstChild
property firstElementChild
property focus
- property getAnimationPlayers
+ property getAnimations
property getAttribute
property getAttributeNS
property getAttributeNode
diff --git a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
index d3b884c..5d1a93e 100644
--- a/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/global-interface-listing-expected.txt
@@ -32,16 +32,34 @@ interface AnalyserNode
setter maxDecibels
setter minDecibels
setter smoothingTimeConstant
-interface Animation
+interface AnimationEffectReadOnly
+ getter computedTiming
+ getter timing
+ method constructor
+interface AnimationEffectTiming
+ getter delay
+ getter direction
+ getter duration
+ getter easing
+ getter endDelay
+ getter fill
+ getter iterationStart
+ getter iterations
+ getter playbackRate
method constructor
+ setter delay
+ setter direction
+ setter duration
+ setter easing
+ setter endDelay
+ setter fill
+ setter iterationStart
+ setter iterations
+ setter playbackRate
interface AnimationEvent
getter animationName
getter elapsedTime
method constructor
-interface AnimationNode
- getter computedTiming
- getter timing
- method constructor
interface AnimationPlayerEvent
getter currentTime
getter timelineTime
@@ -50,7 +68,7 @@ interface AnimationTimeline
getter currentTime
getter playbackRate
method constructor
- method getAnimationPlayers
+ method getAnimations
method play
setter currentTime
setter playbackRate
@@ -1297,7 +1315,7 @@ interface Element
method constructor
method createShadowRoot
method focus
- method getAnimationPlayers
+ method getAnimations
method getAttribute
method getAttributeNS
method getAttributeNode
@@ -3097,6 +3115,8 @@ interface KeyboardEvent
method constructor
method getModifierState
method initKeyboardEvent
+interface KeyframeEffect
+ method constructor
interface LocalCredential
getter formData
getter password
@@ -5474,26 +5494,6 @@ interface TimeRanges
method constructor
method end
method start
-interface Timing
- getter delay
- getter direction
- getter duration
- getter easing
- getter endDelay
- getter fill
- getter iterationStart
- getter iterations
- getter playbackRate
- method constructor
- setter delay
- setter direction
- setter duration
- setter easing
- setter endDelay
- setter fill
- setter iterationStart
- setter iterations
- setter playbackRate
interface Touch
getter clientX
getter clientY
diff --git a/third_party/WebKit/LayoutTests/webexposed/web-animations-api-expected.txt b/third_party/WebKit/LayoutTests/webexposed/web-animations-api-expected.txt
index 068b535..04dc68e 100644
--- a/third_party/WebKit/LayoutTests/webexposed/web-animations-api-expected.txt
+++ b/third_party/WebKit/LayoutTests/webexposed/web-animations-api-expected.txt
@@ -1,16 +1,16 @@
This is a testharness.js-based test.
PASS Element.animate() should be exposed.
-FAIL Element.getAnimationPlayers() should not be exposed without experimental web platform features enabled.
-This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
-FAIL Animation constructor should not be exposed without experimental web platform features enabled.
+FAIL Element.getAnimations() should not be exposed without experimental web platform features enabled.
This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
+PASS Animation constructor should not be exposed without experimental web platform features enabled.
+This test is expected to fail in LayoutTests/webexposed.
FAIL Timeline should not be exposed without experimental web platform features enabled.
This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
FAIL document.timeline should not be exposed without experimental web platform features enabled.
This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
-FAIL Timing should not be exposed without experimental web platform features enabled.
-This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
-FAIL AnimationNode should not be exposed without experimental web platform features enabled.
-This test is expected to fail in LayoutTests/webexposed. assert_false: expected false got true
+PASS Timing should not be exposed without experimental web platform features enabled.
+This test is expected to fail in LayoutTests/webexposed.
+PASS AnimationNode should not be exposed without experimental web platform features enabled.
+This test is expected to fail in LayoutTests/webexposed.
Harness: the test ran to completion.
diff --git a/third_party/WebKit/LayoutTests/webexposed/web-animations-api.html b/third_party/WebKit/LayoutTests/webexposed/web-animations-api.html
index 516b920..403e292 100644
--- a/third_party/WebKit/LayoutTests/webexposed/web-animations-api.html
+++ b/third_party/WebKit/LayoutTests/webexposed/web-animations-api.html
@@ -7,8 +7,8 @@ test(function() {
}, 'Element.animate() should be exposed.');
test(function() {
- assert_false('getAnimationPlayers' in Element.prototype);
-}, 'Element.getAnimationPlayers() should not be exposed without experimental web platform features enabled.\nThis test is expected to fail in LayoutTests/webexposed.')
+ assert_false('getAnimations' in Element.prototype);
+}, 'Element.getAnimations() should not be exposed without experimental web platform features enabled.\nThis test is expected to fail in LayoutTests/webexposed.')
test(function() {
assert_false('Animation' in window);
diff --git a/third_party/WebKit/Source/core/animation/Animation.cpp b/third_party/WebKit/Source/core/animation/Animation.cpp
index 1d829a2..aa1ddae 100644
--- a/third_party/WebKit/Source/core/animation/Animation.cpp
+++ b/third_party/WebKit/Source/core/animation/Animation.cpp
@@ -31,311 +31,1002 @@
#include "config.h"
#include "core/animation/Animation.h"
-#include "bindings/core/v8/Dictionary.h"
-#include "bindings/core/v8/ExceptionState.h"
-#include "core/animation/AnimationPlayer.h"
#include "core/animation/AnimationTimeline.h"
-#include "core/animation/AnimationTimingProperties.h"
-#include "core/animation/CompositorAnimations.h"
-#include "core/animation/ElementAnimations.h"
-#include "core/animation/Interpolation.h"
-#include "core/animation/KeyframeEffectModel.h"
-#include "core/animation/PropertyHandle.h"
-#include "core/dom/Element.h"
-#include "core/dom/NodeComputedStyle.h"
+#include "core/animation/KeyframeEffect.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/events/AnimationPlayerEvent.h"
#include "core/frame/UseCounter.h"
-#include "core/paint/DeprecatedPaintLayer.h"
-#include "core/svg/SVGElement.h"
+#include "core/inspector/InspectorInstrumentation.h"
+#include "core/inspector/InspectorTraceEvents.h"
+#include "platform/RuntimeEnabledFeatures.h"
+#include "platform/TraceEvent.h"
+#include "public/platform/Platform.h"
+#include "public/platform/WebCompositorAnimationPlayer.h"
+#include "public/platform/WebCompositorSupport.h"
+#include "wtf/MathExtras.h"
namespace blink {
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
+namespace {
+
+static unsigned nextSequenceNumber()
{
- return adoptRefWillBeNoop(new Animation(target, effect, timing, priority, eventDelegate));
+ static unsigned next = 0;
+ return ++next;
}
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState)
-{
- ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
- if (element)
- UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming);
- return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), TimingInput::convert(duration));
}
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, const AnimationTimingProperties& timingInput, ExceptionState& exceptionState)
+
+PassRefPtrWillBeRawPtr<Animation> Animation::create(AnimationEffect* source, AnimationTimeline* timeline)
{
- ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
- if (element)
- UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming);
- return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), TimingInput::convert(timingInput));
+ if (!timeline) {
+ // FIXME: Support creating animations without a timeline.
+ return nullptr;
+ }
+
+ RefPtrWillBeRawPtr<Animation> animation = adoptRefWillBeNoop(new Animation(timeline->document()->contextDocument().get(), *timeline, source));
+ animation->suspendIfNeeded();
+
+ if (timeline) {
+ timeline->animationAttached(*animation);
+ animation->attachCompositorTimeline();
+ }
+
+ return animation.release();
}
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState)
+
+Animation::Animation(ExecutionContext* executionContext, AnimationTimeline& timeline, AnimationEffect* content)
+ : ActiveDOMObject(executionContext)
+ , m_playState(Idle)
+ , m_playbackRate(1)
+ , m_startTime(nullValue())
+ , m_holdTime(0)
+ , m_sequenceNumber(nextSequenceNumber())
+ , m_content(content)
+ , m_timeline(&timeline)
+ , m_paused(false)
+ , m_held(true)
+ , m_isPausedForTesting(false)
+ , m_outdated(false)
+ , m_finished(true)
+ , m_compositorState(nullptr)
+ , m_compositorPending(false)
+ , m_compositorGroup(0)
+ , m_currentTimePending(false)
+ , m_stateIsBeingUpdated(false)
{
- ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
- if (element)
- UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectNoTiming);
- return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), Timing());
+ if (m_content) {
+ if (m_content->animation()) {
+ m_content->animation()->cancel();
+ m_content->animation()->setSource(0);
+ }
+ m_content->attach(this);
+ }
}
-Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
- : AnimationNode(timing, eventDelegate)
- , m_target(target)
- , m_effect(effect)
- , m_sampledEffect(nullptr)
- , m_priority(priority)
+Animation::~Animation()
{
#if !ENABLE(OILPAN)
- if (m_target)
- m_target->ensureElementAnimations().addAnimation(this);
+ if (m_content)
+ m_content->detach();
+ if (m_timeline)
+ m_timeline->animationDestroyed(this);
#endif
+
+ destroyCompositorPlayer();
}
-Animation::~Animation()
-{
#if !ENABLE(OILPAN)
- if (m_target)
- m_target->elementAnimations()->notifyAnimationDestroyed(this);
+void Animation::detachFromTimeline()
+{
+ dispose();
+ m_timeline = nullptr;
+}
#endif
+
+double Animation::sourceEnd() const
+{
+ return m_content ? m_content->endTimeInternal() : 0;
}
-void Animation::attach(AnimationPlayer* player)
+bool Animation::limited(double currentTime) const
{
- if (m_target) {
- m_target->ensureElementAnimations().players().add(player);
- m_target->setNeedsAnimationStyleRecalc();
- }
- AnimationNode::attach(player);
+ return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && currentTime >= sourceEnd());
}
-void Animation::detach()
+void Animation::setCurrentTime(double newCurrentTime)
{
- if (m_target)
- m_target->elementAnimations()->players().remove(player());
- if (m_sampledEffect)
- clearEffects();
- AnimationNode::detach();
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ m_currentTimePending = false;
+ setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand);
+
+ if (calculatePlayState() == Finished)
+ m_startTime = calculateStartTime(newCurrentTime);
}
-void Animation::specifiedTimingChanged()
+void Animation::setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason reason)
{
- if (player()) {
- // FIXME: Needs to consider groups when added.
- ASSERT(player()->source() == this);
- player()->setCompositorPending(true);
+ ASSERT(std::isfinite(newCurrentTime));
+
+ bool oldHeld = m_held;
+ bool outdated = false;
+ bool isLimited = limited(newCurrentTime);
+ m_held = m_paused || !m_playbackRate || isLimited || std::isnan(m_startTime);
+ if (m_held) {
+ if (!oldHeld || m_holdTime != newCurrentTime)
+ outdated = true;
+ m_holdTime = newCurrentTime;
+ if (m_paused || !m_playbackRate) {
+ m_startTime = nullValue();
+ } else if (isLimited && std::isnan(m_startTime) && reason == TimingUpdateForAnimationFrame) {
+ m_startTime = calculateStartTime(newCurrentTime);
+ }
+ } else {
+ m_holdTime = nullValue();
+ m_startTime = calculateStartTime(newCurrentTime);
+ m_finished = false;
+ outdated = true;
}
+
+ if (outdated) {
+ setOutdated();
+ }
+}
+
+// Update timing to reflect updated animation clock due to tick
+void Animation::updateCurrentTimingState(TimingUpdateReason reason)
+{
+ if (m_held) {
+ double newCurrentTime = m_holdTime;
+ if (playStateInternal() == Finished && !isNull(m_startTime) && m_timeline) {
+ // Add hystersis due to floating point error accumulation
+ if (!limited(calculateCurrentTime() + 0.001 * m_playbackRate)) {
+ // The current time became unlimited, eg. due to a backwards
+ // seek of the timeline.
+ newCurrentTime = calculateCurrentTime();
+ } else if (!limited(m_holdTime)) {
+ // The hold time became unlimited, eg. due to the source content
+ // becoming longer.
+ newCurrentTime = clampTo<double>(calculateCurrentTime(), 0, sourceEnd());
+ }
+ }
+ setCurrentTimeInternal(newCurrentTime, reason);
+ } else if (limited(calculateCurrentTime())) {
+ m_held = true;
+ m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd();
+ }
+}
+
+double Animation::startTime(bool& isNull) const
+{
+ double result = startTime();
+ isNull = std::isnan(result);
+ return result;
+}
+
+double Animation::startTime() const
+{
+ return m_startTime * 1000;
}
-static AnimationStack& ensureAnimationStack(Element* element)
+double Animation::currentTime(bool& isNull)
{
- return element->ensureElementAnimations().defaultStack();
+ double result = currentTime();
+ isNull = std::isnan(result);
+ return result;
}
-void Animation::applyEffects()
+double Animation::currentTime()
{
- ASSERT(isInEffect());
- ASSERT(player());
- if (!m_target || !m_effect)
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ if (m_currentTimePending || playStateInternal() == Idle)
+ return std::numeric_limits<double>::quiet_NaN();
+
+ return currentTimeInternal() * 1000;
+}
+
+double Animation::currentTimeInternal() const
+{
+ double result = m_held ? m_holdTime : calculateCurrentTime();
+#if ENABLE(ASSERT)
+ const_cast<Animation*>(this)->updateCurrentTimingState(TimingUpdateOnDemand);
+ ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime()));
+#endif
+ return result;
+}
+
+double Animation::unlimitedCurrentTimeInternal() const
+{
+#if ENABLE(ASSERT)
+ currentTimeInternal();
+#endif
+ return playStateInternal() == Paused || isNull(m_startTime)
+ ? currentTimeInternal()
+ : calculateCurrentTime();
+}
+
+void Animation::preCommit(int compositorGroup, bool startOnCompositor)
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
+
+ bool softChange = m_compositorState && (paused() || m_compositorState->playbackRate != m_playbackRate);
+ bool hardChange = m_compositorState && (m_compositorState->sourceChanged || m_compositorState->startTime != m_startTime);
+
+ // FIXME: softChange && !hardChange should generate a Pause/ThenStart,
+ // not a Cancel, but we can't communicate these to the compositor yet.
+
+ bool changed = softChange || hardChange;
+ bool shouldCancel = (!playing() && m_compositorState) || changed;
+ bool shouldStart = playing() && (!m_compositorState || changed);
+
+ if (shouldCancel) {
+ cancelAnimationOnCompositor();
+ m_compositorState = nullptr;
+ }
+
+ if (m_compositorState && m_compositorState->pendingAction == Start) {
+ // Still waiting for a start time.
return;
+ }
- // Cancel composited animation of transform if a motion path has been introduced on the element.
- if (m_target->computedStyle()
- && m_target->computedStyle()->hasMotionPath()
- && player()->hasActiveAnimationsOnCompositor()
- && player()->affects(*m_target, CSSPropertyTransform)) {
- player()->cancelAnimationOnCompositor();
- }
-
- double iteration = currentIteration();
- ASSERT(iteration >= 0);
- OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullptr;
- // FIXME: Handle iteration values which overflow int.
- m_effect->sample(static_cast<int>(iteration), timeFraction(), iterationDuration(), interpolations);
- if (m_sampledEffect) {
- m_sampledEffect->setInterpolations(interpolations.release());
- } else if (interpolations && !interpolations->isEmpty()) {
- OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interpolations.release());
- m_sampledEffect = sampledEffect.get();
- ensureAnimationStack(m_target).add(sampledEffect.release());
- } else {
+ ASSERT(!m_compositorState || !std::isnan(m_compositorState->startTime));
+
+ if (!shouldStart) {
+ m_currentTimePending = false;
+ }
+
+ if (shouldStart) {
+ m_compositorGroup = compositorGroup;
+ if (startOnCompositor) {
+ if (isCandidateForAnimationOnCompositor())
+ createCompositorPlayer();
+
+ if (maybeStartAnimationOnCompositor())
+ m_compositorState = adoptPtr(new CompositorState(*this));
+ else
+ cancelIncompatibleAnimationsOnCompositor();
+ }
+ }
+}
+
+void Animation::postCommit(double timelineTime)
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
+
+ m_compositorPending = false;
+
+ if (!m_compositorState || m_compositorState->pendingAction == None)
return;
+
+ switch (m_compositorState->pendingAction) {
+ case Start:
+ if (!std::isnan(m_compositorState->startTime)) {
+ ASSERT(m_startTime == m_compositorState->startTime);
+ m_compositorState->pendingAction = None;
+ }
+ break;
+ case Pause:
+ case PauseThenStart:
+ ASSERT(std::isnan(m_startTime));
+ m_compositorState->pendingAction = None;
+ setCurrentTimeInternal((timelineTime - m_compositorState->startTime) * m_playbackRate, TimingUpdateForAnimationFrame);
+ m_currentTimePending = false;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+}
+
+void Animation::notifyCompositorStartTime(double timelineTime)
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
+
+ if (m_compositorState) {
+ ASSERT(m_compositorState->pendingAction == Start);
+ ASSERT(std::isnan(m_compositorState->startTime));
+
+ double initialCompositorHoldTime = m_compositorState->holdTime;
+ m_compositorState->pendingAction = None;
+ m_compositorState->startTime = timelineTime + currentTimeInternal() / -m_playbackRate;
+
+ if (m_startTime == timelineTime) {
+ // The start time was set to the incoming compositor start time.
+ // Unlikely, but possible.
+ // FIXME: Depending on what changed above this might still be pending.
+ // Maybe...
+ m_currentTimePending = false;
+ return;
+ }
+
+ if (!std::isnan(m_startTime) || currentTimeInternal() != initialCompositorHoldTime) {
+ // A new start time or current time was set while starting.
+ setCompositorPending(true);
+ return;
+ }
}
- m_target->setNeedsAnimationStyleRecalc();
- if (m_target->isSVGElement())
- m_sampledEffect->applySVGUpdate(toSVGElement(*m_target));
+ notifyStartTime(timelineTime);
+}
+
+void Animation::notifyStartTime(double timelineTime)
+{
+ if (playing()) {
+ ASSERT(std::isnan(m_startTime));
+ ASSERT(m_held);
+
+ if (m_playbackRate == 0) {
+ setStartTimeInternal(timelineTime);
+ } else {
+ setStartTimeInternal(timelineTime + currentTimeInternal() / -m_playbackRate);
+ }
+
+ // FIXME: This avoids marking this animation as outdated needlessly when a start time
+ // is notified, but we should refactor how outdating works to avoid this.
+ m_outdated = false;
+
+ m_currentTimePending = false;
+ }
}
-void Animation::clearEffects()
+bool Animation::affects(const Element& element, CSSPropertyID property) const
{
- ASSERT(player());
- ASSERT(m_sampledEffect);
+ if (!m_content || !m_content->isAnimation())
+ return false;
- m_sampledEffect->clear();
- m_sampledEffect = nullptr;
- restartAnimationOnCompositor();
- m_target->setNeedsAnimationStyleRecalc();
- invalidate();
+ const KeyframeEffect* effect = toKeyframeEffect(m_content.get());
+ return (effect->target() == &element) && effect->affects(PropertyHandle(property));
}
-void Animation::updateChildrenAndEffects() const
+double Animation::calculateStartTime(double currentTime) const
{
- if (!m_effect)
+ return m_timeline->effectiveTime() - currentTime / m_playbackRate;
+}
+
+double Animation::calculateCurrentTime() const
+{
+ if (isNull(m_startTime) || !m_timeline)
+ return 0;
+ return (m_timeline->effectiveTime() - m_startTime) * m_playbackRate;
+}
+
+void Animation::setStartTime(double startTime)
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ if (m_paused || playStateInternal() == Idle)
+ return;
+ if (startTime == m_startTime)
return;
- if (isInEffect())
- const_cast<Animation*>(this)->applyEffects();
- else if (m_sampledEffect)
- const_cast<Animation*>(this)->clearEffects();
+
+ m_currentTimePending = false;
+ setStartTimeInternal(startTime / 1000);
}
-double Animation::calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const
+void Animation::setStartTimeInternal(double newStartTime)
{
- const double start = startTimeInternal() + specifiedTiming().startDelay;
- const double end = start + activeDurationInternal();
+ ASSERT(!m_paused);
+ ASSERT(std::isfinite(newStartTime));
+ ASSERT(newStartTime != m_startTime);
- switch (phase()) {
- case PhaseNone:
- return std::numeric_limits<double>::infinity();
- case PhaseBefore:
- ASSERT(start >= localTime);
- return forwards
- ? start - localTime
- : std::numeric_limits<double>::infinity();
- case PhaseActive:
- if (forwards) {
- // Need service to apply fill / fire events.
- const double timeToEnd = end - localTime;
- if (requiresIterationEvents()) {
- return std::min(timeToEnd, timeToNextIteration);
- }
- return timeToEnd;
+ bool hadStartTime = hasStartTime();
+ double previousCurrentTime = currentTimeInternal();
+ m_startTime = newStartTime;
+ if (m_held && m_playbackRate) {
+ // If held, the start time would still be derrived from the hold time.
+ // Force a new, limited, current time.
+ m_held = false;
+ double currentTime = calculateCurrentTime();
+ if (m_playbackRate > 0 && currentTime > sourceEnd()) {
+ currentTime = sourceEnd();
+ } else if (m_playbackRate < 0 && currentTime < 0) {
+ currentTime = 0;
}
- return 0;
- case PhaseAfter:
- ASSERT(localTime >= end);
- // If this Animation is still in effect then it will need to update
- // when its parent goes out of effect. We have no way of knowing when
- // that will be, however, so the parent will need to supply it.
- return forwards
- ? std::numeric_limits<double>::infinity()
- : localTime - end;
+ setCurrentTimeInternal(currentTime, TimingUpdateOnDemand);
+ }
+ updateCurrentTimingState(TimingUpdateOnDemand);
+ double newCurrentTime = currentTimeInternal();
+
+ if (previousCurrentTime != newCurrentTime) {
+ setOutdated();
+ } else if (!hadStartTime && m_timeline) {
+ // Even though this animation is not outdated, time to effect change is
+ // infinity until start time is set.
+ m_timeline->wake();
+ }
+}
+
+void Animation::setSource(AnimationEffect* newSource)
+{
+ if (m_content == newSource)
+ return;
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, SetCompositorPendingWithSourceChanged);
+
+ double storedCurrentTime = currentTimeInternal();
+ if (m_content)
+ m_content->detach();
+ m_content = newSource;
+ if (newSource) {
+ // FIXME: This logic needs to be updated once groups are implemented
+ if (newSource->animation()) {
+ newSource->animation()->cancel();
+ newSource->animation()->setSource(0);
+ }
+ newSource->attach(this);
+ setOutdated();
+ }
+ setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand);
+}
+
+const char* Animation::playStateString(AnimationPlayState playState)
+{
+ switch (playState) {
+ case Idle:
+ return "idle";
+ case Pending:
+ return "pending";
+ case Running:
+ return "running";
+ case Paused:
+ return "paused";
+ case Finished:
+ return "finished";
default:
ASSERT_NOT_REACHED();
- return std::numeric_limits<double>::infinity();
+ return "";
}
}
-#if !ENABLE(OILPAN)
-void Animation::notifyElementDestroyed()
-{
- // If our player is kept alive just by the sampledEffect, we might get our
- // destructor called when we call SampledEffect::clear(), so we need to
- // clear m_sampledEffect first.
- m_target = nullptr;
- clearEventDelegate();
- SampledEffect* sampledEffect = m_sampledEffect;
- m_sampledEffect = nullptr;
- if (sampledEffect)
- sampledEffect->clear();
+Animation::AnimationPlayState Animation::playStateInternal() const
+{
+ return m_playState;
}
-#endif
-bool Animation::isCandidateForAnimationOnCompositor(double playerPlaybackRate) const
+Animation::AnimationPlayState Animation::calculatePlayState()
{
- if (!effect()
- || !m_target
- || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPath()))
- return false;
+ if (m_playState == Idle)
+ return Idle;
+ if (m_currentTimePending || (isNull(m_startTime) && !m_paused && m_playbackRate != 0))
+ return Pending;
+ if (m_paused)
+ return Paused;
+ if (limited())
+ return Finished;
+ return Running;
+}
+
+void Animation::pause()
+{
+ if (m_paused)
+ return;
+
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
- return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(specifiedTiming(), *m_target, player(), *effect(), playerPlaybackRate);
+ if (playing()) {
+ m_currentTimePending = true;
+ }
+ m_paused = true;
+ setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
}
-bool Animation::maybeStartAnimationOnCompositor(int group, double startTime, double currentTime, double playerPlaybackRate)
+void Animation::unpause()
{
- ASSERT(!hasActiveAnimationsOnCompositor());
- if (!isCandidateForAnimationOnCompositor(playerPlaybackRate))
- return false;
- if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_target))
- return false;
- if (!CompositorAnimations::instance()->startAnimationOnCompositor(*m_target, group, startTime, currentTime, specifiedTiming(), *player(), *effect(), m_compositorAnimationIds, playerPlaybackRate))
- return false;
- ASSERT(!m_compositorAnimationIds.isEmpty());
- return true;
+ if (!m_paused)
+ return;
+
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ m_currentTimePending = true;
+ unpauseInternal();
+}
+
+void Animation::unpauseInternal()
+{
+ if (!m_paused)
+ return;
+ m_paused = false;
+ setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
+}
+
+void Animation::play()
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ if (!playing())
+ m_startTime = nullValue();
+
+ if (playStateInternal() == Idle) {
+ // We may not go into the pending state, but setting it to something other
+ // than Idle here will force an update.
+ ASSERT(isNull(m_startTime));
+ m_playState = Pending;
+ m_held = true;
+ m_holdTime = 0;
+ }
+
+ m_finished = false;
+ unpauseInternal();
+ if (!m_content)
+ return;
+ double currentTime = this->currentTimeInternal();
+ if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= sourceEnd())) {
+ m_startTime = nullValue();
+ setCurrentTimeInternal(0, TimingUpdateOnDemand);
+ } else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > sourceEnd())) {
+ m_startTime = nullValue();
+ setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
+ }
+}
+
+void Animation::reverse()
+{
+ if (!m_playbackRate) {
+ return;
+ }
+
+ setPlaybackRateInternal(-m_playbackRate);
+ play();
}
-bool Animation::hasActiveAnimationsOnCompositor() const
+void Animation::finish(ExceptionState& exceptionState)
{
- return !m_compositorAnimationIds.isEmpty();
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ if (!m_playbackRate || playStateInternal() == Idle) {
+ return;
+ }
+ if (m_playbackRate > 0 && sourceEnd() == std::numeric_limits<double>::infinity()) {
+ exceptionState.throwDOMException(InvalidStateError, "Animation has source content whose end time is infinity.");
+ return;
+ }
+
+ double newCurrentTime = m_playbackRate < 0 ? 0 : sourceEnd();
+ setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand);
+ if (!paused()) {
+ m_startTime = calculateStartTime(newCurrentTime);
+ }
+
+ m_currentTimePending = false;
+ ASSERT(playStateInternal() != Idle);
+ ASSERT(limited());
+}
+
+ScriptPromise Animation::finished(ScriptState* scriptState)
+{
+ if (!m_finishedPromise) {
+ m_finishedPromise = new AnimationPromise(scriptState->executionContext(), this, AnimationPromise::Finished);
+ if (playStateInternal() == Finished)
+ m_finishedPromise->resolve(this);
+ }
+ return m_finishedPromise->promise(scriptState->world());
+}
+
+ScriptPromise Animation::ready(ScriptState* scriptState)
+{
+ if (!m_readyPromise) {
+ m_readyPromise = new AnimationPromise(scriptState->executionContext(), this, AnimationPromise::Ready);
+ if (playStateInternal() != Pending)
+ m_readyPromise->resolve(this);
+ }
+ return m_readyPromise->promise(scriptState->world());
+}
+
+const AtomicString& Animation::interfaceName() const
+{
+ return EventTargetNames::AnimationPlayer;
+}
+
+ExecutionContext* Animation::executionContext() const
+{
+ return ActiveDOMObject::executionContext();
+}
+
+bool Animation::hasPendingActivity() const
+{
+ return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventTypeNames::finish));
+}
+
+void Animation::stop()
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ m_finished = true;
+ m_pendingFinishedEvent = nullptr;
+}
+
+bool Animation::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
+{
+ if (m_pendingFinishedEvent == event)
+ m_pendingFinishedEvent = nullptr;
+ return EventTargetWithInlineData::dispatchEvent(event);
+}
+
+double Animation::playbackRate() const
+{
+ return m_playbackRate;
+}
+
+void Animation::setPlaybackRate(double playbackRate)
+{
+ if (playbackRate == m_playbackRate)
+ return;
+
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ setPlaybackRateInternal(playbackRate);
+}
+
+void Animation::setPlaybackRateInternal(double playbackRate)
+{
+ ASSERT(std::isfinite(playbackRate));
+ ASSERT(playbackRate != m_playbackRate);
+
+ if (!limited() && !paused() && hasStartTime())
+ m_currentTimePending = true;
+
+ double storedCurrentTime = currentTimeInternal();
+ if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && playbackRate <= 0))
+ m_finished = false;
+
+ m_playbackRate = playbackRate;
+ m_startTime = std::numeric_limits<double>::quiet_NaN();
+ setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand);
}
-bool Animation::hasActiveAnimationsOnCompositor(CSSPropertyID property) const
+void Animation::setOutdated()
{
- return hasActiveAnimationsOnCompositor() && affects(PropertyHandle(property));
+ m_outdated = true;
+ if (m_timeline)
+ m_timeline->setOutdatedAnimation(this);
}
-bool Animation::affects(PropertyHandle property) const
+bool Animation::canStartAnimationOnCompositor() const
{
- return m_effect && m_effect->affects(property);
+ // FIXME: Timeline playback rates should be compositable
+ if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0) || (timeline() && timeline()->playbackRate() != 1))
+ return false;
+
+ return m_timeline && m_content && m_content->isAnimation() && playing();
}
-bool Animation::cancelAnimationOnCompositor()
+bool Animation::isCandidateForAnimationOnCompositor() const
{
- // FIXME: cancelAnimationOnCompositor is called from withins style recalc.
- // This queries compositingState, which is not necessarily up to date.
- // https://code.google.com/p/chromium/issues/detail?id=339847
- DisableCompositingQueryAsserts disabler;
- if (!hasActiveAnimationsOnCompositor())
+ if (!canStartAnimationOnCompositor())
return false;
- if (!m_target || !m_target->layoutObject())
+
+ return toKeyframeEffect(m_content.get())->isCandidateForAnimationOnCompositor(m_playbackRate);
+}
+
+bool Animation::maybeStartAnimationOnCompositor()
+{
+ if (!canStartAnimationOnCompositor())
return false;
- ASSERT(player());
- for (const auto& compositorAnimationId : m_compositorAnimationIds)
- CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target, *player(), compositorAnimationId);
- m_compositorAnimationIds.clear();
- return true;
+
+ bool reversed = m_playbackRate < 0;
+
+ double startTime = timeline()->zeroTime() + startTimeInternal();
+ if (reversed) {
+ startTime -= sourceEnd() / fabs(m_playbackRate);
+ }
+
+ double timeOffset = 0;
+ if (std::isnan(startTime)) {
+ timeOffset = reversed ? sourceEnd() - currentTimeInternal() : currentTimeInternal();
+ timeOffset = timeOffset / fabs(m_playbackRate);
+ }
+ ASSERT(m_compositorGroup != 0);
+ return toKeyframeEffect(m_content.get())->maybeStartAnimationOnCompositor(m_compositorGroup, startTime, timeOffset, m_playbackRate);
+}
+
+void Animation::setCompositorPending(bool sourceChanged)
+{
+ // FIXME: KeyframeEffect could notify this directly?
+ if (!hasActiveAnimationsOnCompositor()) {
+ destroyCompositorPlayer();
+ m_compositorState.release();
+ }
+ if (sourceChanged && m_compositorState) {
+ m_compositorState->sourceChanged = true;
+ }
+ if (m_compositorPending || m_isPausedForTesting) {
+ return;
+ }
+
+ if (sourceChanged || !m_compositorState
+ || !playing() || m_compositorState->playbackRate != m_playbackRate
+ || m_compositorState->startTime != m_startTime) {
+ m_compositorPending = true;
+ ASSERT(timeline());
+ ASSERT(timeline()->document());
+ timeline()->document()->compositorPendingAnimations().add(this);
+ }
+}
+
+void Animation::cancelAnimationOnCompositor()
+{
+ if (hasActiveAnimationsOnCompositor())
+ toKeyframeEffect(m_content.get())->cancelAnimationOnCompositor();
+
+ destroyCompositorPlayer();
}
void Animation::restartAnimationOnCompositor()
{
- if (cancelAnimationOnCompositor())
- player()->setCompositorPending(true);
+ if (hasActiveAnimationsOnCompositor())
+ toKeyframeEffect(m_content.get())->restartAnimationOnCompositor();
}
void Animation::cancelIncompatibleAnimationsOnCompositor()
{
- if (m_target && player() && effect())
- CompositorAnimations::instance()->cancelIncompatibleAnimationsOnCompositor(*m_target, *player(), *effect());
+ if (m_content && m_content->isAnimation())
+ toKeyframeEffect(m_content.get())->cancelIncompatibleAnimationsOnCompositor();
}
-void Animation::pauseAnimationForTestingOnCompositor(double pauseTime)
+bool Animation::hasActiveAnimationsOnCompositor()
{
- ASSERT(hasActiveAnimationsOnCompositor());
- if (!m_target || !m_target->layoutObject())
- return;
- ASSERT(player());
- for (const auto& compositorAnimationId : m_compositorAnimationIds)
- CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*m_target, *player(), compositorAnimationId, pauseTime);
+ if (!m_content || !m_content->isAnimation())
+ return false;
+
+ return toKeyframeEffect(m_content.get())->hasActiveAnimationsOnCompositor();
}
-bool Animation::canAttachCompositedLayers() const
+bool Animation::update(TimingUpdateReason reason)
{
- if (!m_target || !player())
+ if (!m_timeline)
return false;
- return CompositorAnimations::instance()->canAttachCompositedLayers(*m_target, *player());
+ PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);
+
+ m_outdated = false;
+ bool idle = playStateInternal() == Idle;
+
+ if (m_content) {
+ double inheritedTime = idle || isNull(m_timeline->currentTimeInternal()) ? nullValue() : currentTimeInternal();
+ // Special case for end-exclusivity when playing backwards.
+ if (inheritedTime == 0 && m_playbackRate < 0)
+ inheritedTime = -1;
+ m_content->updateInheritedTime(inheritedTime, reason);
+ }
+
+ if ((idle || limited()) && !m_finished) {
+ if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime())) {
+ const AtomicString& eventType = EventTypeNames::finish;
+ if (executionContext() && hasEventListeners(eventType)) {
+ double eventCurrentTime = currentTimeInternal() * 1000;
+ m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, eventCurrentTime, timeline()->currentTime());
+ m_pendingFinishedEvent->setTarget(this);
+ m_pendingFinishedEvent->setCurrentTarget(this);
+ m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
+ }
+ m_finished = true;
+ }
+ }
+ ASSERT(!m_outdated);
+ return !m_finished;
+}
+
+double Animation::timeToEffectChange()
+{
+ ASSERT(!m_outdated);
+ if (m_held || !hasStartTime())
+ return std::numeric_limits<double>::infinity();
+ if (!m_content)
+ return -currentTimeInternal() / m_playbackRate;
+ double result = m_playbackRate > 0
+ ? m_content->timeToForwardsEffectChange() / m_playbackRate
+ : m_content->timeToReverseEffectChange() / -m_playbackRate;
+ return !hasActiveAnimationsOnCompositor() && m_content->phase() == AnimationEffect::PhaseActive
+ ? 0
+ : result;
+}
+
+void Animation::cancel()
+{
+ PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
+
+ if (playStateInternal() == Idle)
+ return;
+
+ m_holdTime = currentTimeInternal();
+ m_held = true;
+ // TODO
+ m_playState = Idle;
+ m_startTime = nullValue();
+ m_currentTimePending = false;
+
+ InspectorInstrumentation::didCancelAnimation(timeline()->document(), this);
+}
+
+void Animation::beginUpdatingState()
+{
+ // Nested calls are not allowed!
+ ASSERT(!m_stateIsBeingUpdated);
+ m_stateIsBeingUpdated = true;
+}
+
+void Animation::endUpdatingState()
+{
+ ASSERT(m_stateIsBeingUpdated);
+ m_stateIsBeingUpdated = false;
+}
+
+void Animation::createCompositorPlayer()
+{
+ if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && !m_compositorPlayer && Platform::current()->compositorSupport()) {
+ m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->createAnimationPlayer());
+ ASSERT(m_compositorPlayer);
+ m_compositorPlayer->setAnimationDelegate(this);
+ attachCompositorTimeline();
+ }
+
+ attachCompositedLayers();
+}
+
+void Animation::destroyCompositorPlayer()
+{
+ detachCompositedLayers();
+
+ if (m_compositorPlayer) {
+ detachCompositorTimeline();
+ m_compositorPlayer->setAnimationDelegate(nullptr);
+ }
+ m_compositorPlayer.clear();
+}
+
+void Animation::attachCompositorTimeline()
+{
+ if (m_compositorPlayer) {
+ WebCompositorAnimationTimeline* timeline = m_timeline ? m_timeline->compositorTimeline() : nullptr;
+ if (timeline)
+ timeline->playerAttached(*this);
+ }
+}
+
+void Animation::detachCompositorTimeline()
+{
+ if (m_compositorPlayer) {
+ WebCompositorAnimationTimeline* timeline = m_timeline ? m_timeline->compositorTimeline() : nullptr;
+ if (timeline)
+ timeline->playerDestroyed(*this);
+ }
}
void Animation::attachCompositedLayers()
{
- ASSERT(m_target);
- ASSERT(player());
- CompositorAnimations::instance()->attachCompositedLayers(*m_target, *player());
+ if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() || !m_compositorPlayer)
+ return;
+
+ ASSERT(m_content);
+ ASSERT(m_content->isAnimation());
+
+ if (toKeyframeEffect(m_content.get())->canAttachCompositedLayers())
+ toKeyframeEffect(m_content.get())->attachCompositedLayers();
+}
+
+void Animation::detachCompositedLayers()
+{
+ if (m_compositorPlayer && m_compositorPlayer->isLayerAttached())
+ m_compositorPlayer->detachLayer();
+}
+
+void Animation::notifyAnimationStarted(double monotonicTime, int group)
+{
+ ASSERT(RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled());
+ timeline()->document()->compositorPendingAnimations().notifyCompositorAnimationStarted(monotonicTime, group);
+}
+
+Animation::PlayStateUpdateScope::PlayStateUpdateScope(Animation& animation, TimingUpdateReason reason, CompositorPendingChange compositorPendingChange)
+ : m_animation(animation)
+ , m_initialPlayState(m_animation->playStateInternal())
+ , m_compositorPendingChange(compositorPendingChange)
+{
+ m_animation->beginUpdatingState();
+ m_animation->updateCurrentTimingState(reason);
+}
+
+Animation::PlayStateUpdateScope::~PlayStateUpdateScope()
+{
+ AnimationPlayState oldPlayState = m_initialPlayState;
+ AnimationPlayState newPlayState = m_animation->calculatePlayState();
+
+ m_animation->m_playState = newPlayState;
+ if (oldPlayState != newPlayState) {
+ bool wasActive = oldPlayState == Pending || oldPlayState == Running;
+ bool isActive = newPlayState == Pending || newPlayState == Running;
+ if (!wasActive && isActive)
+ TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "KeyframeEffect", m_animation, "data", InspectorAnimationEvent::data(*m_animation));
+ else if (wasActive && !isActive)
+ TRACE_EVENT_NESTABLE_ASYNC_END1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "KeyframeEffect", m_animation, "endData", InspectorAnimationStateEvent::data(*m_animation));
+ else
+ TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "KeyframeEffect", m_animation, "data", InspectorAnimationStateEvent::data(*m_animation));
+ }
+
+ // Ordering is important, the ready promise should resolve/reject before
+ // the finished promise.
+ if (m_animation->m_readyPromise && newPlayState != oldPlayState) {
+ if (newPlayState == Idle) {
+ if (m_animation->m_readyPromise->state() == AnimationPromise::Pending) {
+ m_animation->m_readyPromise->reject(DOMException::create(AbortError));
+ }
+ m_animation->m_readyPromise->reset();
+ m_animation->m_readyPromise->resolve(m_animation);
+ } else if (oldPlayState == Pending) {
+ m_animation->m_readyPromise->resolve(m_animation);
+ } else if (newPlayState == Pending) {
+ ASSERT(m_animation->m_readyPromise->state() != AnimationPromise::Pending);
+ m_animation->m_readyPromise->reset();
+ }
+ }
+
+ if (m_animation->m_finishedPromise && newPlayState != oldPlayState) {
+ if (newPlayState == Idle) {
+ if (m_animation->m_finishedPromise->state() == AnimationPromise::Pending) {
+ m_animation->m_finishedPromise->reject(DOMException::create(AbortError));
+ }
+ m_animation->m_finishedPromise->reset();
+ } else if (newPlayState == Finished) {
+ m_animation->m_finishedPromise->resolve(m_animation);
+ } else if (oldPlayState == Finished) {
+ m_animation->m_finishedPromise->reset();
+ }
+ }
+
+ if (oldPlayState != newPlayState && (oldPlayState == Idle || newPlayState == Idle)) {
+ m_animation->setOutdated();
+ }
+
+#if ENABLE(ASSERT)
+ // Verify that current time is up to date.
+ m_animation->currentTimeInternal();
+#endif
+
+ switch (m_compositorPendingChange) {
+ case SetCompositorPending:
+ m_animation->setCompositorPending();
+ break;
+ case SetCompositorPendingWithSourceChanged:
+ m_animation->setCompositorPending(true);
+ break;
+ case DoNotSetCompositorPending:
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ m_animation->endUpdatingState();
+
+ if (oldPlayState != newPlayState && newPlayState == Running)
+ InspectorInstrumentation::didCreateAnimation(m_animation->timeline()->document(), m_animation);
+}
+
+bool Animation::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
+{
+ if (eventType == EventTypeNames::finish)
+ UseCounter::count(executionContext(), UseCounter::AnimationFinishEvent);
+ return EventTargetWithInlineData::addEventListener(eventType, listener, useCapture);
+}
+
+void Animation::pauseForTesting(double pauseTime)
+{
+ RELEASE_ASSERT(!paused());
+ setCurrentTimeInternal(pauseTime, TimingUpdateOnDemand);
+ if (hasActiveAnimationsOnCompositor())
+ toKeyframeEffect(m_content.get())->pauseAnimationForTestingOnCompositor(currentTimeInternal());
+ m_isPausedForTesting = true;
+ pause();
}
DEFINE_TRACE(Animation)
{
- visitor->trace(m_target);
- visitor->trace(m_effect);
- visitor->trace(m_sampledEffect);
- AnimationNode::trace(visitor);
+ visitor->trace(m_content);
+ visitor->trace(m_timeline);
+ visitor->trace(m_pendingFinishedEvent);
+ visitor->trace(m_finishedPromise);
+ visitor->trace(m_readyPromise);
+ EventTargetWithInlineData::trace(visitor);
+ ActiveDOMObject::trace(visitor);
}
-} // namespace blink
+} // namespace
diff --git a/third_party/WebKit/Source/core/animation/Animation.h b/third_party/WebKit/Source/core/animation/Animation.h
index 3f89371..9433247 100644
--- a/third_party/WebKit/Source/core/animation/Animation.h
+++ b/third_party/WebKit/Source/core/animation/Animation.h
@@ -31,92 +31,257 @@
#ifndef Animation_h
#define Animation_h
+#include "bindings/core/v8/ScriptPromise.h"
+#include "bindings/core/v8/ScriptPromiseProperty.h"
+#include "core/CSSPropertyNames.h"
#include "core/CoreExport.h"
#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNode.h"
-#include "core/animation/EffectInput.h"
-#include "core/animation/TimingInput.h"
+#include "core/dom/ActiveDOMObject.h"
+#include "core/dom/DOMException.h"
+#include "core/events/EventTarget.h"
#include "platform/heap/Handle.h"
+#include "public/platform/WebCompositorAnimationDelegate.h"
+#include "public/platform/WebCompositorAnimationPlayerClient.h"
#include "wtf/RefPtr.h"
namespace blink {
-class AnimationTimingProperties;
-class Dictionary;
+class AnimationTimeline;
class Element;
class ExceptionState;
-class PropertyHandle;
-class SampledEffect;
+class WebCompositorAnimationPlayer;
-class CORE_EXPORT Animation final : public AnimationNode {
+class CORE_EXPORT Animation final
+ : public EventTargetWithInlineData
+ , public RefCountedWillBeNoBase<Animation>
+ , public ActiveDOMObject
+ , public WebCompositorAnimationDelegate
+ , public WebCompositorAnimationPlayerClient {
DEFINE_WRAPPERTYPEINFO();
+ REFCOUNTED_EVENT_TARGET(Animation);
+ WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(Animation);
public:
- enum Priority { DefaultPriority, TransitionPriority };
+ enum AnimationPlayState {
+ Idle,
+ Pending,
+ Running,
+ Paused,
+ Finished
+ };
- static PassRefPtrWillBeRawPtr<Animation> create(Element*, PassRefPtrWillBeRawPtr<AnimationEffect>, const Timing&, Priority = DefaultPriority, PassOwnPtrWillBeRawPtr<EventDelegate> = nullptr);
- // Web Animations API Bindings constructors.
- static PassRefPtrWillBeRawPtr<Animation> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState&);
- static PassRefPtrWillBeRawPtr<Animation> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, const AnimationTimingProperties& timingInput, ExceptionState&);
- static PassRefPtrWillBeRawPtr<Animation> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState&);
+ ~Animation();
+ static PassRefPtrWillBeRawPtr<Animation> create(AnimationEffect*, AnimationTimeline*);
- virtual ~Animation();
+ // Returns whether the animation is finished.
+ bool update(TimingUpdateReason);
- virtual bool isAnimation() const override { return true; }
+ // timeToEffectChange returns:
+ // infinity - if this animation is no longer in effect
+ // 0 - if this animation requires an update on the next frame
+ // n - if this animation requires an update after 'n' units of time
+ double timeToEffectChange();
- bool affects(PropertyHandle) const;
- const AnimationEffect* effect() const { return m_effect.get(); }
- AnimationEffect* effect() { return m_effect.get(); }
- void setEffect(PassRefPtrWillBeRawPtr<AnimationEffect> effect) { m_effect = effect; }
- Priority priority() const { return m_priority; }
- Element* target() const { return m_target; }
+ void cancel();
+
+ double currentTime(bool& isNull);
+ double currentTime();
+ void setCurrentTime(double newCurrentTime);
+
+ double currentTimeInternal() const;
+ double unlimitedCurrentTimeInternal() const;
+
+ void setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason = TimingUpdateOnDemand);
+ bool paused() const { return m_paused && !m_isPausedForTesting; }
+ static const char* playStateString(AnimationPlayState);
+ String playState() const { return playStateString(playStateInternal()); }
+ AnimationPlayState playStateInternal() const;
+
+ void pause();
+ void play();
+ void reverse();
+ void finish(ExceptionState&);
+
+ ScriptPromise finished(ScriptState*);
+ ScriptPromise ready(ScriptState*);
+
+ bool playing() const { return !(playStateInternal() == Idle || limited() || m_paused || m_isPausedForTesting); }
+ bool limited() const { return limited(currentTimeInternal()); }
+ bool finishedInternal() const { return m_finished; }
+
+ DEFINE_ATTRIBUTE_EVENT_LISTENER(finish);
+
+ virtual const AtomicString& interfaceName() const override;
+ virtual ExecutionContext* executionContext() const override;
+ virtual bool hasPendingActivity() const override;
+ virtual void stop() override;
+ virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override;
+
+ double playbackRate() const;
+ void setPlaybackRate(double);
+ const AnimationTimeline* timeline() const { return m_timeline; }
+ AnimationTimeline* timeline() { return m_timeline; }
#if !ENABLE(OILPAN)
- void notifyElementDestroyed();
+ void detachFromTimeline();
#endif
- bool isCandidateForAnimationOnCompositor(double playerPlaybackRate) const;
- // Must only be called once.
- bool maybeStartAnimationOnCompositor(int group, double startTime, double timeOffset, double playerPlaybackRate);
- bool hasActiveAnimationsOnCompositor() const;
- bool hasActiveAnimationsOnCompositor(CSSPropertyID) const;
- bool cancelAnimationOnCompositor();
+ double calculateStartTime(double currentTime) const;
+ bool hasStartTime() const { return !isNull(m_startTime); }
+ double startTime(bool& isNull) const;
+ double startTime() const;
+ double startTimeInternal() const { return m_startTime; }
+ void setStartTime(double);
+ void setStartTimeInternal(double);
+
+ const AnimationEffect* source() const { return m_content.get(); }
+ AnimationEffect* source() { return m_content.get(); }
+ void setSource(AnimationEffect*);
+
+ // Pausing via this method is not reflected in the value returned by
+ // paused() and must never overlap with pausing via pause().
+ void pauseForTesting(double pauseTime);
+ // This should only be used for CSS
+ void unpause();
+
+ void setOutdated();
+ bool outdated() { return m_outdated; }
+
+ bool canStartAnimationOnCompositor() const;
+ bool isCandidateForAnimationOnCompositor() const;
+ bool maybeStartAnimationOnCompositor();
+ void cancelAnimationOnCompositor();
void restartAnimationOnCompositor();
void cancelIncompatibleAnimationsOnCompositor();
- void pauseAnimationForTestingOnCompositor(double pauseTime);
+ bool hasActiveAnimationsOnCompositor();
+ void setCompositorPending(bool sourceChanged = false);
+ void notifyCompositorStartTime(double timelineTime);
+ void notifyStartTime(double timelineTime);
+ // WebCompositorAnimationPlayerClient implementation.
+ WebCompositorAnimationPlayer* compositorPlayer() const override { return m_compositorPlayer.get(); }
- bool canAttachCompositedLayers() const;
- void attachCompositedLayers();
+ bool affects(const Element&, CSSPropertyID) const;
- void setCompositorAnimationIdsForTesting(const Vector<int>& compositorAnimationIds) { m_compositorAnimationIds = compositorAnimationIds; }
+ void preCommit(int compositorGroup, bool startOnCompositor);
+ void postCommit(double timelineTime);
- DECLARE_VIRTUAL_TRACE();
+ unsigned sequenceNumber() const { return m_sequenceNumber; }
+ int compositorGroup() const { return m_compositorGroup; }
- void downgradeToNormalAnimation() { m_priority = DefaultPriority; }
+ static bool hasLowerPriority(const Animation* animation1, const Animation* animation2)
+ {
+ return animation1->sequenceNumber() < animation2->sequenceNumber();
+ }
-protected:
- void applyEffects();
- void clearEffects();
- virtual void updateChildrenAndEffects() const override;
- virtual void attach(AnimationPlayer*) override;
- virtual void detach() override;
- virtual void specifiedTimingChanged() override;
- virtual double calculateTimeToEffectChange(bool forwards, double inheritedTime, double timeToNextIteration) const override;
+ virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture = false) override;
+
+ DECLARE_VIRTUAL_TRACE();
private:
- Animation(Element*, PassRefPtrWillBeRawPtr<AnimationEffect>, const Timing&, Priority, PassOwnPtrWillBeRawPtr<EventDelegate>);
+ Animation(ExecutionContext*, AnimationTimeline&, AnimationEffect*);
- RawPtrWillBeMember<Element> m_target;
- RefPtrWillBeMember<AnimationEffect> m_effect;
- RawPtrWillBeMember<SampledEffect> m_sampledEffect;
+ double sourceEnd() const;
+ bool limited(double currentTime) const;
- Priority m_priority;
+ AnimationPlayState calculatePlayState();
+ double calculateCurrentTime() const;
- Vector<int> m_compositorAnimationIds;
+ void unpauseInternal();
+ void setPlaybackRateInternal(double);
+ void updateCurrentTimingState(TimingUpdateReason);
- friend class AnimationAnimationV8Test;
-};
+ void beginUpdatingState();
+ void endUpdatingState();
+
+ void createCompositorPlayer();
+ void destroyCompositorPlayer();
+ void attachCompositorTimeline();
+ void detachCompositorTimeline();
+ void attachCompositedLayers();
+ void detachCompositedLayers();
+ // WebCompositorAnimationDelegate implementation.
+ void notifyAnimationStarted(double monotonicTime, int group) override;
+ void notifyAnimationFinished(double monotonicTime, int group) override { }
+
+ AnimationPlayState m_playState;
+ double m_playbackRate;
+ double m_startTime;
+ double m_holdTime;
+
+ unsigned m_sequenceNumber;
+
+ typedef ScriptPromiseProperty<RawPtrWillBeMember<Animation>, RawPtrWillBeMember<Animation>, Member<DOMException>> AnimationPromise;
+ PersistentWillBeMember<AnimationPromise> m_finishedPromise;
+ PersistentWillBeMember<AnimationPromise> m_readyPromise;
+
+ RefPtrWillBeMember<AnimationEffect> m_content;
+ RawPtrWillBeMember<AnimationTimeline> m_timeline;
+ // Reflects all pausing, including via pauseForTesting().
+ bool m_paused;
+ bool m_held;
+ bool m_isPausedForTesting;
+
+ // This indicates timing information relevant to the animation's effect
+ // has changed by means other than the ordinary progression of time
+ bool m_outdated;
-DEFINE_TYPE_CASTS(Animation, AnimationNode, animationNode, animationNode->isAnimation(), animationNode.isAnimation());
+ bool m_finished;
+ // Holds a 'finished' event queued for asynchronous dispatch via the
+ // ScriptedAnimationController. This object remains active until the
+ // event is actually dispatched.
+ RefPtrWillBeMember<Event> m_pendingFinishedEvent;
+
+ enum CompositorAction {
+ None,
+ Pause,
+ Start,
+ PauseThenStart
+ };
+
+ class CompositorState {
+ public:
+ CompositorState(Animation& animation)
+ : startTime(animation.m_startTime)
+ , holdTime(animation.m_holdTime)
+ , playbackRate(animation.m_playbackRate)
+ , sourceChanged(false)
+ , pendingAction(Start)
+ { }
+ double startTime;
+ double holdTime;
+ double playbackRate;
+ bool sourceChanged;
+ CompositorAction pendingAction;
+ };
+
+ enum CompositorPendingChange {
+ SetCompositorPending,
+ SetCompositorPendingWithSourceChanged,
+ DoNotSetCompositorPending,
+ };
+
+ class PlayStateUpdateScope {
+ STACK_ALLOCATED();
+ public:
+ PlayStateUpdateScope(Animation&, TimingUpdateReason, CompositorPendingChange = SetCompositorPending);
+ ~PlayStateUpdateScope();
+ private:
+ RawPtrWillBeMember<Animation> m_animation;
+ AnimationPlayState m_initialPlayState;
+ CompositorPendingChange m_compositorPendingChange;
+ };
+
+ // This mirrors the known compositor state. It is created when a compositor
+ // animation is started. Updated once the start time is known and each time
+ // modifications are pushed to the compositor.
+ OwnPtr<CompositorState> m_compositorState;
+ bool m_compositorPending;
+ int m_compositorGroup;
+
+ OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer;
+
+ bool m_currentTimePending;
+ bool m_stateIsBeingUpdated;
+};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/Animation.idl b/third_party/WebKit/Source/core/animation/Animation.idl
index 2da00b3..cb339a2 100644
--- a/third_party/WebKit/Source/core/animation/Animation.idl
+++ b/third_party/WebKit/Source/core/animation/Animation.idl
@@ -28,18 +28,28 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// http://www.w3.org/TR/web-animations/#the-animation-interface
+// https://w3c.github.io/web-animations/#animation
-// TODO(dstockwell): This interface has been renamed to KeyframeEffect in the
-// latest spec:
-// https://w3c.github.io/web-animations/#the-keyframeeffect-interfaces
+enum AnimationPlayState { "idle", "pending", "running", "paused", "finished" };
[
- // FIXME: the third argument should be "optional (unrestricted double or AnimationTimingProperties) timing".
- Constructor(Element? target, sequence<Dictionary> keyframes, optional unrestricted double timing),
- Constructor(Element? target, sequence<Dictionary> keyframes, AnimationTimingProperties timing),
- RaisesException=Constructor,
- RuntimeEnabled=WebAnimationsAPI,
- TypeChecking=Interface,
-] interface Animation : AnimationNode {
+ ActiveDOMObject,
+ NoInterfaceObject,
+] interface Animation : EventTarget {
+ // TODO(dstockwell): Add timeline property.
+ // TODO(dstockwell): Rename source to effect.
+ [RuntimeEnabled=WebAnimationsAPI] attribute AnimationEffectReadOnly? source;
+ [Measure] attribute double? startTime;
+ [Measure] attribute double? currentTime;
+ [Measure] attribute double playbackRate;
+ [Measure] readonly attribute AnimationPlayState playState;
+ [Measure, RaisesException] void finish();
+ [Measure] void play();
+ [Measure] void pause();
+ [Measure] void reverse();
+
+ [Measure] void cancel();
+ [Measure] attribute EventHandler onfinish;
+ [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> finished;
+ [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<Animation> ready;
};
diff --git a/third_party/WebKit/Source/core/animation/AnimationNode.cpp b/third_party/WebKit/Source/core/animation/AnimationEffect.cpp
index 630a716..430bab4 100644
--- a/third_party/WebKit/Source/core/animation/AnimationNode.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationEffect.cpp
@@ -29,10 +29,10 @@
*/
#include "config.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNodeTiming.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/Animation.h"
+#include "core/animation/AnimationEffectTiming.h"
#include "core/animation/ComputedTimingProperties.h"
#include "core/animation/TimingCalculations.h"
@@ -51,10 +51,10 @@ Timing::FillMode resolvedFillMode(Timing::FillMode fillMode, bool isAnimation)
} // namespace
-AnimationNode::AnimationNode(const Timing& timing, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
+AnimationEffect::AnimationEffect(const Timing& timing, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
: m_parent(nullptr)
, m_startTime(0)
- , m_player(nullptr)
+ , m_animation(nullptr)
, m_timing(timing)
, m_eventDelegate(eventDelegate)
, m_calculated()
@@ -64,21 +64,21 @@ AnimationNode::AnimationNode(const Timing& timing, PassOwnPtrWillBeRawPtr<EventD
m_timing.assertValid();
}
-double AnimationNode::iterationDuration() const
+double AnimationEffect::iterationDuration() const
{
double result = std::isnan(m_timing.iterationDuration) ? intrinsicIterationDuration() : m_timing.iterationDuration;
ASSERT(result >= 0);
return result;
}
-double AnimationNode::repeatedDuration() const
+double AnimationEffect::repeatedDuration() const
{
const double result = multiplyZeroAlwaysGivesZero(iterationDuration(), m_timing.iterationCount);
ASSERT(result >= 0);
return result;
}
-double AnimationNode::activeDurationInternal() const
+double AnimationEffect::activeDurationInternal() const
{
const double result = m_timing.playbackRate
? repeatedDuration() / std::abs(m_timing.playbackRate)
@@ -87,17 +87,17 @@ double AnimationNode::activeDurationInternal() const
return result;
}
-void AnimationNode::updateSpecifiedTiming(const Timing& timing)
+void AnimationEffect::updateSpecifiedTiming(const Timing& timing)
{
// FIXME: Test whether the timing is actually different?
m_timing = timing;
invalidate();
- if (m_player)
- m_player->setOutdated();
+ if (m_animation)
+ m_animation->setOutdated();
specifiedTimingChanged();
}
-void AnimationNode::computedTiming(ComputedTimingProperties& computedTiming)
+void AnimationEffect::computedTiming(ComputedTimingProperties& computedTiming)
{
// ComputedTimingProperties members.
computedTiming.setStartTime(startTimeInternal() * 1000);
@@ -112,7 +112,7 @@ void AnimationNode::computedTiming(ComputedTimingProperties& computedTiming)
computedTiming.setCurrentIteration(ensureCalculated().currentIteration);
}
- // AnimationTimingProperties members.
+ // KeyframeEffectOptions members.
computedTiming.setDelay(specifiedTiming().startDelay * 1000);
computedTiming.setEndDelay(specifiedTiming().endDelay * 1000);
computedTiming.setFill(Timing::fillModeString(resolvedFillMode(specifiedTiming().fillMode, isAnimation())));
@@ -128,7 +128,7 @@ void AnimationNode::computedTiming(ComputedTimingProperties& computedTiming)
computedTiming.setEasing(specifiedTiming().timingFunction->toString());
}
-ComputedTimingProperties AnimationNode::computedTiming()
+ComputedTimingProperties AnimationEffect::computedTiming()
{
ComputedTimingProperties result;
computedTiming(result);
@@ -136,7 +136,7 @@ ComputedTimingProperties AnimationNode::computedTiming()
}
-void AnimationNode::updateInheritedTime(double inheritedTime, TimingUpdateReason reason) const
+void AnimationEffect::updateInheritedTime(double inheritedTime, TimingUpdateReason reason) const
{
bool needsUpdate = m_needsUpdate || (m_lastUpdateTime != inheritedTime && !(isNull(m_lastUpdateTime) && isNull(inheritedTime)));
m_needsUpdate = false;
@@ -149,7 +149,7 @@ void AnimationNode::updateInheritedTime(double inheritedTime, TimingUpdateReason
const Phase currentPhase = calculatePhase(activeDuration, localTime, m_timing);
// FIXME: parentPhase depends on groups being implemented.
- const AnimationNode::Phase parentPhase = AnimationNode::PhaseActive;
+ const AnimationEffect::Phase parentPhase = AnimationEffect::PhaseActive;
const double activeTime = calculateActiveTime(activeDuration, resolvedFillMode(m_timing.fillMode, isAnimation()), localTime, parentPhase, currentPhase, m_timing);
double currentIteration;
@@ -175,7 +175,7 @@ void AnimationNode::updateInheritedTime(double inheritedTime, TimingUpdateReason
const double localActiveDuration = m_timing.playbackRate ? localRepeatedDuration / std::abs(m_timing.playbackRate) : std::numeric_limits<double>::infinity();
ASSERT(localActiveDuration >= 0);
const double localLocalTime = localTime < m_timing.startDelay ? localTime : localActiveDuration + m_timing.startDelay;
- const AnimationNode::Phase localCurrentPhase = calculatePhase(localActiveDuration, localLocalTime, m_timing);
+ const AnimationEffect::Phase localCurrentPhase = calculatePhase(localActiveDuration, localLocalTime, m_timing);
const double localActiveTime = calculateActiveTime(localActiveDuration, resolvedFillMode(m_timing.fillMode, isAnimation()), localLocalTime, parentPhase, localCurrentPhase, m_timing);
const double startOffset = m_timing.iterationStart * localIterationDuration;
ASSERT(startOffset >= 0);
@@ -196,9 +196,9 @@ void AnimationNode::updateInheritedTime(double inheritedTime, TimingUpdateReason
m_calculated.localTime = m_lastUpdateTime - m_startTime;
}
- // Test for events even if timing didn't need an update as the player may have gained a start time.
- // FIXME: Refactor so that we can ASSERT(m_player) here, this is currently required to be nullable for testing.
- if (reason == TimingUpdateForAnimationFrame && (!m_player || m_player->hasStartTime() || m_player->paused())) {
+ // Test for events even if timing didn't need an update as the animation may have gained a start time.
+ // FIXME: Refactor so that we can ASSERT(m_animation) here, this is currently required to be nullable for testing.
+ if (reason == TimingUpdateForAnimationFrame && (!m_animation || m_animation->hasStartTime() || m_animation->paused())) {
if (m_eventDelegate)
m_eventDelegate->onEventCondition(*this);
}
@@ -211,25 +211,25 @@ void AnimationNode::updateInheritedTime(double inheritedTime, TimingUpdateReason
}
}
-const AnimationNode::CalculatedTiming& AnimationNode::ensureCalculated() const
+const AnimationEffect::CalculatedTiming& AnimationEffect::ensureCalculated() const
{
- if (!m_player)
+ if (!m_animation)
return m_calculated;
- if (m_player->outdated())
- m_player->update(TimingUpdateOnDemand);
- ASSERT(!m_player->outdated());
+ if (m_animation->outdated())
+ m_animation->update(TimingUpdateOnDemand);
+ ASSERT(!m_animation->outdated());
return m_calculated;
}
-PassRefPtrWillBeRawPtr<AnimationNodeTiming> AnimationNode::timing()
+PassRefPtrWillBeRawPtr<AnimationEffectTiming> AnimationEffect::timing()
{
- return AnimationNodeTiming::create(this);
+ return AnimationEffectTiming::create(this);
}
-DEFINE_TRACE(AnimationNode)
+DEFINE_TRACE(AnimationEffect)
{
visitor->trace(m_parent);
- visitor->trace(m_player);
+ visitor->trace(m_animation);
visitor->trace(m_eventDelegate);
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationEffect.h b/third_party/WebKit/Source/core/animation/AnimationEffect.h
index ff65991..a7409cf 100644
--- a/third_party/WebKit/Source/core/animation/AnimationEffect.h
+++ b/third_party/WebKit/Source/core/animation/AnimationEffect.h
@@ -32,34 +32,139 @@
#define AnimationEffect_h
#include "bindings/core/v8/ScriptWrappable.h"
-#include "core/CSSPropertyNames.h"
#include "core/CoreExport.h"
-#include "core/animation/PropertyHandle.h"
+#include "core/animation/Timing.h"
#include "platform/heap/Handle.h"
-#include "wtf/HashMap.h"
+#include "wtf/OwnPtr.h"
#include "wtf/PassOwnPtr.h"
#include "wtf/RefCounted.h"
namespace blink {
-class Interpolation;
+class Animation;
+class AnimationEffect;
+class AnimationEffectTiming;
+class ComputedTimingProperties;
+
+enum TimingUpdateReason {
+ TimingUpdateOnDemand,
+ TimingUpdateForAnimationFrame
+};
+
+static inline bool isNull(double value)
+{
+ return std::isnan(value);
+}
+
+static inline double nullValue()
+{
+ return std::numeric_limits<double>::quiet_NaN();
+}
class CORE_EXPORT AnimationEffect : public RefCountedWillBeGarbageCollectedFinalized<AnimationEffect>, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
+ friend class Animation; // Calls attach/detach, updateInheritedTime.
public:
- enum CompositeOperation {
- CompositeReplace,
- CompositeAdd,
+ // Note that logic in CSSAnimations depends on the order of these values.
+ enum Phase {
+ PhaseBefore,
+ PhaseActive,
+ PhaseAfter,
+ PhaseNone,
+ };
+
+ class EventDelegate : public NoBaseWillBeGarbageCollectedFinalized<EventDelegate> {
+ public:
+ virtual ~EventDelegate() { }
+ virtual bool requiresIterationEvents(const AnimationEffect&) = 0;
+ virtual void onEventCondition(const AnimationEffect&) = 0;
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
};
- AnimationEffect() { }
virtual ~AnimationEffect() { }
- virtual void sample(int iteration, double fraction, double iterationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const = 0;
- virtual bool affects(PropertyHandle) const { return false; };
- virtual bool isKeyframeEffectModel() const { return false; }
+ virtual bool isAnimation() const { return false; }
+
+ Phase phase() const { return ensureCalculated().phase; }
+ bool isCurrent() const { return ensureCalculated().isCurrent; }
+ bool isInEffect() const { return ensureCalculated().isInEffect; }
+ bool isInPlay() const { return ensureCalculated().isInPlay; }
+ double currentIteration() const { return ensureCalculated().currentIteration; }
+ double timeFraction() const { return ensureCalculated().timeFraction; }
+ double timeToForwardsEffectChange() const { return ensureCalculated().timeToForwardsEffectChange; }
+ double timeToReverseEffectChange() const { return ensureCalculated().timeToReverseEffectChange; }
+
+ double iterationDuration() const;
+ double activeDurationInternal() const;
+ double startTimeInternal() const { return m_startTime; }
+ double endTimeInternal() const { return std::max(startTimeInternal(), startTimeInternal() + specifiedTiming().startDelay + activeDurationInternal() + specifiedTiming().endDelay); }
+
+ const Animation* animation() const { return m_animation; }
+ Animation* animation() { return m_animation; }
+ const Timing& specifiedTiming() const { return m_timing; }
+ PassRefPtrWillBeRawPtr<AnimationEffectTiming> timing();
+ void updateSpecifiedTiming(const Timing&);
+
+ void computedTiming(ComputedTimingProperties&);
+ ComputedTimingProperties computedTiming();
+
+ void setName(const String& name) { m_name = name; }
+ const String& name() const { return m_name; }
+
+ DECLARE_VIRTUAL_TRACE();
+
+protected:
+ explicit AnimationEffect(const Timing&, PassOwnPtrWillBeRawPtr<EventDelegate> = nullptr);
+
+ // When AnimationEffect receives a new inherited time via updateInheritedTime
+ // it will (if necessary) recalculate timings and (if necessary) call
+ // updateChildrenAndEffects.
+ void updateInheritedTime(double inheritedTime, TimingUpdateReason) const;
+ void invalidate() const { m_needsUpdate = true; };
+ bool requiresIterationEvents() const { return m_eventDelegate && m_eventDelegate->requiresIterationEvents(*this); }
+ void clearEventDelegate() { m_eventDelegate = nullptr; }
+
+ virtual void attach(Animation* animation)
+ {
+ m_animation = animation;
+ }
+
+ virtual void detach()
+ {
+ ASSERT(m_animation);
+ m_animation = nullptr;
+ }
+
+ double repeatedDuration() const;
+
+ virtual void updateChildrenAndEffects() const = 0;
+ virtual double intrinsicIterationDuration() const { return 0; };
+ virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const = 0;
+ virtual void specifiedTimingChanged() { }
+
+ // FIXME: m_parent and m_startTime are placeholders, they depend on timing groups.
+ RawPtrWillBeMember<AnimationEffect> m_parent;
+ const double m_startTime;
+ RawPtrWillBeMember<Animation> m_animation;
+ Timing m_timing;
+ OwnPtrWillBeMember<EventDelegate> m_eventDelegate;
+
+ mutable struct CalculatedTiming {
+ Phase phase;
+ double currentIteration;
+ double timeFraction;
+ bool isCurrent;
+ bool isInEffect;
+ bool isInPlay;
+ double localTime;
+ double timeToForwardsEffectChange;
+ double timeToReverseEffectChange;
+ } m_calculated;
+ mutable bool m_needsUpdate;
+ mutable double m_lastUpdateTime;
+ String m_name;
- DEFINE_INLINE_VIRTUAL_TRACE() { }
+ const CalculatedTiming& ensureCalculated() const;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/AnimationNode.idl b/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.idl
index 119cba2..06540d1 100644
--- a/third_party/WebKit/Source/core/animation/AnimationNode.idl
+++ b/third_party/WebKit/Source/core/animation/AnimationEffectReadOnly.idl
@@ -28,16 +28,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// http://www.w3.org/TR/web-animations/#the-animationnode-interface
-
-// TODO(dstockwell): This interface has been renamed to AnimationEffectReadonly
-// in the latest spec:
// https://w3c.github.io/web-animations/#the-animationeffectreadonly-interface
[
RuntimeEnabled=WebAnimationsAPI,
WillBeGarbageCollected,
-] interface AnimationNode {
- readonly attribute Timing timing;
+ ImplementedAs=AnimationEffect,
+] interface AnimationEffectReadOnly {
+ readonly attribute AnimationEffectTiming timing;
readonly attribute ComputedTimingProperties computedTiming;
};
diff --git a/third_party/WebKit/Source/core/animation/AnimationNodeTest.cpp b/third_party/WebKit/Source/core/animation/AnimationEffectTest.cpp
index d883b80..ca35967 100644
--- a/third_party/WebKit/Source/core/animation/AnimationNodeTest.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationEffectTest.cpp
@@ -29,7 +29,8 @@
*/
#include "config.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
+
#include "core/animation/ComputedTimingProperties.h"
#include <gtest/gtest.h>
@@ -38,14 +39,14 @@ using namespace blink;
namespace {
-class TestAnimationNodeEventDelegate : public AnimationNode::EventDelegate {
+class TestAnimationEffectEventDelegate : public AnimationEffect::EventDelegate {
public:
- virtual void onEventCondition(const AnimationNode& animationNode) override
+ virtual void onEventCondition(const AnimationEffect& animationNode) override
{
m_eventTriggered = true;
}
- virtual bool requiresIterationEvents(const AnimationNode& animationNode) override
+ virtual bool requiresIterationEvents(const AnimationEffect& animationNode) override
{
return true;
}
@@ -59,11 +60,11 @@ private:
bool m_eventTriggered;
};
-class TestAnimationNode : public AnimationNode {
+class TestAnimationEffect : public AnimationEffect {
public:
- static PassRefPtrWillBeRawPtr<TestAnimationNode> create(const Timing& specified)
+ static PassRefPtrWillBeRawPtr<TestAnimationEffect> create(const Timing& specified)
{
- return adoptRefWillBeNoop(new TestAnimationNode(specified, new TestAnimationNodeEventDelegate()));
+ return adoptRefWillBeNoop(new TestAnimationEffect(specified, new TestAnimationEffectEventDelegate()));
}
void updateInheritedTime(double time)
@@ -74,12 +75,12 @@ public:
void updateInheritedTime(double time, TimingUpdateReason reason)
{
m_eventDelegate->reset();
- AnimationNode::updateInheritedTime(time, reason);
+ AnimationEffect::updateInheritedTime(time, reason);
}
virtual void updateChildrenAndEffects() const override { }
void willDetach() { }
- TestAnimationNodeEventDelegate* eventDelegate() { return m_eventDelegate.get(); }
+ TestAnimationEffectEventDelegate* eventDelegate() { return m_eventDelegate.get(); }
virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const override
{
m_localTime = localTime;
@@ -103,32 +104,32 @@ public:
DEFINE_INLINE_VIRTUAL_TRACE()
{
visitor->trace(m_eventDelegate);
- AnimationNode::trace(visitor);
+ AnimationEffect::trace(visitor);
}
private:
- TestAnimationNode(const Timing& specified, TestAnimationNodeEventDelegate* eventDelegate)
- : AnimationNode(specified, adoptPtrWillBeNoop(eventDelegate))
+ TestAnimationEffect(const Timing& specified, TestAnimationEffectEventDelegate* eventDelegate)
+ : AnimationEffect(specified, adoptPtrWillBeNoop(eventDelegate))
, m_eventDelegate(eventDelegate)
{
}
- RawPtrWillBeMember<TestAnimationNodeEventDelegate> m_eventDelegate;
+ RawPtrWillBeMember<TestAnimationEffectEventDelegate> m_eventDelegate;
mutable double m_localTime;
mutable double m_timeToNextIteration;
};
-TEST(AnimationAnimationNodeTest, Sanity)
+TEST(AnimationAnimationEffectTest, Sanity)
{
Timing timing;
timing.iterationDuration = 2;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -139,7 +140,7 @@ TEST(AnimationAnimationNodeTest, Sanity)
animationNode->updateInheritedTime(1);
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -150,7 +151,7 @@ TEST(AnimationAnimationNodeTest, Sanity)
animationNode->updateInheritedTime(2);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -161,7 +162,7 @@ TEST(AnimationAnimationNodeTest, Sanity)
animationNode->updateInheritedTime(3);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -171,11 +172,11 @@ TEST(AnimationAnimationNodeTest, Sanity)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, FillAuto)
+TEST(AnimationAnimationEffectTest, FillAuto)
{
Timing timing;
timing.iterationDuration = 1;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->timeFraction());
@@ -184,12 +185,12 @@ TEST(AnimationAnimationNodeTest, FillAuto)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, FillForwards)
+TEST(AnimationAnimationEffectTest, FillForwards)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeForwards;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->timeFraction()));
@@ -198,12 +199,12 @@ TEST(AnimationAnimationNodeTest, FillForwards)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, FillBackwards)
+TEST(AnimationAnimationEffectTest, FillBackwards)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeBackwards;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->timeFraction());
@@ -212,12 +213,12 @@ TEST(AnimationAnimationNodeTest, FillBackwards)
EXPECT_TRUE(isNull(animationNode->timeFraction()));
}
-TEST(AnimationAnimationNodeTest, FillBoth)
+TEST(AnimationAnimationEffectTest, FillBoth)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeBoth;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->timeFraction());
@@ -226,13 +227,13 @@ TEST(AnimationAnimationNodeTest, FillBoth)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, StartDelay)
+TEST(AnimationAnimationEffectTest, StartDelay)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeForwards;
timing.startDelay = 0.5;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0);
EXPECT_TRUE(isNull(animationNode->timeFraction()));
@@ -244,13 +245,13 @@ TEST(AnimationAnimationNodeTest, StartDelay)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroIteration)
+TEST(AnimationAnimationEffectTest, ZeroIteration)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = 0;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->activeDurationInternal());
@@ -263,13 +264,13 @@ TEST(AnimationAnimationNodeTest, ZeroIteration)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, InfiniteIteration)
+TEST(AnimationAnimationEffectTest, InfiniteIteration)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = std::numeric_limits<double>::infinity();
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->currentIteration()));
@@ -282,12 +283,12 @@ TEST(AnimationAnimationNodeTest, InfiniteIteration)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, Iteration)
+TEST(AnimationAnimationEffectTest, Iteration)
{
Timing timing;
timing.iterationCount = 2;
timing.iterationDuration = 2;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0);
EXPECT_EQ(0, animationNode->currentIteration());
@@ -310,14 +311,14 @@ TEST(AnimationAnimationNodeTest, Iteration)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, IterationStart)
+TEST(AnimationAnimationEffectTest, IterationStart)
{
Timing timing;
timing.iterationStart = 1.2;
timing.iterationCount = 2.2;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeBoth;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(1, animationNode->currentIteration());
@@ -332,13 +333,13 @@ TEST(AnimationAnimationNodeTest, IterationStart)
EXPECT_NEAR(0.4, animationNode->timeFraction(), 0.000000000000001);
}
-TEST(AnimationAnimationNodeTest, IterationAlternate)
+TEST(AnimationAnimationEffectTest, IterationAlternate)
{
Timing timing;
timing.iterationCount = 10;
timing.iterationDuration = 1;
timing.direction = Timing::PlaybackDirectionAlternate;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0.75);
EXPECT_EQ(0, animationNode->currentIteration());
@@ -353,13 +354,13 @@ TEST(AnimationAnimationNodeTest, IterationAlternate)
EXPECT_EQ(0.75, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, IterationAlternateReverse)
+TEST(AnimationAnimationEffectTest, IterationAlternateReverse)
{
Timing timing;
timing.iterationCount = 10;
timing.iterationDuration = 1;
timing.direction = Timing::PlaybackDirectionAlternateReverse;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0.75);
EXPECT_EQ(0, animationNode->currentIteration());
@@ -374,16 +375,16 @@ TEST(AnimationAnimationNodeTest, IterationAlternateReverse)
EXPECT_EQ(0.25, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationSanity)
+TEST(AnimationAnimationEffectTest, ZeroDurationSanity)
{
Timing timing;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -394,7 +395,7 @@ TEST(AnimationAnimationNodeTest, ZeroDurationSanity)
animationNode->updateInheritedTime(1);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -404,11 +405,11 @@ TEST(AnimationAnimationNodeTest, ZeroDurationSanity)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationFillForwards)
+TEST(AnimationAnimationEffectTest, ZeroDurationFillForwards)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->timeFraction()));
@@ -420,11 +421,11 @@ TEST(AnimationAnimationNodeTest, ZeroDurationFillForwards)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationFillBackwards)
+TEST(AnimationAnimationEffectTest, ZeroDurationFillBackwards)
{
Timing timing;
timing.fillMode = Timing::FillModeBackwards;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->timeFraction());
@@ -436,11 +437,11 @@ TEST(AnimationAnimationNodeTest, ZeroDurationFillBackwards)
EXPECT_TRUE(isNull(animationNode->timeFraction()));
}
-TEST(AnimationAnimationNodeTest, ZeroDurationFillBoth)
+TEST(AnimationAnimationEffectTest, ZeroDurationFillBoth)
{
Timing timing;
timing.fillMode = Timing::FillModeBoth;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->timeFraction());
@@ -452,12 +453,12 @@ TEST(AnimationAnimationNodeTest, ZeroDurationFillBoth)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationStartDelay)
+TEST(AnimationAnimationEffectTest, ZeroDurationStartDelay)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
timing.startDelay = 0.5;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0);
EXPECT_TRUE(isNull(animationNode->timeFraction()));
@@ -469,14 +470,14 @@ TEST(AnimationAnimationNodeTest, ZeroDurationStartDelay)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationIterationStartAndCount)
+TEST(AnimationAnimationEffectTest, ZeroDurationIterationStartAndCount)
{
Timing timing;
timing.iterationStart = 0.1;
timing.iterationCount = 0.2;
timing.fillMode = Timing::FillModeBoth;
timing.startDelay = 0.3;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0);
EXPECT_EQ(0.1, animationNode->timeFraction());
@@ -489,12 +490,12 @@ TEST(AnimationAnimationNodeTest, ZeroDurationIterationStartAndCount)
}
// FIXME: Needs specification work.
-TEST(AnimationAnimationNodeTest, ZeroDurationInfiniteIteration)
+TEST(AnimationAnimationEffectTest, ZeroDurationInfiniteIteration)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = std::numeric_limits<double>::infinity();
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(0, animationNode->activeDurationInternal());
@@ -507,12 +508,12 @@ TEST(AnimationAnimationNodeTest, ZeroDurationInfiniteIteration)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationIteration)
+TEST(AnimationAnimationEffectTest, ZeroDurationIteration)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = 2;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->currentIteration()));
@@ -527,13 +528,13 @@ TEST(AnimationAnimationNodeTest, ZeroDurationIteration)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationIterationStart)
+TEST(AnimationAnimationEffectTest, ZeroDurationIterationStart)
{
Timing timing;
timing.iterationStart = 1.2;
timing.iterationCount = 2.2;
timing.fillMode = Timing::FillModeBoth;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_EQ(1, animationNode->currentIteration());
@@ -548,13 +549,13 @@ TEST(AnimationAnimationNodeTest, ZeroDurationIterationStart)
EXPECT_NEAR(0.4, animationNode->timeFraction(), 0.000000000000001);
}
-TEST(AnimationAnimationNodeTest, ZeroDurationIterationAlternate)
+TEST(AnimationAnimationEffectTest, ZeroDurationIterationAlternate)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = 2;
timing.direction = Timing::PlaybackDirectionAlternate;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->currentIteration()));
@@ -569,13 +570,13 @@ TEST(AnimationAnimationNodeTest, ZeroDurationIterationAlternate)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, ZeroDurationIterationAlternateReverse)
+TEST(AnimationAnimationEffectTest, ZeroDurationIterationAlternateReverse)
{
Timing timing;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = 2;
timing.direction = Timing::PlaybackDirectionAlternateReverse;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(-1);
EXPECT_TRUE(isNull(animationNode->currentIteration()));
@@ -590,19 +591,19 @@ TEST(AnimationAnimationNodeTest, ZeroDurationIterationAlternateReverse)
EXPECT_EQ(1, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, InfiniteDurationSanity)
+TEST(AnimationAnimationEffectTest, InfiniteDurationSanity)
{
Timing timing;
timing.iterationDuration = std::numeric_limits<double>::infinity();
timing.iterationCount = 1;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -612,7 +613,7 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationSanity)
animationNode->updateInheritedTime(1);
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -621,19 +622,19 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationSanity)
}
// FIXME: Needs specification work.
-TEST(AnimationAnimationNodeTest, InfiniteDurationZeroIterations)
+TEST(AnimationAnimationEffectTest, InfiniteDurationZeroIterations)
{
Timing timing;
timing.iterationDuration = std::numeric_limits<double>::infinity();
timing.iterationCount = 0;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
EXPECT_EQ(0, animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -642,8 +643,8 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationZeroIterations)
animationNode->updateInheritedTime(1);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -651,19 +652,19 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationZeroIterations)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, InfiniteDurationInfiniteIterations)
+TEST(AnimationAnimationEffectTest, InfiniteDurationInfiniteIterations)
{
Timing timing;
timing.iterationDuration = std::numeric_limits<double>::infinity();
timing.iterationCount = std::numeric_limits<double>::infinity();
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -673,7 +674,7 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationInfiniteIterations)
animationNode->updateInheritedTime(1);
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -681,19 +682,19 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationInfiniteIterations)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, InfiniteDurationZeroPlaybackRate)
+TEST(AnimationAnimationEffectTest, InfiniteDurationZeroPlaybackRate)
{
Timing timing;
timing.iterationDuration = std::numeric_limits<double>::infinity();
timing.playbackRate = 0;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(0, animationNode->computedTiming().startTime());
animationNode->updateInheritedTime(0);
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_TRUE(animationNode->isInPlay());
EXPECT_TRUE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -703,7 +704,7 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationZeroPlaybackRate)
animationNode->updateInheritedTime(std::numeric_limits<double>::infinity());
EXPECT_EQ(std::numeric_limits<double>::infinity(), animationNode->activeDurationInternal());
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_FALSE(animationNode->isInPlay());
EXPECT_FALSE(animationNode->isCurrent());
EXPECT_TRUE(animationNode->isInEffect());
@@ -711,25 +712,25 @@ TEST(AnimationAnimationNodeTest, InfiniteDurationZeroPlaybackRate)
EXPECT_EQ(0, animationNode->timeFraction());
}
-TEST(AnimationAnimationNodeTest, EndTime)
+TEST(AnimationAnimationEffectTest, EndTime)
{
Timing timing;
timing.startDelay = 1;
timing.endDelay = 2;
timing.iterationDuration = 4;
timing.iterationCount = 2;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
EXPECT_EQ(11, animationNode->endTimeInternal());
}
-TEST(AnimationAnimationNodeTest, Events)
+TEST(AnimationAnimationEffectTest, Events)
{
Timing timing;
timing.iterationDuration = 1;
timing.fillMode = Timing::FillModeForwards;
timing.iterationCount = 2;
timing.startDelay = 1;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0.0, TimingUpdateOnDemand);
EXPECT_FALSE(animationNode->eventDelegate()->eventTriggered());
@@ -745,7 +746,7 @@ TEST(AnimationAnimationNodeTest, Events)
}
-TEST(AnimationAnimationNodeTest, TimeToEffectChange)
+TEST(AnimationAnimationEffectTest, TimeToEffectChange)
{
Timing timing;
timing.iterationDuration = 1;
@@ -754,7 +755,7 @@ TEST(AnimationAnimationNodeTest, TimeToEffectChange)
timing.iterationCount = 2.5;
timing.startDelay = 1;
timing.direction = Timing::PlaybackDirectionAlternate;
- RefPtrWillBeRawPtr<TestAnimationNode> animationNode = TestAnimationNode::create(timing);
+ RefPtrWillBeRawPtr<TestAnimationEffect> animationNode = TestAnimationEffect::create(timing);
animationNode->updateInheritedTime(0);
EXPECT_EQ(0, animationNode->takeLocalTime());
@@ -772,13 +773,13 @@ TEST(AnimationAnimationNodeTest, TimeToEffectChange)
// Item ends before iteration finishes.
animationNode->updateInheritedTime(3.4);
- EXPECT_EQ(AnimationNode::PhaseActive, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseActive, animationNode->phase());
EXPECT_EQ(3.4, animationNode->takeLocalTime());
EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration()));
// Item has finished.
animationNode->updateInheritedTime(3.5);
- EXPECT_EQ(AnimationNode::PhaseAfter, animationNode->phase());
+ EXPECT_EQ(AnimationEffect::PhaseAfter, animationNode->phase());
EXPECT_EQ(3.5, animationNode->takeLocalTime());
EXPECT_TRUE(std::isinf(animationNode->takeTimeToNextIteration()));
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationNodeTiming.cpp b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp
index 07624e8..6f9fd6f 100644
--- a/third_party/WebKit/Source/core/animation/AnimationNodeTiming.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.cpp
@@ -3,51 +3,51 @@
// found in the LICENSE file.
#include "config.h"
-#include "core/animation/AnimationNodeTiming.h"
+#include "core/animation/AnimationEffectTiming.h"
#include "bindings/core/v8/UnionTypesCore.h"
-#include "core/animation/Animation.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
+#include "core/animation/KeyframeEffect.h"
#include "platform/animation/TimingFunction.h"
namespace blink {
-PassRefPtrWillBeRawPtr<AnimationNodeTiming> AnimationNodeTiming::create(AnimationNode* parent)
+PassRefPtrWillBeRawPtr<AnimationEffectTiming> AnimationEffectTiming::create(AnimationEffect* parent)
{
- return adoptRefWillBeNoop(new AnimationNodeTiming(parent));
+ return adoptRefWillBeNoop(new AnimationEffectTiming(parent));
}
-AnimationNodeTiming::AnimationNodeTiming(AnimationNode* parent)
+AnimationEffectTiming::AnimationEffectTiming(AnimationEffect* parent)
: m_parent(parent)
{
}
-double AnimationNodeTiming::delay()
+double AnimationEffectTiming::delay()
{
return m_parent->specifiedTiming().startDelay * 1000;
}
-double AnimationNodeTiming::endDelay()
+double AnimationEffectTiming::endDelay()
{
return m_parent->specifiedTiming().endDelay * 1000;
}
-String AnimationNodeTiming::fill()
+String AnimationEffectTiming::fill()
{
return Timing::fillModeString(m_parent->specifiedTiming().fillMode);
}
-double AnimationNodeTiming::iterationStart()
+double AnimationEffectTiming::iterationStart()
{
return m_parent->specifiedTiming().iterationStart;
}
-double AnimationNodeTiming::iterations()
+double AnimationEffectTiming::iterations()
{
return m_parent->specifiedTiming().iterationCount;
}
-void AnimationNodeTiming::duration(UnrestrictedDoubleOrString& returnValue)
+void AnimationEffectTiming::duration(UnrestrictedDoubleOrString& returnValue)
{
if (std::isnan(m_parent->specifiedTiming().iterationDuration))
returnValue.setString("auto");
@@ -55,57 +55,57 @@ void AnimationNodeTiming::duration(UnrestrictedDoubleOrString& returnValue)
returnValue.setUnrestrictedDouble(m_parent->specifiedTiming().iterationDuration * 1000);
}
-double AnimationNodeTiming::playbackRate()
+double AnimationEffectTiming::playbackRate()
{
return m_parent->specifiedTiming().playbackRate;
}
-String AnimationNodeTiming::direction()
+String AnimationEffectTiming::direction()
{
return Timing::playbackDirectionString(m_parent->specifiedTiming().direction);
}
-String AnimationNodeTiming::easing()
+String AnimationEffectTiming::easing()
{
return m_parent->specifiedTiming().timingFunction->toString();
}
-void AnimationNodeTiming::setDelay(double delay)
+void AnimationEffectTiming::setDelay(double delay)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setStartDelay(timing, delay);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setEndDelay(double endDelay)
+void AnimationEffectTiming::setEndDelay(double endDelay)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setEndDelay(timing, endDelay);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setFill(String fill)
+void AnimationEffectTiming::setFill(String fill)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setFillMode(timing, fill);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setIterationStart(double iterationStart)
+void AnimationEffectTiming::setIterationStart(double iterationStart)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setIterationStart(timing, iterationStart);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setIterations(double iterations)
+void AnimationEffectTiming::setIterations(double iterations)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setIterationCount(timing, iterations);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setDuration(const UnrestrictedDoubleOrString& durationOrAuto)
+void AnimationEffectTiming::setDuration(const UnrestrictedDoubleOrString& durationOrAuto)
{
// Any strings other than "auto" are coerced to "auto".
double duration = durationOrAuto.isString() ? std::numeric_limits<double>::quiet_NaN() : durationOrAuto.getAsUnrestrictedDouble();
@@ -114,28 +114,28 @@ void AnimationNodeTiming::setDuration(const UnrestrictedDoubleOrString& duration
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setPlaybackRate(double playbackRate)
+void AnimationEffectTiming::setPlaybackRate(double playbackRate)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setPlaybackRate(timing, playbackRate);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setDirection(String direction)
+void AnimationEffectTiming::setDirection(String direction)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setPlaybackDirection(timing, direction);
m_parent->updateSpecifiedTiming(timing);
}
-void AnimationNodeTiming::setEasing(String easing)
+void AnimationEffectTiming::setEasing(String easing)
{
Timing timing = m_parent->specifiedTiming();
TimingInput::setTimingFunction(timing, easing);
m_parent->updateSpecifiedTiming(timing);
}
-DEFINE_TRACE(AnimationNodeTiming)
+DEFINE_TRACE(AnimationEffectTiming)
{
visitor->trace(m_parent);
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationNodeTiming.h b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h
index c33dd2c..58e272e 100644
--- a/third_party/WebKit/Source/core/animation/AnimationNodeTiming.h
+++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef AnimationNodeTiming_h
-#define AnimationNodeTiming_h
+#ifndef AnimationEffectTiming_h
+#define AnimationEffectTiming_h
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/CoreExport.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
@@ -15,10 +15,10 @@ namespace blink {
class UnrestrictedDoubleOrString;
-class CORE_EXPORT AnimationNodeTiming : public RefCountedWillBeGarbageCollectedFinalized<AnimationNodeTiming>, public ScriptWrappable {
+class CORE_EXPORT AnimationEffectTiming : public RefCountedWillBeGarbageCollectedFinalized<AnimationEffectTiming>, public ScriptWrappable {
DEFINE_WRAPPERTYPEINFO();
public:
- static PassRefPtrWillBeRawPtr<AnimationNodeTiming> create(AnimationNode* parent);
+ static PassRefPtrWillBeRawPtr<AnimationEffectTiming> create(AnimationEffect* parent);
double delay();
double endDelay();
String fill();
@@ -42,8 +42,8 @@ public:
DECLARE_TRACE();
private:
- RefPtrWillBeMember<AnimationNode> m_parent;
- explicit AnimationNodeTiming(AnimationNode*);
+ RefPtrWillBeMember<AnimationEffect> m_parent;
+ explicit AnimationEffectTiming(AnimationEffect*);
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/Timing.idl b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl
index 6cd5e97..59a395e 100644
--- a/third_party/WebKit/Source/core/animation/Timing.idl
+++ b/third_party/WebKit/Source/core/animation/AnimationEffectTiming.idl
@@ -2,23 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// http://www.w3.org/TR/web-animations/#the-animationtiming-interface
-
-// TODO(dstockwell): This interface does not exist in the latest spec, which
-// instead has a AnimationEffectTimingReadonly interface:
-// https://w3c.github.io/web-animations/#the-animationeffecttimingreadonly-interface
+// https://w3c.github.io/web-animations/#the-animationeffecttiming-interface
+// TODO(dstockwell): Should extend AnimationEffectTimingReadOnly
[
- ImplementedAs=AnimationNodeTiming,
RuntimeEnabled=WebAnimationsAPI,
WillBeGarbageCollected,
-] interface Timing {
+] interface AnimationEffectTiming {
attribute double delay;
attribute double endDelay;
attribute DOMString fill;
attribute double iterationStart;
attribute unrestricted double iterations;
attribute (unrestricted double or DOMString) duration;
+ // TODO(dstockwell): playbackRate has been removed from level 1.
attribute double playbackRate;
attribute DOMString direction;
attribute DOMString easing;
diff --git a/third_party/WebKit/Source/core/animation/AnimationNode.h b/third_party/WebKit/Source/core/animation/AnimationNode.h
deleted file mode 100644
index 985f69d..0000000
--- a/third_party/WebKit/Source/core/animation/AnimationNode.h
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * Copyright (C) 2013 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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.
- */
-
-#ifndef AnimationNode_h
-#define AnimationNode_h
-
-#include "bindings/core/v8/ScriptWrappable.h"
-#include "core/CoreExport.h"
-#include "core/animation/Timing.h"
-#include "platform/heap/Handle.h"
-#include "wtf/OwnPtr.h"
-#include "wtf/PassOwnPtr.h"
-#include "wtf/RefCounted.h"
-
-namespace blink {
-
-class AnimationPlayer;
-class AnimationNode;
-class AnimationNodeTiming;
-class ComputedTimingProperties;
-
-enum TimingUpdateReason {
- TimingUpdateOnDemand,
- TimingUpdateForAnimationFrame
-};
-
-static inline bool isNull(double value)
-{
- return std::isnan(value);
-}
-
-static inline double nullValue()
-{
- return std::numeric_limits<double>::quiet_NaN();
-}
-
-class CORE_EXPORT AnimationNode : public RefCountedWillBeGarbageCollectedFinalized<AnimationNode>, public ScriptWrappable {
- DEFINE_WRAPPERTYPEINFO();
- friend class AnimationPlayer; // Calls attach/detach, updateInheritedTime.
-public:
- // Note that logic in CSSAnimations depends on the order of these values.
- enum Phase {
- PhaseBefore,
- PhaseActive,
- PhaseAfter,
- PhaseNone,
- };
-
- class EventDelegate : public NoBaseWillBeGarbageCollectedFinalized<EventDelegate> {
- public:
- virtual ~EventDelegate() { }
- virtual bool requiresIterationEvents(const AnimationNode&) = 0;
- virtual void onEventCondition(const AnimationNode&) = 0;
- DEFINE_INLINE_VIRTUAL_TRACE() { }
- };
-
- virtual ~AnimationNode() { }
-
- virtual bool isAnimation() const { return false; }
-
- Phase phase() const { return ensureCalculated().phase; }
- bool isCurrent() const { return ensureCalculated().isCurrent; }
- bool isInEffect() const { return ensureCalculated().isInEffect; }
- bool isInPlay() const { return ensureCalculated().isInPlay; }
- double currentIteration() const { return ensureCalculated().currentIteration; }
- double timeFraction() const { return ensureCalculated().timeFraction; }
- double timeToForwardsEffectChange() const { return ensureCalculated().timeToForwardsEffectChange; }
- double timeToReverseEffectChange() const { return ensureCalculated().timeToReverseEffectChange; }
-
- double iterationDuration() const;
- double activeDurationInternal() const;
- double startTimeInternal() const { return m_startTime; }
- double endTimeInternal() const { return std::max(startTimeInternal(), startTimeInternal() + specifiedTiming().startDelay + activeDurationInternal() + specifiedTiming().endDelay); }
-
- const AnimationPlayer* player() const { return m_player; }
- AnimationPlayer* player() { return m_player; }
- const Timing& specifiedTiming() const { return m_timing; }
- PassRefPtrWillBeRawPtr<AnimationNodeTiming> timing();
- void updateSpecifiedTiming(const Timing&);
-
- void computedTiming(ComputedTimingProperties&);
- ComputedTimingProperties computedTiming();
-
- void setName(const String& name) { m_name = name; }
- const String& name() const { return m_name; }
-
- DECLARE_VIRTUAL_TRACE();
-
-protected:
- explicit AnimationNode(const Timing&, PassOwnPtrWillBeRawPtr<EventDelegate> = nullptr);
-
- // When AnimationNode receives a new inherited time via updateInheritedTime
- // it will (if necessary) recalculate timings and (if necessary) call
- // updateChildrenAndEffects.
- void updateInheritedTime(double inheritedTime, TimingUpdateReason) const;
- void invalidate() const { m_needsUpdate = true; };
- bool requiresIterationEvents() const { return m_eventDelegate && m_eventDelegate->requiresIterationEvents(*this); }
- void clearEventDelegate() { m_eventDelegate = nullptr; }
-
- virtual void attach(AnimationPlayer* player)
- {
- m_player = player;
- }
-
- virtual void detach()
- {
- ASSERT(m_player);
- m_player = nullptr;
- }
-
- double repeatedDuration() const;
-
- virtual void updateChildrenAndEffects() const = 0;
- virtual double intrinsicIterationDuration() const { return 0; };
- virtual double calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const = 0;
- virtual void specifiedTimingChanged() { }
-
- // FIXME: m_parent and m_startTime are placeholders, they depend on timing groups.
- RawPtrWillBeMember<AnimationNode> m_parent;
- const double m_startTime;
- RawPtrWillBeMember<AnimationPlayer> m_player;
- Timing m_timing;
- OwnPtrWillBeMember<EventDelegate> m_eventDelegate;
-
- mutable struct CalculatedTiming {
- Phase phase;
- double currentIteration;
- double timeFraction;
- bool isCurrent;
- bool isInEffect;
- bool isInPlay;
- double localTime;
- double timeToForwardsEffectChange;
- double timeToReverseEffectChange;
- } m_calculated;
- mutable bool m_needsUpdate;
- mutable double m_lastUpdateTime;
- String m_name;
-
- const CalculatedTiming& ensureCalculated() const;
-};
-
-} // namespace blink
-
-#endif // AnimationNode_h
diff --git a/third_party/WebKit/Source/core/animation/AnimationPlayer.cpp b/third_party/WebKit/Source/core/animation/AnimationPlayer.cpp
deleted file mode 100644
index 99a947b..0000000
--- a/third_party/WebKit/Source/core/animation/AnimationPlayer.cpp
+++ /dev/null
@@ -1,1032 +0,0 @@
-/*
- * Copyright (C) 2013 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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 "core/animation/AnimationPlayer.h"
-
-#include "core/animation/Animation.h"
-#include "core/animation/AnimationTimeline.h"
-#include "core/dom/Document.h"
-#include "core/dom/ExceptionCode.h"
-#include "core/events/AnimationPlayerEvent.h"
-#include "core/frame/UseCounter.h"
-#include "core/inspector/InspectorInstrumentation.h"
-#include "core/inspector/InspectorTraceEvents.h"
-#include "platform/RuntimeEnabledFeatures.h"
-#include "platform/TraceEvent.h"
-#include "public/platform/Platform.h"
-#include "public/platform/WebCompositorAnimationPlayer.h"
-#include "public/platform/WebCompositorSupport.h"
-#include "wtf/MathExtras.h"
-
-namespace blink {
-
-namespace {
-
-static unsigned nextSequenceNumber()
-{
- static unsigned next = 0;
- return ++next;
-}
-
-}
-
-PassRefPtrWillBeRawPtr<AnimationPlayer> AnimationPlayer::create(AnimationNode* source, AnimationTimeline* timeline)
-{
- if (!timeline) {
- // FIXME: Support creating players without a timeline.
- return nullptr;
- }
-
- RefPtrWillBeRawPtr<AnimationPlayer> player = adoptRefWillBeNoop(new AnimationPlayer(timeline->document()->contextDocument().get(), *timeline, source));
- player->suspendIfNeeded();
-
- if (timeline) {
- timeline->playerAttached(*player);
- player->attachCompositorTimeline();
- }
-
- return player.release();
-}
-
-AnimationPlayer::AnimationPlayer(ExecutionContext* executionContext, AnimationTimeline& timeline, AnimationNode* content)
- : ActiveDOMObject(executionContext)
- , m_playState(Idle)
- , m_playbackRate(1)
- , m_startTime(nullValue())
- , m_holdTime(0)
- , m_sequenceNumber(nextSequenceNumber())
- , m_content(content)
- , m_timeline(&timeline)
- , m_paused(false)
- , m_held(true)
- , m_isPausedForTesting(false)
- , m_outdated(false)
- , m_finished(true)
- , m_compositorState(nullptr)
- , m_compositorPending(false)
- , m_compositorGroup(0)
- , m_currentTimePending(false)
- , m_stateIsBeingUpdated(false)
-{
- if (m_content) {
- if (m_content->player()) {
- m_content->player()->cancel();
- m_content->player()->setSource(0);
- }
- m_content->attach(this);
- }
-}
-
-AnimationPlayer::~AnimationPlayer()
-{
-#if !ENABLE(OILPAN)
- if (m_content)
- m_content->detach();
- if (m_timeline)
- m_timeline->playerDestroyed(this);
-#endif
-
- destroyCompositorPlayer();
-}
-
-#if !ENABLE(OILPAN)
-void AnimationPlayer::detachFromTimeline()
-{
- dispose();
- m_timeline = nullptr;
-}
-#endif
-
-double AnimationPlayer::sourceEnd() const
-{
- return m_content ? m_content->endTimeInternal() : 0;
-}
-
-bool AnimationPlayer::limited(double currentTime) const
-{
- return (m_playbackRate < 0 && currentTime <= 0) || (m_playbackRate > 0 && currentTime >= sourceEnd());
-}
-
-void AnimationPlayer::setCurrentTime(double newCurrentTime)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- m_currentTimePending = false;
- setCurrentTimeInternal(newCurrentTime / 1000, TimingUpdateOnDemand);
-
- if (calculatePlayState() == Finished)
- m_startTime = calculateStartTime(newCurrentTime);
-}
-
-void AnimationPlayer::setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason reason)
-{
- ASSERT(std::isfinite(newCurrentTime));
-
- bool oldHeld = m_held;
- bool outdated = false;
- bool isLimited = limited(newCurrentTime);
- m_held = m_paused || !m_playbackRate || isLimited || std::isnan(m_startTime);
- if (m_held) {
- if (!oldHeld || m_holdTime != newCurrentTime)
- outdated = true;
- m_holdTime = newCurrentTime;
- if (m_paused || !m_playbackRate) {
- m_startTime = nullValue();
- } else if (isLimited && std::isnan(m_startTime) && reason == TimingUpdateForAnimationFrame) {
- m_startTime = calculateStartTime(newCurrentTime);
- }
- } else {
- m_holdTime = nullValue();
- m_startTime = calculateStartTime(newCurrentTime);
- m_finished = false;
- outdated = true;
- }
-
- if (outdated) {
- setOutdated();
- }
-}
-
-// Update timing to reflect updated animation clock due to tick
-void AnimationPlayer::updateCurrentTimingState(TimingUpdateReason reason)
-{
- if (m_held) {
- double newCurrentTime = m_holdTime;
- if (playStateInternal() == Finished && !isNull(m_startTime) && m_timeline) {
- // Add hystersis due to floating point error accumulation
- if (!limited(calculateCurrentTime() + 0.001 * m_playbackRate)) {
- // The current time became unlimited, eg. due to a backwards
- // seek of the timeline.
- newCurrentTime = calculateCurrentTime();
- } else if (!limited(m_holdTime)) {
- // The hold time became unlimited, eg. due to the source content
- // becoming longer.
- newCurrentTime = clampTo<double>(calculateCurrentTime(), 0, sourceEnd());
- }
- }
- setCurrentTimeInternal(newCurrentTime, reason);
- } else if (limited(calculateCurrentTime())) {
- m_held = true;
- m_holdTime = m_playbackRate < 0 ? 0 : sourceEnd();
- }
-}
-
-double AnimationPlayer::startTime(bool& isNull) const
-{
- double result = startTime();
- isNull = std::isnan(result);
- return result;
-}
-
-double AnimationPlayer::startTime() const
-{
- return m_startTime * 1000;
-}
-
-double AnimationPlayer::currentTime(bool& isNull)
-{
- double result = currentTime();
- isNull = std::isnan(result);
- return result;
-}
-
-double AnimationPlayer::currentTime()
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (m_currentTimePending || playStateInternal() == Idle)
- return std::numeric_limits<double>::quiet_NaN();
-
- return currentTimeInternal() * 1000;
-}
-
-double AnimationPlayer::currentTimeInternal() const
-{
- double result = m_held ? m_holdTime : calculateCurrentTime();
-#if ENABLE(ASSERT)
- const_cast<AnimationPlayer*>(this)->updateCurrentTimingState(TimingUpdateOnDemand);
- ASSERT(result == (m_held ? m_holdTime : calculateCurrentTime()));
-#endif
- return result;
-}
-
-double AnimationPlayer::unlimitedCurrentTimeInternal() const
-{
-#if ENABLE(ASSERT)
- currentTimeInternal();
-#endif
- return playStateInternal() == Paused || isNull(m_startTime)
- ? currentTimeInternal()
- : calculateCurrentTime();
-}
-
-void AnimationPlayer::preCommit(int compositorGroup, bool startOnCompositor)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
-
- bool softChange = m_compositorState && (paused() || m_compositorState->playbackRate != m_playbackRate);
- bool hardChange = m_compositorState && (m_compositorState->sourceChanged || m_compositorState->startTime != m_startTime);
-
- // FIXME: softChange && !hardChange should generate a Pause/ThenStart,
- // not a Cancel, but we can't communicate these to the compositor yet.
-
- bool changed = softChange || hardChange;
- bool shouldCancel = (!playing() && m_compositorState) || changed;
- bool shouldStart = playing() && (!m_compositorState || changed);
-
- if (shouldCancel) {
- cancelAnimationOnCompositor();
- m_compositorState = nullptr;
- }
-
- if (m_compositorState && m_compositorState->pendingAction == Start) {
- // Still waiting for a start time.
- return;
- }
-
- ASSERT(!m_compositorState || !std::isnan(m_compositorState->startTime));
-
- if (!shouldStart) {
- m_currentTimePending = false;
- }
-
- if (shouldStart) {
- m_compositorGroup = compositorGroup;
- if (startOnCompositor) {
- if (isCandidateForAnimationOnCompositor())
- createCompositorPlayer();
-
- if (maybeStartAnimationOnCompositor())
- m_compositorState = adoptPtr(new CompositorState(*this));
- else
- cancelIncompatibleAnimationsOnCompositor();
- }
- }
-}
-
-void AnimationPlayer::postCommit(double timelineTime)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
-
- m_compositorPending = false;
-
- if (!m_compositorState || m_compositorState->pendingAction == None)
- return;
-
- switch (m_compositorState->pendingAction) {
- case Start:
- if (!std::isnan(m_compositorState->startTime)) {
- ASSERT(m_startTime == m_compositorState->startTime);
- m_compositorState->pendingAction = None;
- }
- break;
- case Pause:
- case PauseThenStart:
- ASSERT(std::isnan(m_startTime));
- m_compositorState->pendingAction = None;
- setCurrentTimeInternal((timelineTime - m_compositorState->startTime) * m_playbackRate, TimingUpdateForAnimationFrame);
- m_currentTimePending = false;
- break;
- default:
- ASSERT_NOT_REACHED();
- }
-}
-
-void AnimationPlayer::notifyCompositorStartTime(double timelineTime)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, DoNotSetCompositorPending);
-
- if (m_compositorState) {
- ASSERT(m_compositorState->pendingAction == Start);
- ASSERT(std::isnan(m_compositorState->startTime));
-
- double initialCompositorHoldTime = m_compositorState->holdTime;
- m_compositorState->pendingAction = None;
- m_compositorState->startTime = timelineTime + currentTimeInternal() / -m_playbackRate;
-
- if (m_startTime == timelineTime) {
- // The start time was set to the incoming compositor start time.
- // Unlikely, but possible.
- // FIXME: Depending on what changed above this might still be pending.
- // Maybe...
- m_currentTimePending = false;
- return;
- }
-
- if (!std::isnan(m_startTime) || currentTimeInternal() != initialCompositorHoldTime) {
- // A new start time or current time was set while starting.
- setCompositorPending(true);
- return;
- }
- }
-
- notifyStartTime(timelineTime);
-}
-
-void AnimationPlayer::notifyStartTime(double timelineTime)
-{
- if (playing()) {
- ASSERT(std::isnan(m_startTime));
- ASSERT(m_held);
-
- if (m_playbackRate == 0) {
- setStartTimeInternal(timelineTime);
- } else {
- setStartTimeInternal(timelineTime + currentTimeInternal() / -m_playbackRate);
- }
-
- // FIXME: This avoids marking this player as outdated needlessly when a start time
- // is notified, but we should refactor how outdating works to avoid this.
- m_outdated = false;
-
- m_currentTimePending = false;
- }
-}
-
-bool AnimationPlayer::affects(const Element& element, CSSPropertyID property) const
-{
- if (!m_content || !m_content->isAnimation())
- return false;
-
- const Animation* animation = toAnimation(m_content.get());
- return (animation->target() == &element) && animation->affects(PropertyHandle(property));
-}
-
-double AnimationPlayer::calculateStartTime(double currentTime) const
-{
- return m_timeline->effectiveTime() - currentTime / m_playbackRate;
-}
-
-double AnimationPlayer::calculateCurrentTime() const
-{
- if (isNull(m_startTime) || !m_timeline)
- return 0;
- return (m_timeline->effectiveTime() - m_startTime) * m_playbackRate;
-}
-
-void AnimationPlayer::setStartTime(double startTime)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (m_paused || playStateInternal() == Idle)
- return;
- if (startTime == m_startTime)
- return;
-
- m_currentTimePending = false;
- setStartTimeInternal(startTime / 1000);
-}
-
-void AnimationPlayer::setStartTimeInternal(double newStartTime)
-{
- ASSERT(!m_paused);
- ASSERT(std::isfinite(newStartTime));
- ASSERT(newStartTime != m_startTime);
-
- bool hadStartTime = hasStartTime();
- double previousCurrentTime = currentTimeInternal();
- m_startTime = newStartTime;
- if (m_held && m_playbackRate) {
- // If held, the start time would still be derrived from the hold time.
- // Force a new, limited, current time.
- m_held = false;
- double currentTime = calculateCurrentTime();
- if (m_playbackRate > 0 && currentTime > sourceEnd()) {
- currentTime = sourceEnd();
- } else if (m_playbackRate < 0 && currentTime < 0) {
- currentTime = 0;
- }
- setCurrentTimeInternal(currentTime, TimingUpdateOnDemand);
- }
- updateCurrentTimingState(TimingUpdateOnDemand);
- double newCurrentTime = currentTimeInternal();
-
- if (previousCurrentTime != newCurrentTime) {
- setOutdated();
- } else if (!hadStartTime && m_timeline) {
- // Even though this player is not outdated, time to effect change is
- // infinity until start time is set.
- m_timeline->wake();
- }
-}
-
-void AnimationPlayer::setSource(AnimationNode* newSource)
-{
- if (m_content == newSource)
- return;
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand, SetCompositorPendingWithSourceChanged);
-
- double storedCurrentTime = currentTimeInternal();
- if (m_content)
- m_content->detach();
- m_content = newSource;
- if (newSource) {
- // FIXME: This logic needs to be updated once groups are implemented
- if (newSource->player()) {
- newSource->player()->cancel();
- newSource->player()->setSource(0);
- }
- newSource->attach(this);
- setOutdated();
- }
- setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand);
-}
-
-const char* AnimationPlayer::playStateString(AnimationPlayState playState)
-{
- switch (playState) {
- case Idle:
- return "idle";
- case Pending:
- return "pending";
- case Running:
- return "running";
- case Paused:
- return "paused";
- case Finished:
- return "finished";
- default:
- ASSERT_NOT_REACHED();
- return "";
- }
-}
-
-AnimationPlayer::AnimationPlayState AnimationPlayer::playStateInternal() const
-{
- return m_playState;
-}
-
-AnimationPlayer::AnimationPlayState AnimationPlayer::calculatePlayState()
-{
- if (m_playState == Idle)
- return Idle;
- if (m_currentTimePending || (isNull(m_startTime) && !m_paused && m_playbackRate != 0))
- return Pending;
- if (m_paused)
- return Paused;
- if (limited())
- return Finished;
- return Running;
-}
-
-void AnimationPlayer::pause()
-{
- if (m_paused)
- return;
-
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (playing()) {
- m_currentTimePending = true;
- }
- m_paused = true;
- setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
-}
-
-void AnimationPlayer::unpause()
-{
- if (!m_paused)
- return;
-
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- m_currentTimePending = true;
- unpauseInternal();
-}
-
-void AnimationPlayer::unpauseInternal()
-{
- if (!m_paused)
- return;
- m_paused = false;
- setCurrentTimeInternal(currentTimeInternal(), TimingUpdateOnDemand);
-}
-
-void AnimationPlayer::play()
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (!playing())
- m_startTime = nullValue();
-
- if (playStateInternal() == Idle) {
- // We may not go into the pending state, but setting it to something other
- // than Idle here will force an update.
- ASSERT(isNull(m_startTime));
- m_playState = Pending;
- m_held = true;
- m_holdTime = 0;
- }
-
- m_finished = false;
- unpauseInternal();
- if (!m_content)
- return;
- double currentTime = this->currentTimeInternal();
- if (m_playbackRate > 0 && (currentTime < 0 || currentTime >= sourceEnd())) {
- m_startTime = nullValue();
- setCurrentTimeInternal(0, TimingUpdateOnDemand);
- } else if (m_playbackRate < 0 && (currentTime <= 0 || currentTime > sourceEnd())) {
- m_startTime = nullValue();
- setCurrentTimeInternal(sourceEnd(), TimingUpdateOnDemand);
- }
-}
-
-void AnimationPlayer::reverse()
-{
- if (!m_playbackRate) {
- return;
- }
-
- setPlaybackRateInternal(-m_playbackRate);
- play();
-}
-
-void AnimationPlayer::finish(ExceptionState& exceptionState)
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (!m_playbackRate || playStateInternal() == Idle) {
- return;
- }
- if (m_playbackRate > 0 && sourceEnd() == std::numeric_limits<double>::infinity()) {
- exceptionState.throwDOMException(InvalidStateError, "AnimationPlayer has source content whose end time is infinity.");
- return;
- }
-
- double newCurrentTime = m_playbackRate < 0 ? 0 : sourceEnd();
- setCurrentTimeInternal(newCurrentTime, TimingUpdateOnDemand);
- if (!paused()) {
- m_startTime = calculateStartTime(newCurrentTime);
- }
-
- m_currentTimePending = false;
- ASSERT(playStateInternal() != Idle);
- ASSERT(limited());
-}
-
-ScriptPromise AnimationPlayer::finished(ScriptState* scriptState)
-{
- if (!m_finishedPromise) {
- m_finishedPromise = new AnimationPlayerPromise(scriptState->executionContext(), this, AnimationPlayerPromise::Finished);
- if (playStateInternal() == Finished)
- m_finishedPromise->resolve(this);
- }
- return m_finishedPromise->promise(scriptState->world());
-}
-
-ScriptPromise AnimationPlayer::ready(ScriptState* scriptState)
-{
- if (!m_readyPromise) {
- m_readyPromise = new AnimationPlayerPromise(scriptState->executionContext(), this, AnimationPlayerPromise::Ready);
- if (playStateInternal() != Pending)
- m_readyPromise->resolve(this);
- }
- return m_readyPromise->promise(scriptState->world());
-}
-
-const AtomicString& AnimationPlayer::interfaceName() const
-{
- return EventTargetNames::AnimationPlayer;
-}
-
-ExecutionContext* AnimationPlayer::executionContext() const
-{
- return ActiveDOMObject::executionContext();
-}
-
-bool AnimationPlayer::hasPendingActivity() const
-{
- return m_pendingFinishedEvent || (!m_finished && hasEventListeners(EventTypeNames::finish));
-}
-
-void AnimationPlayer::stop()
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- m_finished = true;
- m_pendingFinishedEvent = nullptr;
-}
-
-bool AnimationPlayer::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
-{
- if (m_pendingFinishedEvent == event)
- m_pendingFinishedEvent = nullptr;
- return EventTargetWithInlineData::dispatchEvent(event);
-}
-
-double AnimationPlayer::playbackRate() const
-{
- return m_playbackRate;
-}
-
-void AnimationPlayer::setPlaybackRate(double playbackRate)
-{
- if (playbackRate == m_playbackRate)
- return;
-
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- setPlaybackRateInternal(playbackRate);
-}
-
-void AnimationPlayer::setPlaybackRateInternal(double playbackRate)
-{
- ASSERT(std::isfinite(playbackRate));
- ASSERT(playbackRate != m_playbackRate);
-
- if (!limited() && !paused() && hasStartTime())
- m_currentTimePending = true;
-
- double storedCurrentTime = currentTimeInternal();
- if ((m_playbackRate < 0 && playbackRate >= 0) || (m_playbackRate > 0 && playbackRate <= 0))
- m_finished = false;
-
- m_playbackRate = playbackRate;
- m_startTime = std::numeric_limits<double>::quiet_NaN();
- setCurrentTimeInternal(storedCurrentTime, TimingUpdateOnDemand);
-}
-
-void AnimationPlayer::setOutdated()
-{
- m_outdated = true;
- if (m_timeline)
- m_timeline->setOutdatedAnimationPlayer(this);
-}
-
-bool AnimationPlayer::canStartAnimationOnCompositor() const
-{
- // FIXME: Timeline playback rates should be compositable
- if (m_playbackRate == 0 || (std::isinf(sourceEnd()) && m_playbackRate < 0) || (timeline() && timeline()->playbackRate() != 1))
- return false;
-
- return m_timeline && m_content && m_content->isAnimation() && playing();
-}
-
-bool AnimationPlayer::isCandidateForAnimationOnCompositor() const
-{
- if (!canStartAnimationOnCompositor())
- return false;
-
- return toAnimation(m_content.get())->isCandidateForAnimationOnCompositor(m_playbackRate);
-}
-
-bool AnimationPlayer::maybeStartAnimationOnCompositor()
-{
- if (!canStartAnimationOnCompositor())
- return false;
-
- bool reversed = m_playbackRate < 0;
-
- double startTime = timeline()->zeroTime() + startTimeInternal();
- if (reversed) {
- startTime -= sourceEnd() / fabs(m_playbackRate);
- }
-
- double timeOffset = 0;
- if (std::isnan(startTime)) {
- timeOffset = reversed ? sourceEnd() - currentTimeInternal() : currentTimeInternal();
- timeOffset = timeOffset / fabs(m_playbackRate);
- }
- ASSERT(m_compositorGroup != 0);
- return toAnimation(m_content.get())->maybeStartAnimationOnCompositor(m_compositorGroup, startTime, timeOffset, m_playbackRate);
-}
-
-void AnimationPlayer::setCompositorPending(bool sourceChanged)
-{
- // FIXME: Animation could notify this directly?
- if (!hasActiveAnimationsOnCompositor()) {
- destroyCompositorPlayer();
- m_compositorState.release();
- }
- if (sourceChanged && m_compositorState) {
- m_compositorState->sourceChanged = true;
- }
- if (m_compositorPending || m_isPausedForTesting) {
- return;
- }
-
- if (sourceChanged || !m_compositorState
- || !playing() || m_compositorState->playbackRate != m_playbackRate
- || m_compositorState->startTime != m_startTime) {
- m_compositorPending = true;
- ASSERT(timeline());
- ASSERT(timeline()->document());
- timeline()->document()->compositorPendingAnimations().add(this);
- }
-}
-
-void AnimationPlayer::cancelAnimationOnCompositor()
-{
- if (hasActiveAnimationsOnCompositor())
- toAnimation(m_content.get())->cancelAnimationOnCompositor();
-
- destroyCompositorPlayer();
-}
-
-void AnimationPlayer::restartAnimationOnCompositor()
-{
- if (hasActiveAnimationsOnCompositor())
- toAnimation(m_content.get())->restartAnimationOnCompositor();
-}
-
-void AnimationPlayer::cancelIncompatibleAnimationsOnCompositor()
-{
- if (m_content && m_content->isAnimation())
- toAnimation(m_content.get())->cancelIncompatibleAnimationsOnCompositor();
-}
-
-bool AnimationPlayer::hasActiveAnimationsOnCompositor()
-{
- if (!m_content || !m_content->isAnimation())
- return false;
-
- return toAnimation(m_content.get())->hasActiveAnimationsOnCompositor();
-}
-
-bool AnimationPlayer::update(TimingUpdateReason reason)
-{
- if (!m_timeline)
- return false;
-
- PlayStateUpdateScope updateScope(*this, reason, DoNotSetCompositorPending);
-
- m_outdated = false;
- bool idle = playStateInternal() == Idle;
-
- if (m_content) {
- double inheritedTime = idle || isNull(m_timeline->currentTimeInternal()) ? nullValue() : currentTimeInternal();
- // Special case for end-exclusivity when playing backwards.
- if (inheritedTime == 0 && m_playbackRate < 0)
- inheritedTime = -1;
- m_content->updateInheritedTime(inheritedTime, reason);
- }
-
- if ((idle || limited()) && !m_finished) {
- if (reason == TimingUpdateForAnimationFrame && (idle || hasStartTime())) {
- const AtomicString& eventType = EventTypeNames::finish;
- if (executionContext() && hasEventListeners(eventType)) {
- double eventCurrentTime = currentTimeInternal() * 1000;
- m_pendingFinishedEvent = AnimationPlayerEvent::create(eventType, eventCurrentTime, timeline()->currentTime());
- m_pendingFinishedEvent->setTarget(this);
- m_pendingFinishedEvent->setCurrentTarget(this);
- m_timeline->document()->enqueueAnimationFrameEvent(m_pendingFinishedEvent);
- }
- m_finished = true;
- }
- }
- ASSERT(!m_outdated);
- return !m_finished;
-}
-
-double AnimationPlayer::timeToEffectChange()
-{
- ASSERT(!m_outdated);
- if (m_held || !hasStartTime())
- return std::numeric_limits<double>::infinity();
- if (!m_content)
- return -currentTimeInternal() / m_playbackRate;
- double result = m_playbackRate > 0
- ? m_content->timeToForwardsEffectChange() / m_playbackRate
- : m_content->timeToReverseEffectChange() / -m_playbackRate;
- return !hasActiveAnimationsOnCompositor() && m_content->phase() == AnimationNode::PhaseActive
- ? 0
- : result;
-}
-
-void AnimationPlayer::cancel()
-{
- PlayStateUpdateScope updateScope(*this, TimingUpdateOnDemand);
-
- if (playStateInternal() == Idle)
- return;
-
- m_holdTime = currentTimeInternal();
- m_held = true;
- // TODO
- m_playState = Idle;
- m_startTime = nullValue();
- m_currentTimePending = false;
-
- InspectorInstrumentation::didCancelAnimationPlayer(timeline()->document(), this);
-}
-
-void AnimationPlayer::beginUpdatingState()
-{
- // Nested calls are not allowed!
- ASSERT(!m_stateIsBeingUpdated);
- m_stateIsBeingUpdated = true;
-}
-
-void AnimationPlayer::endUpdatingState()
-{
- ASSERT(m_stateIsBeingUpdated);
- m_stateIsBeingUpdated = false;
-}
-
-void AnimationPlayer::createCompositorPlayer()
-{
- if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() && !m_compositorPlayer && Platform::current()->compositorSupport()) {
- m_compositorPlayer = adoptPtr(Platform::current()->compositorSupport()->createAnimationPlayer());
- ASSERT(m_compositorPlayer);
- m_compositorPlayer->setAnimationDelegate(this);
- attachCompositorTimeline();
- }
-
- attachCompositedLayers();
-}
-
-void AnimationPlayer::destroyCompositorPlayer()
-{
- detachCompositedLayers();
-
- if (m_compositorPlayer) {
- detachCompositorTimeline();
- m_compositorPlayer->setAnimationDelegate(nullptr);
- }
- m_compositorPlayer.clear();
-}
-
-void AnimationPlayer::attachCompositorTimeline()
-{
- if (m_compositorPlayer) {
- WebCompositorAnimationTimeline* timeline = m_timeline ? m_timeline->compositorTimeline() : nullptr;
- if (timeline)
- timeline->playerAttached(*this);
- }
-}
-
-void AnimationPlayer::detachCompositorTimeline()
-{
- if (m_compositorPlayer) {
- WebCompositorAnimationTimeline* timeline = m_timeline ? m_timeline->compositorTimeline() : nullptr;
- if (timeline)
- timeline->playerDestroyed(*this);
- }
-}
-
-void AnimationPlayer::attachCompositedLayers()
-{
- if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled() || !m_compositorPlayer)
- return;
-
- ASSERT(m_content);
- ASSERT(m_content->isAnimation());
-
- if (toAnimation(m_content.get())->canAttachCompositedLayers())
- toAnimation(m_content.get())->attachCompositedLayers();
-}
-
-void AnimationPlayer::detachCompositedLayers()
-{
- if (m_compositorPlayer && m_compositorPlayer->isLayerAttached())
- m_compositorPlayer->detachLayer();
-}
-
-void AnimationPlayer::notifyAnimationStarted(double monotonicTime, int group)
-{
- ASSERT(RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled());
- timeline()->document()->compositorPendingAnimations().notifyCompositorAnimationStarted(monotonicTime, group);
-}
-
-AnimationPlayer::PlayStateUpdateScope::PlayStateUpdateScope(AnimationPlayer& player, TimingUpdateReason reason, CompositorPendingChange compositorPendingChange)
- : m_player(player)
- , m_initialPlayState(m_player->playStateInternal())
- , m_compositorPendingChange(compositorPendingChange)
-{
- m_player->beginUpdatingState();
- m_player->updateCurrentTimingState(reason);
-}
-
-AnimationPlayer::PlayStateUpdateScope::~PlayStateUpdateScope()
-{
- AnimationPlayState oldPlayState = m_initialPlayState;
- AnimationPlayState newPlayState = m_player->calculatePlayState();
-
- m_player->m_playState = newPlayState;
- if (oldPlayState != newPlayState) {
- bool wasActive = oldPlayState == Pending || oldPlayState == Running;
- bool isActive = newPlayState == Pending || newPlayState == Running;
- if (!wasActive && isActive)
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnimationEvent::data(*m_player));
- else if (wasActive && !isActive)
- TRACE_EVENT_NESTABLE_ASYNC_END1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "endData", InspectorAnimationStateEvent::data(*m_player));
- else
- TRACE_EVENT_NESTABLE_ASYNC_INSTANT1("blink.animations," TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Animation", m_player, "data", InspectorAnimationStateEvent::data(*m_player));
- }
-
- // Ordering is important, the ready promise should resolve/reject before
- // the finished promise.
- if (m_player->m_readyPromise && newPlayState != oldPlayState) {
- if (newPlayState == Idle) {
- if (m_player->m_readyPromise->state() == AnimationPlayerPromise::Pending) {
- m_player->m_readyPromise->reject(DOMException::create(AbortError));
- }
- m_player->m_readyPromise->reset();
- m_player->m_readyPromise->resolve(m_player);
- } else if (oldPlayState == Pending) {
- m_player->m_readyPromise->resolve(m_player);
- } else if (newPlayState == Pending) {
- ASSERT(m_player->m_readyPromise->state() != AnimationPlayerPromise::Pending);
- m_player->m_readyPromise->reset();
- }
- }
-
- if (m_player->m_finishedPromise && newPlayState != oldPlayState) {
- if (newPlayState == Idle) {
- if (m_player->m_finishedPromise->state() == AnimationPlayerPromise::Pending) {
- m_player->m_finishedPromise->reject(DOMException::create(AbortError));
- }
- m_player->m_finishedPromise->reset();
- } else if (newPlayState == Finished) {
- m_player->m_finishedPromise->resolve(m_player);
- } else if (oldPlayState == Finished) {
- m_player->m_finishedPromise->reset();
- }
- }
-
- if (oldPlayState != newPlayState && (oldPlayState == Idle || newPlayState == Idle)) {
- m_player->setOutdated();
- }
-
-#if ENABLE(ASSERT)
- // Verify that current time is up to date.
- m_player->currentTimeInternal();
-#endif
-
- switch (m_compositorPendingChange) {
- case SetCompositorPending:
- m_player->setCompositorPending();
- break;
- case SetCompositorPendingWithSourceChanged:
- m_player->setCompositorPending(true);
- break;
- case DoNotSetCompositorPending:
- break;
- default:
- ASSERT_NOT_REACHED();
- break;
- }
- m_player->endUpdatingState();
-
- if (oldPlayState != newPlayState && newPlayState == Running)
- InspectorInstrumentation::didCreateAnimationPlayer(m_player->timeline()->document(), m_player);
-}
-
-bool AnimationPlayer::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
-{
- if (eventType == EventTypeNames::finish)
- UseCounter::count(executionContext(), UseCounter::AnimationPlayerFinishEvent);
- return EventTargetWithInlineData::addEventListener(eventType, listener, useCapture);
-}
-
-void AnimationPlayer::pauseForTesting(double pauseTime)
-{
- RELEASE_ASSERT(!paused());
- setCurrentTimeInternal(pauseTime, TimingUpdateOnDemand);
- if (hasActiveAnimationsOnCompositor())
- toAnimation(m_content.get())->pauseAnimationForTestingOnCompositor(currentTimeInternal());
- m_isPausedForTesting = true;
- pause();
-}
-
-DEFINE_TRACE(AnimationPlayer)
-{
- visitor->trace(m_content);
- visitor->trace(m_timeline);
- visitor->trace(m_pendingFinishedEvent);
- visitor->trace(m_finishedPromise);
- visitor->trace(m_readyPromise);
- EventTargetWithInlineData::trace(visitor);
- ActiveDOMObject::trace(visitor);
-}
-
-} // namespace
diff --git a/third_party/WebKit/Source/core/animation/AnimationPlayer.h b/third_party/WebKit/Source/core/animation/AnimationPlayer.h
deleted file mode 100644
index 784e87f..0000000
--- a/third_party/WebKit/Source/core/animation/AnimationPlayer.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2013 Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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.
- */
-
-#ifndef AnimationPlayer_h
-#define AnimationPlayer_h
-
-#include "bindings/core/v8/ScriptPromise.h"
-#include "bindings/core/v8/ScriptPromiseProperty.h"
-#include "core/CSSPropertyNames.h"
-#include "core/CoreExport.h"
-#include "core/animation/AnimationNode.h"
-#include "core/dom/ActiveDOMObject.h"
-#include "core/dom/DOMException.h"
-#include "core/events/EventTarget.h"
-#include "platform/heap/Handle.h"
-#include "public/platform/WebCompositorAnimationDelegate.h"
-#include "public/platform/WebCompositorAnimationPlayerClient.h"
-#include "wtf/RefPtr.h"
-
-namespace blink {
-
-class AnimationTimeline;
-class Element;
-class ExceptionState;
-class WebCompositorAnimationPlayer;
-
-class CORE_EXPORT AnimationPlayer final
- : public EventTargetWithInlineData
- , public RefCountedWillBeNoBase<AnimationPlayer>
- , public ActiveDOMObject
- , public WebCompositorAnimationDelegate
- , public WebCompositorAnimationPlayerClient {
- DEFINE_WRAPPERTYPEINFO();
- REFCOUNTED_EVENT_TARGET(AnimationPlayer);
- WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AnimationPlayer);
-public:
- enum AnimationPlayState {
- Idle,
- Pending,
- Running,
- Paused,
- Finished
- };
-
- ~AnimationPlayer();
- static PassRefPtrWillBeRawPtr<AnimationPlayer> create(AnimationNode*, AnimationTimeline*);
-
- // Returns whether the player is finished.
- bool update(TimingUpdateReason);
-
- // timeToEffectChange returns:
- // infinity - if this player is no longer in effect
- // 0 - if this player requires an update on the next frame
- // n - if this player requires an update after 'n' units of time
- double timeToEffectChange();
-
- void cancel();
-
- double currentTime(bool& isNull);
- double currentTime();
- void setCurrentTime(double newCurrentTime);
-
- double currentTimeInternal() const;
- double unlimitedCurrentTimeInternal() const;
-
- void setCurrentTimeInternal(double newCurrentTime, TimingUpdateReason = TimingUpdateOnDemand);
- bool paused() const { return m_paused && !m_isPausedForTesting; }
- static const char* playStateString(AnimationPlayState);
- String playState() const { return playStateString(playStateInternal()); }
- AnimationPlayState playStateInternal() const;
-
- void pause();
- void play();
- void reverse();
- void finish(ExceptionState&);
-
- ScriptPromise finished(ScriptState*);
- ScriptPromise ready(ScriptState*);
-
- bool playing() const { return !(playStateInternal() == Idle || limited() || m_paused || m_isPausedForTesting); }
- bool limited() const { return limited(currentTimeInternal()); }
- bool finishedInternal() const { return m_finished; }
-
- DEFINE_ATTRIBUTE_EVENT_LISTENER(finish);
-
- virtual const AtomicString& interfaceName() const override;
- virtual ExecutionContext* executionContext() const override;
- virtual bool hasPendingActivity() const override;
- virtual void stop() override;
- virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>) override;
-
- double playbackRate() const;
- void setPlaybackRate(double);
- const AnimationTimeline* timeline() const { return m_timeline; }
- AnimationTimeline* timeline() { return m_timeline; }
-
-#if !ENABLE(OILPAN)
- void detachFromTimeline();
-#endif
-
- double calculateStartTime(double currentTime) const;
- bool hasStartTime() const { return !isNull(m_startTime); }
- double startTime(bool& isNull) const;
- double startTime() const;
- double startTimeInternal() const { return m_startTime; }
- void setStartTime(double);
- void setStartTimeInternal(double);
-
- const AnimationNode* source() const { return m_content.get(); }
- AnimationNode* source() { return m_content.get(); }
- void setSource(AnimationNode*);
-
- // Pausing via this method is not reflected in the value returned by
- // paused() and must never overlap with pausing via pause().
- void pauseForTesting(double pauseTime);
- // This should only be used for CSS
- void unpause();
-
- void setOutdated();
- bool outdated() { return m_outdated; }
-
- bool canStartAnimationOnCompositor() const;
- bool isCandidateForAnimationOnCompositor() const;
- bool maybeStartAnimationOnCompositor();
- void cancelAnimationOnCompositor();
- void restartAnimationOnCompositor();
- void cancelIncompatibleAnimationsOnCompositor();
- bool hasActiveAnimationsOnCompositor();
- void setCompositorPending(bool sourceChanged = false);
- void notifyCompositorStartTime(double timelineTime);
- void notifyStartTime(double timelineTime);
- // WebCompositorAnimationPlayerClient implementation.
- WebCompositorAnimationPlayer* compositorPlayer() const override { return m_compositorPlayer.get(); }
-
- bool affects(const Element&, CSSPropertyID) const;
-
- void preCommit(int compositorGroup, bool startOnCompositor);
- void postCommit(double timelineTime);
-
- unsigned sequenceNumber() const { return m_sequenceNumber; }
- int compositorGroup() const { return m_compositorGroup; }
-
- static bool hasLowerPriority(const AnimationPlayer* player1, const AnimationPlayer* player2)
- {
- return player1->sequenceNumber() < player2->sequenceNumber();
- }
-
- virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture = false) override;
-
- DECLARE_VIRTUAL_TRACE();
-
-private:
- AnimationPlayer(ExecutionContext*, AnimationTimeline&, AnimationNode*);
-
- double sourceEnd() const;
- bool limited(double currentTime) const;
-
- AnimationPlayState calculatePlayState();
- double calculateCurrentTime() const;
-
- void unpauseInternal();
- void setPlaybackRateInternal(double);
- void updateCurrentTimingState(TimingUpdateReason);
-
- void beginUpdatingState();
- void endUpdatingState();
-
- void createCompositorPlayer();
- void destroyCompositorPlayer();
- void attachCompositorTimeline();
- void detachCompositorTimeline();
- void attachCompositedLayers();
- void detachCompositedLayers();
- // WebCompositorAnimationDelegate implementation.
- void notifyAnimationStarted(double monotonicTime, int group) override;
- void notifyAnimationFinished(double monotonicTime, int group) override { }
-
- AnimationPlayState m_playState;
- double m_playbackRate;
- double m_startTime;
- double m_holdTime;
-
- unsigned m_sequenceNumber;
-
- typedef ScriptPromiseProperty<RawPtrWillBeMember<AnimationPlayer>, RawPtrWillBeMember<AnimationPlayer>, Member<DOMException>> AnimationPlayerPromise;
- PersistentWillBeMember<AnimationPlayerPromise> m_finishedPromise;
- PersistentWillBeMember<AnimationPlayerPromise> m_readyPromise;
-
- RefPtrWillBeMember<AnimationNode> m_content;
- RawPtrWillBeMember<AnimationTimeline> m_timeline;
- // Reflects all pausing, including via pauseForTesting().
- bool m_paused;
- bool m_held;
- bool m_isPausedForTesting;
-
- // This indicates timing information relevant to the player's effect
- // has changed by means other than the ordinary progression of time
- bool m_outdated;
-
- bool m_finished;
- // Holds a 'finished' event queued for asynchronous dispatch via the
- // ScriptedAnimationController. This object remains active until the
- // event is actually dispatched.
- RefPtrWillBeMember<Event> m_pendingFinishedEvent;
-
- enum CompositorAction {
- None,
- Pause,
- Start,
- PauseThenStart
- };
-
- class CompositorState {
- public:
- CompositorState(AnimationPlayer& player)
- : startTime(player.m_startTime)
- , holdTime(player.m_holdTime)
- , playbackRate(player.m_playbackRate)
- , sourceChanged(false)
- , pendingAction(Start)
- { }
- double startTime;
- double holdTime;
- double playbackRate;
- bool sourceChanged;
- CompositorAction pendingAction;
- };
-
- enum CompositorPendingChange {
- SetCompositorPending,
- SetCompositorPendingWithSourceChanged,
- DoNotSetCompositorPending,
- };
-
- class PlayStateUpdateScope {
- STACK_ALLOCATED();
- public:
- PlayStateUpdateScope(AnimationPlayer&, TimingUpdateReason, CompositorPendingChange = SetCompositorPending);
- ~PlayStateUpdateScope();
- private:
- RawPtrWillBeMember<AnimationPlayer> m_player;
- AnimationPlayState m_initialPlayState;
- CompositorPendingChange m_compositorPendingChange;
- };
-
- // This mirrors the known compositor state. It is created when a compositor
- // animation is started. Updated once the start time is known and each time
- // modifications are pushed to the compositor.
- OwnPtr<CompositorState> m_compositorState;
- bool m_compositorPending;
- int m_compositorGroup;
-
- OwnPtr<WebCompositorAnimationPlayer> m_compositorPlayer;
-
- bool m_currentTimePending;
- bool m_stateIsBeingUpdated;
-};
-
-} // namespace blink
-
-#endif // AnimationPlayer_h
diff --git a/third_party/WebKit/Source/core/animation/AnimationPlayerTest.cpp b/third_party/WebKit/Source/core/animation/AnimationPlayerTest.cpp
deleted file mode 100644
index c943bef..0000000
--- a/third_party/WebKit/Source/core/animation/AnimationPlayerTest.cpp
+++ /dev/null
@@ -1,882 +0,0 @@
-/*
- * Copyright (c) 2013, Google 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:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * 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.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "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 THE COPYRIGHT
- * OWNER 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 "core/animation/AnimationPlayer.h"
-
-#include "core/animation/Animation.h"
-#include "core/animation/AnimationClock.h"
-#include "core/animation/AnimationTimeline.h"
-#include "core/animation/ElementAnimations.h"
-#include "core/dom/Document.h"
-#include "core/dom/ExceptionCode.h"
-#include "core/dom/QualifiedName.h"
-#include "platform/weborigin/KURL.h"
-#include <gtest/gtest.h>
-
-using namespace blink;
-
-namespace {
-
-class AnimationAnimationPlayerTest : public ::testing::Test {
-protected:
- virtual void SetUp()
- {
- setUpWithoutStartingTimeline();
- startTimeline();
- }
-
- void setUpWithoutStartingTimeline()
- {
- document = Document::create();
- document->animationClock().resetTimeForTesting();
- timeline = AnimationTimeline::create(document.get());
- player = timeline->play(0);
- player->setStartTime(0);
- player->setSource(makeAnimation().get());
- }
-
- void startTimeline()
- {
- simulateFrame(0);
- }
-
- PassRefPtrWillBeRawPtr<Animation> makeAnimation(double duration = 30, double playbackRate = 1)
- {
- Timing timing;
- timing.iterationDuration = duration;
- timing.playbackRate = playbackRate;
- return Animation::create(0, nullptr, timing);
- }
-
- bool simulateFrame(double time)
- {
- document->animationClock().updateTime(time);
- document->compositorPendingAnimations().update(false);
- // The timeline does not know about our player, so we have to explicitly call update().
- return player->update(TimingUpdateForAnimationFrame);
- }
-
- RefPtrWillBePersistent<Document> document;
- RefPtrWillBePersistent<AnimationTimeline> timeline;
- RefPtrWillBePersistent<AnimationPlayer> player;
- TrackExceptionState exceptionState;
-};
-
-TEST_F(AnimationAnimationPlayerTest, InitialState)
-{
- setUpWithoutStartingTimeline();
- player = timeline->play(0);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_FALSE(player->paused());
- EXPECT_EQ(1, player->playbackRate());
- EXPECT_FALSE(player->hasStartTime());
- EXPECT_TRUE(isNull(player->startTimeInternal()));
-
- startTimeline();
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(0, timeline->currentTimeInternal());
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_FALSE(player->paused());
- EXPECT_EQ(1, player->playbackRate());
- EXPECT_EQ(0, player->startTimeInternal());
- EXPECT_TRUE(player->hasStartTime());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, CurrentTimeDoesNotSetOutdated)
-{
- EXPECT_FALSE(player->outdated());
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_FALSE(player->outdated());
- // FIXME: We should split simulateFrame into a version that doesn't update
- // the player and one that does, as most of the tests don't require update()
- // to be called.
- document->animationClock().updateTime(10);
- EXPECT_EQ(10, player->currentTimeInternal());
- EXPECT_FALSE(player->outdated());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTime)
-{
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- player->setCurrentTimeInternal(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(10, player->currentTimeInternal());
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeNegative)
-{
- player->setCurrentTimeInternal(-10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(-10, player->currentTimeInternal());
- simulateFrame(20);
- EXPECT_EQ(10, player->currentTimeInternal());
-
- player->setPlaybackRate(-2);
- player->setCurrentTimeInternal(-10);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(-10, player->currentTimeInternal());
- simulateFrame(40);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(-10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeNegativeWithoutSimultaneousPlaybackRateChange)
-{
- simulateFrame(20);
- EXPECT_EQ(20, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- player->setPlaybackRate(-1);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(30);
- EXPECT_EQ(20, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- player->setCurrentTime(-10 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimePastContentEnd)
-{
- player->setCurrentTime(50 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(50, player->currentTimeInternal());
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(50, player->currentTimeInternal());
-
- player->setPlaybackRate(-2);
- player->setCurrentTime(50 * 1000);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(50, player->currentTimeInternal());
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- simulateFrame(40);
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeBeforeTimelineStarted)
-{
- setUpWithoutStartingTimeline();
- player->setCurrentTimeInternal(5);
- EXPECT_EQ(5, player->currentTimeInternal());
- startTimeline();
- simulateFrame(10);
- EXPECT_EQ(15, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimePastContentEndBeforeTimelineStarted)
-{
- setUpWithoutStartingTimeline();
- player->setCurrentTime(250 * 1000);
- EXPECT_EQ(250, player->currentTimeInternal());
- startTimeline();
- simulateFrame(10);
- EXPECT_EQ(250, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeMax)
-{
- player->setCurrentTimeInternal(std::numeric_limits<double>::max());
- EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal());
- simulateFrame(100);
- EXPECT_EQ(std::numeric_limits<double>::max(), player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetCurrentTimeSetsStartTime)
-{
- EXPECT_EQ(0, player->startTime());
- player->setCurrentTime(1000);
- EXPECT_EQ(-1000, player->startTime());
- simulateFrame(1);
- EXPECT_EQ(-1000, player->startTime());
- EXPECT_EQ(2000, player->currentTime());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetStartTime)
-{
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(0, player->startTimeInternal());
- EXPECT_EQ(20 * 1000, player->currentTime());
- player->setStartTime(10 * 1000);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(10, player->startTimeInternal());
- EXPECT_EQ(10 * 1000, player->currentTime());
- simulateFrame(30);
- EXPECT_EQ(10, player->startTimeInternal());
- EXPECT_EQ(20 * 1000, player->currentTime());
- player->setStartTime(-20 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetStartTimeLimitsAnimationPlayer)
-{
- player->setStartTime(-50 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(30, player->currentTimeInternal());
- player->setPlaybackRate(-1);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- player->setStartTime(-100 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_TRUE(player->limited());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetStartTimeOnLimitedAnimationPlayer)
-{
- simulateFrame(30);
- player->setStartTime(-10 * 1000);
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_EQ(30, player->currentTimeInternal());
- player->setCurrentTimeInternal(50);
- player->setStartTime(-40 * 1000);
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
- EXPECT_TRUE(player->limited());
-}
-
-TEST_F(AnimationAnimationPlayerTest, StartTimePauseFinish)
-{
- player->pause();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->finish(exceptionState);
- EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->startTime()));
-}
-
-TEST_F(AnimationAnimationPlayerTest, PauseBeatsFinish)
-{
- player->pause();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
- player->finish(exceptionState);
- EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, StartTimeFinishPause)
-{
- player->finish(exceptionState);
- EXPECT_EQ(-30 * 1000, player->startTime());
- player->pause();
- EXPECT_TRUE(std::isnan(player->startTime()));
-}
-
-TEST_F(AnimationAnimationPlayerTest, StartTimeWithZeroPlaybackRate)
-{
- player->setPlaybackRate(0);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->startTime()));
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PausePlay)
-{
- simulateFrame(10);
- player->pause();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_TRUE(player->paused());
- EXPECT_EQ(10, player->currentTimeInternal());
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
- player->play();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_FALSE(player->paused());
- EXPECT_EQ(10, player->currentTimeInternal());
- simulateFrame(30);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PauseBeforeTimelineStarted)
-{
- setUpWithoutStartingTimeline();
- player->pause();
- EXPECT_TRUE(player->paused());
- player->play();
- EXPECT_FALSE(player->paused());
-
- player->pause();
- startTimeline();
- simulateFrame(100);
- EXPECT_TRUE(player->paused());
- EXPECT_EQ(0, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayRewindsToStart)
-{
- player->setCurrentTimeInternal(30);
- player->play();
- EXPECT_EQ(0, player->currentTimeInternal());
-
- player->setCurrentTimeInternal(40);
- player->play();
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-
- player->setCurrentTimeInternal(-10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- player->play();
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayRewindsToEnd)
-{
- player->setPlaybackRate(-1);
- player->play();
- EXPECT_EQ(30, player->currentTimeInternal());
-
- player->setCurrentTimeInternal(40);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- player->play();
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-
- player->setCurrentTimeInternal(-10);
- player->play();
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- simulateFrame(20);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayWithPlaybackRateZeroDoesNotSeek)
-{
- player->setPlaybackRate(0);
- player->play();
- EXPECT_EQ(0, player->currentTimeInternal());
-
- player->setCurrentTimeInternal(40);
- player->play();
- EXPECT_EQ(40, player->currentTimeInternal());
-
- player->setCurrentTimeInternal(-10);
- player->play();
- EXPECT_EQ(-10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayAfterPauseWithPlaybackRateZeroUpdatesPlayState)
-{
- player->pause();
- player->setPlaybackRate(0);
- simulateFrame(1);
- EXPECT_EQ(AnimationPlayer::Paused, player->playStateInternal());
- player->play();
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, Reverse)
-{
- player->setCurrentTimeInternal(10);
- player->pause();
- player->reverse();
- EXPECT_FALSE(player->paused());
- EXPECT_EQ(-1, player->playbackRate());
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseDoesNothingWithPlaybackRateZero)
-{
- player->setCurrentTimeInternal(10);
- player->setPlaybackRate(0);
- player->pause();
- player->reverse();
- EXPECT_TRUE(player->paused());
- EXPECT_EQ(0, player->playbackRate());
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseDoesNotSeekWithNoSource)
-{
- player->setSource(0);
- player->setCurrentTimeInternal(10);
- player->reverse();
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseSeeksToStart)
-{
- player->setCurrentTimeInternal(-10);
- player->setPlaybackRate(-1);
- player->reverse();
- EXPECT_EQ(0, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseSeeksToEnd)
-{
- player->setCurrentTime(40 * 1000);
- player->reverse();
- EXPECT_EQ(30, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseBeyondLimit)
-{
- player->setCurrentTimeInternal(40);
- player->setPlaybackRate(-1);
- player->reverse();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(0, player->currentTimeInternal());
-
- player->setCurrentTimeInternal(-10);
- player->reverse();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(30, player->currentTimeInternal());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, Finish)
-{
- player->finish(exceptionState);
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
-
- player->setPlaybackRate(-1);
- player->finish(exceptionState);
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_EQ(AnimationPlayer::Finished, player->playStateInternal());
-
- EXPECT_FALSE(exceptionState.hadException());
-}
-
-TEST_F(AnimationAnimationPlayerTest, FinishAfterSourceEnd)
-{
- player->setCurrentTime(40 * 1000);
- player->finish(exceptionState);
- EXPECT_EQ(30, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, FinishBeforeStart)
-{
- player->setCurrentTimeInternal(-10);
- player->setPlaybackRate(-1);
- player->finish(exceptionState);
- EXPECT_EQ(0, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, FinishDoesNothingWithPlaybackRateZero)
-{
- player->setCurrentTimeInternal(10);
- player->setPlaybackRate(0);
- player->finish(exceptionState);
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, FinishRaisesException)
-{
- Timing timing;
- timing.iterationDuration = 1;
- timing.iterationCount = std::numeric_limits<double>::infinity();
- player->setSource(Animation::create(0, nullptr, timing).get());
- player->setCurrentTimeInternal(10);
-
- player->finish(exceptionState);
- EXPECT_EQ(10, player->currentTimeInternal());
- EXPECT_TRUE(exceptionState.hadException());
- EXPECT_EQ(InvalidStateError, exceptionState.code());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, LimitingAtSourceEnd)
-{
- simulateFrame(30);
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_TRUE(player->limited());
- simulateFrame(40);
- EXPECT_EQ(30, player->currentTimeInternal());
- EXPECT_FALSE(player->paused());
-}
-
-TEST_F(AnimationAnimationPlayerTest, LimitingAtStart)
-{
- simulateFrame(30);
- player->setPlaybackRate(-2);
- simulateFrame(30);
- simulateFrame(45);
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_TRUE(player->limited());
- simulateFrame(60);
- EXPECT_EQ(0, player->currentTimeInternal());
- EXPECT_FALSE(player->paused());
-}
-
-TEST_F(AnimationAnimationPlayerTest, LimitingWithNoSource)
-{
- player->setSource(0);
- EXPECT_TRUE(player->limited());
- simulateFrame(30);
- EXPECT_EQ(0, player->currentTimeInternal());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRate)
-{
- player->setPlaybackRate(2);
- simulateFrame(0);
- EXPECT_EQ(2, player->playbackRate());
- EXPECT_EQ(0, player->currentTimeInternal());
- simulateFrame(10);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRateBeforeTimelineStarted)
-{
- setUpWithoutStartingTimeline();
- player->setPlaybackRate(2);
- EXPECT_EQ(2, player->playbackRate());
- EXPECT_EQ(0, player->currentTimeInternal());
- startTimeline();
- simulateFrame(10);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRateWhilePaused)
-{
- simulateFrame(10);
- player->pause();
- player->setPlaybackRate(2);
- simulateFrame(20);
- player->play();
- EXPECT_EQ(10, player->currentTimeInternal());
- simulateFrame(20);
- simulateFrame(25);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRateWhileLimited)
-{
- simulateFrame(40);
- EXPECT_EQ(30, player->currentTimeInternal());
- player->setPlaybackRate(2);
- simulateFrame(50);
- EXPECT_EQ(30, player->currentTimeInternal());
- player->setPlaybackRate(-2);
- simulateFrame(50);
- simulateFrame(60);
- EXPECT_FALSE(player->limited());
- EXPECT_EQ(10, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRateZero)
-{
- simulateFrame(0);
- simulateFrame(10);
- player->setPlaybackRate(0);
- simulateFrame(10);
- EXPECT_EQ(10, player->currentTimeInternal());
- simulateFrame(20);
- EXPECT_EQ(10, player->currentTimeInternal());
- player->setCurrentTimeInternal(20);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetPlaybackRateMax)
-{
- player->setPlaybackRate(std::numeric_limits<double>::max());
- simulateFrame(0);
- EXPECT_EQ(std::numeric_limits<double>::max(), player->playbackRate());
- EXPECT_EQ(0, player->currentTimeInternal());
- simulateFrame(1);
- EXPECT_EQ(30, player->currentTimeInternal());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, SetSource)
-{
- player = timeline->play(0);
- player->setStartTime(0);
- RefPtrWillBeRawPtr<AnimationNode> source1 = makeAnimation();
- RefPtrWillBeRawPtr<AnimationNode> source2 = makeAnimation();
- player->setSource(source1.get());
- EXPECT_EQ(source1, player->source());
- EXPECT_EQ(0, player->currentTimeInternal());
- player->setCurrentTimeInternal(15);
- player->setSource(source2.get());
- EXPECT_EQ(15, player->currentTimeInternal());
- EXPECT_EQ(0, source1->player());
- EXPECT_EQ(player.get(), source2->player());
- EXPECT_EQ(source2, player->source());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetSourceLimitsAnimationPlayer)
-{
- player->setCurrentTimeInternal(20);
- player->setSource(makeAnimation(10).get());
- EXPECT_EQ(20, player->currentTimeInternal());
- EXPECT_TRUE(player->limited());
- simulateFrame(10);
- EXPECT_EQ(20, player->currentTimeInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, SetSourceUnlimitsAnimationPlayer)
-{
- player->setCurrentTimeInternal(40);
- player->setSource(makeAnimation(60).get());
- EXPECT_FALSE(player->limited());
- EXPECT_EQ(40, player->currentTimeInternal());
- simulateFrame(10);
- EXPECT_EQ(50, player->currentTimeInternal());
-}
-
-
-TEST_F(AnimationAnimationPlayerTest, EmptyAnimationPlayersDontUpdateEffects)
-{
- player = timeline->play(0);
- player->update(TimingUpdateOnDemand);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-
- simulateFrame(1234);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, AnimationPlayersDisassociateFromSource)
-{
- AnimationNode* animationNode = player->source();
- AnimationPlayer* player2 = timeline->play(animationNode);
- EXPECT_EQ(0, player->source());
- player->setSource(animationNode);
- EXPECT_EQ(0, player2->source());
-}
-
-TEST_F(AnimationAnimationPlayerTest, AnimationPlayersReturnTimeToNextEffect)
-{
- Timing timing;
- timing.startDelay = 1;
- timing.iterationDuration = 1;
- timing.endDelay = 1;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timing);
- player = timeline->play(animation.get());
- player->setStartTime(0);
-
- simulateFrame(0);
- EXPECT_EQ(1, player->timeToEffectChange());
-
- simulateFrame(0.5);
- EXPECT_EQ(0.5, player->timeToEffectChange());
-
- simulateFrame(1);
- EXPECT_EQ(0, player->timeToEffectChange());
-
- simulateFrame(1.5);
- EXPECT_EQ(0, player->timeToEffectChange());
-
- simulateFrame(2);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-
- simulateFrame(3);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-
- player->setCurrentTimeInternal(0);
- simulateFrame(3);
- EXPECT_EQ(1, player->timeToEffectChange());
-
- player->setPlaybackRate(2);
- simulateFrame(3);
- EXPECT_EQ(0.5, player->timeToEffectChange());
-
- player->setPlaybackRate(0);
- player->update(TimingUpdateOnDemand);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-
- player->setCurrentTimeInternal(3);
- player->setPlaybackRate(-1);
- player->update(TimingUpdateOnDemand);
- simulateFrame(3);
- EXPECT_EQ(1, player->timeToEffectChange());
-
- player->setPlaybackRate(-2);
- player->update(TimingUpdateOnDemand);
- simulateFrame(3);
- EXPECT_EQ(0.5, player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenPaused)
-{
- EXPECT_EQ(0, player->timeToEffectChange());
- player->pause();
- player->update(TimingUpdateOnDemand);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStart)
-{
- EXPECT_EQ(0, player->timeToEffectChange());
- player->setCurrentTimeInternal(-8);
- player->setPlaybackRate(2);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- player->update(TimingUpdateOnDemand);
- // This frame will fire the finish event event though no start time has been
- // received from the compositor yet, as cancel() nukes start times.
- simulateFrame(0);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectWhenCancelledBeforeStartReverse)
-{
- EXPECT_EQ(0, player->timeToEffectChange());
- player->setCurrentTimeInternal(9);
- player->setPlaybackRate(-3);
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- player->update(TimingUpdateOnDemand);
- // This frame will fire the finish event event though no start time has been
- // received from the compositor yet, as cancel() nukes start times.
- simulateFrame(0);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, TimeToNextEffectSimpleCancelledBeforeStart)
-{
- EXPECT_EQ(0, player->timeToEffectChange());
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- player->cancel();
- player->update(TimingUpdateOnDemand);
- // This frame will fire the finish event event though no start time has been
- // received from the compositor yet, as cancel() nukes start times.
- simulateFrame(0);
- EXPECT_EQ(std::numeric_limits<double>::infinity(), player->timeToEffectChange());
-}
-
-TEST_F(AnimationAnimationPlayerTest, AttachedAnimationPlayers)
-{
- RefPtrWillBePersistent<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION);
-
- Timing timing;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), nullptr, timing);
- RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->play(animation.get());
- simulateFrame(0);
- timeline->serviceAnimations(TimingUpdateForAnimationFrame);
- EXPECT_EQ(1U, element->elementAnimations()->players().find(player.get())->value);
-
- player.release();
- Heap::collectAllGarbage();
- EXPECT_TRUE(element->elementAnimations()->players().isEmpty());
-}
-
-TEST_F(AnimationAnimationPlayerTest, HasLowerPriority)
-{
- RefPtrWillBeRawPtr<AnimationPlayer> player1 = timeline->play(0);
- RefPtrWillBeRawPtr<AnimationPlayer> player2 = timeline->play(0);
- EXPECT_TRUE(AnimationPlayer::hasLowerPriority(player1.get(), player2.get()));
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayAfterCancel)
-{
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->play();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(0, player->currentTime());
- EXPECT_TRUE(std::isnan(player->startTime()));
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(0, player->currentTime());
- EXPECT_EQ(10 * 1000, player->startTime());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PlayBackwardsAfterCancel)
-{
- player->setPlaybackRate(-1);
- player->setCurrentTime(15 * 1000);
- simulateFrame(0);
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->play();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(30 * 1000, player->currentTime());
- EXPECT_TRUE(std::isnan(player->startTime()));
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(30 * 1000, player->currentTime());
- EXPECT_EQ(40 * 1000, player->startTime());
-}
-
-TEST_F(AnimationAnimationPlayerTest, ReverseAfterCancel)
-{
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->reverse();
- EXPECT_EQ(AnimationPlayer::Pending, player->playStateInternal());
- EXPECT_EQ(30 * 1000, player->currentTime());
- EXPECT_TRUE(std::isnan(player->startTime()));
- simulateFrame(10);
- EXPECT_EQ(AnimationPlayer::Running, player->playStateInternal());
- EXPECT_EQ(30 * 1000, player->currentTime());
- EXPECT_EQ(40 * 1000, player->startTime());
-}
-
-TEST_F(AnimationAnimationPlayerTest, FinishAfterCancel)
-{
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->finish(exceptionState);
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
-}
-
-TEST_F(AnimationAnimationPlayerTest, PauseAfterCancel)
-{
- player->cancel();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
- player->pause();
- EXPECT_EQ(AnimationPlayer::Idle, player->playStateInternal());
- EXPECT_TRUE(std::isnan(player->currentTime()));
- EXPECT_TRUE(std::isnan(player->startTime()));
-}
-
-}
diff --git a/third_party/WebKit/Source/core/animation/AnimationStack.cpp b/third_party/WebKit/Source/core/animation/AnimationStack.cpp
index f144006..607f314 100644
--- a/third_party/WebKit/Source/core/animation/AnimationStack.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationStack.cpp
@@ -74,13 +74,13 @@ AnimationStack::AnimationStack()
bool AnimationStack::hasActiveAnimationsOnCompositor(CSSPropertyID property) const
{
for (const auto& effect : m_effects) {
- if (effect->animation() && effect->animation()->hasActiveAnimationsOnCompositor(property))
+ if (effect->effect() && effect->effect()->hasActiveAnimationsOnCompositor(property))
return true;
}
return false;
}
-ActiveInterpolationMap AnimationStack::activeInterpolations(AnimationStack* animationStack, const WillBeHeapVector<RawPtrWillBeMember<InertAnimation>>* newAnimations, const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>* suppressedAnimationPlayers, Animation::Priority priority, double timelineCurrentTime)
+ActiveInterpolationMap AnimationStack::activeInterpolations(AnimationStack* animationStack, const WillBeHeapVector<RawPtrWillBeMember<InertAnimation>>* newAnimations, const WillBeHeapHashSet<RawPtrWillBeMember<const Animation>>* suppressedAnimations, KeyframeEffect::Priority priority, double timelineCurrentTime)
{
// We don't exactly know when new animations will start, but timelineCurrentTime is a good estimate.
@@ -92,7 +92,7 @@ ActiveInterpolationMap AnimationStack::activeInterpolations(AnimationStack* anim
nonCopyingSort(effects.begin(), effects.end(), compareEffects);
animationStack->removeClearedEffects();
for (const auto& effect : effects) {
- if (effect->priority() != priority || (suppressedAnimationPlayers && effect->animation() && suppressedAnimationPlayers->contains(effect->animation()->player())))
+ if (effect->priority() != priority || (suppressedAnimations && effect->effect() && suppressedAnimations->contains(effect->effect()->animation())))
continue;
copyToActiveInterpolationMap(effect->interpolations(), result);
}
@@ -108,7 +108,7 @@ void AnimationStack::removeClearedEffects()
{
size_t dest = 0;
for (auto& effect : m_effects) {
- if (effect->animation())
+ if (effect->effect())
m_effects[dest++].swap(effect);
}
m_effects.shrink(dest);
@@ -122,17 +122,15 @@ DEFINE_TRACE(AnimationStack)
bool AnimationStack::getAnimatedBoundingBox(FloatBox& box, CSSPropertyID property) const
{
FloatBox originalBox(box);
- for (const auto& effect : m_effects) {
- if (effect->animation() && effect->animation()->affects(PropertyHandle(property))) {
- Animation* anim = effect->animation();
- if (!anim)
- continue;
- const Timing& timing = anim->specifiedTiming();
+ for (const auto& sampledEffect : m_effects) {
+ if (sampledEffect->effect() && sampledEffect->effect()->affects(PropertyHandle(property))) {
+ KeyframeEffect* effect = sampledEffect->effect();
+ const Timing& timing = effect->specifiedTiming();
double startRange = 0;
double endRange = 1;
timing.timingFunction->range(&startRange, &endRange);
FloatBox expandingBox(originalBox);
- if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expandingBox, *anim->effect(), startRange, endRange))
+ if (!CompositorAnimations::instance()->getAnimatedBoundingBox(expandingBox, *effect->effect(), startRange, endRange))
return false;
box.expandTo(expandingBox);
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationStack.h b/third_party/WebKit/Source/core/animation/AnimationStack.h
index 9b93fde..cbd70ed7 100644
--- a/third_party/WebKit/Source/core/animation/AnimationStack.h
+++ b/third_party/WebKit/Source/core/animation/AnimationStack.h
@@ -33,8 +33,9 @@
#include "core/CoreExport.h"
#include "core/animation/Animation.h"
-#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/EffectModel.h"
+#include "core/animation/KeyframeEffect.h"
+#include "core/animation/PropertyHandle.h"
#include "core/animation/SampledEffect.h"
#include "platform/geometry/FloatBox.h"
#include "wtf/HashSet.h"
@@ -55,7 +56,7 @@ public:
void add(PassOwnPtrWillBeRawPtr<SampledEffect> effect) { m_effects.append(effect); }
bool isEmpty() const { return m_effects.isEmpty(); }
bool hasActiveAnimationsOnCompositor(CSSPropertyID) const;
- static ActiveInterpolationMap activeInterpolations(AnimationStack*, const WillBeHeapVector<RawPtrWillBeMember<InertAnimation>>* newAnimations, const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>* suppressedAnimationPlayers, Animation::Priority, double timelineCurrentTime);
+ static ActiveInterpolationMap activeInterpolations(AnimationStack*, const WillBeHeapVector<RawPtrWillBeMember<InertAnimation>>* newAnimations, const WillBeHeapHashSet<RawPtrWillBeMember<const Animation>>* suppressedAnimations, KeyframeEffect::Priority, double timelineCurrentTime);
bool getAnimatedBoundingBox(FloatBox&, CSSPropertyID) const;
DECLARE_TRACE();
diff --git a/third_party/WebKit/Source/core/animation/AnimationStackTest.cpp b/third_party/WebKit/Source/core/animation/AnimationStackTest.cpp
index a2e44e9..cfe0e21 100644
--- a/third_party/WebKit/Source/core/animation/AnimationStackTest.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationStackTest.cpp
@@ -25,12 +25,12 @@ protected:
element = document->createElement("foo", ASSERT_NO_EXCEPTION);
}
- AnimationPlayer* play(Animation* animation, double startTime)
+ Animation* play(KeyframeEffect* effect, double startTime)
{
- AnimationPlayer* player = timeline->play(animation);
- player->setStartTime(startTime * 1000);
- player->update(TimingUpdateOnDemand);
- return player;
+ Animation* animation = timeline->play(effect);
+ animation->setStartTime(startTime * 1000);
+ animation->update(TimingUpdateOnDemand);
+ return animation;
}
void updateTimeline(double time)
@@ -44,7 +44,7 @@ protected:
return element->ensureElementAnimations().defaultStack().m_effects;
}
- PassRefPtrWillBeRawPtr<AnimationEffect> makeAnimationEffect(CSSPropertyID id, PassRefPtrWillBeRawPtr<AnimatableValue> value)
+ PassRefPtrWillBeRawPtr<EffectModel> makeEffectModel(CSSPropertyID id, PassRefPtrWillBeRawPtr<AnimatableValue> value)
{
AnimatableValueKeyframeVector keyframes(2);
keyframes[0] = AnimatableValueKeyframe::create();
@@ -56,19 +56,19 @@ protected:
return AnimatableValueKeyframeEffectModel::create(keyframes);
}
- PassRefPtrWillBeRawPtr<InertAnimation> makeInertAnimation(PassRefPtrWillBeRawPtr<AnimationEffect> effect)
+ PassRefPtrWillBeRawPtr<InertAnimation> makeInertAnimation(PassRefPtrWillBeRawPtr<EffectModel> effect)
{
Timing timing;
timing.fillMode = Timing::FillModeBoth;
return InertAnimation::create(effect, timing, false, 0);
}
- PassRefPtrWillBeRawPtr<Animation> makeAnimation(PassRefPtrWillBeRawPtr<AnimationEffect> effect, double duration = 10)
+ PassRefPtrWillBeRawPtr<KeyframeEffect> makeKeyframeEffect(PassRefPtrWillBeRawPtr<EffectModel> effect, double duration = 10)
{
Timing timing;
timing.fillMode = Timing::FillModeBoth;
timing.iterationDuration = duration;
- return Animation::create(element.get(), effect, timing);
+ return KeyframeEffect::create(element.get(), effect, timing);
}
AnimatableValue* interpolationValue(const ActiveInterpolationMap& activeInterpolations, CSSPropertyID id)
@@ -84,49 +84,49 @@ protected:
TEST_F(AnimationAnimationStackTest, ElementAnimationsSorted)
{
- play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 10);
- play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(2))).get(), 15);
- play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(3))).get(), 5);
- ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0);
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 10);
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(2))).get(), 15);
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3))).get(), 5);
+ ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, KeyframeEffect::DefaultPriority, 0);
EXPECT_EQ(1u, result.size());
EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(AnimatableDouble::create(3).get()));
}
TEST_F(AnimationAnimationStackTest, NewAnimations)
{
- play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 15);
- play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::create(2))).get(), 10);
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 15);
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))).get(), 10);
WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newAnimations;
- RefPtrWillBeRawPtr<InertAnimation> inert1 = makeInertAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(3)));
- RefPtrWillBeRawPtr<InertAnimation> inert2 = makeInertAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::create(4)));
+ RefPtrWillBeRawPtr<InertAnimation> inert1 = makeInertAnimation(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(3)));
+ RefPtrWillBeRawPtr<InertAnimation> inert2 = makeInertAnimation(makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(4)));
newAnimations.append(inert1.get());
newAnimations.append(inert2.get());
- ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), &newAnimations, 0, Animation::DefaultPriority, 10);
+ ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), &newAnimations, 0, KeyframeEffect::DefaultPriority, 10);
EXPECT_EQ(2u, result.size());
EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(AnimatableDouble::create(3).get()));
EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(AnimatableDouble::create(4).get()));
}
-TEST_F(AnimationAnimationStackTest, CancelledAnimationPlayers)
+TEST_F(AnimationAnimationStackTest, CancelledAnimations)
{
- WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAnimationPlayers;
- RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 0);
- cancelledAnimationPlayers.add(player.get());
- play(makeAnimation(makeAnimationEffect(CSSPropertyZIndex, AnimatableDouble::create(2))).get(), 0);
- ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, &cancelledAnimationPlayers, Animation::DefaultPriority, 0);
+ WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> cancelledAnimations;
+ RefPtrWillBeRawPtr<Animation> animation = play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 0);
+ cancelledAnimations.add(animation.get());
+ play(makeKeyframeEffect(makeEffectModel(CSSPropertyZIndex, AnimatableDouble::create(2))).get(), 0);
+ ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, &cancelledAnimations, KeyframeEffect::DefaultPriority, 0);
EXPECT_EQ(1u, result.size());
EXPECT_TRUE(interpolationValue(result, CSSPropertyZIndex)->equals(AnimatableDouble::create(2).get()));
}
TEST_F(AnimationAnimationStackTest, ClearedEffectsRemoved)
{
- RefPtrWillBeRawPtr<AnimationPlayer> player = play(makeAnimation(makeAnimationEffect(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 10);
- ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0);
+ RefPtrWillBeRawPtr<Animation> animation = play(makeKeyframeEffect(makeEffectModel(CSSPropertyFontSize, AnimatableDouble::create(1))).get(), 10);
+ ActiveInterpolationMap result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, KeyframeEffect::DefaultPriority, 0);
EXPECT_EQ(1u, result.size());
EXPECT_TRUE(interpolationValue(result, CSSPropertyFontSize)->equals(AnimatableDouble::create(1).get()));
- player->setSource(0);
- result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, Animation::DefaultPriority, 0);
+ animation->setSource(0);
+ result = AnimationStack::activeInterpolations(&element->elementAnimations()->defaultStack(), 0, 0, KeyframeEffect::DefaultPriority, 0);
EXPECT_EQ(0u, result.size());
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationTest.cpp b/third_party/WebKit/Source/core/animation/AnimationTest.cpp
index d271e83..ff88caa 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTest.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationTest.cpp
@@ -1,464 +1,882 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
+/*
+ * Copyright (c) 2013, Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "core/animation/Animation.h"
-#include "bindings/core/v8/Dictionary.h"
-#include "bindings/core/v8/UnionTypesCore.h"
-#include "bindings/core/v8/V8AnimationTimingProperties.h"
-#include "bindings/core/v8/V8BindingForTesting.h"
#include "core/animation/AnimationClock.h"
-#include "core/animation/AnimationNodeTiming.h"
-#include "core/animation/AnimationTestHelper.h"
#include "core/animation/AnimationTimeline.h"
-#include "core/animation/KeyframeEffectModel.h"
-#include "core/animation/Timing.h"
+#include "core/animation/ElementAnimations.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
-#include "core/testing/DummyPageHolder.h"
+#include "core/dom/QualifiedName.h"
+#include "platform/weborigin/KURL.h"
#include <gtest/gtest.h>
-#include <v8.h>
-namespace blink {
+using namespace blink;
+
+namespace {
class AnimationAnimationTest : public ::testing::Test {
protected:
- AnimationAnimationTest()
- : pageHolder(DummyPageHolder::create())
- , document(pageHolder->document())
- , element(document.createElement("foo", ASSERT_NO_EXCEPTION))
+ virtual void SetUp()
{
- document.animationClock().resetTimeForTesting(document.timeline().zeroTime());
- EXPECT_EQ(0, document.timeline().currentTime());
+ setUpWithoutStartingTimeline();
+ startTimeline();
}
- OwnPtr<DummyPageHolder> pageHolder;
- Document& document;
- RefPtrWillBePersistent<Element> element;
- TrackExceptionState exceptionState;
-};
-
-class AnimationAnimationV8Test : public AnimationAnimationTest {
-protected:
- AnimationAnimationV8Test()
- : m_isolate(v8::Isolate::GetCurrent())
- , m_scope(m_isolate)
+ void setUpWithoutStartingTimeline()
{
+ document = Document::create();
+ document->animationClock().resetTimeForTesting();
+ timeline = AnimationTimeline::create(document.get());
+ animation = timeline->play(0);
+ animation->setStartTime(0);
+ animation->setSource(makeAnimation().get());
}
- template<typename T>
- static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState)
+ void startTimeline()
{
- return Animation::create(element, keyframeDictionaryVector, timingInput, exceptionState);
+ simulateFrame(0);
}
- static PassRefPtrWillBeRawPtr<Animation> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState)
+
+ PassRefPtrWillBeRawPtr<KeyframeEffect> makeAnimation(double duration = 30, double playbackRate = 1)
{
- return Animation::create(element, keyframeDictionaryVector, exceptionState);
+ Timing timing;
+ timing.iterationDuration = duration;
+ timing.playbackRate = playbackRate;
+ return KeyframeEffect::create(0, nullptr, timing);
}
- v8::Isolate* m_isolate;
+ bool simulateFrame(double time)
+ {
+ document->animationClock().updateTime(time);
+ document->compositorPendingAnimations().update(false);
+ // The timeline does not know about our animation, so we have to explicitly call update().
+ return animation->update(TimingUpdateForAnimationFrame);
+ }
-private:
- V8TestingScope m_scope;
+ RefPtrWillBePersistent<Document> document;
+ RefPtrWillBePersistent<AnimationTimeline> timeline;
+ RefPtrWillBePersistent<Animation> animation;
+ TrackExceptionState exceptionState;
};
-TEST_F(AnimationAnimationV8Test, CanCreateAnAnimation)
+TEST_F(AnimationAnimationTest, InitialState)
{
- Vector<Dictionary> jsKeyframes;
- v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
- v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
-
- setV8ObjectPropertyAsString(keyframe1, "width", "100px");
- setV8ObjectPropertyAsString(keyframe1, "offset", "0");
- setV8ObjectPropertyAsString(keyframe1, "easing", "ease-in-out");
- setV8ObjectPropertyAsString(keyframe2, "width", "0px");
- setV8ObjectPropertyAsString(keyframe2, "offset", "1");
- setV8ObjectPropertyAsString(keyframe2, "easing", "cubic-bezier(1, 1, 0.3, 0.3)");
-
- jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
- jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+ setUpWithoutStartingTimeline();
+ animation = timeline->play(0);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->paused());
+ EXPECT_EQ(1, animation->playbackRate());
+ EXPECT_FALSE(animation->hasStartTime());
+ EXPECT_TRUE(isNull(animation->startTimeInternal()));
+
+ startTimeline();
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(0, timeline->currentTimeInternal());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->paused());
+ EXPECT_EQ(1, animation->playbackRate());
+ EXPECT_EQ(0, animation->startTimeInternal());
+ EXPECT_TRUE(animation->hasStartTime());
+}
- String value1;
- ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[0], "width", value1));
- ASSERT_EQ("100px", value1);
- String value2;
- ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[1], "width", value2));
- ASSERT_EQ("0px", value2);
+TEST_F(AnimationAnimationTest, CurrentTimeDoesNotSetOutdated)
+{
+ EXPECT_FALSE(animation->outdated());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->outdated());
+ // FIXME: We should split simulateFrame into a version that doesn't update
+ // the animation and one that does, as most of the tests don't require update()
+ // to be called.
+ document->animationClock().updateTime(10);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->outdated());
+}
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+TEST_F(AnimationAnimationTest, SetCurrentTime)
+{
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ animation->setCurrentTimeInternal(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(20, animation->currentTimeInternal());
+}
- Element* target = animation->target();
- EXPECT_EQ(*element.get(), *target);
+TEST_F(AnimationAnimationTest, SetCurrentTimeNegative)
+{
+ animation->setCurrentTimeInternal(-10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(-10, animation->currentTimeInternal());
+ simulateFrame(20);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+
+ animation->setPlaybackRate(-2);
+ animation->setCurrentTimeInternal(-10);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(-10, animation->currentTimeInternal());
+ simulateFrame(40);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(-10, animation->currentTimeInternal());
+}
- const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect())->getFrames();
+TEST_F(AnimationAnimationTest, SetCurrentTimeNegativeWithoutSimultaneousPlaybackRateChange)
+{
+ simulateFrame(20);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ animation->setPlaybackRate(-1);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(30);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ animation->setCurrentTime(-10 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+}
- EXPECT_EQ(0, keyframes[0]->offset());
- EXPECT_EQ(1, keyframes[1]->offset());
+TEST_F(AnimationAnimationTest, SetCurrentTimePastContentEnd)
+{
+ animation->setCurrentTime(50 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(50, animation->currentTimeInternal());
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(50, animation->currentTimeInternal());
+
+ animation->setPlaybackRate(-2);
+ animation->setCurrentTime(50 * 1000);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(50, animation->currentTimeInternal());
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ simulateFrame(40);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+}
- const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->cssPropertyValue(CSSPropertyWidth);
- const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->cssPropertyValue(CSSPropertyWidth);
- ASSERT(keyframe1Width);
- ASSERT(keyframe2Width);
+TEST_F(AnimationAnimationTest, SetCurrentTimeBeforeTimelineStarted)
+{
+ setUpWithoutStartingTimeline();
+ animation->setCurrentTimeInternal(5);
+ EXPECT_EQ(5, animation->currentTimeInternal());
+ startTimeline();
+ simulateFrame(10);
+ EXPECT_EQ(15, animation->currentTimeInternal());
+}
- EXPECT_EQ("100px", keyframe1Width->cssText());
- EXPECT_EQ("0px", keyframe2Width->cssText());
+TEST_F(AnimationAnimationTest, SetCurrentTimePastContentEndBeforeTimelineStarted)
+{
+ setUpWithoutStartingTimeline();
+ animation->setCurrentTime(250 * 1000);
+ EXPECT_EQ(250, animation->currentTimeInternal());
+ startTimeline();
+ simulateFrame(10);
+ EXPECT_EQ(250, animation->currentTimeInternal());
+}
- EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut)), keyframes[0]->easing());
- EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), keyframes[1]->easing());
+TEST_F(AnimationAnimationTest, SetCurrentTimeMax)
+{
+ animation->setCurrentTimeInternal(std::numeric_limits<double>::max());
+ EXPECT_EQ(std::numeric_limits<double>::max(), animation->currentTimeInternal());
+ simulateFrame(100);
+ EXPECT_EQ(std::numeric_limits<double>::max(), animation->currentTimeInternal());
}
-TEST_F(AnimationAnimationV8Test, CanSetDuration)
+TEST_F(AnimationAnimationTest, SetCurrentTimeSetsStartTime)
{
- Vector<Dictionary, 0> jsKeyframes;
- double duration = 2000;
+ EXPECT_EQ(0, animation->startTime());
+ animation->setCurrentTime(1000);
+ EXPECT_EQ(-1000, animation->startTime());
+ simulateFrame(1);
+ EXPECT_EQ(-1000, animation->startTime());
+ EXPECT_EQ(2000, animation->currentTime());
+}
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, duration, exceptionState);
+TEST_F(AnimationAnimationTest, SetStartTime)
+{
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(0, animation->startTimeInternal());
+ EXPECT_EQ(20 * 1000, animation->currentTime());
+ animation->setStartTime(10 * 1000);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(10, animation->startTimeInternal());
+ EXPECT_EQ(10 * 1000, animation->currentTime());
+ simulateFrame(30);
+ EXPECT_EQ(10, animation->startTimeInternal());
+ EXPECT_EQ(20 * 1000, animation->currentTime());
+ animation->setStartTime(-20 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+}
- EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration);
+TEST_F(AnimationAnimationTest, SetStartTimeLimitsAnimation)
+{
+ animation->setStartTime(-50 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ animation->setPlaybackRate(-1);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ animation->setStartTime(-100 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_TRUE(animation->limited());
}
-TEST_F(AnimationAnimationV8Test, CanOmitSpecifiedDuration)
+TEST_F(AnimationAnimationTest, SetStartTimeOnLimitedAnimation)
{
- Vector<Dictionary, 0> jsKeyframes;
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, exceptionState);
- EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
+ simulateFrame(30);
+ animation->setStartTime(-10 * 1000);
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ animation->setCurrentTimeInternal(50);
+ animation->setStartTime(-40 * 1000);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
+ EXPECT_TRUE(animation->limited());
}
-TEST_F(AnimationAnimationV8Test, NegativeDurationIsAuto)
+TEST_F(AnimationAnimationTest, StartTimePauseFinish)
{
- Vector<Dictionary, 0> jsKeyframes;
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
- EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
+ animation->pause();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->finish(exceptionState);
+ EXPECT_EQ(Animation::Paused, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
}
-TEST_F(AnimationAnimationV8Test, MismatchedKeyframePropertyRaisesException)
+TEST_F(AnimationAnimationTest, PauseBeatsFinish)
{
- Vector<Dictionary> jsKeyframes;
- v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
- v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+ animation->pause();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Paused, animation->playStateInternal());
+ animation->finish(exceptionState);
+ EXPECT_EQ(Animation::Paused, animation->playStateInternal());
+}
- setV8ObjectPropertyAsString(keyframe1, "width", "100px");
- setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+TEST_F(AnimationAnimationTest, StartTimeFinishPause)
+{
+ animation->finish(exceptionState);
+ EXPECT_EQ(-30 * 1000, animation->startTime());
+ animation->pause();
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+}
- // Height property appears only in keyframe2
- setV8ObjectPropertyAsString(keyframe2, "height", "100px");
- setV8ObjectPropertyAsString(keyframe2, "width", "0px");
- setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+TEST_F(AnimationAnimationTest, StartTimeWithZeroPlaybackRate)
+{
+ animation->setPlaybackRate(0);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+}
- jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
- jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+TEST_F(AnimationAnimationTest, PausePlay)
+{
+ simulateFrame(10);
+ animation->pause();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_TRUE(animation->paused());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Paused, animation->playStateInternal());
+ animation->play();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_FALSE(animation->paused());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ simulateFrame(30);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+}
- createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+TEST_F(AnimationAnimationTest, PauseBeforeTimelineStarted)
+{
+ setUpWithoutStartingTimeline();
+ animation->pause();
+ EXPECT_TRUE(animation->paused());
+ animation->play();
+ EXPECT_FALSE(animation->paused());
+
+ animation->pause();
+ startTimeline();
+ simulateFrame(100);
+ EXPECT_TRUE(animation->paused());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+}
- EXPECT_TRUE(exceptionState.hadException());
- EXPECT_EQ(NotSupportedError, exceptionState.code());
+TEST_F(AnimationAnimationTest, PlayRewindsToStart)
+{
+ animation->setCurrentTimeInternal(30);
+ animation->play();
+ EXPECT_EQ(0, animation->currentTimeInternal());
+
+ animation->setCurrentTimeInternal(40);
+ animation->play();
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+
+ animation->setCurrentTimeInternal(-10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ animation->play();
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
}
-TEST_F(AnimationAnimationV8Test, MissingOffsetZeroRaisesException)
+TEST_F(AnimationAnimationTest, PlayRewindsToEnd)
{
- Vector<Dictionary> jsKeyframes;
- v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
- v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+ animation->setPlaybackRate(-1);
+ animation->play();
+ EXPECT_EQ(30, animation->currentTimeInternal());
+
+ animation->setCurrentTimeInternal(40);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ animation->play();
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+
+ animation->setCurrentTimeInternal(-10);
+ animation->play();
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ simulateFrame(20);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+}
- setV8ObjectPropertyAsString(keyframe1, "width", "100px");
- setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
- setV8ObjectPropertyAsString(keyframe2, "width", "0px");
- setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+TEST_F(AnimationAnimationTest, PlayWithPlaybackRateZeroDoesNotSeek)
+{
+ animation->setPlaybackRate(0);
+ animation->play();
+ EXPECT_EQ(0, animation->currentTimeInternal());
- jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
- jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+ animation->setCurrentTimeInternal(40);
+ animation->play();
+ EXPECT_EQ(40, animation->currentTimeInternal());
- createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+ animation->setCurrentTimeInternal(-10);
+ animation->play();
+ EXPECT_EQ(-10, animation->currentTimeInternal());
+}
- EXPECT_TRUE(exceptionState.hadException());
- EXPECT_EQ(NotSupportedError, exceptionState.code());
+TEST_F(AnimationAnimationTest, PlayAfterPauseWithPlaybackRateZeroUpdatesPlayState)
+{
+ animation->pause();
+ animation->setPlaybackRate(0);
+ simulateFrame(1);
+ EXPECT_EQ(Animation::Paused, animation->playStateInternal());
+ animation->play();
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
}
-TEST_F(AnimationAnimationV8Test, MissingOffsetOneRaisesException)
+TEST_F(AnimationAnimationTest, Reverse)
{
- Vector<Dictionary> jsKeyframes;
- v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
- v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+ animation->setCurrentTimeInternal(10);
+ animation->pause();
+ animation->reverse();
+ EXPECT_FALSE(animation->paused());
+ EXPECT_EQ(-1, animation->playbackRate());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+}
- setV8ObjectPropertyAsString(keyframe1, "width", "100px");
- setV8ObjectPropertyAsString(keyframe1, "offset", "0");
- setV8ObjectPropertyAsString(keyframe2, "width", "0px");
- setV8ObjectPropertyAsString(keyframe2, "offset", "0.1");
+TEST_F(AnimationAnimationTest, ReverseDoesNothingWithPlaybackRateZero)
+{
+ animation->setCurrentTimeInternal(10);
+ animation->setPlaybackRate(0);
+ animation->pause();
+ animation->reverse();
+ EXPECT_TRUE(animation->paused());
+ EXPECT_EQ(0, animation->playbackRate());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+}
- jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
- jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+TEST_F(AnimationAnimationTest, ReverseDoesNotSeekWithNoSource)
+{
+ animation->setSource(0);
+ animation->setCurrentTimeInternal(10);
+ animation->reverse();
+ EXPECT_EQ(10, animation->currentTimeInternal());
+}
- createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+TEST_F(AnimationAnimationTest, ReverseSeeksToStart)
+{
+ animation->setCurrentTimeInternal(-10);
+ animation->setPlaybackRate(-1);
+ animation->reverse();
+ EXPECT_EQ(0, animation->currentTimeInternal());
+}
- EXPECT_TRUE(exceptionState.hadException());
- EXPECT_EQ(NotSupportedError, exceptionState.code());
+TEST_F(AnimationAnimationTest, ReverseSeeksToEnd)
+{
+ animation->setCurrentTime(40 * 1000);
+ animation->reverse();
+ EXPECT_EQ(30, animation->currentTimeInternal());
}
-TEST_F(AnimationAnimationV8Test, MissingOffsetZeroAndOneRaisesException)
+TEST_F(AnimationAnimationTest, ReverseBeyondLimit)
{
- Vector<Dictionary> jsKeyframes;
- v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
- v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+ animation->setCurrentTimeInternal(40);
+ animation->setPlaybackRate(-1);
+ animation->reverse();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+
+ animation->setCurrentTimeInternal(-10);
+ animation->reverse();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(30, animation->currentTimeInternal());
+}
- setV8ObjectPropertyAsString(keyframe1, "width", "100px");
- setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
- setV8ObjectPropertyAsString(keyframe2, "width", "0px");
- setV8ObjectPropertyAsString(keyframe2, "offset", "0.2");
- jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
- jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+TEST_F(AnimationAnimationTest, Finish)
+{
+ animation->finish(exceptionState);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
- createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+ animation->setPlaybackRate(-1);
+ animation->finish(exceptionState);
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_EQ(Animation::Finished, animation->playStateInternal());
- EXPECT_TRUE(exceptionState.hadException());
- EXPECT_EQ(NotSupportedError, exceptionState.code());
+ EXPECT_FALSE(exceptionState.hadException());
}
-TEST_F(AnimationAnimationV8Test, SpecifiedGetters)
+TEST_F(AnimationAnimationTest, FinishAfterSourceEnd)
{
- Vector<Dictionary, 0> jsKeyframes;
-
- v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
- setV8ObjectPropertyAsNumber(timingInput, "delay", 2);
- setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5);
- setV8ObjectPropertyAsString(timingInput, "fill", "backwards");
- setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2);
- setV8ObjectPropertyAsNumber(timingInput, "iterations", 10);
- setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2);
- setV8ObjectPropertyAsString(timingInput, "direction", "reverse");
- setV8ObjectPropertyAsString(timingInput, "easing", "step-start");
- AnimationTimingProperties timingInputDictionary;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+ animation->setCurrentTime(40 * 1000);
+ animation->finish(exceptionState);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+}
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
+TEST_F(AnimationAnimationTest, FinishBeforeStart)
+{
+ animation->setCurrentTimeInternal(-10);
+ animation->setPlaybackRate(-1);
+ animation->finish(exceptionState);
+ EXPECT_EQ(0, animation->currentTimeInternal());
+}
- RefPtrWillBeRawPtr<AnimationNodeTiming> specified = animation->timing();
- EXPECT_EQ(2, specified->delay());
- EXPECT_EQ(0.5, specified->endDelay());
- EXPECT_EQ("backwards", specified->fill());
- EXPECT_EQ(2, specified->iterationStart());
- EXPECT_EQ(10, specified->iterations());
- EXPECT_EQ(2, specified->playbackRate());
- EXPECT_EQ("reverse", specified->direction());
- EXPECT_EQ("step-start", specified->easing());
+TEST_F(AnimationAnimationTest, FinishDoesNothingWithPlaybackRateZero)
+{
+ animation->setCurrentTimeInternal(10);
+ animation->setPlaybackRate(0);
+ animation->finish(exceptionState);
+ EXPECT_EQ(10, animation->currentTimeInternal());
}
-TEST_F(AnimationAnimationV8Test, SpecifiedDurationGetter)
+TEST_F(AnimationAnimationTest, FinishRaisesException)
{
- Vector<Dictionary, 0> jsKeyframes;
+ Timing timing;
+ timing.iterationDuration = 1;
+ timing.iterationCount = std::numeric_limits<double>::infinity();
+ animation->setSource(KeyframeEffect::create(0, nullptr, timing).get());
+ animation->setCurrentTimeInternal(10);
- v8::Local<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate);
- setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
- AnimationTimingProperties timingInputDictionaryWithDuration;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInputWithDuration, timingInputDictionaryWithDuration, exceptionState);
+ animation->finish(exceptionState);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(InvalidStateError, exceptionState.code());
+}
- RefPtrWillBeRawPtr<Animation> animationWithDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState);
- RefPtrWillBeRawPtr<AnimationNodeTiming> specifiedWithDuration = animationWithDuration->timing();
- UnrestrictedDoubleOrString duration;
- specifiedWithDuration->duration(duration);
- EXPECT_TRUE(duration.isUnrestrictedDouble());
- EXPECT_EQ(2.5, duration.getAsUnrestrictedDouble());
- EXPECT_FALSE(duration.isString());
+TEST_F(AnimationAnimationTest, LimitingAtSourceEnd)
+{
+ simulateFrame(30);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_TRUE(animation->limited());
+ simulateFrame(40);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->paused());
+}
+TEST_F(AnimationAnimationTest, LimitingAtStart)
+{
+ simulateFrame(30);
+ animation->setPlaybackRate(-2);
+ simulateFrame(30);
+ simulateFrame(45);
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_TRUE(animation->limited());
+ simulateFrame(60);
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ EXPECT_FALSE(animation->paused());
+}
- v8::Local<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate);
- AnimationTimingProperties timingInputDictionaryNoDuration;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInputNoDuration, timingInputDictionaryNoDuration, exceptionState);
+TEST_F(AnimationAnimationTest, LimitingWithNoSource)
+{
+ animation->setSource(0);
+ EXPECT_TRUE(animation->limited());
+ simulateFrame(30);
+ EXPECT_EQ(0, animation->currentTimeInternal());
+}
- RefPtrWillBeRawPtr<Animation> animationNoDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState);
- RefPtrWillBeRawPtr<AnimationNodeTiming> specifiedNoDuration = animationNoDuration->timing();
- UnrestrictedDoubleOrString duration2;
- specifiedNoDuration->duration(duration2);
- EXPECT_FALSE(duration2.isUnrestrictedDouble());
- EXPECT_TRUE(duration2.isString());
- EXPECT_EQ("auto", duration2.getAsString());
+TEST_F(AnimationAnimationTest, SetPlaybackRate)
+{
+ animation->setPlaybackRate(2);
+ simulateFrame(0);
+ EXPECT_EQ(2, animation->playbackRate());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ simulateFrame(10);
+ EXPECT_EQ(20, animation->currentTimeInternal());
}
-TEST_F(AnimationAnimationV8Test, SpecifiedSetters)
+TEST_F(AnimationAnimationTest, SetPlaybackRateBeforeTimelineStarted)
{
- Vector<Dictionary, 0> jsKeyframes;
- v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
- AnimationTimingProperties timingInputDictionary;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
-
- RefPtrWillBeRawPtr<AnimationNodeTiming> specified = animation->timing();
-
- EXPECT_EQ(0, specified->delay());
- specified->setDelay(2);
- EXPECT_EQ(2, specified->delay());
+ setUpWithoutStartingTimeline();
+ animation->setPlaybackRate(2);
+ EXPECT_EQ(2, animation->playbackRate());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ startTimeline();
+ simulateFrame(10);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+}
- EXPECT_EQ(0, specified->endDelay());
- specified->setEndDelay(0.5);
- EXPECT_EQ(0.5, specified->endDelay());
+TEST_F(AnimationAnimationTest, SetPlaybackRateWhilePaused)
+{
+ simulateFrame(10);
+ animation->pause();
+ animation->setPlaybackRate(2);
+ simulateFrame(20);
+ animation->play();
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ simulateFrame(20);
+ simulateFrame(25);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+}
- EXPECT_EQ("auto", specified->fill());
- specified->setFill("backwards");
- EXPECT_EQ("backwards", specified->fill());
+TEST_F(AnimationAnimationTest, SetPlaybackRateWhileLimited)
+{
+ simulateFrame(40);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ animation->setPlaybackRate(2);
+ simulateFrame(50);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+ animation->setPlaybackRate(-2);
+ simulateFrame(50);
+ simulateFrame(60);
+ EXPECT_FALSE(animation->limited());
+ EXPECT_EQ(10, animation->currentTimeInternal());
+}
- EXPECT_EQ(0, specified->iterationStart());
- specified->setIterationStart(2);
- EXPECT_EQ(2, specified->iterationStart());
+TEST_F(AnimationAnimationTest, SetPlaybackRateZero)
+{
+ simulateFrame(0);
+ simulateFrame(10);
+ animation->setPlaybackRate(0);
+ simulateFrame(10);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ simulateFrame(20);
+ EXPECT_EQ(10, animation->currentTimeInternal());
+ animation->setCurrentTimeInternal(20);
+ EXPECT_EQ(20, animation->currentTimeInternal());
+}
- EXPECT_EQ(1, specified->iterations());
- specified->setIterations(10);
- EXPECT_EQ(10, specified->iterations());
+TEST_F(AnimationAnimationTest, SetPlaybackRateMax)
+{
+ animation->setPlaybackRate(std::numeric_limits<double>::max());
+ simulateFrame(0);
+ EXPECT_EQ(std::numeric_limits<double>::max(), animation->playbackRate());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ simulateFrame(1);
+ EXPECT_EQ(30, animation->currentTimeInternal());
+}
- EXPECT_EQ(1, specified->playbackRate());
- specified->setPlaybackRate(2);
- EXPECT_EQ(2, specified->playbackRate());
- EXPECT_EQ("normal", specified->direction());
- specified->setDirection("reverse");
- EXPECT_EQ("reverse", specified->direction());
+TEST_F(AnimationAnimationTest, SetSource)
+{
+ animation = timeline->play(0);
+ animation->setStartTime(0);
+ RefPtrWillBeRawPtr<AnimationEffect> source1 = makeAnimation();
+ RefPtrWillBeRawPtr<AnimationEffect> source2 = makeAnimation();
+ animation->setSource(source1.get());
+ EXPECT_EQ(source1, animation->source());
+ EXPECT_EQ(0, animation->currentTimeInternal());
+ animation->setCurrentTimeInternal(15);
+ animation->setSource(source2.get());
+ EXPECT_EQ(15, animation->currentTimeInternal());
+ EXPECT_EQ(0, source1->animation());
+ EXPECT_EQ(animation.get(), source2->animation());
+ EXPECT_EQ(source2, animation->source());
+}
- EXPECT_EQ("linear", specified->easing());
- specified->setEasing("step-start");
- EXPECT_EQ("step-start", specified->easing());
+TEST_F(AnimationAnimationTest, SetSourceLimitsAnimation)
+{
+ animation->setCurrentTimeInternal(20);
+ animation->setSource(makeAnimation(10).get());
+ EXPECT_EQ(20, animation->currentTimeInternal());
+ EXPECT_TRUE(animation->limited());
+ simulateFrame(10);
+ EXPECT_EQ(20, animation->currentTimeInternal());
}
-TEST_F(AnimationAnimationV8Test, SetSpecifiedDuration)
+TEST_F(AnimationAnimationTest, SetSourceUnlimitsAnimation)
{
- Vector<Dictionary, 0> jsKeyframes;
- v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
- AnimationTimingProperties timingInputDictionary;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
- RefPtrWillBeRawPtr<Animation> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
+ animation->setCurrentTimeInternal(40);
+ animation->setSource(makeAnimation(60).get());
+ EXPECT_FALSE(animation->limited());
+ EXPECT_EQ(40, animation->currentTimeInternal());
+ simulateFrame(10);
+ EXPECT_EQ(50, animation->currentTimeInternal());
+}
- RefPtrWillBeRawPtr<AnimationNodeTiming> specified = animation->timing();
- UnrestrictedDoubleOrString duration;
- specified->duration(duration);
- EXPECT_FALSE(duration.isUnrestrictedDouble());
- EXPECT_TRUE(duration.isString());
- EXPECT_EQ("auto", duration.getAsString());
+TEST_F(AnimationAnimationTest, EmptyAnimationsDontUpdateEffects)
+{
+ animation = timeline->play(0);
+ animation->update(TimingUpdateOnDemand);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
- UnrestrictedDoubleOrString inDuration;
- inDuration.setUnrestrictedDouble(2.5);
- specified->setDuration(inDuration);
- UnrestrictedDoubleOrString duration2;
- specified->duration(duration2);
- EXPECT_TRUE(duration2.isUnrestrictedDouble());
- EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble());
- EXPECT_FALSE(duration2.isString());
+ simulateFrame(1234);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
+}
+
+TEST_F(AnimationAnimationTest, AnimationsDisassociateFromSource)
+{
+ AnimationEffect* animationNode = animation->source();
+ Animation* animation2 = timeline->play(animationNode);
+ EXPECT_EQ(0, animation->source());
+ animation->setSource(animationNode);
+ EXPECT_EQ(0, animation2->source());
}
-TEST_F(AnimationAnimationTest, TimeToEffectChange)
+TEST_F(AnimationAnimationTest, AnimationsReturnTimeToNextEffect)
{
Timing timing;
- timing.iterationDuration = 100;
- timing.startDelay = 100;
- timing.endDelay = 100;
- timing.fillMode = Timing::FillModeNone;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timing);
- RefPtrWillBeRawPtr<AnimationPlayer> player = document.timeline().play(animation.get());
- double inf = std::numeric_limits<double>::infinity();
+ timing.startDelay = 1;
+ timing.iterationDuration = 1;
+ timing.endDelay = 1;
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(0, nullptr, timing);
+ animation = timeline->play(keyframeEffect.get());
+ animation->setStartTime(0);
- EXPECT_EQ(100, animation->timeToForwardsEffectChange());
- EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+ simulateFrame(0);
+ EXPECT_EQ(1, animation->timeToEffectChange());
- player->setCurrentTimeInternal(100);
- EXPECT_EQ(100, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ simulateFrame(0.5);
+ EXPECT_EQ(0.5, animation->timeToEffectChange());
- player->setCurrentTimeInternal(199);
- EXPECT_EQ(1, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ simulateFrame(1);
+ EXPECT_EQ(0, animation->timeToEffectChange());
- player->setCurrentTimeInternal(200);
- // End-exclusive.
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ simulateFrame(1.5);
+ EXPECT_EQ(0, animation->timeToEffectChange());
- player->setCurrentTimeInternal(300);
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(100, animation->timeToReverseEffectChange());
-}
+ simulateFrame(2);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
-TEST_F(AnimationAnimationTest, TimeToEffectChangeWithPlaybackRate)
-{
- Timing timing;
- timing.iterationDuration = 100;
- timing.startDelay = 100;
- timing.endDelay = 100;
- timing.playbackRate = 2;
- timing.fillMode = Timing::FillModeNone;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timing);
- RefPtrWillBeRawPtr<AnimationPlayer> player = document.timeline().play(animation.get());
- double inf = std::numeric_limits<double>::infinity();
+ simulateFrame(3);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
+
+ animation->setCurrentTimeInternal(0);
+ simulateFrame(3);
+ EXPECT_EQ(1, animation->timeToEffectChange());
- EXPECT_EQ(100, animation->timeToForwardsEffectChange());
- EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+ animation->setPlaybackRate(2);
+ simulateFrame(3);
+ EXPECT_EQ(0.5, animation->timeToEffectChange());
- player->setCurrentTimeInternal(100);
- EXPECT_EQ(50, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ animation->setPlaybackRate(0);
+ animation->update(TimingUpdateOnDemand);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
- player->setCurrentTimeInternal(149);
- EXPECT_EQ(1, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ animation->setCurrentTimeInternal(3);
+ animation->setPlaybackRate(-1);
+ animation->update(TimingUpdateOnDemand);
+ simulateFrame(3);
+ EXPECT_EQ(1, animation->timeToEffectChange());
- player->setCurrentTimeInternal(150);
- // End-exclusive.
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+ animation->setPlaybackRate(-2);
+ animation->update(TimingUpdateOnDemand);
+ simulateFrame(3);
+ EXPECT_EQ(0.5, animation->timeToEffectChange());
+}
+
+TEST_F(AnimationAnimationTest, TimeToNextEffectWhenPaused)
+{
+ EXPECT_EQ(0, animation->timeToEffectChange());
+ animation->pause();
+ animation->update(TimingUpdateOnDemand);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
+}
- player->setCurrentTimeInternal(200);
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(50, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, TimeToNextEffectWhenCancelledBeforeStart)
+{
+ EXPECT_EQ(0, animation->timeToEffectChange());
+ animation->setCurrentTimeInternal(-8);
+ animation->setPlaybackRate(2);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ animation->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
+ simulateFrame(0);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
+}
+
+TEST_F(AnimationAnimationTest, TimeToNextEffectWhenCancelledBeforeStartReverse)
+{
+ EXPECT_EQ(0, animation->timeToEffectChange());
+ animation->setCurrentTimeInternal(9);
+ animation->setPlaybackRate(-3);
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ animation->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
+ simulateFrame(0);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
+}
+
+TEST_F(AnimationAnimationTest, TimeToNextEffectSimpleCancelledBeforeStart)
+{
+ EXPECT_EQ(0, animation->timeToEffectChange());
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ animation->cancel();
+ animation->update(TimingUpdateOnDemand);
+ // This frame will fire the finish event event though no start time has been
+ // received from the compositor yet, as cancel() nukes start times.
+ simulateFrame(0);
+ EXPECT_EQ(std::numeric_limits<double>::infinity(), animation->timeToEffectChange());
}
-TEST_F(AnimationAnimationTest, TimeToEffectChangeWithNegativePlaybackRate)
+TEST_F(AnimationAnimationTest, AttachedAnimations)
{
+ RefPtrWillBePersistent<Element> element = document->createElement("foo", ASSERT_NO_EXCEPTION);
+
Timing timing;
- timing.iterationDuration = 100;
- timing.startDelay = 100;
- timing.endDelay = 100;
- timing.playbackRate = -2;
- timing.fillMode = Timing::FillModeNone;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(0, nullptr, timing);
- RefPtrWillBeRawPtr<AnimationPlayer> player = document.timeline().play(animation.get());
- double inf = std::numeric_limits<double>::infinity();
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(element.get(), nullptr, timing);
+ RefPtrWillBeRawPtr<Animation> animation = timeline->play(keyframeEffect.get());
+ simulateFrame(0);
+ timeline->serviceAnimations(TimingUpdateForAnimationFrame);
+ EXPECT_EQ(1U, element->elementAnimations()->animations().find(animation.get())->value);
+
+ animation.release();
+ Heap::collectAllGarbage();
+ EXPECT_TRUE(element->elementAnimations()->animations().isEmpty());
+}
- EXPECT_EQ(100, animation->timeToForwardsEffectChange());
- EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, HasLowerPriority)
+{
+ RefPtrWillBeRawPtr<Animation> animation1 = timeline->play(0);
+ RefPtrWillBeRawPtr<Animation> animation2 = timeline->play(0);
+ EXPECT_TRUE(Animation::hasLowerPriority(animation1.get(), animation2.get()));
+}
- player->setCurrentTimeInternal(100);
- EXPECT_EQ(50, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, PlayAfterCancel)
+{
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->play();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(0, animation->currentTime());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(0, animation->currentTime());
+ EXPECT_EQ(10 * 1000, animation->startTime());
+}
- player->setCurrentTimeInternal(149);
- EXPECT_EQ(1, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, PlayBackwardsAfterCancel)
+{
+ animation->setPlaybackRate(-1);
+ animation->setCurrentTime(15 * 1000);
+ simulateFrame(0);
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->play();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(30 * 1000, animation->currentTime());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(30 * 1000, animation->currentTime());
+ EXPECT_EQ(40 * 1000, animation->startTime());
+}
- player->setCurrentTimeInternal(150);
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(0, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, ReverseAfterCancel)
+{
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->reverse();
+ EXPECT_EQ(Animation::Pending, animation->playStateInternal());
+ EXPECT_EQ(30 * 1000, animation->currentTime());
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ simulateFrame(10);
+ EXPECT_EQ(Animation::Running, animation->playStateInternal());
+ EXPECT_EQ(30 * 1000, animation->currentTime());
+ EXPECT_EQ(40 * 1000, animation->startTime());
+}
- player->setCurrentTimeInternal(200);
- EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
- EXPECT_EQ(50, animation->timeToReverseEffectChange());
+TEST_F(AnimationAnimationTest, FinishAfterCancel)
+{
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->finish(exceptionState);
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
}
-TEST_F(AnimationAnimationTest, ElementDestructorClearsAnimationTarget)
+TEST_F(AnimationAnimationTest, PauseAfterCancel)
{
- // This test expects incorrect behaviour should be removed once Element
- // and Animation are moved to Oilpan. See crbug.com/362404 for context.
- Timing timing;
- timing.iterationDuration = 5;
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(element.get(), nullptr, timing);
- EXPECT_EQ(element.get(), animation->target());
- document.timeline().play(animation.get());
- pageHolder.clear();
- element.clear();
-#if !ENABLE(OILPAN)
- EXPECT_EQ(0, animation->target());
-#endif
-}
-
-} // namespace blink
+ animation->cancel();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+ animation->pause();
+ EXPECT_EQ(Animation::Idle, animation->playStateInternal());
+ EXPECT_TRUE(std::isnan(animation->currentTime()));
+ EXPECT_TRUE(std::isnan(animation->startTime()));
+}
+
+}
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp b/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
index 657ab55..82af9a7 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationTimeline.cpp
@@ -47,9 +47,9 @@ namespace blink {
namespace {
-bool compareAnimationPlayers(const RefPtrWillBeMember<AnimationPlayer>& left, const RefPtrWillBeMember<AnimationPlayer>& right)
+bool compareAnimations(const RefPtrWillBeMember<Animation>& left, const RefPtrWillBeMember<Animation>& right)
{
- return AnimationPlayer::hasLowerPriority(left.get(), right.get());
+ return Animation::hasLowerPriority(left.get(), right.get());
}
}
@@ -85,41 +85,41 @@ AnimationTimeline::AnimationTimeline(Document* document, PassOwnPtrWillBeRawPtr<
AnimationTimeline::~AnimationTimeline()
{
#if !ENABLE(OILPAN)
- for (const auto& player : m_players)
- player->detachFromTimeline();
+ for (const auto& animation : m_animations)
+ animation->detachFromTimeline();
#endif
}
-void AnimationTimeline::playerAttached(AnimationPlayer& player)
+void AnimationTimeline::animationAttached(Animation& animation)
{
- ASSERT(player.timeline() == this);
- ASSERT(!m_players.contains(&player));
- m_players.add(&player);
+ ASSERT(animation.timeline() == this);
+ ASSERT(!m_animations.contains(&animation));
+ m_animations.add(&animation);
}
-AnimationPlayer* AnimationTimeline::play(AnimationNode* child)
+Animation* AnimationTimeline::play(AnimationEffect* child)
{
if (!m_document)
return nullptr;
- RefPtrWillBeRawPtr<AnimationPlayer> player = AnimationPlayer::create(child, this);
- ASSERT(m_players.contains(player.get()));
+ RefPtrWillBeRawPtr<Animation> animation = Animation::create(child, this);
+ ASSERT(m_animations.contains(animation.get()));
- player->play();
- ASSERT(m_playersNeedingUpdate.contains(player));
+ animation->play();
+ ASSERT(m_animationsNeedingUpdate.contains(animation));
- return player.get();
+ return animation.get();
}
-WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> AnimationTimeline::getAnimationPlayers()
+WillBeHeapVector<RefPtrWillBeMember<Animation>> AnimationTimeline::getAnimations()
{
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> animationPlayers;
- for (const auto& player : m_players) {
- if (player->source() && (player->source()->isCurrent() || player->source()->isInEffect()))
- animationPlayers.append(player);
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> animations;
+ for (const auto& animation : m_animations) {
+ if (animation->source() && (animation->source()->isCurrent() || animation->source()->isInEffect()))
+ animations.append(animation);
}
- std::sort(animationPlayers.begin(), animationPlayers.end(), compareAnimationPlayers);
- return animationPlayers;
+ std::sort(animations.begin(), animations.end(), compareAnimations);
+ return animations;
}
void AnimationTimeline::wake()
@@ -135,28 +135,28 @@ void AnimationTimeline::serviceAnimations(TimingUpdateReason reason)
m_timing->cancelWake();
- WillBeHeapVector<RawPtrWillBeMember<AnimationPlayer>> players;
- players.reserveInitialCapacity(m_playersNeedingUpdate.size());
- for (RefPtrWillBeMember<AnimationPlayer> player : m_playersNeedingUpdate)
- players.append(player.get());
+ WillBeHeapVector<RawPtrWillBeMember<Animation>> animations;
+ animations.reserveInitialCapacity(m_animationsNeedingUpdate.size());
+ for (RefPtrWillBeMember<Animation> animation : m_animationsNeedingUpdate)
+ animations.append(animation.get());
- std::sort(players.begin(), players.end(), AnimationPlayer::hasLowerPriority);
+ std::sort(animations.begin(), animations.end(), Animation::hasLowerPriority);
- for (AnimationPlayer* player : players) {
- if (!player->update(reason))
- m_playersNeedingUpdate.remove(player);
+ for (Animation* animation : animations) {
+ if (!animation->update(reason))
+ m_animationsNeedingUpdate.remove(animation);
}
- ASSERT(!hasOutdatedAnimationPlayer());
+ ASSERT(!hasOutdatedAnimation());
}
void AnimationTimeline::scheduleNextService()
{
- ASSERT(!hasOutdatedAnimationPlayer());
+ ASSERT(!hasOutdatedAnimation());
double timeToNextEffect = std::numeric_limits<double>::infinity();
- for (const auto& player : m_playersNeedingUpdate) {
- timeToNextEffect = std::min(timeToNextEffect, player->timeToEffectChange());
+ for (const auto& animation : m_animationsNeedingUpdate) {
+ timeToNextEffect = std::min(timeToNextEffect, animation->timeToEffectChange());
}
if (timeToNextEffect < s_minimumDelay) {
@@ -240,12 +240,12 @@ void AnimationTimeline::setCurrentTimeInternal(double currentTime)
: document()->animationClock().currentTime() - currentTime / m_playbackRate;
m_zeroTimeInitialized = true;
- for (const auto& player : m_players) {
+ for (const auto& animation : m_animations) {
// The Player needs a timing update to pick up a new time.
- player->setOutdated();
+ animation->setOutdated();
// Any corresponding compositor animation will need to be restarted. Marking the
// source changed forces this.
- player->setCompositorPending(true);
+ animation->setCompositorPending(true);
}
}
@@ -257,15 +257,15 @@ double AnimationTimeline::effectiveTime()
void AnimationTimeline::pauseAnimationsForTesting(double pauseTime)
{
- for (const auto& player : m_playersNeedingUpdate)
- player->pauseForTesting(pauseTime);
+ for (const auto& animation : m_animationsNeedingUpdate)
+ animation->pauseForTesting(pauseTime);
serviceAnimations(TimingUpdateOnDemand);
}
-bool AnimationTimeline::hasOutdatedAnimationPlayer() const
+bool AnimationTimeline::hasOutdatedAnimation() const
{
- for (const auto& player : m_playersNeedingUpdate) {
- if (player->outdated())
+ for (const auto& animation : m_animationsNeedingUpdate) {
+ if (animation->outdated())
return true;
}
return false;
@@ -273,13 +273,13 @@ bool AnimationTimeline::hasOutdatedAnimationPlayer() const
bool AnimationTimeline::needsAnimationTimingUpdate()
{
- return m_playersNeedingUpdate.size() && currentTimeInternal() != m_lastCurrentTimeInternal;
+ return m_animationsNeedingUpdate.size() && currentTimeInternal() != m_lastCurrentTimeInternal;
}
-void AnimationTimeline::setOutdatedAnimationPlayer(AnimationPlayer* player)
+void AnimationTimeline::setOutdatedAnimation(Animation* animation)
{
- ASSERT(player->outdated());
- m_playersNeedingUpdate.add(player);
+ ASSERT(animation->outdated());
+ m_animationsNeedingUpdate.add(animation);
if (m_document && m_document->page() && !m_document->page()->animator().isServicingAnimations())
m_timing->serviceOnNextFrame();
}
@@ -295,10 +295,10 @@ void AnimationTimeline::setPlaybackRate(double playbackRate)
: document()->animationClock().currentTime() - currentTime / playbackRate;
m_zeroTimeInitialized = true;
- for (const auto& player : m_players) {
+ for (const auto& animation : m_animations) {
// Corresponding compositor animation may need to be restarted to pick up
// the new playback rate. Marking the source changed forces this.
- player->setCompositorPending(true);
+ animation->setCompositorPending(true);
}
}
@@ -320,8 +320,8 @@ DEFINE_TRACE(AnimationTimeline)
#if ENABLE(OILPAN)
visitor->trace(m_document);
visitor->trace(m_timing);
- visitor->trace(m_playersNeedingUpdate);
- visitor->trace(m_players);
+ visitor->trace(m_animationsNeedingUpdate);
+ visitor->trace(m_animations);
#endif
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimeline.h b/third_party/WebKit/Source/core/animation/AnimationTimeline.h
index cbf51d2..5e24cd2 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimeline.h
+++ b/third_party/WebKit/Source/core/animation/AnimationTimeline.h
@@ -33,8 +33,8 @@
#include "bindings/core/v8/ScriptWrappable.h"
#include "core/CoreExport.h"
-#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/Animation.h"
+#include "core/animation/EffectModel.h"
#include "core/dom/Element.h"
#include "platform/Timer.h"
#include "platform/heap/Handle.h"
@@ -46,7 +46,7 @@
namespace blink {
class Document;
-class AnimationNode;
+class AnimationEffect;
// AnimationTimeline is constructed and owned by Document, and tied to its lifecycle.
class CORE_EXPORT AnimationTimeline : public RefCountedWillBeGarbageCollectedFinalized<AnimationTimeline>, public ScriptWrappable {
@@ -69,19 +69,19 @@ public:
void serviceAnimations(TimingUpdateReason);
void scheduleNextService();
- AnimationPlayer* play(AnimationNode*);
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers();
+ Animation* play(AnimationEffect*);
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> getAnimations();
- void playerAttached(AnimationPlayer&);
+ void animationAttached(Animation&);
#if !ENABLE(OILPAN)
- void playerDestroyed(AnimationPlayer* player)
+ void animationDestroyed(Animation* animation)
{
- ASSERT(m_players.contains(player));
- m_players.remove(player);
+ ASSERT(m_animations.contains(animation));
+ m_animations.remove(animation);
}
#endif
- bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); }
+ bool hasPendingUpdates() const { return !m_animationsNeedingUpdate.isEmpty(); }
double zeroTime();
double currentTime(bool& isNull);
double currentTime();
@@ -92,8 +92,8 @@ public:
double effectiveTime();
void pauseAnimationsForTesting(double);
- void setOutdatedAnimationPlayer(AnimationPlayer*);
- bool hasOutdatedAnimationPlayer() const;
+ void setOutdatedAnimation(Animation*);
+ bool hasOutdatedAnimation() const;
bool needsAnimationTimingUpdate();
void setPlaybackRate(double);
@@ -116,10 +116,10 @@ private:
RawPtrWillBeMember<Document> m_document;
double m_zeroTime;
bool m_zeroTimeInitialized;
- // AnimationPlayers which will be updated on the next frame
+ // Animations which will be updated on the next frame
// i.e. current, in effect, or had timing changed
- WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer>> m_playersNeedingUpdate;
- WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer>> m_players;
+ WillBeHeapHashSet<RefPtrWillBeMember<Animation>> m_animationsNeedingUpdate;
+ WillBeHeapHashSet<RawPtrWillBeWeakMember<Animation>> m_animations;
double m_playbackRate;
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimeline.idl b/third_party/WebKit/Source/core/animation/AnimationTimeline.idl
index cde30e1..81f4238 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimeline.idl
+++ b/third_party/WebKit/Source/core/animation/AnimationTimeline.idl
@@ -13,6 +13,6 @@
] interface AnimationTimeline {
attribute double? currentTime;
attribute double playbackRate;
- AnimationPlayer play(AnimationNode source);
- sequence<AnimationPlayer> getAnimationPlayers();
+ Animation play(AnimationEffectReadOnly source);
+ sequence<Animation> getAnimations();
};
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimelineTest.cpp b/third_party/WebKit/Source/core/animation/AnimationTimelineTest.cpp
index ecb532e..79482a1 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimelineTest.cpp
+++ b/third_party/WebKit/Source/core/animation/AnimationTimelineTest.cpp
@@ -31,9 +31,9 @@
#include "config.h"
#include "core/animation/AnimationTimeline.h"
-#include "core/animation/Animation.h"
#include "core/animation/AnimationClock.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/animation/KeyframeEffectModel.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
@@ -139,14 +139,14 @@ TEST_F(AnimationAnimationTimelineTest, HasStarted)
TEST_F(AnimationAnimationTimelineTest, EmptyKeyframeAnimation)
{
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector());
- RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), effect, timing);
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(element.get(), effect, timing);
- timeline->play(anim.get());
+ timeline->play(keyframeEffect.get());
platformTiming->expectNoMoreActions();
updateClockAndService(0);
EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal());
- EXPECT_FALSE(anim->isInEffect());
+ EXPECT_FALSE(keyframeEffect->isInEffect());
platformTiming->expectNoMoreActions();
updateClockAndService(100);
@@ -157,14 +157,14 @@ TEST_F(AnimationAnimationTimelineTest, EmptyForwardsKeyframeAnimation)
{
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector());
timing.fillMode = Timing::FillModeForwards;
- RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), effect, timing);
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(element.get(), effect, timing);
- timeline->play(anim.get());
+ timeline->play(keyframeEffect.get());
platformTiming->expectNoMoreActions();
updateClockAndService(0);
EXPECT_FLOAT_EQ(0, timeline->currentTimeInternal());
- EXPECT_TRUE(anim->isInEffect());
+ EXPECT_TRUE(keyframeEffect->isInEffect());
platformTiming->expectNoMoreActions();
updateClockAndService(100);
@@ -346,14 +346,14 @@ TEST_F(AnimationAnimationTimelineTest, PauseForTesting)
{
float seekTime = 1;
timing.fillMode = Timing::FillModeForwards;
- RefPtrWillBeRawPtr<Animation> anim1 = Animation::create(element.get(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing);
- RefPtrWillBeRawPtr<Animation> anim2 = Animation::create(element.get(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing);
- AnimationPlayer* player1 = timeline->play(anim1.get());
- AnimationPlayer* player2 = timeline->play(anim2.get());
+ RefPtrWillBeRawPtr<KeyframeEffect> anim1 = KeyframeEffect::create(element.get(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing);
+ RefPtrWillBeRawPtr<KeyframeEffect> anim2 = KeyframeEffect::create(element.get(), AnimatableValueKeyframeEffectModel::create(AnimatableValueKeyframeVector()), timing);
+ Animation* animation1 = timeline->play(anim1.get());
+ Animation* animation2 = timeline->play(anim2.get());
timeline->pauseAnimationsForTesting(seekTime);
- EXPECT_FLOAT_EQ(seekTime, player1->currentTime() / 1000.0);
- EXPECT_FLOAT_EQ(seekTime, player2->currentTime() / 1000.0);
+ EXPECT_FLOAT_EQ(seekTime, animation1->currentTime() / 1000.0);
+ EXPECT_FLOAT_EQ(seekTime, animation2->currentTime() / 1000.0);
}
TEST_F(AnimationAnimationTimelineTest, DelayBeforeAnimationStart)
@@ -361,11 +361,11 @@ TEST_F(AnimationAnimationTimelineTest, DelayBeforeAnimationStart)
timing.iterationDuration = 2;
timing.startDelay = 5;
- RefPtrWillBeRawPtr<Animation> anim = Animation::create(element.get(), nullptr, timing);
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(element.get(), nullptr, timing);
- timeline->play(anim.get());
+ timeline->play(keyframeEffect.get());
- // TODO: Put the player startTime in the future when we add the capability to change player startTime
+ // TODO: Put the animation startTime in the future when we add the capability to change animation startTime
platformTiming->expectDelayedAction(timing.startDelay - minimumDelay());
updateClockAndService(0);
@@ -388,17 +388,17 @@ TEST_F(AnimationAnimationTimelineTest, PlayAfterDocumentDeref)
element = nullptr;
document = nullptr;
- RefPtrWillBeRawPtr<Animation> anim = Animation::create(0, nullptr, timing);
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(0, nullptr, timing);
// Test passes if this does not crash.
- timeline->play(anim.get());
+ timeline->play(keyframeEffect.get());
}
-TEST_F(AnimationAnimationTimelineTest, UseAnimationPlayerAfterTimelineDeref)
+TEST_F(AnimationAnimationTimelineTest, UseAnimationAfterTimelineDeref)
{
- RefPtrWillBeRawPtr<AnimationPlayer> player = timeline->play(0);
+ RefPtrWillBeRawPtr<Animation> animation = timeline->play(0);
timeline.clear();
// Test passes if this does not crash.
- player->setStartTime(0);
+ animation->setStartTime(0);
}
}
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp
index 62eef54..24dd788 100644
--- a/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp
+++ b/third_party/WebKit/Source/core/animation/CompositorAnimations.cpp
@@ -31,7 +31,7 @@
#include "config.h"
#include "core/animation/CompositorAnimations.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
#include "core/animation/AnimationTranslationUtil.h"
#include "core/animation/ElementAnimations.h"
#include "core/animation/CompositorAnimationsImpl.h"
@@ -73,27 +73,27 @@ void getKeyframeValuesForProperty(const KeyframeEffectModelBase* effect, Propert
}
}
-bool considerPlayerAsIncompatible(const AnimationPlayer& player, const AnimationPlayer& playerToAdd)
+bool considerAnimationAsIncompatible(const Animation& animation, const Animation& animationToAdd)
{
- if (&player == &playerToAdd)
+ if (&animation == &animationToAdd)
return false;
- switch (player.playStateInternal()) {
- case AnimationPlayer::Idle:
+ switch (animation.playStateInternal()) {
+ case Animation::Idle:
return false;
- case AnimationPlayer::Pending:
- case AnimationPlayer::Running:
+ case Animation::Pending:
+ case Animation::Running:
return true;
- case AnimationPlayer::Paused:
- case AnimationPlayer::Finished:
- return AnimationPlayer::hasLowerPriority(&playerToAdd, &player);
+ case Animation::Paused:
+ case Animation::Finished:
+ return Animation::hasLowerPriority(&animationToAdd, &animation);
default:
ASSERT_NOT_REACHED();
return true;
}
}
-bool hasIncompatibleAnimations(const Element& targetElement, const AnimationPlayer& playerToAdd, const AnimationEffect& effectToAdd)
+bool hasIncompatibleAnimations(const Element& targetElement, const Animation& animationToAdd, const EffectModel& effectToAdd)
{
const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOpacity));
const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyTransform));
@@ -105,14 +105,14 @@ bool hasIncompatibleAnimations(const Element& targetElement, const AnimationPlay
ElementAnimations* elementAnimations = targetElement.elementAnimations();
ASSERT(elementAnimations);
- for (const auto& entry : elementAnimations->players()) {
- const AnimationPlayer* attachedPlayer = entry.key;
- if (!considerPlayerAsIncompatible(*attachedPlayer, playerToAdd))
+ for (const auto& entry : elementAnimations->animations()) {
+ const Animation* attachedAnimation = entry.key;
+ if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd))
continue;
- if ((affectsOpacity && attachedPlayer->affects(targetElement, CSSPropertyOpacity))
- || (affectsTransform && attachedPlayer->affects(targetElement, CSSPropertyTransform))
- || (affectsFilter && attachedPlayer->affects(targetElement, CSSPropertyWebkitFilter)))
+ if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity))
+ || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform))
+ || (affectsFilter && attachedAnimation->affects(targetElement, CSSPropertyWebkitFilter)))
return true;
}
@@ -125,7 +125,7 @@ CSSPropertyID CompositorAnimations::CompositableProperties[3] = {
CSSPropertyOpacity, CSSPropertyTransform, CSSPropertyWebkitFilter
};
-bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const AnimationEffect& effect, double minValue, double maxValue) const
+bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const EffectModel& effect, double minValue, double maxValue) const
{
const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(effect);
@@ -158,7 +158,7 @@ bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const Animation
return false;
// TODO: Add support for inflating modes other than Replace.
- if (frames[j]->composite() != AnimationEffect::CompositeReplace)
+ if (frames[j]->composite() != EffectModel::CompositeReplace)
return false;
const TimingFunction& timing = frames[j]->easing();
@@ -192,7 +192,7 @@ bool CompositorAnimations::getAnimatedBoundingBox(FloatBox& box, const Animation
// CompositorAnimations public API
// -----------------------------------------------------------------------
-bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& timing, const Element& targetElement, const AnimationPlayer* playerToAdd, const AnimationEffect& effect, double playerPlaybackRate)
+bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& timing, const Element& targetElement, const Animation* animationToAdd, const EffectModel& effect, double animationPlaybackRate)
{
const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(effect);
@@ -208,8 +208,8 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim
ASSERT(keyframes.size() >= 2);
for (const auto& keyframe : keyframes) {
// FIXME: Determine candidacy based on the CSSValue instead of a snapshot AnimatableValue.
- bool isNeutralKeyframe = keyframe->isCSSPropertySpecificKeyframe() && !toCSSPropertySpecificKeyframe(keyframe.get())->value() && keyframe->composite() == AnimationEffect::CompositeAdd;
- if ((keyframe->composite() != AnimationEffect::CompositeReplace && !isNeutralKeyframe) || !keyframe->getAnimatableValue())
+ bool isNeutralKeyframe = keyframe->isCSSPropertySpecificKeyframe() && !toCSSPropertySpecificKeyframe(keyframe.get())->value() && keyframe->composite() == EffectModel::CompositeAdd;
+ if ((keyframe->composite() != EffectModel::CompositeReplace && !isNeutralKeyframe) || !keyframe->getAnimatableValue())
return false;
switch (property.cssProperty()) {
@@ -232,17 +232,17 @@ bool CompositorAnimations::isCandidateForAnimationOnCompositor(const Timing& tim
}
}
- if (playerToAdd && hasIncompatibleAnimations(targetElement, *playerToAdd, effect))
+ if (animationToAdd && hasIncompatibleAnimations(targetElement, *animationToAdd, effect))
return false;
CompositorAnimationsImpl::CompositorTiming out;
- if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, playerPlaybackRate))
+ if (!CompositorAnimationsImpl::convertTimingForCompositor(timing, 0, out, animationPlaybackRate))
return false;
return true;
}
-void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Element& targetElement, const AnimationPlayer& playerToAdd, const AnimationEffect& effectToAdd)
+void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Element& targetElement, const Animation& animationToAdd, const EffectModel& effectToAdd)
{
const bool affectsOpacity = effectToAdd.affects(PropertyHandle(CSSPropertyOpacity));
const bool affectsTransform = effectToAdd.affects(PropertyHandle(CSSPropertyTransform));
@@ -254,15 +254,15 @@ void CompositorAnimations::cancelIncompatibleAnimationsOnCompositor(const Elemen
ElementAnimations* elementAnimations = targetElement.elementAnimations();
ASSERT(elementAnimations);
- for (const auto& entry : elementAnimations->players()) {
- AnimationPlayer* attachedPlayer = entry.key;
- if (!considerPlayerAsIncompatible(*attachedPlayer, playerToAdd))
+ for (const auto& entry : elementAnimations->animations()) {
+ Animation* attachedAnimation = entry.key;
+ if (!considerAnimationAsIncompatible(*attachedAnimation, animationToAdd))
continue;
- if ((affectsOpacity && attachedPlayer->affects(targetElement, CSSPropertyOpacity))
- || (affectsTransform && attachedPlayer->affects(targetElement, CSSPropertyTransform))
- || (affectsFilter && attachedPlayer->affects(targetElement, CSSPropertyWebkitFilter)))
- attachedPlayer->cancelAnimationOnCompositor();
+ if ((affectsOpacity && attachedAnimation->affects(targetElement, CSSPropertyOpacity))
+ || (affectsTransform && attachedAnimation->affects(targetElement, CSSPropertyTransform))
+ || (affectsFilter && attachedAnimation->affects(targetElement, CSSPropertyWebkitFilter)))
+ attachedAnimation->cancelAnimationOnCompositor();
}
}
@@ -271,10 +271,10 @@ bool CompositorAnimations::canStartAnimationOnCompositor(const Element& element)
return element.layoutObject() && element.layoutObject()->compositingState() == PaintsIntoOwnBacking;
}
-bool CompositorAnimations::startAnimationOnCompositor(const Element& element, int group, double startTime, double timeOffset, const Timing& timing, const AnimationPlayer& player, const AnimationEffect& effect, Vector<int>& startedAnimationIds, double playerPlaybackRate)
+bool CompositorAnimations::startAnimationOnCompositor(const Element& element, int group, double startTime, double timeOffset, const Timing& timing, const Animation& animation, const EffectModel& effect, Vector<int>& startedAnimationIds, double animationPlaybackRate)
{
ASSERT(startedAnimationIds.isEmpty());
- ASSERT(isCandidateForAnimationOnCompositor(timing, element, &player, effect, playerPlaybackRate));
+ ASSERT(isCandidateForAnimationOnCompositor(timing, element, &animation, effect, animationPlaybackRate));
ASSERT(canStartAnimationOnCompositor(element));
const KeyframeEffectModelBase& keyframeEffect = toKeyframeEffectModelBase(effect);
@@ -283,18 +283,18 @@ bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in
ASSERT(layer);
Vector<OwnPtr<WebCompositorAnimation>> animations;
- CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, playerPlaybackRate);
+ CompositorAnimationsImpl::getAnimationOnCompositor(timing, group, startTime, timeOffset, keyframeEffect, animations, animationPlaybackRate);
ASSERT(!animations.isEmpty());
- for (auto& animation : animations) {
- int id = animation->id();
+ for (auto& compositorAnimation : animations) {
+ int id = compositorAnimation->id();
if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
- WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer();
+ WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
ASSERT(compositorPlayer);
- compositorPlayer->addAnimation(animation.leakPtr());
- } else if (!layer->compositedDeprecatedPaintLayerMapping()->mainGraphicsLayer()->addAnimation(animation.release())) {
+ compositorPlayer->addAnimation(compositorAnimation.leakPtr());
+ } else if (!layer->compositedDeprecatedPaintLayerMapping()->mainGraphicsLayer()->addAnimation(compositorAnimation.release())) {
// FIXME: We should know ahead of time whether these animations can be started.
for (int startedAnimationId : startedAnimationIds)
- cancelAnimationOnCompositor(element, player, startedAnimationId);
+ cancelAnimationOnCompositor(element, animation, startedAnimationId);
startedAnimationIds.clear();
return false;
}
@@ -304,18 +304,18 @@ bool CompositorAnimations::startAnimationOnCompositor(const Element& element, in
return true;
}
-void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, const AnimationPlayer& player, int id)
+void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, const Animation& animation, int id)
{
if (!canStartAnimationOnCompositor(element)) {
// When an element is being detached, we cancel any associated
- // AnimationPlayers for CSS animations. But by the time we get
+ // Animations for CSS animations. But by the time we get
// here the mapping will have been removed.
// FIXME: Defer remove/pause operations until after the
// compositing update.
return;
}
if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
- WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer();
+ WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
ASSERT(compositorPlayer);
compositorPlayer->removeAnimation(id);
} else {
@@ -323,7 +323,7 @@ void CompositorAnimations::cancelAnimationOnCompositor(const Element& element, c
}
}
-void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& element, const AnimationPlayer& player, int id, double pauseTime)
+void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& element, const Animation& animation, int id, double pauseTime)
{
// FIXME: canStartAnimationOnCompositor queries compositingState, which is not necessarily up to date.
// https://code.google.com/p/chromium/issues/detail?id=339847
@@ -334,7 +334,7 @@ void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
return;
}
if (RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled()) {
- WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer();
+ WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
ASSERT(compositorPlayer);
compositorPlayer->pauseAnimation(id, pauseTime);
} else {
@@ -342,12 +342,12 @@ void CompositorAnimations::pauseAnimationForTestingOnCompositor(const Element& e
}
}
-bool CompositorAnimations::canAttachCompositedLayers(const Element& element, const AnimationPlayer& player)
+bool CompositorAnimations::canAttachCompositedLayers(const Element& element, const Animation& animation)
{
if (!RuntimeEnabledFeatures::compositorAnimationTimelinesEnabled())
return false;
- if (!player.compositorPlayer())
+ if (!animation.compositorPlayer())
return false;
if (!element.layoutObject() || !element.layoutObject()->isBoxModelObject())
@@ -366,14 +366,14 @@ bool CompositorAnimations::canAttachCompositedLayers(const Element& element, con
return true;
}
-void CompositorAnimations::attachCompositedLayers(const Element& element, const AnimationPlayer& player)
+void CompositorAnimations::attachCompositedLayers(const Element& element, const Animation& animation)
{
ASSERT(element.layoutObject());
DeprecatedPaintLayer* layer = toLayoutBoxModelObject(element.layoutObject())->layer();
ASSERT(layer);
- WebCompositorAnimationPlayer* compositorPlayer = player.compositorPlayer();
+ WebCompositorAnimationPlayer* compositorPlayer = animation.compositorPlayer();
ASSERT(compositorPlayer);
ASSERT(layer->compositedDeprecatedPaintLayerMapping());
@@ -384,7 +384,7 @@ void CompositorAnimations::attachCompositedLayers(const Element& element, const
// CompositorAnimationsImpl
// -----------------------------------------------------------------------
-bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, double timeOffset, CompositorTiming& out, double playerPlaybackRate)
+bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing, double timeOffset, CompositorTiming& out, double animationPlaybackRate)
{
timing.assertValid();
@@ -404,8 +404,8 @@ bool CompositorAnimationsImpl::convertTimingForCompositor(const Timing& timing,
out.scaledDuration = timing.iterationDuration;
out.direction = timing.direction;
// Compositor's time offset is positive for seeking into the animation.
- out.scaledTimeOffset = -timing.startDelay / playerPlaybackRate + timeOffset;
- out.playbackRate = timing.playbackRate * playerPlaybackRate;
+ out.scaledTimeOffset = -timing.startDelay / animationPlaybackRate + timeOffset;
+ out.playbackRate = timing.playbackRate * animationPlaybackRate;
out.fillMode = timing.fillMode == Timing::FillModeAuto ? Timing::FillModeNone : timing.fillMode;
out.iterationStart = timing.iterationStart;
out.assertValid();
@@ -597,11 +597,11 @@ void CompositorAnimationsImpl::addKeyframesToCurve(WebCompositorAnimationCurve&
}
}
-void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, int group, double startTime, double timeOffset, const KeyframeEffectModelBase& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double playerPlaybackRate)
+void CompositorAnimationsImpl::getAnimationOnCompositor(const Timing& timing, int group, double startTime, double timeOffset, const KeyframeEffectModelBase& effect, Vector<OwnPtr<WebCompositorAnimation>>& animations, double animationPlaybackRate)
{
ASSERT(animations.isEmpty());
CompositorTiming compositorTiming;
- bool timingValid = convertTimingForCompositor(timing, timeOffset, compositorTiming, playerPlaybackRate);
+ bool timingValid = convertTimingForCompositor(timing, timeOffset, compositorTiming, animationPlaybackRate);
ASSERT_UNUSED(timingValid, timingValid);
PropertyHandleSet properties = effect.properties();
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimations.h b/third_party/WebKit/Source/core/animation/CompositorAnimations.h
index 06e5fae..0ba57ee 100644
--- a/third_party/WebKit/Source/core/animation/CompositorAnimations.h
+++ b/third_party/WebKit/Source/core/animation/CompositorAnimations.h
@@ -32,14 +32,14 @@
#define CompositorAnimations_h
#include "core/CoreExport.h"
-#include "core/animation/AnimationEffect.h"
+#include "core/animation/EffectModel.h"
#include "core/animation/Timing.h"
#include "platform/animation/TimingFunction.h"
#include "wtf/Vector.h"
namespace blink {
-class AnimationPlayer;
+class Animation;
class Element;
class FloatBox;
@@ -50,18 +50,18 @@ public:
static bool isCompositableProperty(CSSPropertyID property) { return property == CSSPropertyOpacity || property == CSSPropertyTransform || property == CSSPropertyWebkitFilter; }
static CSSPropertyID CompositableProperties[3];
- virtual bool isCandidateForAnimationOnCompositor(const Timing&, const Element&, const AnimationPlayer*, const AnimationEffect&, double playerPlaybackRate);
- virtual void cancelIncompatibleAnimationsOnCompositor(const Element&, const AnimationPlayer&, const AnimationEffect&);
+ virtual bool isCandidateForAnimationOnCompositor(const Timing&, const Element&, const Animation*, const EffectModel&, double animationPlaybackRate);
+ virtual void cancelIncompatibleAnimationsOnCompositor(const Element&, const Animation&, const EffectModel&);
virtual bool canStartAnimationOnCompositor(const Element&);
// FIXME: This should return void. We should know ahead of time whether these animations can be started.
- virtual bool startAnimationOnCompositor(const Element&, int group, double startTime, double timeOffset, const Timing&, const AnimationPlayer&, const AnimationEffect&, Vector<int>& startedAnimationIds, double playerPlaybackRate);
- virtual void cancelAnimationOnCompositor(const Element&, const AnimationPlayer&, int id);
- virtual void pauseAnimationForTestingOnCompositor(const Element&, const AnimationPlayer&, int id, double pauseTime);
+ virtual bool startAnimationOnCompositor(const Element&, int group, double startTime, double timeOffset, const Timing&, const Animation&, const EffectModel&, Vector<int>& startedAnimationIds, double animationPlaybackRate);
+ virtual void cancelAnimationOnCompositor(const Element&, const Animation&, int id);
+ virtual void pauseAnimationForTestingOnCompositor(const Element&, const Animation&, int id, double pauseTime);
- virtual bool canAttachCompositedLayers(const Element&, const AnimationPlayer&);
- virtual void attachCompositedLayers(const Element&, const AnimationPlayer&);
+ virtual bool canAttachCompositedLayers(const Element&, const Animation&);
+ virtual void attachCompositedLayers(const Element&, const Animation&);
- virtual bool getAnimatedBoundingBox(FloatBox&, const AnimationEffect&, double minValue, double maxValue) const;
+ virtual bool getAnimatedBoundingBox(FloatBox&, const EffectModel&, double minValue, double maxValue) const;
protected:
CompositorAnimations() { }
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h b/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h
index ae6c6cf..272d582 100644
--- a/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h
+++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsImpl.h
@@ -29,7 +29,7 @@
*/
#include "core/CoreExport.h"
-#include "core/animation/AnimationEffect.h"
+#include "core/animation/EffectModel.h"
#include "core/animation/KeyframeEffectModel.h"
#include "core/animation/Timing.h"
#include "platform/animation/TimingFunction.h"
@@ -60,9 +60,9 @@ private:
double iterationStart;
};
- static bool convertTimingForCompositor(const Timing&, double timeOffset, CompositorTiming& out, double playerPlaybackRate);
+ static bool convertTimingForCompositor(const Timing&, double timeOffset, CompositorTiming& out, double animationPlaybackRate);
- static void getAnimationOnCompositor(const Timing&, int group, double startTime, double timeOffset, const KeyframeEffectModelBase&, Vector<OwnPtr<WebCompositorAnimation>>& animations, double playerPlaybackRate);
+ static void getAnimationOnCompositor(const Timing&, int group, double startTime, double timeOffset, const KeyframeEffectModelBase&, Vector<OwnPtr<WebCompositorAnimation>>& animations, double animationPlaybackRate);
static void addKeyframesToCurve(WebCompositorAnimationCurve&, const AnimatableValuePropertySpecificKeyframeVector&, const Timing&);
diff --git a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
index fada242..7d4cfa4 100644
--- a/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
+++ b/third_party/WebKit/Source/core/animation/CompositorAnimationsTest.cpp
@@ -33,11 +33,11 @@
#include "core/animation/CompositorAnimations.h"
#include "core/animation/Animation.h"
-#include "core/animation/AnimationPlayer.h"
#include "core/animation/AnimationTimeline.h"
-#include "core/animation/ElementAnimations.h"
#include "core/animation/CompositorAnimationsImpl.h"
#include "core/animation/CompositorAnimationsTestHelper.h"
+#include "core/animation/ElementAnimations.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/animation/animatable/AnimatableDouble.h"
#include "core/animation/animatable/AnimatableFilterOperations.h"
#include "core/animation/animatable/AnimatableTransform.h"
@@ -118,7 +118,7 @@ public:
{
return CompositorAnimationsImpl::convertTimingForCompositor(t, 0, out, 1);
}
- bool isCandidateForAnimationOnCompositor(const Timing& timing, const AnimationEffect& effect)
+ bool isCandidateForAnimationOnCompositor(const Timing& timing, const EffectModel& effect)
{
return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(timing, *m_element.get(), nullptr, effect, 1);
}
@@ -130,7 +130,7 @@ public:
{
return CompositorAnimationsImpl::getAnimationOnCompositor(timing, 0, std::numeric_limits<double>::quiet_NaN(), 0, effect, animations, playerPlaybackRate);
}
- bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect, double minValue, double maxValue)
+ bool getAnimationBounds(FloatBox& boundingBox, const EffectModel& effect, double minValue, double maxValue)
{
return CompositorAnimations::instance()->getAnimatedBoundingBox(boundingBox, effect, minValue, maxValue);
}
@@ -167,13 +167,13 @@ public:
{
RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframe = AnimatableValueKeyframe::create();
keyframe->setPropertyValue(id, value);
- keyframe->setComposite(AnimationEffect::CompositeReplace);
+ keyframe->setComposite(EffectModel::CompositeReplace);
keyframe->setOffset(offset);
keyframe->setEasing(LinearTimingFunction::shared());
return keyframe;
}
- PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createDefaultKeyframe(CSSPropertyID id, AnimationEffect::CompositeOperation op, double offset = 0)
+ PassRefPtrWillBeRawPtr<AnimatableValueKeyframe> createDefaultKeyframe(CSSPropertyID id, EffectModel::CompositeOperation op, double offset = 0)
{
RefPtrWillBeRawPtr<AnimatableValue> value = nullptr;
if (id == CSSPropertyTransform)
@@ -281,11 +281,11 @@ private:
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKeyframeMultipleCSSProperties)
{
- RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace);
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeGoodMultiple = createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace);
keyframeGoodMultiple->setPropertyValue(CSSPropertyTransform, AnimatableTransform::create(TransformOperations()).get());
EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMultiple.get()));
- RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDefaultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace);
+ RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace);
keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble::create(10.0).get());
EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMultipleID.get()));
}
@@ -311,26 +311,26 @@ TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKeyframeEffectModelMultipleFramesOkay)
{
AnimatableValueKeyframeVector framesSame;
- framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 1.0).get());
+ framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 1.0).get());
EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame).get()));
AnimatableValueKeyframeVector framesMixed;
- framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, AnimationEffect::CompositeReplace, 1.0).get());
+ framesMixed.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ framesMixed.append(createDefaultKeyframe(CSSPropertyTransform, EffectModel::CompositeReplace, 1.0).get());
EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKeyframeEffectModel::create(framesMixed).get()));
}
TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKeyframeEffectModel)
{
AnimatableValueKeyframeVector framesSame;
- framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace, 0.0).get());
- framesSame.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace, 1.0).get());
+ framesSame.append(createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace, 0.0).get());
+ framesSame.append(createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace, 1.0).get());
EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKeyframeEffectModel::create(framesSame).get()));
AnimatableValueKeyframeVector framesMixedProperties;
- framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace, 1.0).get());
+ framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, EffectModel::CompositeReplace, 1.0).get());
EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKeyframeEffectModel::create(framesMixedProperties).get()));
}
@@ -607,13 +607,13 @@ TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor)
Timing linearTiming(createCompositableTiming());
AnimatableValueKeyframeVector basicFramesVector;
- basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 1.0).get());
+ basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ basicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 1.0).get());
AnimatableValueKeyframeVector nonBasicFramesVector;
- nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.5).get());
- nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 1.0).get());
+ nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.5).get());
+ nonBasicFramesVector.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 1.0).get());
basicFramesVector[0]->setEasing(m_linearTimingFunction.get());
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> basicFrames = AnimatableValueKeyframeEffectModel::create(basicFramesVector).get();
@@ -634,7 +634,7 @@ TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositor)
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -680,7 +680,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimation)
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -728,7 +728,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration)
TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationLinear)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25),
@@ -754,7 +754,7 @@ TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0), WebCompositorAnimationCurve::TimingFunctionTypeLinear));
usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)));
- // Animation is created
+ // KeyframeEffect is created
WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(WebCompositorAnimation::TargetPropertyOpacity);
ExpectationSet usesMockAnimation;
@@ -783,7 +783,7 @@ TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -833,7 +833,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimationChained)
{
- // Animation to convert
+ // KeyframeEffect to convert
AnimatableValueKeyframeVector frames;
frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0));
frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25));
@@ -864,7 +864,7 @@ TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 20.0), 1.0, 2.0, 3.0, 4.0));
usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(2.0, 5.0)));
- // Animation is created
+ // KeyframeEffect is created
WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMock(WebCompositorAnimation::TargetPropertyOpacity);
ExpectationSet usesMockAnimation;
@@ -895,7 +895,7 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation)
{
RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFunction::create(0.0, 0.0, 0.0, 1.0);
- // Animation to convert
+ // KeyframeEffect to convert
AnimatableValueKeyframeVector frames;
frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0));
frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.0).get(), 0.25));
@@ -954,7 +954,7 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation)
TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegativeStartDelay)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -1005,7 +1005,7 @@ TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRates)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -1054,7 +1054,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationPlaybackRa
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNone)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -1102,7 +1102,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeNo
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAuto)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -1150,7 +1150,7 @@ TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationFillModeAu
TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTimingFunction)
{
- // Animation to convert
+ // KeyframeEffect to convert
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyframeEffectModel(
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0).get(), 0),
createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0).get(), 1.0));
@@ -1207,48 +1207,48 @@ TEST_F(AnimationCompositorAnimationsTest, CancelIncompatibleCompositorAnimations
element->setLayoutObject(layoutObject);
AnimatableValueKeyframeVector keyFrames;
- keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 0.0).get());
- keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect::CompositeReplace, 1.0).get());
- RefPtrWillBeRawPtr<AnimationEffect> animationEffect1 = AnimatableValueKeyframeEffectModel::create(keyFrames);
- RefPtrWillBeRawPtr<AnimationEffect> animationEffect2 = AnimatableValueKeyframeEffectModel::create(keyFrames);
+ keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 0.0).get());
+ keyFrames.append(createDefaultKeyframe(CSSPropertyOpacity, EffectModel::CompositeReplace, 1.0).get());
+ RefPtrWillBeRawPtr<EffectModel> animationEffect1 = AnimatableValueKeyframeEffectModel::create(keyFrames);
+ RefPtrWillBeRawPtr<EffectModel> animationEffect2 = AnimatableValueKeyframeEffectModel::create(keyFrames);
Timing timing;
timing.iterationDuration = 1.f;
- // The first player for opacity is ok to run on compositor.
- RefPtrWillBeRawPtr<Animation> animation1 = Animation::create(element.get(), animationEffect1, timing);
- RefPtrWillBePersistent<AnimationPlayer> player1 = m_timeline->play(animation1.get());
- EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(timing, *element.get(), player1.get(), *animationEffect1.get(), 1));
+ // The first animation for opacity is ok to run on compositor.
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect1 = KeyframeEffect::create(element.get(), animationEffect1, timing);
+ RefPtrWillBePersistent<Animation> animation1 = m_timeline->play(keyframeEffect1.get());
+ EXPECT_TRUE(CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(timing, *element.get(), animation1.get(), *animationEffect1.get(), 1));
- // simulate Animation::maybeStartAnimationOnCompositor
+ // simulate KeyframeEffect::maybeStartAnimationOnCompositor
Vector<int> compositorAnimationIds;
compositorAnimationIds.append(1);
- animation1->setCompositorAnimationIdsForTesting(compositorAnimationIds);
- EXPECT_TRUE(player1->hasActiveAnimationsOnCompositor());
+ keyframeEffect1->setCompositorAnimationIdsForTesting(compositorAnimationIds);
+ EXPECT_TRUE(animation1->hasActiveAnimationsOnCompositor());
- // The second player for opacity is not ok to run on compositor.
- RefPtrWillBeRawPtr<Animation> animation2 = Animation::create(element.get(), animationEffect2, timing);
- RefPtrWillBePersistent<AnimationPlayer> player2 = m_timeline->play(animation2.get());
- EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(timing, *element.get(), player2.get(), *animationEffect2.get(), 1));
- EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor());
+ // The second animation for opacity is not ok to run on compositor.
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect2 = KeyframeEffect::create(element.get(), animationEffect2, timing);
+ RefPtrWillBePersistent<Animation> animation2 = m_timeline->play(keyframeEffect2.get());
+ EXPECT_FALSE(CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(timing, *element.get(), animation2.get(), *animationEffect2.get(), 1));
+ EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor());
// A fallback to blink implementation needed, so cancel all compositor-side opacity animations for this element.
- player2->cancelIncompatibleAnimationsOnCompositor();
+ animation2->cancelIncompatibleAnimationsOnCompositor();
- EXPECT_FALSE(player1->hasActiveAnimationsOnCompositor());
- EXPECT_FALSE(player2->hasActiveAnimationsOnCompositor());
+ EXPECT_FALSE(animation1->hasActiveAnimationsOnCompositor());
+ EXPECT_FALSE(animation2->hasActiveAnimationsOnCompositor());
simulateFrame(0);
- EXPECT_EQ(2U, element->elementAnimations()->players().size());
+ EXPECT_EQ(2U, element->elementAnimations()->animations().size());
simulateFrame(1.);
element->setLayoutObject(nullptr);
LayoutObjectProxy::dispose(layoutObject);
- player1.release();
- player2.release();
+ animation1.release();
+ animation2.release();
Heap::collectAllGarbage();
- EXPECT_TRUE(element->elementAnimations()->players().isEmpty());
+ EXPECT_TRUE(element->elementAnimations()->animations().isEmpty());
}
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp b/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp
index 5e1a4d1..896f13b 100644
--- a/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp
+++ b/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.cpp
@@ -31,8 +31,8 @@
#include "config.h"
#include "core/animation/CompositorPendingAnimations.h"
-#include "core/animation/Animation.h"
#include "core/animation/AnimationTimeline.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/dom/Document.h"
#include "core/frame/FrameView.h"
#include "core/page/Page.h"
@@ -40,13 +40,13 @@
namespace blink {
-void CompositorPendingAnimations::add(AnimationPlayer* player)
+void CompositorPendingAnimations::add(Animation* animation)
{
- ASSERT(player);
- ASSERT(m_pending.find(player) == kNotFound);
- m_pending.append(player);
+ ASSERT(animation);
+ ASSERT(m_pending.find(animation) == kNotFound);
+ m_pending.append(animation);
- Document* document = player->timeline()->document();
+ Document* document = animation->timeline()->document();
if (document->view())
document->view()->scheduleAnimation();
@@ -58,26 +58,26 @@ void CompositorPendingAnimations::add(AnimationPlayer* player)
bool CompositorPendingAnimations::update(bool startOnCompositor)
{
- WillBeHeapVector<RawPtrWillBeMember<AnimationPlayer>> waitingForStartTime;
+ WillBeHeapVector<RawPtrWillBeMember<Animation>> waitingForStartTime;
bool startedSynchronizedOnCompositor = false;
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> players;
- players.swap(m_pending);
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> animations;
+ animations.swap(m_pending);
int compositorGroup = ++m_compositorGroup;
if (compositorGroup == 0) {
// Wrap around, skipping 0.
compositorGroup = ++m_compositorGroup;
}
- for (auto& player : players) {
- bool hadCompositorAnimation = player->hasActiveAnimationsOnCompositor();
- player->preCommit(compositorGroup, startOnCompositor);
- if (player->hasActiveAnimationsOnCompositor() && !hadCompositorAnimation) {
+ for (auto& animation : animations) {
+ bool hadCompositorAnimation = animation->hasActiveAnimationsOnCompositor();
+ animation->preCommit(compositorGroup, startOnCompositor);
+ if (animation->hasActiveAnimationsOnCompositor() && !hadCompositorAnimation) {
startedSynchronizedOnCompositor = true;
}
- if (player->playing() && !player->hasStartTime()) {
- waitingForStartTime.append(player.get());
+ if (animation->playing() && !animation->hasStartTime()) {
+ waitingForStartTime.append(animation.get());
}
}
@@ -85,22 +85,22 @@ bool CompositorPendingAnimations::update(bool startOnCompositor)
// remaning synchronized animations need to wait for the synchronized
// start time. Otherwise they may start immediately.
if (startedSynchronizedOnCompositor) {
- for (auto& player : waitingForStartTime) {
- if (!player->hasStartTime()) {
- m_waitingForCompositorAnimationStart.append(player);
+ for (auto& animation : waitingForStartTime) {
+ if (!animation->hasStartTime()) {
+ m_waitingForCompositorAnimationStart.append(animation);
}
}
} else {
- for (auto& player : waitingForStartTime) {
- if (!player->hasStartTime()) {
- player->notifyCompositorStartTime(player->timeline()->currentTimeInternal());
+ for (auto& animation : waitingForStartTime) {
+ if (!animation->hasStartTime()) {
+ animation->notifyCompositorStartTime(animation->timeline()->currentTimeInternal());
}
}
}
// FIXME: The postCommit should happen *after* the commit, not before.
- for (auto& player : players)
- player->postCommit(player->timeline()->currentTimeInternal());
+ for (auto& animation : animations)
+ animation->postCommit(animation->timeline()->currentTimeInternal());
ASSERT(m_pending.isEmpty());
@@ -111,8 +111,8 @@ bool CompositorPendingAnimations::update(bool startOnCompositor)
return false;
// Check if we're still waiting for any compositor animations to start.
- for (auto& player : m_waitingForCompositorAnimationStart) {
- if (player->hasActiveAnimationsOnCompositor())
+ for (auto& animation : m_waitingForCompositorAnimationStart) {
+ if (animation->hasActiveAnimationsOnCompositor())
return true;
}
@@ -126,20 +126,20 @@ bool CompositorPendingAnimations::update(bool startOnCompositor)
void CompositorPendingAnimations::notifyCompositorAnimationStarted(double monotonicAnimationStartTime, int compositorGroup)
{
TRACE_EVENT0("blink", "CompositorPendingAnimations::notifyCompositorAnimationStarted");
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> players;
- players.swap(m_waitingForCompositorAnimationStart);
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> animations;
+ animations.swap(m_waitingForCompositorAnimationStart);
- for (auto player : players) {
- if (player->hasStartTime() || player->playStateInternal() != AnimationPlayer::Pending) {
+ for (auto animation : animations) {
+ if (animation->hasStartTime() || animation->playStateInternal() != Animation::Pending) {
// Already started or no longer relevant.
continue;
}
- if (compositorGroup && player->compositorGroup() != compositorGroup) {
+ if (compositorGroup && animation->compositorGroup() != compositorGroup) {
// Still waiting.
- m_waitingForCompositorAnimationStart.append(player);
+ m_waitingForCompositorAnimationStart.append(animation);
continue;
}
- player->notifyCompositorStartTime(monotonicAnimationStartTime - player->timeline()->zeroTime());
+ animation->notifyCompositorStartTime(monotonicAnimationStartTime - animation->timeline()->zeroTime());
}
}
diff --git a/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.h b/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.h
index 2f721f7..03e81c3 100644
--- a/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.h
+++ b/third_party/WebKit/Source/core/animation/CompositorPendingAnimations.h
@@ -32,7 +32,7 @@
#define CompositorPendingAnimations_h
#include "core/CoreExport.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/Animation.h"
#include "platform/Timer.h"
#include "platform/heap/Handle.h"
#include "wtf/Vector.h"
@@ -53,7 +53,7 @@ public:
, m_compositorGroup(1)
{ }
- void add(AnimationPlayer*);
+ void add(Animation*);
// Returns whether we are waiting for an animation to start and should
// service again on the next frame.
bool update(bool startOnCompositor = true);
@@ -64,8 +64,8 @@ public:
private:
void timerFired(Timer<CompositorPendingAnimations>*) { update(false); }
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> m_pending;
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> m_waitingForCompositorAnimationStart;
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> m_pending;
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> m_waitingForCompositorAnimationStart;
Timer<CompositorPendingAnimations> m_timer;
int m_compositorGroup;
};
diff --git a/third_party/WebKit/Source/core/animation/ComputedTimingProperties.idl b/third_party/WebKit/Source/core/animation/ComputedTimingProperties.idl
index cde76f5..71e0530 100644
--- a/third_party/WebKit/Source/core/animation/ComputedTimingProperties.idl
+++ b/third_party/WebKit/Source/core/animation/ComputedTimingProperties.idl
@@ -4,7 +4,7 @@
// https://w3c.github.io/web-animations/#the-computedtimingproperties-dictionary
-dictionary ComputedTimingProperties : AnimationTimingProperties {
+dictionary ComputedTimingProperties : KeyframeEffectOptions {
// TODO(dstockwell): There is no startTime member in the spec.
double startTime;
unrestricted double endTime;
diff --git a/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp b/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp
index ec3a548..f262f56 100644
--- a/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp
+++ b/third_party/WebKit/Source/core/animation/DocumentAnimations.cpp
@@ -60,7 +60,7 @@ void DocumentAnimations::updateAnimationTimingForAnimationFrame(Document& docume
void DocumentAnimations::updateAnimationTimingIfNeeded(Document& document)
{
- if (needsOutdatedAnimationPlayerUpdate(document) || document.timeline().needsAnimationTimingUpdate())
+ if (needsOutdatedAnimationUpdate(document) || document.timeline().needsAnimationTimingUpdate())
updateAnimationTiming(document, TimingUpdateOnDemand);
}
@@ -78,9 +78,9 @@ void DocumentAnimations::updateAnimationTimingForGetComputedStyle(Node& node, CS
}
}
-bool DocumentAnimations::needsOutdatedAnimationPlayerUpdate(const Document& document)
+bool DocumentAnimations::needsOutdatedAnimationUpdate(const Document& document)
{
- return document.timeline().hasOutdatedAnimationPlayer();
+ return document.timeline().hasOutdatedAnimation();
}
void DocumentAnimations::updateCompositorAnimations(Document& document)
diff --git a/third_party/WebKit/Source/core/animation/DocumentAnimations.h b/third_party/WebKit/Source/core/animation/DocumentAnimations.h
index d3f6a22..3116855 100644
--- a/third_party/WebKit/Source/core/animation/DocumentAnimations.h
+++ b/third_party/WebKit/Source/core/animation/DocumentAnimations.h
@@ -41,7 +41,7 @@ class Node;
class DocumentAnimations {
public:
static void updateAnimationTimingForAnimationFrame(Document&, double monotonicAnimationStartTime);
- static bool needsOutdatedAnimationPlayerUpdate(const Document&);
+ static bool needsOutdatedAnimationUpdate(const Document&);
static void updateAnimationTimingIfNeeded(Document&);
static void updateAnimationTimingForGetComputedStyle(Node&, CSSPropertyID);
static void updateCompositorAnimations(Document&);
diff --git a/third_party/WebKit/Source/core/animation/EffectInput.cpp b/third_party/WebKit/Source/core/animation/EffectInput.cpp
index 49783b7..ed925e3 100644
--- a/third_party/WebKit/Source/core/animation/EffectInput.cpp
+++ b/third_party/WebKit/Source/core/animation/EffectInput.cpp
@@ -189,7 +189,7 @@ const QualifiedName* supportedSVGAttribute(const String& property, SVGElement* s
} // namespace
-PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<EffectModel> EffectInput::convert(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState)
{
// FIXME: Remove the dependency on element.
if (!element)
@@ -233,7 +233,7 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
String compositeString;
DictionaryHelper::get(keyframeDictionary, "composite", compositeString);
if (compositeString == "add")
- keyframe->setComposite(AnimationEffect::CompositeAdd);
+ keyframe->setComposite(EffectModel::CompositeAdd);
String timingFunctionString;
if (DictionaryHelper::get(keyframeDictionary, "easing", timingFunctionString)) {
@@ -283,10 +283,10 @@ PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, c
return keyframeEffectModel;
}
-PassRefPtrWillBeRawPtr<AnimationEffect> EffectInput::convert(Element* element, const AnimationEffectOrDictionarySequence& effectInput, ExceptionState& exceptionState)
+PassRefPtrWillBeRawPtr<EffectModel> EffectInput::convert(Element* element, const EffectModelOrDictionarySequence& effectInput, ExceptionState& exceptionState)
{
- if (effectInput.isAnimationEffect())
- return effectInput.getAsAnimationEffect();
+ if (effectInput.isEffectModel())
+ return effectInput.getAsEffectModel();
if (effectInput.isDictionarySequence())
return convert(element, effectInput.getAsDictionarySequence(), exceptionState);
return nullptr;
diff --git a/third_party/WebKit/Source/core/animation/EffectInput.h b/third_party/WebKit/Source/core/animation/EffectInput.h
index 634a458..186a633 100644
--- a/third_party/WebKit/Source/core/animation/EffectInput.h
+++ b/third_party/WebKit/Source/core/animation/EffectInput.h
@@ -6,21 +6,21 @@
#define EffectInput_h
#include "core/CoreExport.h"
-#include "core/animation/AnimationEffect.h"
+#include "core/animation/EffectModel.h"
#include "wtf/Vector.h"
namespace blink {
-class AnimationEffect;
-class AnimationEffectOrDictionarySequence;
+class EffectModel;
+class EffectModelOrDictionarySequence;
class Dictionary;
class Element;
class ExceptionState;
class CORE_EXPORT EffectInput {
public:
- static PassRefPtrWillBeRawPtr<AnimationEffect> convert(Element*, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState&);
- static PassRefPtrWillBeRawPtr<AnimationEffect> convert(Element*, const AnimationEffectOrDictionarySequence&, ExceptionState&);
+ static PassRefPtrWillBeRawPtr<EffectModel> convert(Element*, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState&);
+ static PassRefPtrWillBeRawPtr<EffectModel> convert(Element*, const EffectModelOrDictionarySequence&, ExceptionState&);
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/EffectInputTest.cpp b/third_party/WebKit/Source/core/animation/EffectInputTest.cpp
index 51e406e..2ab4046 100644
--- a/third_party/WebKit/Source/core/animation/EffectInputTest.cpp
+++ b/third_party/WebKit/Source/core/animation/EffectInputTest.cpp
@@ -52,7 +52,7 @@ TEST_F(AnimationEffectInputTest, SortedOffsets)
jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
- RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(element.get(), jsKeyframes, exceptionState);
+ RefPtrWillBeRawPtr<EffectModel> animationEffect = EffectInput::convert(element.get(), jsKeyframes, exceptionState);
EXPECT_FALSE(exceptionState.hadException());
const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(animationEffect.get());
EXPECT_EQ(1.0, keyframeEffect.getFrames()[1]->offset());
@@ -94,7 +94,7 @@ TEST_F(AnimationEffectInputTest, LooslySorted)
jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
jsKeyframes.append(Dictionary(keyframe3, m_isolate, exceptionState));
- RefPtrWillBeRawPtr<AnimationEffect> animationEffect = EffectInput::convert(element.get(), jsKeyframes, exceptionState);
+ RefPtrWillBeRawPtr<EffectModel> animationEffect = EffectInput::convert(element.get(), jsKeyframes, exceptionState);
EXPECT_FALSE(exceptionState.hadException());
const KeyframeEffectModelBase& keyframeEffect = *toKeyframeEffectModelBase(animationEffect.get());
EXPECT_EQ(1, keyframeEffect.getFrames()[2]->offset());
diff --git a/third_party/WebKit/Source/core/animation/AnimationPlayer.idl b/third_party/WebKit/Source/core/animation/EffectModel.h
index a405eb2..2e13194 100644
--- a/third_party/WebKit/Source/core/animation/AnimationPlayer.idl
+++ b/third_party/WebKit/Source/core/animation/EffectModel.h
@@ -28,30 +28,40 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-// http://www.w3.org/TR/web-animations/#the-animationplayer-interface
-
-// TODO(dstockwell): This interface has been renamed to Animation in the latest
-// spec, which also has several other changes:
-// https://w3c.github.io/web-animations/#the-animation-interface
-
-enum AnimationPlayState { "idle", "pending", "running", "paused", "finished" };
-
-[
- ActiveDOMObject,
- NoInterfaceObject,
-] interface AnimationPlayer : EventTarget {
- [RuntimeEnabled=WebAnimationsAPI] attribute AnimationNode? source;
- [Measure] attribute double? startTime;
- [Measure] attribute double? currentTime;
- [Measure] attribute double playbackRate;
- [Measure] readonly attribute AnimationPlayState playState;
- [Measure, RaisesException] void finish();
- [Measure] void play();
- [Measure] void pause();
- [Measure] void reverse();
-
- [Measure] void cancel();
- [Measure] attribute EventHandler onfinish;
- [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<AnimationPlayer> finished;
- [RuntimeEnabled=WebAnimationsAPI, CallWith=ScriptState] readonly attribute Promise<AnimationPlayer> ready;
+#ifndef EffectModel_h
+#define EffectModel_h
+
+#include "bindings/core/v8/ScriptWrappable.h"
+#include "core/CSSPropertyNames.h"
+#include "core/CoreExport.h"
+#include "core/animation/PropertyHandle.h"
+#include "platform/heap/Handle.h"
+#include "wtf/HashMap.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/RefCounted.h"
+
+namespace blink {
+
+class Interpolation;
+
+class CORE_EXPORT EffectModel : public RefCountedWillBeGarbageCollectedFinalized<EffectModel>, public ScriptWrappable {
+ DEFINE_WRAPPERTYPEINFO();
+public:
+ enum CompositeOperation {
+ CompositeReplace,
+ CompositeAdd,
+ };
+
+ EffectModel() { }
+ virtual ~EffectModel() { }
+ virtual void sample(int iteration, double fraction, double iterationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const = 0;
+
+ virtual bool affects(PropertyHandle) const { return false; };
+ virtual bool isKeyframeEffectModel() const { return false; }
+
+ DEFINE_INLINE_VIRTUAL_TRACE() { }
};
+
+} // namespace blink
+
+#endif // EffectModel_h
diff --git a/third_party/WebKit/Source/core/animation/AnimationEffect.idl b/third_party/WebKit/Source/core/animation/EffectModel.idl
index 6071df6..38c7185 100644
--- a/third_party/WebKit/Source/core/animation/AnimationEffect.idl
+++ b/third_party/WebKit/Source/core/animation/EffectModel.idl
@@ -11,5 +11,5 @@
RuntimeEnabled=WebAnimationsAPI,
NoInterfaceObject,
WillBeGarbageCollected
-] interface AnimationEffect {
+] interface EffectModel {
};
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimation.h b/third_party/WebKit/Source/core/animation/ElementAnimation.h
index eb3a904..ee9884e7 100644
--- a/third_party/WebKit/Source/core/animation/ElementAnimation.h
+++ b/third_party/WebKit/Source/core/animation/ElementAnimation.h
@@ -32,10 +32,10 @@
#define ElementAnimation_h
#include "bindings/core/v8/UnionTypesCore.h"
-#include "core/animation/Animation.h"
#include "core/animation/AnimationTimeline.h"
#include "core/animation/EffectInput.h"
#include "core/animation/ElementAnimations.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/animation/TimingInput.h"
#include "core/dom/Document.h"
#include "core/dom/Element.h"
@@ -48,50 +48,50 @@ class Dictionary;
class ElementAnimation {
public:
- static AnimationPlayer* animate(Element& element, const AnimationEffectOrDictionarySequence& effectInput, double duration, ExceptionState& exceptionState)
+ static Animation* animate(Element& element, const EffectModelOrDictionarySequence& effectInput, double duration, ExceptionState& exceptionState)
{
- RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&element, effectInput, exceptionState);
+ RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element, effectInput, exceptionState);
if (exceptionState.hadException())
return 0;
return animateInternal(element, effect, TimingInput::convert(duration));
}
- static AnimationPlayer* animate(Element& element, const AnimationEffectOrDictionarySequence& effectInput, const AnimationTimingProperties& timingInput, ExceptionState& exceptionState)
+ static Animation* animate(Element& element, const EffectModelOrDictionarySequence& effectInput, const KeyframeEffectOptions& timingInput, ExceptionState& exceptionState)
{
- RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&element, effectInput, exceptionState);
+ RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element, effectInput, exceptionState);
if (exceptionState.hadException())
return 0;
return animateInternal(element, effect, TimingInput::convert(timingInput));
}
- static AnimationPlayer* animate(Element& element, const AnimationEffectOrDictionarySequence& effectInput, ExceptionState& exceptionState)
+ static Animation* animate(Element& element, const EffectModelOrDictionarySequence& effectInput, ExceptionState& exceptionState)
{
- RefPtrWillBeRawPtr<AnimationEffect> effect = EffectInput::convert(&element, effectInput, exceptionState);
+ RefPtrWillBeRawPtr<EffectModel> effect = EffectInput::convert(&element, effectInput, exceptionState);
if (exceptionState.hadException())
return 0;
return animateInternal(element, effect, Timing());
}
- static WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> getAnimationPlayers(Element& element)
+ static WillBeHeapVector<RefPtrWillBeMember<Animation>> getAnimations(Element& element)
{
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer>> animationPlayers;
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> animationss;
if (!element.hasAnimations())
- return animationPlayers;
+ return animationss;
- for (const auto& player : element.document().timeline().getAnimationPlayers()) {
- ASSERT(player->source());
- if (toAnimation(player->source())->target() == element && (player->source()->isCurrent() || player->source()->isInEffect()))
- animationPlayers.append(player);
+ for (const auto& animation : element.document().timeline().getAnimations()) {
+ ASSERT(animation->source());
+ if (toKeyframeEffect(animation->source())->target() == element && (animation->source()->isCurrent() || animation->source()->isInEffect()))
+ animationss.append(animation);
}
- return animationPlayers;
+ return animationss;
}
private:
- static AnimationPlayer* animateInternal(Element& element, PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing)
+ static Animation* animateInternal(Element& element, PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing)
{
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(&element, effect, timing);
- return element.document().timeline().play(animation.get());
+ RefPtrWillBeRawPtr<KeyframeEffect> keyframeEffect = KeyframeEffect::create(&element, effect, timing);
+ return element.document().timeline().play(keyframeEffect.get());
}
};
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimation.idl b/third_party/WebKit/Source/core/animation/ElementAnimation.idl
index 289f8af..e38387e 100644
--- a/third_party/WebKit/Source/core/animation/ElementAnimation.idl
+++ b/third_party/WebKit/Source/core/animation/ElementAnimation.idl
@@ -37,8 +37,8 @@
partial interface Element {
// FIXME: Union types with dictionary type members doesn't work (yet).
- // AnimationPlayer animate((AnimationEffect or sequence<Dictionary>)? effect, optional (double or AnimationTimingProperties) timing);
- [RaisesException] AnimationPlayer animate((AnimationEffect or sequence<Dictionary>)? effect, optional double timing);
- [RaisesException] AnimationPlayer animate((AnimationEffect or sequence<Dictionary>)? effect, AnimationTimingProperties timing);
- [RuntimeEnabled=WebAnimationsAPI] sequence<AnimationPlayer> getAnimationPlayers();
+ // Animation animate((EffectModel or sequence<Dictionary>)? effect, optional (double or KeyframeEffectOptions) timing);
+ [RaisesException] Animation animate((EffectModel or sequence<Dictionary>)? effect, optional double timing);
+ [RaisesException] Animation animate((EffectModel or sequence<Dictionary>)? effect, KeyframeEffectOptions timing);
+ [RuntimeEnabled=WebAnimationsAPI] sequence<Animation> getAnimations();
};
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimations.cpp b/third_party/WebKit/Source/core/animation/ElementAnimations.cpp
index f12a4c8..86bee84 100644
--- a/third_party/WebKit/Source/core/animation/ElementAnimations.cpp
+++ b/third_party/WebKit/Source/core/animation/ElementAnimations.cpp
@@ -43,26 +43,26 @@ ElementAnimations::ElementAnimations()
ElementAnimations::~ElementAnimations()
{
#if !ENABLE(OILPAN)
- for (Animation* animation : m_animations)
- animation->notifyElementDestroyed();
- m_animations.clear();
+ for (KeyframeEffect* effect : m_effects)
+ effect->notifyElementDestroyed();
+ m_effects.clear();
#endif
}
void ElementAnimations::updateAnimationFlags(ComputedStyle& style)
{
- for (const auto& entry : m_players) {
- const AnimationPlayer& player = *entry.key;
- ASSERT(player.source());
+ for (const auto& entry : m_animations) {
+ const Animation& animation = *entry.key;
+ ASSERT(animation.source());
// FIXME: Needs to consider AnimationGroup once added.
- ASSERT(player.source()->isAnimation());
- const Animation& animation = *toAnimation(player.source());
- if (animation.isCurrent()) {
- if (animation.affects(PropertyHandle(CSSPropertyOpacity)))
+ ASSERT(animation.source()->isAnimation());
+ const KeyframeEffect& effect = *toKeyframeEffect(animation.source());
+ if (effect.isCurrent()) {
+ if (effect.affects(PropertyHandle(CSSPropertyOpacity)))
style.setHasCurrentOpacityAnimation(true);
- if (animation.affects(PropertyHandle(CSSPropertyTransform)))
+ if (effect.affects(PropertyHandle(CSSPropertyTransform)))
style.setHasCurrentTransformAnimation(true);
- if (animation.affects(PropertyHandle(CSSPropertyWebkitFilter)))
+ if (effect.affects(PropertyHandle(CSSPropertyWebkitFilter)))
style.setHasCurrentFilterAnimation(true);
}
}
@@ -77,7 +77,7 @@ void ElementAnimations::updateAnimationFlags(ComputedStyle& style)
void ElementAnimations::restartAnimationOnCompositor()
{
- for (const auto& entry : m_players)
+ for (const auto& entry : m_animations)
entry.key->restartAnimationOnCompositor();
}
@@ -86,7 +86,7 @@ DEFINE_TRACE(ElementAnimations)
#if ENABLE(OILPAN)
visitor->trace(m_cssAnimations);
visitor->trace(m_defaultStack);
- visitor->trace(m_players);
+ visitor->trace(m_animations);
#endif
}
diff --git a/third_party/WebKit/Source/core/animation/ElementAnimations.h b/third_party/WebKit/Source/core/animation/ElementAnimations.h
index 3bba2a4..bc2607d 100644
--- a/third_party/WebKit/Source/core/animation/ElementAnimations.h
+++ b/third_party/WebKit/Source/core/animation/ElementAnimations.h
@@ -42,7 +42,7 @@ namespace blink {
class CSSAnimations;
-using AnimationPlayerCountedSet = WillBeHeapHashCountedSet<RawPtrWillBeWeakMember<AnimationPlayer>>;
+using AnimationCountedSet = WillBeHeapHashCountedSet<RawPtrWillBeWeakMember<Animation>>;
class ElementAnimations : public NoBaseWillBeGarbageCollectedFinalized<ElementAnimations> {
WTF_MAKE_NONCOPYABLE(ElementAnimations);
@@ -56,14 +56,14 @@ public:
const AnimationStack& defaultStack() const { return m_defaultStack; }
// Tracks the state of active CSS Animations and Transitions. The individual animations
// will also be part of the default stack, but the mapping betwen animation name and
- // player is kept here.
+ // animation is kept here.
CSSAnimations& cssAnimations() { return m_cssAnimations; }
const CSSAnimations& cssAnimations() const { return m_cssAnimations; }
- // AnimationPlayers which have animations targeting this element.
- AnimationPlayerCountedSet& players() { return m_players; }
+ // Animations which have effects targeting this element.
+ AnimationCountedSet& animations() { return m_animations; }
- bool isEmpty() const { return m_defaultStack.isEmpty() && m_cssAnimations.isEmpty() && m_players.isEmpty(); }
+ bool isEmpty() const { return m_defaultStack.isEmpty() && m_cssAnimations.isEmpty() && m_animations.isEmpty(); }
void restartAnimationOnCompositor();
@@ -75,8 +75,8 @@ public:
void clearBaseComputedStyle();
#if !ENABLE(OILPAN)
- void addAnimation(Animation* animation) { m_animations.append(animation); }
- void notifyAnimationDestroyed(Animation* animation) { m_animations.remove(m_animations.find(animation)); }
+ void addEffect(KeyframeEffect* effect) { m_effects.append(effect); }
+ void notifyEffectDestroyed(KeyframeEffect* effect) { m_effects.remove(m_effects.find(effect)); }
#endif
DECLARE_TRACE();
@@ -86,14 +86,14 @@ private:
AnimationStack m_defaultStack;
CSSAnimations m_cssAnimations;
- AnimationPlayerCountedSet m_players;
+ AnimationCountedSet m_animations;
bool m_animationStyleChange;
RefPtr<ComputedStyle> m_baseComputedStyle;
#if !ENABLE(OILPAN)
// FIXME: Oilpan: This is to avoid a reference cycle that keeps Elements alive
// and won't be needed once the Node hierarchy becomes traceable.
- Vector<Animation*> m_animations;
+ Vector<KeyframeEffect*> m_effects;
#endif
// CSSAnimations and DeferredLegacyStyleInterpolation checks if a style change is due to animation.
diff --git a/third_party/WebKit/Source/core/animation/InertAnimation.cpp b/third_party/WebKit/Source/core/animation/InertAnimation.cpp
index eacfec2..771882c 100644
--- a/third_party/WebKit/Source/core/animation/InertAnimation.cpp
+++ b/third_party/WebKit/Source/core/animation/InertAnimation.cpp
@@ -34,13 +34,13 @@
namespace blink {
-PassRefPtrWillBeRawPtr<InertAnimation> InertAnimation::create(PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, bool paused, double inheritedTime)
+PassRefPtrWillBeRawPtr<InertAnimation> InertAnimation::create(PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing, bool paused, double inheritedTime)
{
return adoptRefWillBeNoop(new InertAnimation(effect, timing, paused, inheritedTime));
}
-InertAnimation::InertAnimation(PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, bool paused, double inheritedTime)
- : AnimationNode(timing)
+InertAnimation::InertAnimation(PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing, bool paused, double inheritedTime)
+ : AnimationEffect(timing)
, m_effect(effect)
, m_paused(paused)
, m_inheritedTime(inheritedTime)
@@ -69,7 +69,7 @@ double InertAnimation::calculateTimeToEffectChange(bool, double, double) const
DEFINE_TRACE(InertAnimation)
{
visitor->trace(m_effect);
- AnimationNode::trace(visitor);
+ AnimationEffect::trace(visitor);
}
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/InertAnimation.h b/third_party/WebKit/Source/core/animation/InertAnimation.h
index 1b3f80a..e9b054f 100644
--- a/third_party/WebKit/Source/core/animation/InertAnimation.h
+++ b/third_party/WebKit/Source/core/animation/InertAnimation.h
@@ -33,16 +33,16 @@
#include "core/CoreExport.h"
#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/EffectModel.h"
#include "wtf/RefPtr.h"
namespace blink {
-class CORE_EXPORT InertAnimation final : public AnimationNode {
+class CORE_EXPORT InertAnimation final : public AnimationEffect {
public:
- static PassRefPtrWillBeRawPtr<InertAnimation> create(PassRefPtrWillBeRawPtr<AnimationEffect>, const Timing&, bool paused, double inheritedTime);
+ static PassRefPtrWillBeRawPtr<InertAnimation> create(PassRefPtrWillBeRawPtr<EffectModel>, const Timing&, bool paused, double inheritedTime);
void sample(OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&);
- AnimationEffect* effect() const { return m_effect.get(); }
+ EffectModel* effect() const { return m_effect.get(); }
bool paused() const { return m_paused; }
DECLARE_VIRTUAL_TRACE();
@@ -52,8 +52,8 @@ protected:
virtual double calculateTimeToEffectChange(bool forwards, double inheritedTime, double timeToNextIteration) const override;
private:
- InertAnimation(PassRefPtrWillBeRawPtr<AnimationEffect>, const Timing&, bool paused, double inheritedTime);
- RefPtrWillBeMember<AnimationEffect> m_effect;
+ InertAnimation(PassRefPtrWillBeRawPtr<EffectModel>, const Timing&, bool paused, double inheritedTime);
+ RefPtrWillBeMember<EffectModel> m_effect;
bool m_paused;
double m_inheritedTime;
};
diff --git a/third_party/WebKit/Source/core/animation/Keyframe.h b/third_party/WebKit/Source/core/animation/Keyframe.h
index 1d6a6fd..346a10d 100644
--- a/third_party/WebKit/Source/core/animation/Keyframe.h
+++ b/third_party/WebKit/Source/core/animation/Keyframe.h
@@ -7,7 +7,7 @@
#include "core/CoreExport.h"
#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/EffectModel.h"
#include "core/animation/PropertyHandle.h"
#include "core/animation/animatable/AnimatableValue.h"
@@ -26,8 +26,8 @@ public:
void setOffset(double offset) { m_offset = offset; }
double offset() const { return m_offset; }
- void setComposite(AnimationEffect::CompositeOperation composite) { m_composite = composite; }
- AnimationEffect::CompositeOperation composite() const { return m_composite; }
+ void setComposite(EffectModel::CompositeOperation composite) { m_composite = composite; }
+ EffectModel::CompositeOperation composite() const { return m_composite; }
void setEasing(PassRefPtr<TimingFunction> easing) { m_easing = easing; }
TimingFunction& easing() const { return *m_easing; }
@@ -57,7 +57,7 @@ public:
virtual ~PropertySpecificKeyframe() { }
double offset() const { return m_offset; }
TimingFunction& easing() const { return *m_easing; }
- AnimationEffect::CompositeOperation composite() const { return m_composite; }
+ EffectModel::CompositeOperation composite() const { return m_composite; }
virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> cloneWithOffset(double offset) const = 0;
// FIXME: Remove this once CompositorAnimations no longer depends on AnimatableValues
@@ -74,11 +74,11 @@ public:
DEFINE_INLINE_VIRTUAL_TRACE() { }
protected:
- PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, AnimationEffect::CompositeOperation);
+ PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, EffectModel::CompositeOperation);
double m_offset;
RefPtr<TimingFunction> m_easing;
- AnimationEffect::CompositeOperation m_composite;
+ EffectModel::CompositeOperation m_composite;
};
virtual PassOwnPtrWillBeRawPtr<PropertySpecificKeyframe> createPropertySpecificKeyframe(PropertyHandle) const = 0;
@@ -86,11 +86,11 @@ public:
protected:
Keyframe()
: m_offset(nullValue())
- , m_composite(AnimationEffect::CompositeReplace)
+ , m_composite(EffectModel::CompositeReplace)
, m_easing(LinearTimingFunction::shared())
{
}
- Keyframe(double offset, AnimationEffect::CompositeOperation composite, PassRefPtr<TimingFunction> easing)
+ Keyframe(double offset, EffectModel::CompositeOperation composite, PassRefPtr<TimingFunction> easing)
: m_offset(offset)
, m_composite(composite)
, m_easing(easing)
@@ -98,7 +98,7 @@ protected:
}
double m_offset;
- AnimationEffect::CompositeOperation m_composite;
+ EffectModel::CompositeOperation m_composite;
RefPtr<TimingFunction> m_easing;
};
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp
new file mode 100644
index 0000000..77c1290
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffect.cpp
@@ -0,0 +1,341 @@
+/*
+ * Copyright (C) 2013 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "core/animation/KeyframeEffect.h"
+
+#include "bindings/core/v8/Dictionary.h"
+#include "bindings/core/v8/ExceptionState.h"
+#include "core/animation/Animation.h"
+#include "core/animation/AnimationTimeline.h"
+#include "core/animation/CompositorAnimations.h"
+#include "core/animation/ElementAnimations.h"
+#include "core/animation/Interpolation.h"
+#include "core/animation/KeyframeEffectModel.h"
+#include "core/animation/KeyframeEffectOptions.h"
+#include "core/animation/PropertyHandle.h"
+#include "core/dom/Element.h"
+#include "core/dom/NodeComputedStyle.h"
+#include "core/frame/UseCounter.h"
+#include "core/paint/DeprecatedPaintLayer.h"
+#include "core/svg/SVGElement.h"
+
+namespace blink {
+
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* target, PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
+{
+ return adoptRefWillBeNoop(new KeyframeEffect(target, effect, timing, priority, eventDelegate));
+}
+
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState)
+{
+ ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
+ if (element)
+ UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming);
+ return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), TimingInput::convert(duration));
+}
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, const KeyframeEffectOptions& timingInput, ExceptionState& exceptionState)
+{
+ ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
+ if (element)
+ UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectObjectTiming);
+ return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), TimingInput::convert(timingInput));
+}
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState)
+{
+ ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled());
+ if (element)
+ UseCounter::count(element->document(), UseCounter::AnimationConstructorKeyframeListEffectNoTiming);
+ return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), Timing());
+}
+
+KeyframeEffect::KeyframeEffect(Element* target, PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate)
+ : AnimationEffect(timing, eventDelegate)
+ , m_target(target)
+ , m_effect(effect)
+ , m_sampledEffect(nullptr)
+ , m_priority(priority)
+{
+#if !ENABLE(OILPAN)
+ if (m_target)
+ m_target->ensureElementAnimations().addEffect(this);
+#endif
+}
+
+KeyframeEffect::~KeyframeEffect()
+{
+#if !ENABLE(OILPAN)
+ if (m_target)
+ m_target->elementAnimations()->notifyEffectDestroyed(this);
+#endif
+}
+
+void KeyframeEffect::attach(Animation* animation)
+{
+ if (m_target) {
+ m_target->ensureElementAnimations().animations().add(animation);
+ m_target->setNeedsAnimationStyleRecalc();
+ }
+ AnimationEffect::attach(animation);
+}
+
+void KeyframeEffect::detach()
+{
+ if (m_target)
+ m_target->elementAnimations()->animations().remove(animation());
+ if (m_sampledEffect)
+ clearEffects();
+ AnimationEffect::detach();
+}
+
+void KeyframeEffect::specifiedTimingChanged()
+{
+ if (animation()) {
+ // FIXME: Needs to consider groups when added.
+ ASSERT(animation()->source() == this);
+ animation()->setCompositorPending(true);
+ }
+}
+
+static AnimationStack& ensureAnimationStack(Element* element)
+{
+ return element->ensureElementAnimations().defaultStack();
+}
+
+void KeyframeEffect::applyEffects()
+{
+ ASSERT(isInEffect());
+ ASSERT(animation());
+ if (!m_target || !m_effect)
+ return;
+
+ // Cancel composited animation of transform if a motion path has been introduced on the element.
+ if (m_target->computedStyle()
+ && m_target->computedStyle()->hasMotionPath()
+ && animation()->hasActiveAnimationsOnCompositor()
+ && animation()->affects(*m_target, CSSPropertyTransform)) {
+ animation()->cancelAnimationOnCompositor();
+ }
+
+ double iteration = currentIteration();
+ ASSERT(iteration >= 0);
+ OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations = m_sampledEffect ? m_sampledEffect->mutableInterpolations() : nullptr;
+ // FIXME: Handle iteration values which overflow int.
+ m_effect->sample(static_cast<int>(iteration), timeFraction(), iterationDuration(), interpolations);
+ if (m_sampledEffect) {
+ m_sampledEffect->setInterpolations(interpolations.release());
+ } else if (interpolations && !interpolations->isEmpty()) {
+ OwnPtrWillBeRawPtr<SampledEffect> sampledEffect = SampledEffect::create(this, interpolations.release());
+ m_sampledEffect = sampledEffect.get();
+ ensureAnimationStack(m_target).add(sampledEffect.release());
+ } else {
+ return;
+ }
+
+ m_target->setNeedsAnimationStyleRecalc();
+ if (m_target->isSVGElement())
+ m_sampledEffect->applySVGUpdate(toSVGElement(*m_target));
+}
+
+void KeyframeEffect::clearEffects()
+{
+ ASSERT(animation());
+ ASSERT(m_sampledEffect);
+
+ m_sampledEffect->clear();
+ m_sampledEffect = nullptr;
+ restartAnimationOnCompositor();
+ m_target->setNeedsAnimationStyleRecalc();
+ invalidate();
+}
+
+void KeyframeEffect::updateChildrenAndEffects() const
+{
+ if (!m_effect)
+ return;
+ if (isInEffect())
+ const_cast<KeyframeEffect*>(this)->applyEffects();
+ else if (m_sampledEffect)
+ const_cast<KeyframeEffect*>(this)->clearEffects();
+}
+
+double KeyframeEffect::calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const
+{
+ const double start = startTimeInternal() + specifiedTiming().startDelay;
+ const double end = start + activeDurationInternal();
+
+ switch (phase()) {
+ case PhaseNone:
+ return std::numeric_limits<double>::infinity();
+ case PhaseBefore:
+ ASSERT(start >= localTime);
+ return forwards
+ ? start - localTime
+ : std::numeric_limits<double>::infinity();
+ case PhaseActive:
+ if (forwards) {
+ // Need service to apply fill / fire events.
+ const double timeToEnd = end - localTime;
+ if (requiresIterationEvents()) {
+ return std::min(timeToEnd, timeToNextIteration);
+ }
+ return timeToEnd;
+ }
+ return 0;
+ case PhaseAfter:
+ ASSERT(localTime >= end);
+ // If this KeyframeEffect is still in effect then it will need to update
+ // when its parent goes out of effect. We have no way of knowing when
+ // that will be, however, so the parent will need to supply it.
+ return forwards
+ ? std::numeric_limits<double>::infinity()
+ : localTime - end;
+ default:
+ ASSERT_NOT_REACHED();
+ return std::numeric_limits<double>::infinity();
+ }
+}
+
+#if !ENABLE(OILPAN)
+void KeyframeEffect::notifyElementDestroyed()
+{
+ // If our animation is kept alive just by the sampledEffect, we might get our
+ // destructor called when we call SampledEffect::clear(), so we need to
+ // clear m_sampledEffect first.
+ m_target = nullptr;
+ clearEventDelegate();
+ SampledEffect* sampledEffect = m_sampledEffect;
+ m_sampledEffect = nullptr;
+ if (sampledEffect)
+ sampledEffect->clear();
+}
+#endif
+
+bool KeyframeEffect::isCandidateForAnimationOnCompositor(double animationPlaybackRate) const
+{
+ if (!effect()
+ || !m_target
+ || (m_target->computedStyle() && m_target->computedStyle()->hasMotionPath()))
+ return false;
+
+ return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(specifiedTiming(), *m_target, animation(), *effect(), animationPlaybackRate);
+}
+
+bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime, double currentTime, double animationPlaybackRate)
+{
+ ASSERT(!hasActiveAnimationsOnCompositor());
+ if (!isCandidateForAnimationOnCompositor(animationPlaybackRate))
+ return false;
+ if (!CompositorAnimations::instance()->canStartAnimationOnCompositor(*m_target))
+ return false;
+ if (!CompositorAnimations::instance()->startAnimationOnCompositor(*m_target, group, startTime, currentTime, specifiedTiming(), *animation(), *effect(), m_compositorAnimationIds, animationPlaybackRate))
+ return false;
+ ASSERT(!m_compositorAnimationIds.isEmpty());
+ return true;
+}
+
+bool KeyframeEffect::hasActiveAnimationsOnCompositor() const
+{
+ return !m_compositorAnimationIds.isEmpty();
+}
+
+bool KeyframeEffect::hasActiveAnimationsOnCompositor(CSSPropertyID property) const
+{
+ return hasActiveAnimationsOnCompositor() && affects(PropertyHandle(property));
+}
+
+bool KeyframeEffect::affects(PropertyHandle property) const
+{
+ return m_effect && m_effect->affects(property);
+}
+
+bool KeyframeEffect::cancelAnimationOnCompositor()
+{
+ // FIXME: cancelAnimationOnCompositor is called from withins style recalc.
+ // This queries compositingState, which is not necessarily up to date.
+ // https://code.google.com/p/chromium/issues/detail?id=339847
+ DisableCompositingQueryAsserts disabler;
+ if (!hasActiveAnimationsOnCompositor())
+ return false;
+ if (!m_target || !m_target->layoutObject())
+ return false;
+ ASSERT(animation());
+ for (const auto& compositorAnimationId : m_compositorAnimationIds)
+ CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target, *animation(), compositorAnimationId);
+ m_compositorAnimationIds.clear();
+ return true;
+}
+
+void KeyframeEffect::restartAnimationOnCompositor()
+{
+ if (cancelAnimationOnCompositor())
+ animation()->setCompositorPending(true);
+}
+
+void KeyframeEffect::cancelIncompatibleAnimationsOnCompositor()
+{
+ if (m_target && animation() && effect())
+ CompositorAnimations::instance()->cancelIncompatibleAnimationsOnCompositor(*m_target, *animation(), *effect());
+}
+
+void KeyframeEffect::pauseAnimationForTestingOnCompositor(double pauseTime)
+{
+ ASSERT(hasActiveAnimationsOnCompositor());
+ if (!m_target || !m_target->layoutObject())
+ return;
+ ASSERT(animation());
+ for (const auto& compositorAnimationId : m_compositorAnimationIds)
+ CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*m_target, *animation(), compositorAnimationId, pauseTime);
+}
+
+bool KeyframeEffect::canAttachCompositedLayers() const
+{
+ if (!m_target || !animation())
+ return false;
+
+ return CompositorAnimations::instance()->canAttachCompositedLayers(*m_target, *animation());
+}
+
+void KeyframeEffect::attachCompositedLayers()
+{
+ ASSERT(m_target);
+ ASSERT(animation());
+ CompositorAnimations::instance()->attachCompositedLayers(*m_target, *animation());
+}
+
+DEFINE_TRACE(KeyframeEffect)
+{
+ visitor->trace(m_target);
+ visitor->trace(m_effect);
+ visitor->trace(m_sampledEffect);
+ AnimationEffect::trace(visitor);
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffect.h b/third_party/WebKit/Source/core/animation/KeyframeEffect.h
new file mode 100644
index 0000000..33dafa7
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffect.h
@@ -0,0 +1,123 @@
+/*
+ * Copyright (C) 2013 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+#ifndef KeyframeEffect_h
+#define KeyframeEffect_h
+
+#include "core/CoreExport.h"
+#include "core/animation/AnimationEffect.h"
+#include "core/animation/EffectInput.h"
+#include "core/animation/EffectModel.h"
+#include "core/animation/TimingInput.h"
+#include "platform/heap/Handle.h"
+#include "wtf/RefPtr.h"
+
+namespace blink {
+
+class KeyframeEffectOptions;
+class Dictionary;
+class Element;
+class ExceptionState;
+class PropertyHandle;
+class SampledEffect;
+
+class CORE_EXPORT KeyframeEffect final : public AnimationEffect {
+ DEFINE_WRAPPERTYPEINFO();
+public:
+ enum Priority { DefaultPriority, TransitionPriority };
+
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> create(Element*, PassRefPtrWillBeRawPtr<EffectModel>, const Timing&, Priority = DefaultPriority, PassOwnPtrWillBeRawPtr<EventDelegate> = nullptr);
+ // Web Animations API Bindings constructors.
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState&);
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, const KeyframeEffectOptions& timingInput, ExceptionState&);
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> create(Element*, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState&);
+
+ virtual ~KeyframeEffect();
+
+ virtual bool isAnimation() const override { return true; }
+
+ bool affects(PropertyHandle) const;
+ const EffectModel* effect() const { return m_effect.get(); }
+ EffectModel* effect() { return m_effect.get(); }
+ void setEffect(PassRefPtrWillBeRawPtr<EffectModel> effect) { m_effect = effect; }
+ Priority priority() const { return m_priority; }
+ Element* target() const { return m_target; }
+
+#if !ENABLE(OILPAN)
+ void notifyElementDestroyed();
+#endif
+
+ bool isCandidateForAnimationOnCompositor(double animationPlaybackRate) const;
+ // Must only be called once.
+ bool maybeStartAnimationOnCompositor(int group, double startTime, double timeOffset, double animationPlaybackRate);
+ bool hasActiveAnimationsOnCompositor() const;
+ bool hasActiveAnimationsOnCompositor(CSSPropertyID) const;
+ bool cancelAnimationOnCompositor();
+ void restartAnimationOnCompositor();
+ void cancelIncompatibleAnimationsOnCompositor();
+ void pauseAnimationForTestingOnCompositor(double pauseTime);
+
+ bool canAttachCompositedLayers() const;
+ void attachCompositedLayers();
+
+ void setCompositorAnimationIdsForTesting(const Vector<int>& compositorAnimationIds) { m_compositorAnimationIds = compositorAnimationIds; }
+
+ DECLARE_VIRTUAL_TRACE();
+
+ void downgradeToNormal() { m_priority = DefaultPriority; }
+
+protected:
+ void applyEffects();
+ void clearEffects();
+ virtual void updateChildrenAndEffects() const override;
+ virtual void attach(Animation*) override;
+ virtual void detach() override;
+ virtual void specifiedTimingChanged() override;
+ virtual double calculateTimeToEffectChange(bool forwards, double inheritedTime, double timeToNextIteration) const override;
+
+private:
+ KeyframeEffect(Element*, PassRefPtrWillBeRawPtr<EffectModel>, const Timing&, Priority, PassOwnPtrWillBeRawPtr<EventDelegate>);
+
+ RawPtrWillBeMember<Element> m_target;
+ RefPtrWillBeMember<EffectModel> m_effect;
+ RawPtrWillBeMember<SampledEffect> m_sampledEffect;
+
+ Priority m_priority;
+
+ Vector<int> m_compositorAnimationIds;
+
+ friend class AnimationAnimationV8Test;
+};
+
+DEFINE_TYPE_CASTS(KeyframeEffect, AnimationEffect, animationNode, animationNode->isAnimation(), animationNode.isAnimation());
+
+} // namespace blink
+
+#endif // KeyframeEffect_h
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffect.idl b/third_party/WebKit/Source/core/animation/KeyframeEffect.idl
new file mode 100644
index 0000000..0235507
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffect.idl
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2013 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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.
+ */
+
+// https://w3c.github.io/web-animations/#the-keyframeeffect-interfaces
+
+[
+ // TODO(dstockwell): the third argument should be "optional (unrestricted double or KeyframeEffectOptions) timing".
+ Constructor(Element? target, sequence<Dictionary> keyframes, optional unrestricted double timing),
+ Constructor(Element? target, sequence<Dictionary> keyframes, KeyframeEffectOptions timing),
+ RaisesException=Constructor,
+ RuntimeEnabled=WebAnimationsAPI,
+ TypeChecking=Interface,
+] interface KeyframeEffect : AnimationEffectReadOnly {
+};
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
index 9b774ec..b39b5de 100644
--- a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.cpp
@@ -32,7 +32,7 @@
#include "core/animation/KeyframeEffectModel.h"
#include "core/StylePropertyShorthand.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
#include "core/animation/CompositorAnimations.h"
#include "core/animation/css/CSSAnimatableValueFactory.h"
#include "core/animation/css/CSSPropertyEquality.h"
@@ -57,7 +57,7 @@ PropertyHandleSet KeyframeEffectModelBase::properties() const
void KeyframeEffectModelBase::setFrames(KeyframeVector& keyframes)
{
- // TODO(samli): Should also notify/invalidate the player
+ // TODO(samli): Should also notify/invalidate the animation
m_keyframes = keyframes;
m_keyframeGroups = nullptr;
m_interpolationEffect = nullptr;
@@ -210,7 +210,7 @@ bool KeyframeEffectModelBase::isReplaceOnly()
ensureKeyframeGroups();
for (const auto& entry : *m_keyframeGroups) {
for (const auto& keyframe : entry.value->keyframes()) {
- if (keyframe->composite() != AnimationEffect::CompositeReplace)
+ if (keyframe->composite() != EffectModel::CompositeReplace)
return false;
}
}
@@ -224,10 +224,10 @@ DEFINE_TRACE(KeyframeEffectModelBase)
visitor->trace(m_keyframeGroups);
#endif
visitor->trace(m_interpolationEffect);
- AnimationEffect::trace(visitor);
+ EffectModel::trace(visitor);
}
-Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, AnimationEffect::CompositeOperation composite)
+Keyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, EffectModel::CompositeOperation composite)
: m_offset(offset)
, m_easing(easing)
, m_composite(composite)
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h
index 61891ab..aec30e8 100644
--- a/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModel.h
@@ -33,7 +33,7 @@
#include "core/CoreExport.h"
#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNode.h"
+#include "core/animation/EffectModel.h"
#include "core/animation/InterpolationEffect.h"
#include "core/animation/PropertyHandle.h"
#include "core/animation/StringKeyframe.h"
@@ -52,7 +52,7 @@ namespace blink {
class Element;
class KeyframeEffectModelTest;
-class CORE_EXPORT KeyframeEffectModelBase : public AnimationEffect {
+class CORE_EXPORT KeyframeEffectModelBase : public EffectModel {
public:
// FIXME: Implement accumulation.
@@ -87,7 +87,7 @@ public:
return m_keyframeGroups->get(property)->keyframes();
}
- // AnimationEffect implementation.
+ // EffectModel implementation.
virtual void sample(int iteration, double fraction, double iterationDuration, OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>&) const override;
virtual bool isKeyframeEffectModel() const override { return true; }
@@ -177,26 +177,26 @@ using StringKeyframeEffectModel = KeyframeEffectModel<StringKeyframe>;
using StringKeyframeVector = StringKeyframeEffectModel::KeyframeVector;
using StringPropertySpecificKeyframeVector = StringKeyframeEffectModel::PropertySpecificKeyframeVector;
-DEFINE_TYPE_CASTS(KeyframeEffectModelBase, AnimationEffect, value, value->isKeyframeEffectModel(), value.isKeyframeEffectModel());
+DEFINE_TYPE_CASTS(KeyframeEffectModelBase, EffectModel, value, value->isKeyframeEffectModel(), value.isKeyframeEffectModel());
DEFINE_TYPE_CASTS(AnimatableValueKeyframeEffectModel, KeyframeEffectModelBase, value, value->isAnimatableValueKeyframeEffectModel(), value.isAnimatableValueKeyframeEffectModel());
DEFINE_TYPE_CASTS(StringKeyframeEffectModel, KeyframeEffectModelBase, value, value->isStringKeyframeEffectModel(), value.isStringKeyframeEffectModel());
-inline const AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(const AnimationEffect* base)
+inline const AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(const EffectModel* base)
{
return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base));
}
-inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(AnimationEffect* base)
+inline AnimatableValueKeyframeEffectModel* toAnimatableValueKeyframeEffectModel(EffectModel* base)
{
return toAnimatableValueKeyframeEffectModel(toKeyframeEffectModelBase(base));
}
-inline const StringKeyframeEffectModel* toStringKeyframeEffectModel(const AnimationEffect* base)
+inline const StringKeyframeEffectModel* toStringKeyframeEffectModel(const EffectModel* base)
{
return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base));
}
-inline StringKeyframeEffectModel* toStringKeyframeEffectModel(AnimationEffect* base)
+inline StringKeyframeEffectModel* toStringKeyframeEffectModel(EffectModel* base)
{
return toStringKeyframeEffectModel(toKeyframeEffectModelBase(base));
}
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp
index a77cbd8..1aece27 100644
--- a/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectModelTest.cpp
@@ -112,8 +112,8 @@ TEST(AnimationKeyframeEffectModel, BasicOperation)
TEST(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(unknownAnimatableValue(3.0), unknownAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -123,8 +123,8 @@ TEST(AnimationKeyframeEffectModel, CompositeReplaceNonInterpolable)
TEST(AnimationKeyframeEffectModel, CompositeReplace)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -135,8 +135,8 @@ TEST(AnimationKeyframeEffectModel, CompositeReplace)
TEST(AnimationKeyframeEffectModel, DISABLED_CompositeAdd)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
- keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
+ keyframes[0]->setComposite(EffectModel::CompositeAdd);
+ keyframes[1]->setComposite(EffectModel::CompositeAdd);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -146,9 +146,9 @@ TEST(AnimationKeyframeEffectModel, DISABLED_CompositeAdd)
TEST(AnimationKeyframeEffectModel, CompositeEaseIn)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
keyframes[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseIn));
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -160,9 +160,9 @@ TEST(AnimationKeyframeEffectModel, CompositeEaseIn)
TEST(AnimationKeyframeEffectModel, CompositeCubicBezier)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
keyframes[0]->setEasing(CubicBezierTimingFunction::create(0.42, 0, 0.58, 1));
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -174,8 +174,8 @@ TEST(AnimationKeyframeEffectModel, CompositeCubicBezier)
TEST(AnimationKeyframeEffectModel, ExtrapolateReplaceNonInterpolable)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(unknownAnimatableValue(3.0), unknownAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 1.6, duration, values);
@@ -186,8 +186,8 @@ TEST(AnimationKeyframeEffectModel, ExtrapolateReplace)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
- keyframes[0]->setComposite(AnimationEffect::CompositeReplace);
- keyframes[1]->setComposite(AnimationEffect::CompositeReplace);
+ keyframes[0]->setComposite(EffectModel::CompositeReplace);
+ keyframes[1]->setComposite(EffectModel::CompositeReplace);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 1.6, duration, values);
expectDoubleValue(3.0 * -0.6 + 5.0 * 1.6, values->at(0));
@@ -197,8 +197,8 @@ TEST(AnimationKeyframeEffectModel, ExtrapolateReplace)
TEST(AnimationKeyframeEffectModel, DISABLED_ExtrapolateAdd)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
- keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
+ keyframes[0]->setComposite(EffectModel::CompositeAdd);
+ keyframes[1]->setComposite(EffectModel::CompositeAdd);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 1.6, duration, values);
@@ -365,7 +365,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_PerKeyframeComposite)
keyframes[1] = AnimatableValueKeyframe::create();
keyframes[1]->setOffset(1.0);
keyframes[1]->setPropertyValue(CSSPropertyLeft, pixelAnimatableValue(5.0).get());
- keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
+ keyframes[1]->setComposite(EffectModel::CompositeAdd);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
@@ -401,8 +401,8 @@ TEST(AnimationKeyframeEffectModel, MultipleProperties)
TEST(AnimationKeyframeEffectModel, DISABLED_RecompositeCompositableValue)
{
AnimatableValueKeyframeVector keyframes = keyframesAtZeroAndOne(pixelAnimatableValue(3.0), pixelAnimatableValue(5.0));
- keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
- keyframes[1]->setComposite(AnimationEffect::CompositeAdd);
+ keyframes[0]->setComposite(EffectModel::CompositeAdd);
+ keyframes[1]->setComposite(EffectModel::CompositeAdd);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
OwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> values = nullptr;
effect->sample(0, 0.6, duration, values);
@@ -430,7 +430,7 @@ TEST(AnimationKeyframeEffectModel, DISABLED_DependsOnUnderlyingValue)
keyframes[0] = AnimatableValueKeyframe::create();
keyframes[0]->setOffset(0.0);
keyframes[0]->setPropertyValue(CSSPropertyLeft, pixelAnimatableValue(1.0).get());
- keyframes[0]->setComposite(AnimationEffect::CompositeAdd);
+ keyframes[0]->setComposite(EffectModel::CompositeAdd);
keyframes[1] = AnimatableValueKeyframe::create();
keyframes[1]->setOffset(0.5);
keyframes[1]->setPropertyValue(CSSPropertyLeft, pixelAnimatableValue(1.0).get());
@@ -480,7 +480,7 @@ TEST(AnimationKeyframeEffectModel, ToKeyframeEffectModel)
AnimatableValueKeyframeVector keyframes(0);
RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableValueKeyframeEffectModel::create(keyframes);
- AnimationEffect* baseEffect = effect.get();
+ EffectModel* baseEffect = effect.get();
EXPECT_TRUE(toAnimatableValueKeyframeEffectModel(baseEffect));
}
diff --git a/third_party/WebKit/Source/core/animation/AnimationTimingProperties.idl b/third_party/WebKit/Source/core/animation/KeyframeEffectOptions.idl
index 10e5910..9585948 100644
--- a/third_party/WebKit/Source/core/animation/AnimationTimingProperties.idl
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectOptions.idl
@@ -5,7 +5,7 @@
// https://w3c.github.io/web-animations/#the-animationeffecttimingproperties-dictionary
// TODO(dstockwell): Rename this to AnimationEffectTimingProperties.
-dictionary AnimationTimingProperties {
+dictionary KeyframeEffectOptions {
double delay = 0;
double endDelay = 0;
// TODO(dstockwell): The fill type should be FillMode.
diff --git a/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp
new file mode 100644
index 0000000..5fb86f7
--- /dev/null
+++ b/third_party/WebKit/Source/core/animation/KeyframeEffectTest.cpp
@@ -0,0 +1,464 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/animation/KeyframeEffect.h"
+
+#include "bindings/core/v8/Dictionary.h"
+#include "bindings/core/v8/UnionTypesCore.h"
+#include "bindings/core/v8/V8BindingForTesting.h"
+#include "bindings/core/v8/V8KeyframeEffectOptions.h"
+#include "core/animation/AnimationClock.h"
+#include "core/animation/AnimationEffectTiming.h"
+#include "core/animation/AnimationTestHelper.h"
+#include "core/animation/AnimationTimeline.h"
+#include "core/animation/KeyframeEffectModel.h"
+#include "core/animation/Timing.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/testing/DummyPageHolder.h"
+#include <gtest/gtest.h>
+#include <v8.h>
+
+namespace blink {
+
+class KeyframeEffectTest : public ::testing::Test {
+protected:
+ KeyframeEffectTest()
+ : pageHolder(DummyPageHolder::create())
+ , document(pageHolder->document())
+ , element(document.createElement("foo", ASSERT_NO_EXCEPTION))
+ {
+ document.animationClock().resetTimeForTesting(document.timeline().zeroTime());
+ EXPECT_EQ(0, document.timeline().currentTime());
+ }
+
+ OwnPtr<DummyPageHolder> pageHolder;
+ Document& document;
+ RefPtrWillBePersistent<Element> element;
+ TrackExceptionState exceptionState;
+};
+
+class AnimationKeyframeEffectV8Test : public KeyframeEffectTest {
+protected:
+ AnimationKeyframeEffectV8Test()
+ : m_isolate(v8::Isolate::GetCurrent())
+ , m_scope(m_isolate)
+ {
+ }
+
+ template<typename T>
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, T timingInput, ExceptionState& exceptionState)
+ {
+ return KeyframeEffect::create(element, keyframeDictionaryVector, timingInput, exceptionState);
+ }
+ static PassRefPtrWillBeRawPtr<KeyframeEffect> createAnimation(Element* element, Vector<Dictionary> keyframeDictionaryVector, ExceptionState& exceptionState)
+ {
+ return KeyframeEffect::create(element, keyframeDictionaryVector, exceptionState);
+ }
+
+ v8::Isolate* m_isolate;
+
+private:
+ V8TestingScope m_scope;
+};
+
+TEST_F(AnimationKeyframeEffectV8Test, CanCreateAnAnimation)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+ setV8ObjectPropertyAsString(keyframe1, "easing", "ease-in-out");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+ setV8ObjectPropertyAsString(keyframe2, "easing", "cubic-bezier(1, 1, 0.3, 0.3)");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+
+ String value1;
+ ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[0], "width", value1));
+ ASSERT_EQ("100px", value1);
+
+ String value2;
+ ASSERT_TRUE(DictionaryHelper::get(jsKeyframes[1], "width", value2));
+ ASSERT_EQ("0px", value2);
+
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ Element* target = animation->target();
+ EXPECT_EQ(*element.get(), *target);
+
+ const KeyframeVector keyframes = toKeyframeEffectModelBase(animation->effect())->getFrames();
+
+ EXPECT_EQ(0, keyframes[0]->offset());
+ EXPECT_EQ(1, keyframes[1]->offset());
+
+ const CSSValue* keyframe1Width = toStringKeyframe(keyframes[0].get())->cssPropertyValue(CSSPropertyWidth);
+ const CSSValue* keyframe2Width = toStringKeyframe(keyframes[1].get())->cssPropertyValue(CSSPropertyWidth);
+ ASSERT(keyframe1Width);
+ ASSERT(keyframe2Width);
+
+ EXPECT_EQ("100px", keyframe1Width->cssText());
+ EXPECT_EQ("0px", keyframe2Width->cssText());
+
+ EXPECT_EQ(*(CubicBezierTimingFunction::preset(CubicBezierTimingFunction::EaseInOut)), keyframes[0]->easing());
+ EXPECT_EQ(*(CubicBezierTimingFunction::create(1, 1, 0.3, 0.3).get()), keyframes[1]->easing());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, CanSetDuration)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+ double duration = 2000;
+
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, duration, exceptionState);
+
+ EXPECT_EQ(duration / 1000, animation->specifiedTiming().iterationDuration);
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, CanOmitSpecifiedDuration)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, exceptionState);
+ EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, NegativeDurationIsAuto)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, -2, exceptionState);
+ EXPECT_TRUE(std::isnan(animation->specifiedTiming().iterationDuration));
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, MismatchedKeyframePropertyRaisesException)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+
+ // Height property appears only in keyframe2
+ setV8ObjectPropertyAsString(keyframe2, "height", "100px");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+
+ createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(NotSupportedError, exceptionState.code());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetZeroRaisesException)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+
+ createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(NotSupportedError, exceptionState.code());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetOneRaisesException)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "0.1");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+
+ createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(NotSupportedError, exceptionState.code());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, MissingOffsetZeroAndOneRaisesException)
+{
+ Vector<Dictionary> jsKeyframes;
+ v8::Local<v8::Object> keyframe1 = v8::Object::New(m_isolate);
+ v8::Local<v8::Object> keyframe2 = v8::Object::New(m_isolate);
+
+ setV8ObjectPropertyAsString(keyframe1, "width", "100px");
+ setV8ObjectPropertyAsString(keyframe1, "offset", "0.1");
+ setV8ObjectPropertyAsString(keyframe2, "width", "0px");
+ setV8ObjectPropertyAsString(keyframe2, "offset", "0.2");
+
+ jsKeyframes.append(Dictionary(keyframe1, m_isolate, exceptionState));
+ jsKeyframes.append(Dictionary(keyframe2, m_isolate, exceptionState));
+
+ createAnimation(element.get(), jsKeyframes, 0, exceptionState);
+
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ(NotSupportedError, exceptionState.code());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, SpecifiedGetters)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+
+ v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
+ setV8ObjectPropertyAsNumber(timingInput, "delay", 2);
+ setV8ObjectPropertyAsNumber(timingInput, "endDelay", 0.5);
+ setV8ObjectPropertyAsString(timingInput, "fill", "backwards");
+ setV8ObjectPropertyAsNumber(timingInput, "iterationStart", 2);
+ setV8ObjectPropertyAsNumber(timingInput, "iterations", 10);
+ setV8ObjectPropertyAsNumber(timingInput, "playbackRate", 2);
+ setV8ObjectPropertyAsString(timingInput, "direction", "reverse");
+ setV8ObjectPropertyAsString(timingInput, "easing", "step-start");
+ KeyframeEffectOptions timingInputDictionary;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
+
+ RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing();
+ EXPECT_EQ(2, specified->delay());
+ EXPECT_EQ(0.5, specified->endDelay());
+ EXPECT_EQ("backwards", specified->fill());
+ EXPECT_EQ(2, specified->iterationStart());
+ EXPECT_EQ(10, specified->iterations());
+ EXPECT_EQ(2, specified->playbackRate());
+ EXPECT_EQ("reverse", specified->direction());
+ EXPECT_EQ("step-start", specified->easing());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, SpecifiedDurationGetter)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+
+ v8::Local<v8::Object> timingInputWithDuration = v8::Object::New(m_isolate);
+ setV8ObjectPropertyAsNumber(timingInputWithDuration, "duration", 2.5);
+ KeyframeEffectOptions timingInputDictionaryWithDuration;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInputWithDuration, timingInputDictionaryWithDuration, exceptionState);
+
+ RefPtrWillBeRawPtr<KeyframeEffect> animationWithDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryWithDuration, exceptionState);
+
+ RefPtrWillBeRawPtr<AnimationEffectTiming> specifiedWithDuration = animationWithDuration->timing();
+ UnrestrictedDoubleOrString duration;
+ specifiedWithDuration->duration(duration);
+ EXPECT_TRUE(duration.isUnrestrictedDouble());
+ EXPECT_EQ(2.5, duration.getAsUnrestrictedDouble());
+ EXPECT_FALSE(duration.isString());
+
+
+ v8::Local<v8::Object> timingInputNoDuration = v8::Object::New(m_isolate);
+ KeyframeEffectOptions timingInputDictionaryNoDuration;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInputNoDuration, timingInputDictionaryNoDuration, exceptionState);
+
+ RefPtrWillBeRawPtr<KeyframeEffect> animationNoDuration = createAnimation(element.get(), jsKeyframes, timingInputDictionaryNoDuration, exceptionState);
+
+ RefPtrWillBeRawPtr<AnimationEffectTiming> specifiedNoDuration = animationNoDuration->timing();
+ UnrestrictedDoubleOrString duration2;
+ specifiedNoDuration->duration(duration2);
+ EXPECT_FALSE(duration2.isUnrestrictedDouble());
+ EXPECT_TRUE(duration2.isString());
+ EXPECT_EQ("auto", duration2.getAsString());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, SpecifiedSetters)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+ v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
+ KeyframeEffectOptions timingInputDictionary;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
+
+ RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing();
+
+ EXPECT_EQ(0, specified->delay());
+ specified->setDelay(2);
+ EXPECT_EQ(2, specified->delay());
+
+ EXPECT_EQ(0, specified->endDelay());
+ specified->setEndDelay(0.5);
+ EXPECT_EQ(0.5, specified->endDelay());
+
+ EXPECT_EQ("auto", specified->fill());
+ specified->setFill("backwards");
+ EXPECT_EQ("backwards", specified->fill());
+
+ EXPECT_EQ(0, specified->iterationStart());
+ specified->setIterationStart(2);
+ EXPECT_EQ(2, specified->iterationStart());
+
+ EXPECT_EQ(1, specified->iterations());
+ specified->setIterations(10);
+ EXPECT_EQ(10, specified->iterations());
+
+ EXPECT_EQ(1, specified->playbackRate());
+ specified->setPlaybackRate(2);
+ EXPECT_EQ(2, specified->playbackRate());
+
+ EXPECT_EQ("normal", specified->direction());
+ specified->setDirection("reverse");
+ EXPECT_EQ("reverse", specified->direction());
+
+ EXPECT_EQ("linear", specified->easing());
+ specified->setEasing("step-start");
+ EXPECT_EQ("step-start", specified->easing());
+}
+
+TEST_F(AnimationKeyframeEffectV8Test, SetSpecifiedDuration)
+{
+ Vector<Dictionary, 0> jsKeyframes;
+ v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
+ KeyframeEffectOptions timingInputDictionary;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = createAnimation(element.get(), jsKeyframes, timingInputDictionary, exceptionState);
+
+ RefPtrWillBeRawPtr<AnimationEffectTiming> specified = animation->timing();
+
+ UnrestrictedDoubleOrString duration;
+ specified->duration(duration);
+ EXPECT_FALSE(duration.isUnrestrictedDouble());
+ EXPECT_TRUE(duration.isString());
+ EXPECT_EQ("auto", duration.getAsString());
+
+ UnrestrictedDoubleOrString inDuration;
+ inDuration.setUnrestrictedDouble(2.5);
+ specified->setDuration(inDuration);
+ UnrestrictedDoubleOrString duration2;
+ specified->duration(duration2);
+ EXPECT_TRUE(duration2.isUnrestrictedDouble());
+ EXPECT_EQ(2.5, duration2.getAsUnrestrictedDouble());
+ EXPECT_FALSE(duration2.isString());
+}
+
+TEST_F(KeyframeEffectTest, TimeToEffectChange)
+{
+ Timing timing;
+ timing.iterationDuration = 100;
+ timing.startDelay = 100;
+ timing.endDelay = 100;
+ timing.fillMode = Timing::FillModeNone;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nullptr, timing);
+ RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.get());
+ double inf = std::numeric_limits<double>::infinity();
+
+ EXPECT_EQ(100, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(100);
+ EXPECT_EQ(100, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(199);
+ EXPECT_EQ(1, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(200);
+ // End-exclusive.
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(300);
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(100, animation->timeToReverseEffectChange());
+}
+
+TEST_F(KeyframeEffectTest, TimeToEffectChangeWithPlaybackRate)
+{
+ Timing timing;
+ timing.iterationDuration = 100;
+ timing.startDelay = 100;
+ timing.endDelay = 100;
+ timing.playbackRate = 2;
+ timing.fillMode = Timing::FillModeNone;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nullptr, timing);
+ RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.get());
+ double inf = std::numeric_limits<double>::infinity();
+
+ EXPECT_EQ(100, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(100);
+ EXPECT_EQ(50, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(149);
+ EXPECT_EQ(1, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(150);
+ // End-exclusive.
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(200);
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(50, animation->timeToReverseEffectChange());
+}
+
+TEST_F(KeyframeEffectTest, TimeToEffectChangeWithNegativePlaybackRate)
+{
+ Timing timing;
+ timing.iterationDuration = 100;
+ timing.startDelay = 100;
+ timing.endDelay = 100;
+ timing.playbackRate = -2;
+ timing.fillMode = Timing::FillModeNone;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(0, nullptr, timing);
+ RefPtrWillBeRawPtr<Animation> player = document.timeline().play(animation.get());
+ double inf = std::numeric_limits<double>::infinity();
+
+ EXPECT_EQ(100, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(inf, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(100);
+ EXPECT_EQ(50, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(149);
+ EXPECT_EQ(1, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(150);
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(0, animation->timeToReverseEffectChange());
+
+ player->setCurrentTimeInternal(200);
+ EXPECT_EQ(inf, animation->timeToForwardsEffectChange());
+ EXPECT_EQ(50, animation->timeToReverseEffectChange());
+}
+
+TEST_F(KeyframeEffectTest, ElementDestructorClearsAnimationTarget)
+{
+ // This test expects incorrect behaviour should be removed once Element
+ // and KeyframeEffect are moved to Oilpan. See crbug.com/362404 for context.
+ Timing timing;
+ timing.iterationDuration = 5;
+ RefPtrWillBeRawPtr<KeyframeEffect> animation = KeyframeEffect::create(element.get(), nullptr, timing);
+ EXPECT_EQ(element.get(), animation->target());
+ document.timeline().play(animation.get());
+ pageHolder.clear();
+ element.clear();
+#if !ENABLE(OILPAN)
+ EXPECT_EQ(0, animation->target());
+#endif
+}
+
+} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/SampledEffect.cpp b/third_party/WebKit/Source/core/animation/SampledEffect.cpp
index 798f039..cc91740 100644
--- a/third_party/WebKit/Source/core/animation/SampledEffect.cpp
+++ b/third_party/WebKit/Source/core/animation/SampledEffect.cpp
@@ -11,27 +11,27 @@
namespace blink {
-SampledEffect::SampledEffect(Animation* animation, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations)
- : m_animation(animation)
- , m_player(animation->player())
+SampledEffect::SampledEffect(KeyframeEffect* effect, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations)
+ : m_effect(effect)
+ , m_animation(effect->animation())
, m_interpolations(interpolations)
- , m_sequenceNumber(animation->player()->sequenceNumber())
- , m_priority(animation->priority())
+ , m_sequenceNumber(effect->animation()->sequenceNumber())
+ , m_priority(effect->priority())
{
ASSERT(m_interpolations && !m_interpolations->isEmpty());
}
void SampledEffect::clear()
{
- m_player = nullptr;
+ m_effect = nullptr;
m_animation = nullptr;
m_interpolations->clear();
}
DEFINE_TRACE(SampledEffect)
{
+ visitor->trace(m_effect);
visitor->trace(m_animation);
- visitor->trace(m_player);
#if ENABLE(OILPAN)
visitor->trace(m_interpolations);
#endif
diff --git a/third_party/WebKit/Source/core/animation/SampledEffect.h b/third_party/WebKit/Source/core/animation/SampledEffect.h
index 67a2c00..16e91c8 100644
--- a/third_party/WebKit/Source/core/animation/SampledEffect.h
+++ b/third_party/WebKit/Source/core/animation/SampledEffect.h
@@ -6,8 +6,8 @@
#define SampledEffect_h
#include "core/animation/Animation.h"
-#include "core/animation/AnimationPlayer.h"
#include "core/animation/Interpolation.h"
+#include "core/animation/KeyframeEffect.h"
#include "wtf/BitArray.h"
#include "wtf/Vector.h"
@@ -17,7 +17,7 @@ class SVGElement;
class SampledEffect : public NoBaseWillBeGarbageCollected<SampledEffect> {
public:
- static PassOwnPtrWillBeRawPtr<SampledEffect> create(Animation* animation, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations)
+ static PassOwnPtrWillBeRawPtr<SampledEffect> create(KeyframeEffect* animation, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations)
{
return adoptPtrWillBeNoop(new SampledEffect(animation, interpolations));
}
@@ -33,22 +33,22 @@ public:
void setInterpolations(PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> interpolations) { m_interpolations = interpolations; }
- Animation* animation() const { return m_animation; }
+ KeyframeEffect* effect() const { return m_effect; }
unsigned sequenceNumber() const { return m_sequenceNumber; }
- Animation::Priority priority() const { return m_priority; }
+ KeyframeEffect::Priority priority() const { return m_priority; }
DECLARE_TRACE();
void applySVGUpdate(SVGElement&);
private:
- SampledEffect(Animation*, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>);
+ SampledEffect(KeyframeEffect*, PassOwnPtrWillBeRawPtr<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>>);
- RawPtrWillBeWeakMember<Animation> m_animation;
- RefPtrWillBeMember<AnimationPlayer> m_player;
+ RawPtrWillBeWeakMember<KeyframeEffect> m_effect;
+ RefPtrWillBeMember<Animation> m_animation;
OwnPtrWillBeMember<WillBeHeapVector<RefPtrWillBeMember<Interpolation>>> m_interpolations;
const unsigned m_sequenceNumber;
- Animation::Priority m_priority;
+ KeyframeEffect::Priority m_priority;
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/animation/StringKeyframe.cpp b/third_party/WebKit/Source/core/animation/StringKeyframe.cpp
index 0ab351e..3f96158 100644
--- a/third_party/WebKit/Source/core/animation/StringKeyframe.cpp
+++ b/third_party/WebKit/Source/core/animation/StringKeyframe.cpp
@@ -103,13 +103,13 @@ DEFINE_TRACE(StringKeyframe)
Keyframe::trace(visitor);
}
-StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, AnimationEffect::CompositeOperation op)
+StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value, EffectModel::CompositeOperation op)
: Keyframe::PropertySpecificKeyframe(offset, easing, op)
, m_value(value)
{ }
StringKeyframe::CSSPropertySpecificKeyframe::CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue* value)
- : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
+ : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeReplace)
, m_value(value)
{
ASSERT(!isNull(m_offset));
@@ -441,7 +441,7 @@ PassRefPtrWillBeRawPtr<Interpolation> StringKeyframe::CSSPropertySpecificKeyfram
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
{
- return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*>(0), AnimationEffect::CompositeAdd));
+ return adoptPtrWillBeNoop(new CSSPropertySpecificKeyframe(offset, easing, static_cast<CSSValue*>(0), EffectModel::CompositeAdd));
}
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> StringKeyframe::CSSPropertySpecificKeyframe::cloneWithOffset(double offset) const
@@ -458,14 +458,14 @@ DEFINE_TRACE(StringKeyframe::CSSPropertySpecificKeyframe)
Keyframe::PropertySpecificKeyframe::trace(visitor);
}
-SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String& value, AnimationEffect::CompositeOperation op)
+SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String& value, EffectModel::CompositeOperation op)
: Keyframe::PropertySpecificKeyframe(offset, easing, op)
, m_value(value)
{
}
SVGPropertySpecificKeyframe::SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String& value)
- : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
+ : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeReplace)
, m_value(value)
{
ASSERT(!isNull(m_offset));
@@ -483,7 +483,7 @@ PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKe
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> SVGPropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
{
- return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, "", AnimationEffect::CompositeAdd));
+ return adoptPtrWillBeNoop(new SVGPropertySpecificKeyframe(offset, easing, "", EffectModel::CompositeAdd));
}
namespace {
diff --git a/third_party/WebKit/Source/core/animation/StringKeyframe.h b/third_party/WebKit/Source/core/animation/StringKeyframe.h
index 58aa569..839fe75 100644
--- a/third_party/WebKit/Source/core/animation/StringKeyframe.h
+++ b/third_party/WebKit/Source/core/animation/StringKeyframe.h
@@ -41,7 +41,7 @@ public:
class CSSPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
public:
- CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, AnimationEffect::CompositeOperation);
+ CSSPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, CSSValue*, EffectModel::CompositeOperation);
CSSValue* value() const { return m_value.get(); }
@@ -70,7 +70,7 @@ public:
class SVGPropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
public:
- SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String&, AnimationEffect::CompositeOperation);
+ SVGPropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const String&, EffectModel::CompositeOperation);
const String& value() const { return m_value; }
diff --git a/third_party/WebKit/Source/core/animation/TimingCalculations.h b/third_party/WebKit/Source/core/animation/TimingCalculations.h
index 12a5d38..f0dd31c 100644
--- a/third_party/WebKit/Source/core/animation/TimingCalculations.h
+++ b/third_party/WebKit/Source/core/animation/TimingCalculations.h
@@ -31,7 +31,7 @@
#ifndef TimingCalculations_h
#define TimingCalculations_h
-#include "core/animation/AnimationNode.h"
+#include "core/animation/AnimationEffect.h"
#include "core/animation/Timing.h"
#include "platform/animation/AnimationUtilities.h"
#include "wtf/MathExtras.h"
@@ -45,26 +45,26 @@ static inline double multiplyZeroAlwaysGivesZero(double x, double y)
return x && y ? x * y : 0;
}
-static inline AnimationNode::Phase calculatePhase(double activeDuration, double localTime, const Timing& specified)
+static inline AnimationEffect::Phase calculatePhase(double activeDuration, double localTime, const Timing& specified)
{
ASSERT(activeDuration >= 0);
if (isNull(localTime))
- return AnimationNode::PhaseNone;
+ return AnimationEffect::PhaseNone;
if (localTime < specified.startDelay)
- return AnimationNode::PhaseBefore;
+ return AnimationEffect::PhaseBefore;
if (localTime >= specified.startDelay + activeDuration)
- return AnimationNode::PhaseAfter;
- return AnimationNode::PhaseActive;
+ return AnimationEffect::PhaseAfter;
+ return AnimationEffect::PhaseActive;
}
-static inline bool isActiveInParentPhase(AnimationNode::Phase parentPhase, Timing::FillMode fillMode)
+static inline bool isActiveInParentPhase(AnimationEffect::Phase parentPhase, Timing::FillMode fillMode)
{
switch (parentPhase) {
- case AnimationNode::PhaseBefore:
+ case AnimationEffect::PhaseBefore:
return fillMode == Timing::FillModeBackwards || fillMode == Timing::FillModeBoth;
- case AnimationNode::PhaseActive:
+ case AnimationEffect::PhaseActive:
return true;
- case AnimationNode::PhaseAfter:
+ case AnimationEffect::PhaseAfter:
return fillMode == Timing::FillModeForwards || fillMode == Timing::FillModeBoth;
default:
ASSERT_NOT_REACHED();
@@ -72,25 +72,25 @@ static inline bool isActiveInParentPhase(AnimationNode::Phase parentPhase, Timin
}
}
-static inline double calculateActiveTime(double activeDuration, Timing::FillMode fillMode, double localTime, AnimationNode::Phase parentPhase, AnimationNode::Phase phase, const Timing& specified)
+static inline double calculateActiveTime(double activeDuration, Timing::FillMode fillMode, double localTime, AnimationEffect::Phase parentPhase, AnimationEffect::Phase phase, const Timing& specified)
{
ASSERT(activeDuration >= 0);
ASSERT(phase == calculatePhase(activeDuration, localTime, specified));
switch (phase) {
- case AnimationNode::PhaseBefore:
+ case AnimationEffect::PhaseBefore:
if (fillMode == Timing::FillModeBackwards || fillMode == Timing::FillModeBoth)
return 0;
return nullValue();
- case AnimationNode::PhaseActive:
+ case AnimationEffect::PhaseActive:
if (isActiveInParentPhase(parentPhase, fillMode))
return localTime - specified.startDelay;
return nullValue();
- case AnimationNode::PhaseAfter:
+ case AnimationEffect::PhaseAfter:
if (fillMode == Timing::FillModeForwards || fillMode == Timing::FillModeBoth)
return activeDuration;
return nullValue();
- case AnimationNode::PhaseNone:
+ case AnimationEffect::PhaseNone:
ASSERT(isNull(localTime));
return nullValue();
default:
diff --git a/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp b/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp
index 0702378..bcaa94f 100644
--- a/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp
+++ b/third_party/WebKit/Source/core/animation/TimingCalculationsTest.cpp
@@ -45,31 +45,31 @@ TEST(AnimationTimingCalculationsTest, ActiveTime)
// Before Phase
timing.startDelay = 10;
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 0, AnimationNode::PhaseActive, AnimationNode::PhaseBefore, timing)));
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 0, AnimationNode::PhaseActive, AnimationNode::PhaseBefore, timing)));
- EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBackwards, 0, AnimationNode::PhaseActive, AnimationNode::PhaseBefore, timing));
- EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBoth, 0, AnimationNode::PhaseActive, AnimationNode::PhaseBefore, timing));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 0, AnimationEffect::PhaseActive, AnimationEffect::PhaseBefore, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 0, AnimationEffect::PhaseActive, AnimationEffect::PhaseBefore, timing)));
+ EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBackwards, 0, AnimationEffect::PhaseActive, AnimationEffect::PhaseBefore, timing));
+ EXPECT_EQ(0, calculateActiveTime(20, Timing::FillModeBoth, 0, AnimationEffect::PhaseActive, AnimationEffect::PhaseBefore, timing));
// Active Phase
timing.startDelay = 10;
// Active, and parent Before
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, AnimationNode::PhaseBefore, AnimationNode::PhaseActive, timing)));
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 15, AnimationNode::PhaseBefore, AnimationNode::PhaseActive, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, AnimationEffect::PhaseBefore, AnimationEffect::PhaseActive, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeForwards, 15, AnimationEffect::PhaseBefore, AnimationEffect::PhaseActive, timing)));
// Active, and parent After
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, AnimationNode::PhaseAfter, AnimationNode::PhaseActive, timing)));
- EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeBackwards, 15, AnimationNode::PhaseAfter, AnimationNode::PhaseActive, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeNone, 15, AnimationEffect::PhaseAfter, AnimationEffect::PhaseActive, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(20, Timing::FillModeBackwards, 15, AnimationEffect::PhaseAfter, AnimationEffect::PhaseActive, timing)));
// Active, and parent Active
- EXPECT_EQ(5, calculateActiveTime(20, Timing::FillModeForwards, 15, AnimationNode::PhaseActive, AnimationNode::PhaseActive, timing));
+ EXPECT_EQ(5, calculateActiveTime(20, Timing::FillModeForwards, 15, AnimationEffect::PhaseActive, AnimationEffect::PhaseActive, timing));
// After Phase
timing.startDelay = 10;
- EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeForwards, 45, AnimationNode::PhaseActive, AnimationNode::PhaseAfter, timing));
- EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeBoth, 45, AnimationNode::PhaseActive, AnimationNode::PhaseAfter, timing));
- EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeBackwards, 45, AnimationNode::PhaseActive, AnimationNode::PhaseAfter, timing)));
- EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeNone, 45, AnimationNode::PhaseActive, AnimationNode::PhaseAfter, timing)));
+ EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeForwards, 45, AnimationEffect::PhaseActive, AnimationEffect::PhaseAfter, timing));
+ EXPECT_EQ(21, calculateActiveTime(21, Timing::FillModeBoth, 45, AnimationEffect::PhaseActive, AnimationEffect::PhaseAfter, timing));
+ EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeBackwards, 45, AnimationEffect::PhaseActive, AnimationEffect::PhaseAfter, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(21, Timing::FillModeNone, 45, AnimationEffect::PhaseActive, AnimationEffect::PhaseAfter, timing)));
// None
- EXPECT_TRUE(isNull(calculateActiveTime(32, Timing::FillModeNone, nullValue(), AnimationNode::PhaseNone, AnimationNode::PhaseNone, timing)));
+ EXPECT_TRUE(isNull(calculateActiveTime(32, Timing::FillModeNone, nullValue(), AnimationEffect::PhaseNone, AnimationEffect::PhaseNone, timing)));
}
TEST(AnimationTimingCalculationsTest, ScaledActiveTime)
diff --git a/third_party/WebKit/Source/core/animation/TimingInput.cpp b/third_party/WebKit/Source/core/animation/TimingInput.cpp
index 64f510e..0e03462 100644
--- a/third_party/WebKit/Source/core/animation/TimingInput.cpp
+++ b/third_party/WebKit/Source/core/animation/TimingInput.cpp
@@ -6,7 +6,7 @@
#include "core/animation/TimingInput.h"
#include "core/animation/AnimationInputHelpers.h"
-#include "core/animation/AnimationTimingProperties.h"
+#include "core/animation/KeyframeEffectOptions.h"
namespace blink {
@@ -94,7 +94,7 @@ void TimingInput::setTimingFunction(Timing& timing, const String& timingFunction
timing.timingFunction = Timing::defaults().timingFunction;
}
-Timing TimingInput::convert(const AnimationTimingProperties& timingInput)
+Timing TimingInput::convert(const KeyframeEffectOptions& timingInput)
{
Timing result;
diff --git a/third_party/WebKit/Source/core/animation/TimingInput.h b/third_party/WebKit/Source/core/animation/TimingInput.h
index bd082da..22a08f7 100644
--- a/third_party/WebKit/Source/core/animation/TimingInput.h
+++ b/third_party/WebKit/Source/core/animation/TimingInput.h
@@ -11,11 +11,11 @@
namespace blink {
class Dictionary;
-class AnimationTimingProperties;
+class KeyframeEffectOptions;
class CORE_EXPORT TimingInput {
public:
- static Timing convert(const AnimationTimingProperties& timingInput);
+ static Timing convert(const KeyframeEffectOptions& timingInput);
static Timing convert(double duration);
static void setStartDelay(Timing&, double startDelay);
diff --git a/third_party/WebKit/Source/core/animation/TimingInputTest.cpp b/third_party/WebKit/Source/core/animation/TimingInputTest.cpp
index 90cdf9a..8114ba5 100644
--- a/third_party/WebKit/Source/core/animation/TimingInputTest.cpp
+++ b/third_party/WebKit/Source/core/animation/TimingInputTest.cpp
@@ -5,9 +5,9 @@
#include "config.h"
#include "core/animation/TimingInput.h"
-#include "bindings/core/v8/V8AnimationTimingProperties.h"
#include "bindings/core/v8/V8BindingForTesting.h"
-#include "core/animation/AnimationNodeTiming.h"
+#include "bindings/core/v8/V8KeyframeEffectOptions.h"
+#include "core/animation/AnimationEffectTiming.h"
#include "core/animation/AnimationTestHelper.h"
#include <gtest/gtest.h>
#include <v8.h>
@@ -26,8 +26,8 @@ protected:
{
v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
setV8ObjectPropertyAsNumber(timingInput, timingProperty, timingPropertyValue);
- AnimationTimingProperties timingInputDictionary;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+ KeyframeEffectOptions timingInputDictionary;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
return TimingInput::convert(timingInputDictionary);
}
@@ -35,8 +35,8 @@ protected:
{
v8::Local<v8::Object> timingInput = v8::Object::New(m_isolate);
setV8ObjectPropertyAsString(timingInput, timingProperty, timingPropertyValue);
- AnimationTimingProperties timingInputDictionary;
- V8AnimationTimingProperties::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
+ KeyframeEffectOptions timingInputDictionary;
+ V8KeyframeEffectOptions::toImpl(m_isolate, timingInput, timingInputDictionary, exceptionState);
return TimingInput::convert(timingInputDictionary);
}
@@ -167,7 +167,7 @@ TEST_F(AnimationTimingInputTest, TimingInputTimingFunction)
TEST_F(AnimationTimingInputTest, TimingInputEmpty)
{
Timing controlTiming;
- Timing updatedTiming = TimingInput::convert(AnimationTimingProperties());
+ Timing updatedTiming = TimingInput::convert(KeyframeEffectOptions());
EXPECT_EQ(controlTiming.startDelay, updatedTiming.startDelay);
EXPECT_EQ(controlTiming.fillMode, updatedTiming.fillMode);
diff --git a/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.cpp b/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.cpp
index 1337dbf..87172c3 100644
--- a/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.cpp
+++ b/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.cpp
@@ -44,13 +44,13 @@ DEFINE_TRACE(AnimatableValueKeyframe)
Keyframe::trace(visitor);
}
-AnimatableValueKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, AnimationEffect::CompositeOperation op)
+AnimatableValueKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue* value, EffectModel::CompositeOperation op)
: Keyframe::PropertySpecificKeyframe(offset, easing, op)
, m_value(const_cast<AnimatableValue*>(value))
{ }
AnimatableValueKeyframe::PropertySpecificKeyframe::PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, PassRefPtrWillBeRawPtr<AnimatableValue> value)
- : Keyframe::PropertySpecificKeyframe(offset, easing, AnimationEffect::CompositeReplace)
+ : Keyframe::PropertySpecificKeyframe(offset, easing, EffectModel::CompositeReplace)
, m_value(value)
{
ASSERT(!isNull(m_offset));
@@ -70,7 +70,7 @@ PassRefPtrWillBeRawPtr<Interpolation> AnimatableValueKeyframe::PropertySpecificK
PassOwnPtrWillBeRawPtr<Keyframe::PropertySpecificKeyframe> AnimatableValueKeyframe::PropertySpecificKeyframe::neutralKeyframe(double offset, PassRefPtr<TimingFunction> easing) const
{
- return adoptPtrWillBeNoop(new AnimatableValueKeyframe::PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), AnimationEffect::CompositeAdd));
+ return adoptPtrWillBeNoop(new AnimatableValueKeyframe::PropertySpecificKeyframe(offset, easing, AnimatableValue::neutralValue(), EffectModel::CompositeAdd));
}
DEFINE_TRACE(AnimatableValueKeyframe::PropertySpecificKeyframe)
diff --git a/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.h b/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.h
index 6e7d330..e1533dbe 100644
--- a/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.h
+++ b/third_party/WebKit/Source/core/animation/animatable/AnimatableValueKeyframe.h
@@ -33,7 +33,7 @@ public:
class PropertySpecificKeyframe : public Keyframe::PropertySpecificKeyframe {
public:
- PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue*, AnimationEffect::CompositeOperation);
+ PropertySpecificKeyframe(double offset, PassRefPtr<TimingFunction> easing, const AnimatableValue*, EffectModel::CompositeOperation);
AnimatableValue* value() const { return m_value.get(); }
virtual const PassRefPtrWillBeRawPtr<AnimatableValue> getAnimatableValue() const override final { return m_value; }
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h b/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h
index 0c601b5..23df209 100644
--- a/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h
+++ b/third_party/WebKit/Source/core/animation/css/CSSAnimationUpdate.h
@@ -18,7 +18,7 @@
namespace blink {
-class AnimationPlayer;
+class Animation;
class InertAnimation;
// This class stores the CSS Animations/Transitions information we use during a style recalc.
@@ -33,9 +33,9 @@ public:
{
}
- NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertAnimation> animation, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
+ NewAnimation(AtomicString name, PassRefPtrWillBeRawPtr<InertAnimation> effect, Timing timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
: name(name)
- , animation(animation)
+ , effect(effect)
, timing(timing)
, styleRule(styleRule)
, styleRuleVersion(this->styleRule->version())
@@ -44,12 +44,12 @@ public:
DEFINE_INLINE_TRACE()
{
- visitor->trace(animation);
+ visitor->trace(effect);
visitor->trace(styleRule);
}
AtomicString name;
- RefPtrWillBeMember<InertAnimation> animation;
+ RefPtrWillBeMember<InertAnimation> effect;
Timing timing;
RefPtrWillBeMember<StyleRuleKeyframes> styleRule;
unsigned styleRuleVersion;
@@ -63,10 +63,10 @@ public:
{
}
- UpdatedAnimation(AtomicString name, AnimationPlayer* player, PassRefPtrWillBeRawPtr<InertAnimation> animation, Timing specifiedTiming, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
+ UpdatedAnimation(AtomicString name, Animation* animation, PassRefPtrWillBeRawPtr<InertAnimation> effect, Timing specifiedTiming, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
: name(name)
- , player(player)
, animation(animation)
+ , effect(effect)
, specifiedTiming(specifiedTiming)
, styleRule(styleRule)
, styleRuleVersion(this->styleRule->version())
@@ -75,14 +75,14 @@ public:
DEFINE_INLINE_TRACE()
{
- visitor->trace(player);
visitor->trace(animation);
+ visitor->trace(effect);
visitor->trace(styleRule);
}
AtomicString name;
- RawPtrWillBeMember<AnimationPlayer> player;
- RefPtrWillBeMember<InertAnimation> animation;
+ RawPtrWillBeMember<Animation> animation;
+ RefPtrWillBeMember<InertAnimation> effect;
Timing specifiedTiming;
RefPtrWillBeMember<StyleRuleKeyframes> styleRule;
unsigned styleRuleVersion;
@@ -111,8 +111,8 @@ public:
{
}
- UpdatedAnimationStyle(AnimationPlayer* player, KeyframeEffectModelBase* effect, const UpdatedAnimationStyle::CompositableStyleSnapshot& snapshot)
- : player(player)
+ UpdatedAnimationStyle(Animation* animation, KeyframeEffectModelBase* effect, const UpdatedAnimationStyle::CompositableStyleSnapshot& snapshot)
+ : animation(animation)
, effect(effect)
, snapshot(snapshot)
{
@@ -120,39 +120,39 @@ public:
DEFINE_INLINE_TRACE()
{
- visitor->trace(player);
+ visitor->trace(animation);
visitor->trace(effect);
visitor->trace(snapshot);
}
- RawPtrWillBeMember<AnimationPlayer> player;
+ RawPtrWillBeMember<Animation> animation;
RawPtrWillBeMember<KeyframeEffectModelBase> effect;
CompositableStyleSnapshot snapshot;
};
- void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPtr<InertAnimation> animation, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
+ void startAnimation(const AtomicString& animationName, PassRefPtrWillBeRawPtr<InertAnimation> effect, const Timing& timing, PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
{
- animation->setName(animationName);
- m_newAnimations.append(NewAnimation(animationName, animation, timing, styleRule));
+ effect->setName(animationName);
+ m_newAnimations.append(NewAnimation(animationName, effect, timing, styleRule));
}
- // Returns whether player has been suppressed and should be filtered during style application.
- bool isSuppressedAnimation(const AnimationPlayer* player) const { return m_suppressedAnimationPlayers.contains(player); }
- void cancelAnimation(const AtomicString& name, AnimationPlayer& player)
+ // Returns whether animation has been suppressed and should be filtered during style application.
+ bool isSuppressedAnimation(const Animation* animation) const { return m_suppressedAnimations.contains(animation); }
+ void cancelAnimation(const AtomicString& name, Animation& animation)
{
m_cancelledAnimationNames.append(name);
- m_suppressedAnimationPlayers.add(&player);
+ m_suppressedAnimations.add(&animation);
}
void toggleAnimationPaused(const AtomicString& name)
{
m_animationsWithPauseToggled.append(name);
}
- void updateAnimation(const AtomicString& name, AnimationPlayer* player, PassRefPtrWillBeRawPtr<InertAnimation> animation, const Timing& specifiedTiming,
+ void updateAnimation(const AtomicString& name, Animation* animation, PassRefPtrWillBeRawPtr<InertAnimation> effect, const Timing& specifiedTiming,
PassRefPtrWillBeRawPtr<StyleRuleKeyframes> styleRule)
{
- m_animationsWithUpdates.append(UpdatedAnimation(name, player, animation, specifiedTiming, styleRule));
- m_suppressedAnimationPlayers.add(player);
+ m_animationsWithUpdates.append(UpdatedAnimation(name, animation, effect, specifiedTiming, styleRule));
+ m_suppressedAnimations.add(animation);
}
- void updateAnimationStyle(AnimationPlayer* player, KeyframeEffectModelBase* effect, LayoutObject* layoutObject, const ComputedStyle& newStyle)
+ void updateAnimationStyle(Animation* animation, KeyframeEffectModelBase* effect, LayoutObject* layoutObject, const ComputedStyle& newStyle)
{
UpdatedAnimationStyle::CompositableStyleSnapshot snapshot;
if (layoutObject) {
@@ -165,18 +165,18 @@ public:
snapshot.webkitFilter = CSSAnimatableValueFactory::create(CSSPropertyWebkitFilter, newStyle);
}
- m_animationsWithStyleUpdates.append(UpdatedAnimationStyle(player, effect, snapshot));
+ m_animationsWithStyleUpdates.append(UpdatedAnimationStyle(animation, effect, snapshot));
}
- void startTransition(CSSPropertyID id, CSSPropertyID eventId, const AnimatableValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation)
+ void startTransition(CSSPropertyID id, CSSPropertyID eventId, const AnimatableValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> effect)
{
- animation->setName(getPropertyName(id));
+ effect->setName(getPropertyName(id));
NewTransition newTransition;
newTransition.id = id;
newTransition.eventId = eventId;
newTransition.from = from;
newTransition.to = to;
- newTransition.animation = animation;
+ newTransition.effect = effect;
m_newTransitions.set(id, newTransition);
}
bool isCancelledTransition(CSSPropertyID id) const { return m_cancelledTransitions.contains(id); }
@@ -185,7 +185,7 @@ public:
const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAnimations; }
const Vector<AtomicString>& cancelledAnimationNames() const { return m_cancelledAnimationNames; }
- const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>>& suppressedAnimationAnimationPlayers() const { return m_suppressedAnimationPlayers; }
+ const WillBeHeapHashSet<RawPtrWillBeMember<const Animation>>& suppressedAnimationAnimations() const { return m_suppressedAnimations; }
const Vector<AtomicString>& animationsWithPauseToggled() const { return m_animationsWithPauseToggled; }
const WillBeHeapVector<UpdatedAnimation>& animationsWithUpdates() const { return m_animationsWithUpdates; }
const WillBeHeapVector<UpdatedAnimationStyle>& animationsWithStyleUpdates() const { return m_animationsWithStyleUpdates; }
@@ -197,14 +197,14 @@ public:
{
visitor->trace(from);
visitor->trace(to);
- visitor->trace(animation);
+ visitor->trace(effect);
}
CSSPropertyID id;
CSSPropertyID eventId;
RawPtrWillBeMember<const AnimatableValue> from;
RawPtrWillBeMember<const AnimatableValue> to;
- RefPtrWillBeMember<InertAnimation> animation;
+ RefPtrWillBeMember<InertAnimation> effect;
};
using NewTransitionMap = WillBeHeapHashMap<CSSPropertyID, NewTransition>;
const NewTransitionMap& newTransitions() const { return m_newTransitions; }
@@ -221,7 +221,7 @@ public:
{
return m_newAnimations.isEmpty()
&& m_cancelledAnimationNames.isEmpty()
- && m_suppressedAnimationPlayers.isEmpty()
+ && m_suppressedAnimations.isEmpty()
&& m_animationsWithPauseToggled.isEmpty()
&& m_animationsWithUpdates.isEmpty()
&& m_animationsWithStyleUpdates.isEmpty()
@@ -241,7 +241,7 @@ private:
// incomplete keyframes.
WillBeHeapVector<NewAnimation> m_newAnimations;
Vector<AtomicString> m_cancelledAnimationNames;
- WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> m_suppressedAnimationPlayers;
+ WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> m_suppressedAnimations;
Vector<AtomicString> m_animationsWithPauseToggled;
WillBeHeapVector<UpdatedAnimation> m_animationsWithUpdates;
WillBeHeapVector<UpdatedAnimationStyle> m_animationsWithStyleUpdates;
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp
index d4f37e2..b9c8aec 100644
--- a/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp
+++ b/third_party/WebKit/Source/core/animation/css/CSSAnimations.cpp
@@ -32,7 +32,7 @@
#include "core/animation/css/CSSAnimations.h"
#include "core/StylePropertyShorthand.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/Animation.h"
#include "core/animation/AnimationTimeline.h"
#include "core/animation/CompositorAnimations.h"
#include "core/animation/DeferredLegacyStyleInterpolation.h"
@@ -183,19 +183,19 @@ CSSAnimations::CSSAnimations()
{
}
-const AtomicString CSSAnimations::getAnimationNameForInspector(const AnimationPlayer& player)
+const AtomicString CSSAnimations::getAnimationNameForInspector(const Animation& animation)
{
for (const auto& it : m_animations) {
- if (it.value->player->sequenceNumber() == player.sequenceNumber())
+ if (it.value->animation->sequenceNumber() == animation.sequenceNumber())
return it.key;
}
return nullAtom;
}
-bool CSSAnimations::isTransitionAnimationForInspector(const AnimationPlayer& player) const
+bool CSSAnimations::isTransitionAnimationForInspector(const Animation& animation) const
{
for (const auto& it : m_transitions) {
- if (it.value.player->sequenceNumber() == player.sequenceNumber())
+ if (it.value.animation->sequenceNumber() == animation.sequenceNumber())
return true;
}
return false;
@@ -257,23 +257,23 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E
inactive.remove(animationName);
const RunningAnimation* runningAnimation = existing->value.get();
- AnimationPlayer* player = runningAnimation->player.get();
+ Animation* animation = runningAnimation->animation.get();
if (keyframesRule != runningAnimation->styleRule || keyframesRule->version() != runningAnimation->styleRuleVersion || runningAnimation->specifiedTiming != specifiedTiming) {
ASSERT(!isAnimationStyleChange);
- update->updateAnimation(animationName, player, InertAnimation::create(
+ update->updateAnimation(animationName, animation, InertAnimation::create(
createKeyframeEffect(resolver, animatingElement, element, &style, parentStyle, animationName, keyframeTimingFunction.get()),
- timing, isPaused, player->unlimitedCurrentTimeInternal()), specifiedTiming, keyframesRule);
- } else if (!isAnimationStyleChange && player->source() && player->source()->isAnimation()) {
- AnimationEffect* effect = toAnimation(player->source())->effect();
+ timing, isPaused, animation->unlimitedCurrentTimeInternal()), specifiedTiming, keyframesRule);
+ } else if (!isAnimationStyleChange && animation->source() && animation->source()->isAnimation()) {
+ EffectModel* effect = toKeyframeEffect(animation->source())->effect();
if (effect && effect->isKeyframeEffectModel()) {
KeyframeEffectModelBase* keyframeEffect = toKeyframeEffectModelBase(effect);
if (keyframeEffect->hasSyntheticKeyframes())
- update->updateAnimationStyle(player, keyframeEffect, animatingElement->layoutObject(), style);
+ update->updateAnimationStyle(animation, keyframeEffect, animatingElement->layoutObject(), style);
}
}
- if (isPaused != player->paused()) {
+ if (isPaused != animation->paused()) {
ASSERT(!isAnimationStyleChange);
update->toggleAnimationPaused(animationName);
}
@@ -292,7 +292,7 @@ void CSSAnimations::calculateAnimationUpdate(CSSAnimationUpdate* update, const E
ASSERT(inactive.isEmpty() || cssAnimations);
for (const AtomicString& animationName : inactive) {
ASSERT(!isAnimationStyleChange);
- update->cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)->player);
+ update->cancelAnimation(animationName, *cssAnimations->m_animations.get(animationName)->animation);
}
}
@@ -313,26 +313,26 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
DisableCompositingQueryAsserts disabler;
for (const AtomicString& animationName : update->cancelledAnimationNames()) {
- RefPtrWillBeRawPtr<AnimationPlayer> player = m_animations.take(animationName)->player;
- player->cancel();
- player->update(TimingUpdateOnDemand);
+ RefPtrWillBeRawPtr<Animation> animation = m_animations.take(animationName)->animation;
+ animation->cancel();
+ animation->update(TimingUpdateOnDemand);
}
for (const AtomicString& animationName : update->animationsWithPauseToggled()) {
- AnimationPlayer* player = m_animations.get(animationName)->player.get();
- if (player->paused())
- player->unpause();
+ Animation* animation = m_animations.get(animationName)->animation.get();
+ if (animation->paused())
+ animation->unpause();
else
- player->pause();
- if (player->outdated())
- player->update(TimingUpdateOnDemand);
+ animation->pause();
+ if (animation->outdated())
+ animation->update(TimingUpdateOnDemand);
}
for (const auto& entry : update->animationsWithUpdates()) {
- Animation* animation = toAnimation(entry.player->source());
+ KeyframeEffect* effect = toKeyframeEffect(entry.animation->source());
- animation->setEffect(entry.animation->effect());
- animation->updateSpecifiedTiming(entry.animation->specifiedTiming());
+ effect->setEffect(entry.effect->effect());
+ effect->updateSpecifiedTiming(entry.effect->specifiedTiming());
m_animations.find(entry.name)->value->update(entry);
}
@@ -351,22 +351,22 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
if (styleUpdate.snapshot.webkitFilter)
updated |= styleUpdate.effect->updateNeutralKeyframeAnimatableValues(CSSPropertyWebkitFilter, styleUpdate.snapshot.webkitFilter);
if (updated) {
- styleUpdate.player->setOutdated();
- styleUpdate.player->setCompositorPending(true);
+ styleUpdate.animation->setOutdated();
+ styleUpdate.animation->setCompositorPending(true);
}
}
for (const auto& entry : update->newAnimations()) {
- const InertAnimation* inertAnimation = entry.animation.get();
+ const InertAnimation* inertAnimation = entry.effect.get();
OwnPtrWillBeRawPtr<AnimationEventDelegate> eventDelegate = adoptPtrWillBeNoop(new AnimationEventDelegate(element, entry.name));
- RefPtrWillBeRawPtr<Animation> animation = Animation::create(element, inertAnimation->effect(), inertAnimation->specifiedTiming(), Animation::DefaultPriority, eventDelegate.release());
- animation->setName(inertAnimation->name());
- RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timeline().play(animation.get());
+ RefPtrWillBeRawPtr<KeyframeEffect> effect = KeyframeEffect::create(element, inertAnimation->effect(), inertAnimation->specifiedTiming(), KeyframeEffect::DefaultPriority, eventDelegate.release());
+ effect->setName(inertAnimation->name());
+ RefPtrWillBeRawPtr<Animation> animation = element->document().timeline().play(effect.get());
if (inertAnimation->paused())
- player->pause();
- player->update(TimingUpdateOnDemand);
+ animation->pause();
+ animation->update(TimingUpdateOnDemand);
- m_animations.set(entry.name, adoptRefWillBeNoop(new RunningAnimation(player, entry)));
+ m_animations.set(entry.name, adoptRefWillBeNoop(new RunningAnimation(animation, entry)));
}
// Transitions that are run on the compositor only update main-thread state
@@ -374,30 +374,30 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
// be when transitions are retargeted. Instead of triggering complete style
// recalculation, we find these cases by searching for new transitions that
// have matching cancelled animation property IDs on the compositor.
- WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<Animation>, double>> retargetedCompositorTransitions;
+ WillBeHeapHashMap<CSSPropertyID, std::pair<RefPtrWillBeMember<KeyframeEffect>, double>> retargetedCompositorTransitions;
for (CSSPropertyID id : update->cancelledTransitions()) {
ASSERT(m_transitions.contains(id));
- RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).player;
- Animation* animation = toAnimation(player->source());
- if (animation->hasActiveAnimationsOnCompositor(id) && update->newTransitions().find(id) != update->newTransitions().end() && !player->limited())
- retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember<Animation>, double>(animation, player->startTimeInternal()));
- player->cancel();
+ RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).animation;
+ KeyframeEffect* effect = toKeyframeEffect(animation->source());
+ if (effect->hasActiveAnimationsOnCompositor(id) && update->newTransitions().find(id) != update->newTransitions().end() && !animation->limited())
+ retargetedCompositorTransitions.add(id, std::pair<RefPtrWillBeMember<KeyframeEffect>, double>(effect, animation->startTimeInternal()));
+ animation->cancel();
// after cancelation, transitions must be downgraded or they'll fail
// to be considered when retriggering themselves. This can happen if
- // the transition is captured through getAnimationPlayers then played.
- if (player->source() && player->source()->isAnimation())
- toAnimation(player->source())->downgradeToNormalAnimation();
- player->update(TimingUpdateOnDemand);
+ // the transition is captured through getAnimations then played.
+ if (animation->source() && animation->source()->isAnimation())
+ toKeyframeEffect(animation->source())->downgradeToNormal();
+ animation->update(TimingUpdateOnDemand);
}
for (CSSPropertyID id : update->finishedTransitions()) {
// This transition can also be cancelled and finished at the same time
if (m_transitions.contains(id)) {
- RefPtrWillBeRawPtr<AnimationPlayer> player = m_transitions.take(id).player;
+ RefPtrWillBeRawPtr<Animation> animation = m_transitions.take(id).animation;
// Transition must be downgraded
- if (player->source() && player->source()->isAnimation())
- toAnimation(player->source())->downgradeToNormalAnimation();
+ if (animation->source() && animation->source()->isAnimation())
+ toKeyframeEffect(animation->source())->downgradeToNormal();
}
}
@@ -409,14 +409,14 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
runningTransition.to = newTransition.to;
CSSPropertyID id = newTransition.id;
- InertAnimation* inertAnimation = newTransition.animation.get();
+ InertAnimation* inertAnimation = newTransition.effect.get();
OwnPtrWillBeRawPtr<TransitionEventDelegate> eventDelegate = adoptPtrWillBeNoop(new TransitionEventDelegate(element, newTransition.eventId));
- RefPtrWillBeRawPtr<AnimationEffect> effect = inertAnimation->effect();
+ RefPtrWillBeRawPtr<EffectModel> effect = inertAnimation->effect();
if (retargetedCompositorTransitions.contains(id)) {
- const std::pair<RefPtrWillBeMember<Animation>, double>& oldTransition = retargetedCompositorTransitions.get(id);
- RefPtrWillBeRawPtr<Animation> oldAnimation = oldTransition.first;
+ const std::pair<RefPtrWillBeMember<KeyframeEffect>, double>& oldTransition = retargetedCompositorTransitions.get(id);
+ RefPtrWillBeRawPtr<KeyframeEffect> oldAnimation = oldTransition.first;
double oldStartTime = oldTransition.second;
double inheritedTime = isNull(oldStartTime) ? 0 : element->document().timeline().currentTimeInternal() - oldStartTime;
@@ -440,11 +440,11 @@ void CSSAnimations::maybeApplyPendingUpdate(Element* element)
}
}
- RefPtrWillBeRawPtr<Animation> transition = Animation::create(element, effect, inertAnimation->specifiedTiming(), Animation::TransitionPriority, eventDelegate.release());
+ RefPtrWillBeRawPtr<KeyframeEffect> transition = KeyframeEffect::create(element, effect, inertAnimation->specifiedTiming(), KeyframeEffect::TransitionPriority, eventDelegate.release());
transition->setName(inertAnimation->name());
- RefPtrWillBeRawPtr<AnimationPlayer> player = element->document().timeline().play(transition.get());
- player->update(TimingUpdateOnDemand);
- runningTransition.player = player;
+ RefPtrWillBeRawPtr<Animation> animation = element->document().timeline().play(transition.get());
+ animation->update(TimingUpdateOnDemand);
+ runningTransition.animation = animation;
m_transitions.set(id, runningTransition);
ASSERT(id != CSSPropertyInvalid);
Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(id));
@@ -575,9 +575,9 @@ void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
CSSPropertyID id = entry.key;
if (!anyTransitionHadTransitionAll && !animationStyleRecalc && !listedProperties.get(id)) {
// TODO: Figure out why this fails on Chrome OS login page. crbug.com/365507
- // ASSERT(player.playStateInternal() == AnimationPlayer::Finished || !(elementAnimations && elementAnimations->isAnimationStyleChange()));
+ // ASSERT(animation.playStateInternal() == Animation::Finished || !(elementAnimations && elementAnimations->isAnimationStyleChange()));
update->cancelTransition(id);
- } else if (entry.value.player->finishedInternal()) {
+ } else if (entry.value.animation->finishedInternal()) {
update->finishTransition(id);
}
}
@@ -587,13 +587,13 @@ void CSSAnimations::calculateTransitionUpdate(CSSAnimationUpdate* update, const
void CSSAnimations::cancel()
{
for (const auto& entry : m_animations) {
- entry.value->player->cancel();
- entry.value->player->update(TimingUpdateOnDemand);
+ entry.value->animation->cancel();
+ entry.value->animation->update(TimingUpdateOnDemand);
}
for (const auto& entry : m_transitions) {
- entry.value.player->cancel();
- entry.value.player->update(TimingUpdateOnDemand);
+ entry.value.animation->cancel();
+ entry.value.animation->update(TimingUpdateOnDemand);
}
m_animations.clear();
@@ -606,19 +606,19 @@ void CSSAnimations::calculateAnimationActiveInterpolations(CSSAnimationUpdate* u
ElementAnimations* elementAnimations = animatingElement ? animatingElement->elementAnimations() : nullptr;
AnimationStack* animationStack = elementAnimations ? &elementAnimations->defaultStack() : nullptr;
- if (update->newAnimations().isEmpty() && update->suppressedAnimationAnimationPlayers().isEmpty()) {
- ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::DefaultPriority, timelineCurrentTime));
+ if (update->newAnimations().isEmpty() && update->suppressedAnimationAnimations().isEmpty()) {
+ ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack, 0, 0, KeyframeEffect::DefaultPriority, timelineCurrentTime));
update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimations);
return;
}
- WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newAnimations;
+ WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newEffects;
for (const auto& newAnimation : update->newAnimations())
- newAnimations.append(newAnimation.animation.get());
+ newEffects.append(newAnimation.effect.get());
for (const auto& updatedAnimation : update->animationsWithUpdates())
- newAnimations.append(updatedAnimation.animation.get()); // Animations with updates use a temporary InertAnimation for the current frame.
+ newEffects.append(updatedAnimation.effect.get()); // Animations with updates use a temporary InertAnimation for the current frame.
- ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack, &newAnimations, &update->suppressedAnimationAnimationPlayers(), Animation::DefaultPriority, timelineCurrentTime));
+ ActiveInterpolationMap activeInterpolationsForAnimations(AnimationStack::activeInterpolations(animationStack, &newEffects, &update->suppressedAnimationAnimations(), KeyframeEffect::DefaultPriority, timelineCurrentTime));
update->adoptActiveInterpolationsForAnimations(activeInterpolationsForAnimations);
}
@@ -629,23 +629,23 @@ void CSSAnimations::calculateTransitionActiveInterpolations(CSSAnimationUpdate*
ActiveInterpolationMap activeInterpolationsForTransitions;
if (update->newTransitions().isEmpty() && update->cancelledTransitions().isEmpty()) {
- activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, 0, 0, Animation::TransitionPriority, timelineCurrentTime);
+ activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, 0, 0, KeyframeEffect::TransitionPriority, timelineCurrentTime);
} else {
WillBeHeapVector<RawPtrWillBeMember<InertAnimation>> newTransitions;
for (const auto& entry : update->newTransitions())
- newTransitions.append(entry.value.animation.get());
+ newTransitions.append(entry.value.effect.get());
- WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer>> cancelledAnimationPlayers;
+ WillBeHeapHashSet<RawPtrWillBeMember<const Animation>> cancelledAnimations;
if (!update->cancelledTransitions().isEmpty()) {
ASSERT(elementAnimations);
const TransitionMap& transitionMap = elementAnimations->cssAnimations().m_transitions;
for (CSSPropertyID id : update->cancelledTransitions()) {
ASSERT(transitionMap.contains(id));
- cancelledAnimationPlayers.add(transitionMap.get(id).player.get());
+ cancelledAnimations.add(transitionMap.get(id).animation.get());
}
}
- activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, &newTransitions, &cancelledAnimationPlayers, Animation::TransitionPriority, timelineCurrentTime);
+ activeInterpolationsForTransitions = AnimationStack::activeInterpolations(animationStack, &newTransitions, &cancelledAnimations, KeyframeEffect::TransitionPriority, timelineCurrentTime);
}
// Properties being animated by animations don't get values from transitions applied.
@@ -670,25 +670,25 @@ void CSSAnimations::AnimationEventDelegate::maybeDispatch(Document::ListenerType
}
}
-bool CSSAnimations::AnimationEventDelegate::requiresIterationEvents(const AnimationNode& animationNode)
+bool CSSAnimations::AnimationEventDelegate::requiresIterationEvents(const AnimationEffect& animationNode)
{
return document().hasListenerType(Document::ANIMATIONITERATION_LISTENER);
}
-void CSSAnimations::AnimationEventDelegate::onEventCondition(const AnimationNode& animationNode)
+void CSSAnimations::AnimationEventDelegate::onEventCondition(const AnimationEffect& animationNode)
{
- const AnimationNode::Phase currentPhase = animationNode.phase();
+ const AnimationEffect::Phase currentPhase = animationNode.phase();
const double currentIteration = animationNode.currentIteration();
if (m_previousPhase != currentPhase
- && (currentPhase == AnimationNode::PhaseActive || currentPhase == AnimationNode::PhaseAfter)
- && (m_previousPhase == AnimationNode::PhaseNone || m_previousPhase == AnimationNode::PhaseBefore)) {
+ && (currentPhase == AnimationEffect::PhaseActive || currentPhase == AnimationEffect::PhaseAfter)
+ && (m_previousPhase == AnimationEffect::PhaseNone || m_previousPhase == AnimationEffect::PhaseBefore)) {
const double startDelay = animationNode.specifiedTiming().startDelay;
const double elapsedTime = startDelay < 0 ? -startDelay : 0;
maybeDispatch(Document::ANIMATIONSTART_LISTENER, EventTypeNames::animationstart, elapsedTime);
}
- if (currentPhase == AnimationNode::PhaseActive && m_previousPhase == currentPhase && m_previousIteration != currentIteration) {
+ if (currentPhase == AnimationEffect::PhaseActive && m_previousPhase == currentPhase && m_previousIteration != currentIteration) {
// We fire only a single event for all iterations thast terminate
// between a single pair of samples. See http://crbug.com/275263. For
// compatibility with the existing implementation, this event uses
@@ -698,7 +698,7 @@ void CSSAnimations::AnimationEventDelegate::onEventCondition(const AnimationNode
maybeDispatch(Document::ANIMATIONITERATION_LISTENER, EventTypeNames::animationiteration, elapsedTime);
}
- if (currentPhase == AnimationNode::PhaseAfter && m_previousPhase != AnimationNode::PhaseAfter)
+ if (currentPhase == AnimationEffect::PhaseAfter && m_previousPhase != AnimationEffect::PhaseAfter)
maybeDispatch(Document::ANIMATIONEND_LISTENER, EventTypeNames::animationend, animationNode.activeDurationInternal());
m_previousPhase = currentPhase;
@@ -708,7 +708,7 @@ void CSSAnimations::AnimationEventDelegate::onEventCondition(const AnimationNode
DEFINE_TRACE(CSSAnimations::AnimationEventDelegate)
{
visitor->trace(m_animationTarget);
- AnimationNode::EventDelegate::trace(visitor);
+ AnimationEffect::EventDelegate::trace(visitor);
}
EventTarget* CSSAnimations::TransitionEventDelegate::eventTarget() const
@@ -716,10 +716,10 @@ EventTarget* CSSAnimations::TransitionEventDelegate::eventTarget() const
return EventPath::eventTargetRespectingTargetRules(*m_transitionTarget);
}
-void CSSAnimations::TransitionEventDelegate::onEventCondition(const AnimationNode& animationNode)
+void CSSAnimations::TransitionEventDelegate::onEventCondition(const AnimationEffect& animationNode)
{
- const AnimationNode::Phase currentPhase = animationNode.phase();
- if (currentPhase == AnimationNode::PhaseAfter && currentPhase != m_previousPhase && document().hasListenerType(Document::TRANSITIONEND_LISTENER)) {
+ const AnimationEffect::Phase currentPhase = animationNode.phase();
+ if (currentPhase == AnimationEffect::PhaseAfter && currentPhase != m_previousPhase && document().hasListenerType(Document::TRANSITIONEND_LISTENER)) {
String propertyName = getPropertyNameString(m_property);
const Timing& timing = animationNode.specifiedTiming();
double elapsedTime = timing.iterationDuration;
@@ -736,7 +736,7 @@ void CSSAnimations::TransitionEventDelegate::onEventCondition(const AnimationNod
DEFINE_TRACE(CSSAnimations::TransitionEventDelegate)
{
visitor->trace(m_transitionTarget);
- AnimationNode::EventDelegate::trace(visitor);
+ AnimationEffect::EventDelegate::trace(visitor);
}
const StylePropertyShorthand& CSSAnimations::propertiesForTransitionAll()
@@ -761,7 +761,7 @@ const StylePropertyShorthand& CSSAnimations::propertiesForTransitionAll()
return propertyShorthand;
}
-// Animation properties are not allowed to be affected by Web Animations.
+// KeyframeEffect properties are not allowed to be affected by Web Animations.
// http://dev.w3.org/fxtf/web-animations/#not-animatable
bool CSSAnimations::isAllowedAnimation(CSSPropertyID property)
{
@@ -804,7 +804,7 @@ DEFINE_TRACE(CSSAnimationUpdate)
visitor->trace(m_activeInterpolationsForAnimations);
visitor->trace(m_activeInterpolationsForTransitions);
visitor->trace(m_newAnimations);
- visitor->trace(m_suppressedAnimationPlayers);
+ visitor->trace(m_suppressedAnimations);
visitor->trace(m_animationsWithUpdates);
visitor->trace(m_animationsWithStyleUpdates);
#endif
diff --git a/third_party/WebKit/Source/core/animation/css/CSSAnimations.h b/third_party/WebKit/Source/core/animation/css/CSSAnimations.h
index 04825d6..6bb5fee 100644
--- a/third_party/WebKit/Source/core/animation/css/CSSAnimations.h
+++ b/third_party/WebKit/Source/core/animation/css/CSSAnimations.h
@@ -55,8 +55,8 @@ class CSSAnimations final {
public:
CSSAnimations();
- const AtomicString getAnimationNameForInspector(const AnimationPlayer&);
- bool isTransitionAnimationForInspector(const AnimationPlayer&) const;
+ const AtomicString getAnimationNameForInspector(const Animation&);
+ bool isTransitionAnimationForInspector(const Animation&) const;
static const StylePropertyShorthand& propertiesForTransitionAll();
static bool isAllowedAnimation(CSSPropertyID);
@@ -72,11 +72,11 @@ public:
private:
class RunningAnimation final : public RefCountedWillBeGarbageCollectedFinalized<RunningAnimation> {
public:
- RunningAnimation(PassRefPtrWillBeRawPtr<AnimationPlayer> player, CSSAnimationUpdate::NewAnimation animation)
- : player(player)
- , specifiedTiming(animation.timing)
- , styleRule(animation.styleRule)
- , styleRuleVersion(animation.styleRuleVersion)
+ RunningAnimation(PassRefPtrWillBeRawPtr<Animation> animation, CSSAnimationUpdate::NewAnimation newAnimation)
+ : animation(animation)
+ , specifiedTiming(newAnimation.timing)
+ , styleRule(newAnimation.styleRule)
+ , styleRuleVersion(newAnimation.styleRuleVersion)
{
}
@@ -89,11 +89,11 @@ private:
DEFINE_INLINE_TRACE()
{
- visitor->trace(player);
+ visitor->trace(animation);
visitor->trace(styleRule);
}
- RefPtrWillBeMember<AnimationPlayer> player;
+ RefPtrWillBeMember<Animation> animation;
Timing specifiedTiming;
RefPtrWillBeMember<StyleRuleKeyframes> styleRule;
unsigned styleRuleVersion;
@@ -104,12 +104,12 @@ private:
public:
DEFINE_INLINE_TRACE()
{
- visitor->trace(player);
+ visitor->trace(animation);
visitor->trace(from);
visitor->trace(to);
}
- RefPtrWillBeMember<AnimationPlayer> player;
+ RefPtrWillBeMember<Animation> animation;
RawPtrWillBeMember<const AnimatableValue> from;
RawPtrWillBeMember<const AnimatableValue> to;
};
@@ -131,17 +131,17 @@ private:
static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, const Element* animatingElement, double timelineCurrentTime);
static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, const Element* animatingElement, double timelineCurrentTime);
- class AnimationEventDelegate final : public AnimationNode::EventDelegate {
+ class AnimationEventDelegate final : public AnimationEffect::EventDelegate {
public:
AnimationEventDelegate(Element* animationTarget, const AtomicString& name)
: m_animationTarget(animationTarget)
, m_name(name)
- , m_previousPhase(AnimationNode::PhaseNone)
+ , m_previousPhase(AnimationEffect::PhaseNone)
, m_previousIteration(nullValue())
{
}
- virtual bool requiresIterationEvents(const AnimationNode&) override;
- virtual void onEventCondition(const AnimationNode&) override;
+ virtual bool requiresIterationEvents(const AnimationEffect&) override;
+ virtual void onEventCondition(const AnimationEffect&) override;
DECLARE_VIRTUAL_TRACE();
private:
@@ -152,20 +152,20 @@ private:
void maybeDispatch(Document::ListenerType, const AtomicString& eventName, double elapsedTime);
RawPtrWillBeMember<Element> m_animationTarget;
const AtomicString m_name;
- AnimationNode::Phase m_previousPhase;
+ AnimationEffect::Phase m_previousPhase;
double m_previousIteration;
};
- class TransitionEventDelegate final : public AnimationNode::EventDelegate {
+ class TransitionEventDelegate final : public AnimationEffect::EventDelegate {
public:
TransitionEventDelegate(Element* transitionTarget, CSSPropertyID property)
: m_transitionTarget(transitionTarget)
, m_property(property)
- , m_previousPhase(AnimationNode::PhaseNone)
+ , m_previousPhase(AnimationEffect::PhaseNone)
{
}
- virtual bool requiresIterationEvents(const AnimationNode&) override { return false; }
- virtual void onEventCondition(const AnimationNode&) override;
+ virtual bool requiresIterationEvents(const AnimationEffect&) override { return false; }
+ virtual void onEventCondition(const AnimationEffect&) override;
DECLARE_VIRTUAL_TRACE();
private:
@@ -176,7 +176,7 @@ private:
RawPtrWillBeMember<Element> m_transitionTarget;
const CSSPropertyID m_property;
- AnimationNode::Phase m_previousPhase;
+ AnimationEffect::Phase m_previousPhase;
};
};
diff --git a/third_party/WebKit/Source/core/core.gypi b/third_party/WebKit/Source/core/core.gypi
index 14bef39..f1d63c3 100644
--- a/third_party/WebKit/Source/core/core.gypi
+++ b/third_party/WebKit/Source/core/core.gypi
@@ -5,12 +5,12 @@
'variables': {
# Files for which bindings (.cpp and .h files) will be generated
'core_idl_files': [
+ 'animation/KeyframeEffect.idl',
+ 'animation/EffectModel.idl',
+ 'animation/AnimationEffectReadOnly.idl',
+ 'animation/AnimationEffectTiming.idl',
'animation/Animation.idl',
- 'animation/AnimationEffect.idl',
- 'animation/AnimationNode.idl',
- 'animation/AnimationPlayer.idl',
'animation/AnimationTimeline.idl',
- 'animation/Timing.idl',
'clipboard/DataTransfer.idl',
'clipboard/DataTransferItemList.idl',
'css/CSS.idl',
@@ -851,19 +851,19 @@
'Init.cpp',
'Init.h',
'animation/AngleSVGInterpolation.h',
- 'animation/Animation.cpp',
- 'animation/Animation.h',
+ 'animation/KeyframeEffect.cpp',
+ 'animation/KeyframeEffect.h',
'animation/AnimationClock.cpp',
'animation/AnimationClock.h',
- 'animation/AnimationEffect.h',
+ 'animation/EffectModel.h',
'animation/AnimationInputHelpers.cpp',
'animation/AnimationInputHelpers.h',
- 'animation/AnimationNode.cpp',
- 'animation/AnimationNode.h',
- 'animation/AnimationNodeTiming.cpp',
- 'animation/AnimationNodeTiming.h',
- 'animation/AnimationPlayer.cpp',
- 'animation/AnimationPlayer.h',
+ 'animation/AnimationEffect.cpp',
+ 'animation/AnimationEffect.h',
+ 'animation/AnimationEffectTiming.cpp',
+ 'animation/AnimationEffectTiming.h',
+ 'animation/Animation.cpp',
+ 'animation/Animation.h',
'animation/AnimationStack.cpp',
'animation/AnimationStack.h',
'animation/AnimationTimeline.cpp',
@@ -3554,7 +3554,7 @@
'svg/properties/SVGPropertyTearOff.cpp',
],
'core_dictionary_idl_files': [
- 'animation/AnimationTimingProperties.idl',
+ 'animation/KeyframeEffectOptions.idl',
'animation/ComputedTimingProperties.idl',
'css/FontFaceDescriptors.idl',
'css/MediaQueryListEventInit.idl',
@@ -3595,8 +3595,8 @@
'page/EventSourceInit.idl',
],
'generated_core_dictionary_files': [
- '<(blink_core_output_dir)/animation/AnimationTimingProperties.cpp',
- '<(blink_core_output_dir)/animation/AnimationTimingProperties.h',
+ '<(blink_core_output_dir)/animation/KeyframeEffectOptions.cpp',
+ '<(blink_core_output_dir)/animation/KeyframeEffectOptions.h',
'<(blink_core_output_dir)/animation/ComputedTimingProperties.cpp',
'<(blink_core_output_dir)/animation/ComputedTimingProperties.h',
'<(blink_core_output_dir)/css/FontFaceDescriptors.cpp',
@@ -3743,10 +3743,10 @@
'core_unittest_files': [
'animation/AnimationClockTest.cpp',
'animation/AnimationInputHelpersTest.cpp',
- 'animation/AnimationNodeTest.cpp',
- 'animation/AnimationPlayerTest.cpp',
- 'animation/AnimationStackTest.cpp',
+ 'animation/AnimationEffectTest.cpp',
'animation/AnimationTest.cpp',
+ 'animation/AnimationStackTest.cpp',
+ 'animation/KeyframeEffectTest.cpp',
'animation/AnimationTestHelper.cpp',
'animation/AnimationTestHelper.h',
'animation/AnimationTimelineTest.cpp',
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
index 6d60080..1d84bac 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleResolver.cpp
@@ -33,9 +33,9 @@
#include "core/HTMLNames.h"
#include "core/MediaTypeNames.h"
#include "core/StylePropertyShorthand.h"
-#include "core/animation/Animation.h"
#include "core/animation/AnimationTimeline.h"
#include "core/animation/ElementAnimations.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/animation/StyleInterpolation.h"
#include "core/animation/animatable/AnimatableValue.h"
#include "core/animation/css/CSSAnimatableValueFactory.h"
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 21db5a1..0303ef3 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1538,7 +1538,7 @@ bool Document::needsFullLayoutTreeUpdate() const
// FIXME: The childNeedsDistributionRecalc bit means either self or children, we should fix that.
if (childNeedsDistributionRecalc())
return true;
- if (DocumentAnimations::needsOutdatedAnimationPlayerUpdate(*this))
+ if (DocumentAnimations::needsOutdatedAnimationUpdate(*this))
return true;
return false;
}
@@ -1758,7 +1758,7 @@ void Document::updateLayoutTree(StyleRecalcChange change)
if (m_focusedElement && !m_focusedElement->isFocusable())
clearFocusedElementSoon();
- ASSERT(!m_timeline->hasOutdatedAnimationPlayer());
+ ASSERT(!m_timeline->hasOutdatedAnimation());
TRACE_EVENT_END1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "RecalculateStyles", "elementCount", m_styleRecalcElementCounter);
TRACE_EVENT_END1("blink", "Document::updateLayoutTree", "elementCount", m_styleRecalcElementCounter);
diff --git a/third_party/WebKit/Source/core/frame/UseCounter.h b/third_party/WebKit/Source/core/frame/UseCounter.h
index ac17b32..569ee68 100644
--- a/third_party/WebKit/Source/core/frame/UseCounter.h
+++ b/third_party/WebKit/Source/core/frame/UseCounter.h
@@ -301,7 +301,7 @@ public:
SVGForeignObjectElement = 325,
SelectionSetPosition = 327,
- AnimationPlayerFinishEvent = 328,
+ AnimationFinishEvent = 328,
SVGSVGElementInXMLDocument = 329,
PrefixedPerformanceClearResourceTimings = 341,
PrefixedPerformanceSetResourceTimingBufferSize = 342,
@@ -475,17 +475,17 @@ public:
SRIElementWithMatchingIntegrityAttribute = 540,
SRIElementWithNonMatchingIntegrityAttribute = 541,
SRIElementWithUnparsableIntegrityAttribute = 542,
- V8AnimationPlayer_StartTime_AttributeGetter = 545,
- V8AnimationPlayer_StartTime_AttributeSetter = 546,
- V8AnimationPlayer_CurrentTime_AttributeGetter = 547,
- V8AnimationPlayer_CurrentTime_AttributeSetter = 548,
- V8AnimationPlayer_PlaybackRate_AttributeGetter = 549,
- V8AnimationPlayer_PlaybackRate_AttributeSetter = 550,
- V8AnimationPlayer_PlayState_AttributeGetter = 551,
- V8AnimationPlayer_Finish_Method = 552,
- V8AnimationPlayer_Play_Method = 553,
- V8AnimationPlayer_Pause_Method = 554,
- V8AnimationPlayer_Reverse_Method = 555,
+ V8Animation_StartTime_AttributeGetter = 545,
+ V8Animation_StartTime_AttributeSetter = 546,
+ V8Animation_CurrentTime_AttributeGetter = 547,
+ V8Animation_CurrentTime_AttributeSetter = 548,
+ V8Animation_PlaybackRate_AttributeGetter = 549,
+ V8Animation_PlaybackRate_AttributeSetter = 550,
+ V8Animation_PlayState_AttributeGetter = 551,
+ V8Animation_Finish_Method = 552,
+ V8Animation_Play_Method = 553,
+ V8Animation_Pause_Method = 554,
+ V8Animation_Reverse_Method = 555,
// The above items are available in M39 branch.
BreakIterator = 556,
@@ -628,9 +628,9 @@ public:
WindowFind = 696,
WindowScreenLeft = 697,
WindowScreenTop = 698,
- V8AnimationPlayer_Cancel_Method = 699,
- V8AnimationPlayer_Onfinish_AttributeGetter = 700,
- V8AnimationPlayer_Onfinish_AttributeSetter = 701,
+ V8Animation_Cancel_Method = 699,
+ V8Animation_Onfinish_AttributeGetter = 700,
+ V8Animation_Onfinish_AttributeSetter = 701,
ElementOffsetParent = 702,
ElementOffsetTop = 703,
ElementOffsetLeft = 704,
diff --git a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
index c579916..beae397 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp
@@ -8,11 +8,11 @@
#include "core/animation/Animation.h"
#include "core/animation/AnimationEffect.h"
-#include "core/animation/AnimationNode.h"
-#include "core/animation/AnimationNodeTiming.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/AnimationEffectTiming.h"
#include "core/animation/ComputedTimingProperties.h"
+#include "core/animation/EffectModel.h"
#include "core/animation/ElementAnimation.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/animation/KeyframeEffectModel.h"
#include "core/animation/StringKeyframe.h"
#include "core/css/CSSKeyframeRule.h"
@@ -57,19 +57,19 @@ void InspectorAnimationAgent::disable(ErrorString*)
{
m_state->setBoolean(AnimationAgentState::animationAgentEnabled, false);
m_instrumentingAgents->setInspectorAnimationAgent(nullptr);
- m_idToAnimationPlayer.clear();
+ m_idToAnimation.clear();
m_idToAnimationType.clear();
}
void InspectorAnimationAgent::didCommitLoadForLocalFrame(LocalFrame* frame)
{
if (frame == m_pageAgent->inspectedFrame()) {
- m_idToAnimationPlayer.clear();
+ m_idToAnimation.clear();
m_idToAnimationType.clear();
}
}
-static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation(Animation* animation, bool isTransition)
+static PassRefPtr<TypeBuilder::Animation::AnimationNode> buildObjectForAnimation(KeyframeEffect* animation, bool isTransition)
{
ComputedTimingProperties computedTiming;
animation->computedTiming(computedTiming);
@@ -126,12 +126,12 @@ static PassRefPtr<TypeBuilder::Animation::KeyframeStyle> buildObjectForStringKey
return keyframeObject.release();
}
-static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForStyleRuleKeyframes(const AnimationPlayer& player, const StyleRuleKeyframes* keyframesRule)
+static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForStyleRuleKeyframes(const Animation& player, const StyleRuleKeyframes* keyframesRule)
{
RefPtr<TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle> > keyframes = TypeBuilder::Array<TypeBuilder::Animation::KeyframeStyle>::create();
const WillBeHeapVector<RefPtrWillBeMember<StyleRuleKeyframe> >& styleKeyframes = keyframesRule->keyframes();
for (const auto& styleKeyframe : styleKeyframes) {
- WillBeHeapVector<RefPtrWillBeMember<Keyframe> > normalizedKeyframes = KeyframeEffectModelBase::normalizedKeyframesForInspector(toKeyframeEffectModelBase(toAnimation(player.source())->effect())->getFrames());
+ WillBeHeapVector<RefPtrWillBeMember<Keyframe>> normalizedKeyframes = KeyframeEffectModelBase::normalizedKeyframesForInspector(toKeyframeEffectModelBase(toKeyframeEffect(player.source())->effect())->getFrames());
TimingFunction* easing = nullptr;
for (const auto& keyframe : normalizedKeyframes) {
if (styleKeyframe->keys().contains(keyframe->offset()))
@@ -147,7 +147,7 @@ static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForStyleRule
return keyframesObject.release();
}
-static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimationKeyframes(const Animation* animation)
+static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimationKeyframes(const KeyframeEffect* animation)
{
if (!animation->effect()->isKeyframeEffectModel())
return nullptr;
@@ -167,10 +167,10 @@ static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
return keyframesObject.release();
}
-PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::buildObjectForAnimationPlayer(AnimationPlayer& player)
+PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::buildObjectForAnimationPlayer(Animation& player)
{
// Find type of animation
- const Element* element = toAnimation(player.source())->target();
+ const Element* element = toKeyframeEffect(player.source())->target();
StyleResolver& styleResolver = element->ownerDocument()->ensureStyleResolver();
CSSAnimations& cssAnimations = element->elementAnimations()->cssAnimations();
const AtomicString animationName = cssAnimations.getAnimationNameForInspector(player);
@@ -187,15 +187,15 @@ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
animationType = AnimationType::CSSTransition;
} else {
// Web Animations
- keyframeRule = buildObjectForAnimationKeyframes(toAnimation(player.source()));
+ keyframeRule = buildObjectForAnimationKeyframes(toKeyframeEffect(player.source()));
animationType = AnimationType::WebAnimation;
}
String id = String::number(player.sequenceNumber());
- m_idToAnimationPlayer.set(id, &player);
+ m_idToAnimation.set(id, &player);
m_idToAnimationType.set(id, animationType);
- RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectForAnimation(toAnimation(player.source()), animationType == AnimationType::CSSTransition);
+ RefPtr<TypeBuilder::Animation::AnimationNode> animationObject = buildObjectForAnimation(toKeyframeEffect(player.source()), animationType == AnimationType::CSSTransition);
if (keyframeRule)
animationObject->setKeyframesRule(keyframeRule);
@@ -211,12 +211,12 @@ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
return playerObject.release();
}
-PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > InspectorAnimationAgent::buildArrayForAnimationPlayers(Element& element, const WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players)
+PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> InspectorAnimationAgent::buildArrayForAnimations(Element& element, const WillBeHeapVector<RefPtrWillBeMember<Animation>> players)
{
RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > animationPlayersArray = TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>::create();
for (const auto& it : players) {
- AnimationPlayer& player = *(it.get());
- Animation* animation = toAnimation(player.source());
+ Animation& player = *(it.get());
+ KeyframeEffect* animation = toKeyframeEffect(player.source());
if (!element.contains(animation->target()))
continue;
animationPlayersArray->addItem(buildObjectForAnimationPlayer(player));
@@ -229,12 +229,12 @@ void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
Element* element = m_domAgent->assertElement(errorString, nodeId);
if (!element)
return;
- WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> > players;
+ WillBeHeapVector<RefPtrWillBeMember<Animation>> players;
if (!includeSubtreeAnimations)
- players = ElementAnimation::getAnimationPlayers(*element);
+ players = ElementAnimation::getAnimations(*element);
else
- players = element->ownerDocument()->timeline().getAnimationPlayers();
- animationPlayersArray = buildArrayForAnimationPlayers(*element, players);
+ players = element->ownerDocument()->timeline().getAnimations();
+ animationPlayersArray = buildArrayForAnimations(*element, players);
}
void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate)
@@ -263,13 +263,13 @@ void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime)
void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& playerId, double duration, double delay)
{
- AnimationPlayer* player = assertAnimationPlayer(errorString, playerId);
+ Animation* player = assertAnimation(errorString, playerId);
if (!player)
return;
AnimationType type = m_idToAnimationType.get(playerId);
if (type == AnimationType::CSSTransition) {
- Animation* animation = toAnimation(player->source());
+ KeyframeEffect* animation = toKeyframeEffect(player->source());
KeyframeEffectModelBase* effect = toKeyframeEffectModelBase(animation->effect());
const AnimatableValueKeyframeEffectModel* oldEffect = toAnimatableValueKeyframeEffectModel(effect);
// Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the structure of transitions.
@@ -282,12 +282,12 @@ void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
newFrames[1]->setOffset(delay / (delay + duration));
effect->setFrames(newFrames);
- RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timing();
+ RefPtrWillBeRawPtr<AnimationEffectTiming> timing = player->source()->timing();
UnrestrictedDoubleOrString unrestrictedDuration;
unrestrictedDuration.setUnrestrictedDouble(duration + delay);
timing->setDuration(unrestrictedDuration);
} else if (type == AnimationType::WebAnimation) {
- RefPtrWillBeRawPtr<AnimationNodeTiming> timing = player->source()->timing();
+ RefPtrWillBeRawPtr<AnimationEffectTiming> timing = player->source()->timing();
UnrestrictedDoubleOrString unrestrictedDuration;
unrestrictedDuration.setUnrestrictedDouble(duration);
timing->setDuration(unrestrictedDuration);
@@ -295,32 +295,32 @@ void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String&
}
}
-void InspectorAnimationAgent::didCreateAnimationPlayer(AnimationPlayer* player)
+void InspectorAnimationAgent::didCreateAnimation(Animation* player)
{
const String& playerId = String::number(player->sequenceNumber());
- if (m_idToAnimationPlayer.get(playerId))
+ if (m_idToAnimation.get(playerId))
return;
// Check threshold
double latestStartTime = 0;
- for (const auto& p : m_idToAnimationPlayer.values())
+ for (const auto& p : m_idToAnimation.values())
latestStartTime = max(latestStartTime, normalizedStartTime(*p));
bool reset = false;
const double threshold = 1000;
if (normalizedStartTime(*player) - latestStartTime > threshold) {
reset = true;
- m_idToAnimationPlayer.clear();
+ m_idToAnimation.clear();
m_idToAnimationType.clear();
}
frontend()->animationPlayerCreated(buildObjectForAnimationPlayer(*player), reset);
}
-void InspectorAnimationAgent::didCancelAnimationPlayer(AnimationPlayer* player)
+void InspectorAnimationAgent::didCancelAnimation(Animation* player)
{
const String& playerId = String::number(player->sequenceNumber());
- if (!m_idToAnimationPlayer.get(playerId))
+ if (!m_idToAnimation.get(playerId))
return;
frontend()->animationPlayerCanceled(playerId);
}
@@ -333,9 +333,9 @@ void InspectorAnimationAgent::didClearDocumentOfWindowObject(LocalFrame* frame)
frame->document()->timeline().setPlaybackRate(referenceTimeline().playbackRate());
}
-AnimationPlayer* InspectorAnimationAgent::assertAnimationPlayer(ErrorString* errorString, const String& id)
+Animation* InspectorAnimationAgent::assertAnimation(ErrorString* errorString, const String& id)
{
- AnimationPlayer* player = m_idToAnimationPlayer.get(id);
+ Animation* player = m_idToAnimation.get(id);
if (!player) {
*errorString = "Could not find animation player with given id";
return nullptr;
@@ -348,7 +348,7 @@ AnimationTimeline& InspectorAnimationAgent::referenceTimeline()
return m_pageAgent->inspectedFrame()->document()->timeline();
}
-double InspectorAnimationAgent::normalizedStartTime(AnimationPlayer& player)
+double InspectorAnimationAgent::normalizedStartTime(Animation& player)
{
if (referenceTimeline().playbackRate() == 0)
return player.startTime() + referenceTimeline().currentTime() - player.timeline()->currentTime();
@@ -360,7 +360,7 @@ DEFINE_TRACE(InspectorAnimationAgent)
#if ENABLE(OILPAN)
visitor->trace(m_pageAgent);
visitor->trace(m_domAgent);
- visitor->trace(m_idToAnimationPlayer);
+ visitor->trace(m_idToAnimation);
visitor->trace(m_idToAnimationType);
#endif
InspectorBaseAgent::trace(visitor);
diff --git a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h
index 8573f9d..c49690e 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h
+++ b/third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.h
@@ -13,8 +13,8 @@
namespace blink {
+class Animation;
class AnimationNode;
-class AnimationPlayer;
class AnimationTimeline;
class Element;
class InspectorDOMAgent;
@@ -42,15 +42,15 @@ public:
virtual void setTiming(ErrorString*, const String& playerId, double duration, double delay) override;
// API for InspectorInstrumentation
- void didCreateAnimationPlayer(AnimationPlayer*);
- void didCancelAnimationPlayer(AnimationPlayer*);
+ void didCreateAnimation(Animation*);
+ void didCancelAnimation(Animation*);
void didClearDocumentOfWindowObject(LocalFrame*);
// API for InspectorFrontend
virtual void enable(ErrorString*) override;
// Methods for other agents to use.
- AnimationPlayer* assertAnimationPlayer(ErrorString*, const String& id);
+ Animation* assertAnimation(ErrorString*, const String& id);
DECLARE_VIRTUAL_TRACE();
@@ -59,15 +59,15 @@ private:
typedef TypeBuilder::Animation::AnimationPlayer::Type::Enum AnimationType;
- PassRefPtr<TypeBuilder::Animation::AnimationPlayer> buildObjectForAnimationPlayer(AnimationPlayer&);
- PassRefPtr<TypeBuilder::Animation::AnimationPlayer> buildObjectForAnimationPlayer(AnimationPlayer&, AnimationType, PassRefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr);
- PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer> > buildArrayForAnimationPlayers(Element&, const WillBeHeapVector<RefPtrWillBeMember<AnimationPlayer> >);
- double normalizedStartTime(AnimationPlayer&);
+ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> buildObjectForAnimationPlayer(Animation&);
+ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> buildObjectForAnimationPlayer(Animation&, AnimationType, PassRefPtr<TypeBuilder::Animation::KeyframesRule> keyframeRule = nullptr);
+ PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationPlayer>> buildArrayForAnimations(Element&, const WillBeHeapVector<RefPtrWillBeMember<Animation>>);
+ double normalizedStartTime(Animation&);
AnimationTimeline& referenceTimeline();
RawPtrWillBeMember<InspectorPageAgent> m_pageAgent;
RawPtrWillBeMember<InspectorDOMAgent> m_domAgent;
- WillBeHeapHashMap<String, RefPtrWillBeMember<AnimationPlayer>> m_idToAnimationPlayer;
+ WillBeHeapHashMap<String, RefPtrWillBeMember<Animation>> m_idToAnimation;
WillBeHeapHashMap<String, AnimationType> m_idToAnimationType;
};
diff --git a/third_party/WebKit/Source/core/inspector/InspectorInstrumentation.idl b/third_party/WebKit/Source/core/inspector/InspectorInstrumentation.idl
index 60f5620..34b45b6 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorInstrumentation.idl
+++ b/third_party/WebKit/Source/core/inspector/InspectorInstrumentation.idl
@@ -420,10 +420,10 @@ interface InspectorInstrumentation {
void traceAsyncCallbackCompleted(const InspectorInstrumentationCookie&);
[Animation, Inline=FastReturn]
- void didCreateAnimationPlayer(Document*, AnimationPlayer* player);
+ void didCreateAnimation(Document*, Animation* player);
[Animation, Inline=FastReturn]
- void didCancelAnimationPlayer(Document*, AnimationPlayer* player);
+ void didCancelAnimation(Document*, Animation* player);
}
interface InspectorConsoleInstrumentation {
diff --git a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp
index 6aaf2d2..59792d8 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.cpp
@@ -8,7 +8,7 @@
#include "bindings/core/v8/ScriptCallStackFactory.h"
#include "bindings/core/v8/ScriptSourceCode.h"
#include "core/animation/Animation.h"
-#include "core/animation/AnimationPlayer.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/css/invalidation/DescendantInvalidationSet.h"
#include "core/dom/DOMNodeIds.h"
#include "core/dom/StyleChangeReason.h"
@@ -756,22 +756,22 @@ PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorSetLayerTreeId::data(c
return value.release();
}
-PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationEvent::data(const AnimationPlayer& player)
+PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationEvent::data(const Animation& player)
{
RefPtr<TracedValue> value = TracedValue::create();
value->setString("id", String::number(player.sequenceNumber()));
value->setString("state", player.playState());
- if (const AnimationNode* source = player.source()) {
+ if (const AnimationEffect* source = player.source()) {
value->setString("name", source->name());
if (source->isAnimation()) {
- if (Element* target = toAnimation(source)->target())
+ if (Element* target = toKeyframeEffect(source)->target())
setNodeInfo(value.get(), target, "nodeId", "nodeName");
}
}
return value.release();
}
-PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationStateEvent::data(const AnimationPlayer& player)
+PassRefPtr<TraceEvent::ConvertableToTraceFormat> InspectorAnimationStateEvent::data(const Animation& player)
{
RefPtr<TracedValue> value = TracedValue::create();
value->setString("state", player.playState());
diff --git a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h
index 30b23bc..6bf4a7b 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h
+++ b/third_party/WebKit/Source/core/inspector/InspectorTraceEvents.h
@@ -13,7 +13,7 @@
#include "wtf/Functional.h"
namespace blink {
-class AnimationPlayer;
+class Animation;
class CSSStyleSheetResource;
class DescendantInvalidationSet;
class Document;
@@ -342,12 +342,12 @@ public:
class InspectorAnimationEvent {
public:
- static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(const AnimationPlayer&);
+ static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(const Animation&);
};
class InspectorAnimationStateEvent {
public:
- static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(const AnimationPlayer&);
+ static PassRefPtr<TraceEvent::ConvertableToTraceFormat> data(const Animation&);
};
} // namespace blink
diff --git a/third_party/WebKit/Source/core/style/KeyframeList.cpp b/third_party/WebKit/Source/core/style/KeyframeList.cpp
index 36d1e49..f72f4ba 100644
--- a/third_party/WebKit/Source/core/style/KeyframeList.cpp
+++ b/third_party/WebKit/Source/core/style/KeyframeList.cpp
@@ -22,7 +22,7 @@
#include "config.h"
#include "core/style/KeyframeList.h"
-#include "core/animation/Animation.h"
+#include "core/animation/KeyframeEffect.h"
#include "core/css/StylePropertySet.h"
#include "core/layout/LayoutObject.h"