Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: Source/core/svg/animation/SMILTimeContainer.cpp

Issue 802143002: AnimationPolicy setting is applied to SVG animation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Use enum Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..3ca68c1153bec9920a9bce92d5d826dd6bc8fbfa 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,7 +156,8 @@ SMILTime SMILTimeContainer::elapsed() const
bool SMILTimeContainer::isPaused() const
{
- return m_pauseTime;
+ // If animation policy is "none", it is always paused.
+ return m_pauseTime || animationPolicy() == ImageAnimationPolicyNoAnimation;
}
bool SMILTimeContainer::isStarted() const
@@ -163,6 +168,10 @@ bool SMILTimeContainer::isStarted() const
void SMILTimeContainer::begin()
{
RELEASE_ASSERT(!m_beginTime);
+
+ if (!handleAnimationPolicy(RestartOnceTimerIfNotPaused))
+ return;
+
double now = currentTime();
// If 'm_presetStartTime' is set, the timeline was modified via setElapsed() before the document began.
@@ -194,6 +203,9 @@ void SMILTimeContainer::begin()
void SMILTimeContainer::pause()
{
+ if (!handleAnimationPolicy(CancelOnceTimer))
+ return;
+
ASSERT(!isPaused());
m_pauseTime = currentTime();
@@ -206,6 +218,9 @@ void SMILTimeContainer::pause()
void SMILTimeContainer::resume()
{
+ if (!handleAnimationPolicy(RestartOnceTimer))
+ return;
+
ASSERT(isPaused());
m_resumeTime = currentTime();
@@ -221,6 +236,9 @@ void SMILTimeContainer::setElapsed(SMILTime time)
return;
}
+ if (!handleAnimationPolicy(RestartOnceTimerIfNotPaused))
+ return;
+
cancelAnimationFrame();
double now = currentTime();
@@ -295,6 +313,58 @@ 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(AnimationPolicyOnceAction onceAction)
+{
+ 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) {
+ switch (onceAction) {
+ case RestartOnceTimerIfNotPaused:
+ if (isPaused())
+ break;
+ /* fall through */
+ case RestartOnceTimer:
+ scheduleAnimationPolicyTimer();
+ break;
+ case CancelOnceTimer:
+ cancelAnimationPolicyTimer();
+ break;
+ default:
fs 2014/12/27 15:36:35 Shouldn't need this (all values are handled.)
je_julie(Not used) 2014/12/28 05:50:26 Done.
+ break;
+ }
+ }
+ return true;
+}
+
void SMILTimeContainer::updateDocumentOrderIndexes()
{
unsigned timingElementCount = 0;

Powered by Google App Engine
This is Rietveld 408576698