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

Unified Diff: Source/core/animation/Animation.cpp

Issue 19266007: Web Animations: Introduce ActiveAnimations and AnimationStack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 7 years, 5 months 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
« no previous file with comments | « Source/core/animation/Animation.h ('k') | Source/core/animation/AnimationStack.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/animation/Animation.cpp
diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/Animation.cpp
index e2b5673580889cb6ebb40ec2e57b2aa1bf41e618..ad1de80a4adbdba75126aecffa29e1dd81a5d84e 100644
--- a/Source/core/animation/Animation.cpp
+++ b/Source/core/animation/Animation.cpp
@@ -31,6 +31,8 @@
#include "config.h"
#include "core/animation/Animation.h"
+#include "core/animation/DocumentTimeline.h"
+#include "core/animation/Player.h"
#include "core/dom/Element.h"
namespace WebCore {
@@ -44,21 +46,27 @@ Animation::Animation(PassRefPtr<Element> target, PassRefPtr<AnimationEffect> eff
: TimedItem(timing)
, m_target(target)
, m_effect(effect)
- , m_isInTargetActiveAnimationsList(false)
+ , m_activeInAnimationStack(false)
{
}
-Animation::~Animation()
+void Animation::willDetach()
{
- if (m_isInTargetActiveAnimationsList)
- m_target->removeActiveAnimation(this);
+ if (m_activeInAnimationStack)
+ clearEffects();
+}
+
+static AnimationStack* ensureAnimationStack(Element* element)
+{
+ return element->ensureActiveAnimations()->defaultStack();
}
void Animation::applyEffects(bool previouslyActiveOrInEffect)
{
+ ASSERT(player());
if (!previouslyActiveOrInEffect) {
- m_target->addActiveAnimation(this);
- m_isInTargetActiveAnimationsList = true;
+ ensureAnimationStack(m_target.get())->add(this);
+ m_activeInAnimationStack = true;
}
m_compositableValues = m_effect->sample(currentIteration(), timeFraction());
m_target->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer);
@@ -66,15 +74,17 @@ void Animation::applyEffects(bool previouslyActiveOrInEffect)
void Animation::clearEffects()
{
- m_target->removeActiveAnimation(this);
- m_isInTargetActiveAnimationsList = false;
+ ASSERT(player());
+ ASSERT(m_activeInAnimationStack);
+ ensureAnimationStack(m_target.get())->remove(this);
+ m_activeInAnimationStack = false;
m_compositableValues.clear();
}
void Animation::updateChildrenAndEffects(bool wasActiveOrInEffect) const
{
const bool isActiveOrInEffect = isActive() || isInEffect();
- ASSERT(m_isInTargetActiveAnimationsList == wasActiveOrInEffect);
+ ASSERT(m_activeInAnimationStack == wasActiveOrInEffect);
if (wasActiveOrInEffect && !isActiveOrInEffect)
const_cast<Animation*>(this)->clearEffects();
else if (isActiveOrInEffect)
« no previous file with comments | « Source/core/animation/Animation.h ('k') | Source/core/animation/AnimationStack.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698