Index: Source/core/svg/animation/SMILTimeContainer.cpp |
diff --git a/Source/core/svg/animation/SMILTimeContainer.cpp b/Source/core/svg/animation/SMILTimeContainer.cpp |
index ea7c17eb12de3af5d027dd33b6048aa3c0bcc003..69be0abd708095445e6e8e3a0de9b2a40e94edad 100644 |
--- a/Source/core/svg/animation/SMILTimeContainer.cpp |
+++ b/Source/core/svg/animation/SMILTimeContainer.cpp |
@@ -30,12 +30,14 @@ |
#include "core/animation/AnimationTimeline.h" |
#include "core/dom/ElementTraversal.h" |
#include "core/frame/FrameView.h" |
+#include "core/frame/Settings.h" |
#include "core/svg/SVGSVGElement.h" |
#include "core/svg/animation/SVGSMILElement.h" |
namespace blink { |
static const double initialFrameDelay = 0.025; |
+static const double animationPolicyOnceDuration = 3.000; |
#if !ENABLE(OILPAN) |
// Every entry-point that calls updateAnimations() should instantiate a |
@@ -58,6 +60,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner) |
, m_frameSchedulingState(Idle) |
, m_documentOrderIndexesDirty(false) |
, m_wakeupTimer(this, &SMILTimeContainer::wakeupTimerFired) |
+ , m_animationPolicyOnceTimer(this, &SMILTimeContainer::animationPolicyTimerFired) |
, m_ownerSVGElement(owner) |
#if ENABLE(ASSERT) |
, m_preventScheduledAnimationsChanges(false) |
@@ -68,6 +71,7 @@ SMILTimeContainer::SMILTimeContainer(SVGSVGElement& owner) |
SMILTimeContainer::~SMILTimeContainer() |
{ |
cancelAnimationFrame(); |
+ cancelAnimationPolicyTimer(); |
ASSERT(!m_wakeupTimer.isActive()); |
#if ENABLE(ASSERT) |
ASSERT(!m_preventScheduledAnimationsChanges); |
@@ -152,6 +156,9 @@ SMILTime SMILTimeContainer::elapsed() const |
bool SMILTimeContainer::isPaused() const |
{ |
+ // If animation policy is "none", it is always paused. |
+ if (animationPolicy() == ImageAnimationPolicyNoAnimation) |
+ return true; |
return m_pauseTime; |
fs
2014/12/25 17:32:08
return m_oauseTime || animationPolicy() == ...;
(
je_julie(Not used)
2014/12/27 07:08:54
Done.
I assumed that it has the same effect whenev
fs
2014/12/27 15:36:34
That sounds fine. I suppose if the policy could ch
|
} |
@@ -163,6 +170,10 @@ bool SMILTimeContainer::isStarted() const |
void SMILTimeContainer::begin() |
{ |
RELEASE_ASSERT(!m_beginTime); |
+ |
+ if (!handleAnimationPolicy(true, false)) |
fs
2014/12/25 17:32:08
handleAnimationPolicy(RestartOnceTimerIfNotPaused)
je_julie(Not used)
2014/12/27 07:08:53
Done.
|
+ return; |
+ |
double now = currentTime(); |
// If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began. |
@@ -194,6 +205,9 @@ void SMILTimeContainer::begin() |
void SMILTimeContainer::pause() |
{ |
+ if (!handleAnimationPolicy(false, true)) |
fs
2014/12/25 17:32:08
handleAnimationPolicy(CancelOnceTimer)
je_julie(Not used)
2014/12/27 07:08:53
Done.
|
+ return; |
+ |
ASSERT(!isPaused()); |
m_pauseTime = currentTime(); |
@@ -206,6 +220,9 @@ void SMILTimeContainer::pause() |
void SMILTimeContainer::resume() |
{ |
+ if (!handleAnimationPolicy(false, false)) |
fs
2014/12/25 17:32:08
handleAnimationPolicy(RestartOnceTimer)
je_julie(Not used)
2014/12/27 07:08:53
Done.
|
+ return; |
+ |
ASSERT(isPaused()); |
m_resumeTime = currentTime(); |
@@ -221,6 +238,9 @@ void SMILTimeContainer::setElapsed(SMILTime time) |
return; |
} |
+ if (!handleAnimationPolicy(true, false)) |
fs
2014/12/25 17:32:08
Same as in begin().
je_julie(Not used)
2014/12/27 07:08:53
Done.
|
+ return; |
+ |
cancelAnimationFrame(); |
double now = currentTime(); |
@@ -295,6 +315,53 @@ void SMILTimeContainer::wakeupTimerFired(Timer<SMILTimeContainer>*) |
} |
} |
+void SMILTimeContainer::scheduleAnimationPolicyTimer() |
+{ |
+ m_animationPolicyOnceTimer.startOneShot(animationPolicyOnceDuration, FROM_HERE); |
+} |
+ |
+void SMILTimeContainer::cancelAnimationPolicyTimer() |
+{ |
+ if (m_animationPolicyOnceTimer.isActive()) |
+ m_animationPolicyOnceTimer.stop(); |
+} |
+ |
+void SMILTimeContainer::animationPolicyTimerFired(Timer<SMILTimeContainer>*) |
+{ |
+ pause(); |
+} |
+ |
+ImageAnimationPolicy SMILTimeContainer::animationPolicy() const |
+{ |
+ Settings* settings = document().settings(); |
+ if (!settings) |
+ return ImageAnimationPolicyAllowed; |
+ |
+ return settings->imageAnimationPolicy(); |
+} |
+ |
+bool SMILTimeContainer::handleAnimationPolicy(bool checkPausedState, bool cancelTimer) |
+{ |
+ ImageAnimationPolicy policy = animationPolicy(); |
+ // If the animation policy is "none", control is not allowed. |
+ // returns false to exit flow. |
+ if (policy == ImageAnimationPolicyNoAnimation) |
+ return false; |
+ // If the animation policy is "once", |
+ if (policy == ImageAnimationPolicyAnimateOnce) { |
+ // checkPausedState: the paused state should be checked. |
+ bool passed = checkPausedState ? !m_pauseTime : true; |
+ if (passed) { |
fs
2014/12/25 17:32:08
This could've been !checkPausedState || !isPaused(
je_julie(Not used)
2014/12/27 07:08:54
Done.
|
+ // cancelTimer: cancel or start timer. |
+ if (cancelTimer) |
+ cancelAnimationPolicyTimer(); |
+ else |
+ scheduleAnimationPolicyTimer(); |
+ } |
+ } |
+ return true; |
+} |
+ |
void SMILTimeContainer::updateDocumentOrderIndexes() |
{ |
unsigned timingElementCount = 0; |