Index: Source/core/animation/KeyframeEffect.cpp |
diff --git a/Source/core/animation/Animation.cpp b/Source/core/animation/KeyframeEffect.cpp |
similarity index 68% |
copy from Source/core/animation/Animation.cpp |
copy to Source/core/animation/KeyframeEffect.cpp |
index 1d829a2102657783b14fea11664c07f80e8b1720..77c129009fde554eb8e7354e510bb644321f465a 100644 |
--- a/Source/core/animation/Animation.cpp |
+++ b/Source/core/animation/KeyframeEffect.cpp |
@@ -29,17 +29,17 @@ |
*/ |
#include "config.h" |
-#include "core/animation/Animation.h" |
+#include "core/animation/KeyframeEffect.h" |
#include "bindings/core/v8/Dictionary.h" |
#include "bindings/core/v8/ExceptionState.h" |
-#include "core/animation/AnimationPlayer.h" |
+#include "core/animation/Animation.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/KeyframeEffectOptions.h" |
#include "core/animation/PropertyHandle.h" |
#include "core/dom/Element.h" |
#include "core/dom/NodeComputedStyle.h" |
@@ -49,26 +49,26 @@ |
namespace blink { |
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate) |
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* target, PassRefPtrWillBeRawPtr<EffectModel> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate) |
{ |
- return adoptRefWillBeNoop(new Animation(target, effect, timing, priority, eventDelegate)); |
+ return adoptRefWillBeNoop(new KeyframeEffect(target, effect, timing, priority, eventDelegate)); |
} |
-PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, double duration, ExceptionState& exceptionState) |
+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<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, const AnimationTimingProperties& timingInput, ExceptionState& exceptionState) |
+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<Animation> Animation::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState) |
+PassRefPtrWillBeRawPtr<KeyframeEffect> KeyframeEffect::create(Element* element, const Vector<Dictionary>& keyframeDictionaryVector, ExceptionState& exceptionState) |
{ |
ASSERT(RuntimeEnabledFeatures::webAnimationsAPIEnabled()); |
if (element) |
@@ -76,8 +76,8 @@ PassRefPtrWillBeRawPtr<Animation> Animation::create(Element* element, const Vect |
return create(element, EffectInput::convert(element, keyframeDictionaryVector, exceptionState), Timing()); |
} |
-Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> effect, const Timing& timing, Priority priority, PassOwnPtrWillBeRawPtr<EventDelegate> eventDelegate) |
- : AnimationNode(timing, eventDelegate) |
+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) |
@@ -85,42 +85,42 @@ Animation::Animation(Element* target, PassRefPtrWillBeRawPtr<AnimationEffect> ef |
{ |
#if !ENABLE(OILPAN) |
if (m_target) |
- m_target->ensureElementAnimations().addAnimation(this); |
+ m_target->ensureElementAnimations().addEffect(this); |
#endif |
} |
-Animation::~Animation() |
+KeyframeEffect::~KeyframeEffect() |
{ |
#if !ENABLE(OILPAN) |
if (m_target) |
- m_target->elementAnimations()->notifyAnimationDestroyed(this); |
+ m_target->elementAnimations()->notifyEffectDestroyed(this); |
#endif |
} |
-void Animation::attach(AnimationPlayer* player) |
+void KeyframeEffect::attach(Animation* animation) |
{ |
if (m_target) { |
- m_target->ensureElementAnimations().players().add(player); |
+ m_target->ensureElementAnimations().animations().add(animation); |
m_target->setNeedsAnimationStyleRecalc(); |
} |
- AnimationNode::attach(player); |
+ AnimationEffect::attach(animation); |
} |
-void Animation::detach() |
+void KeyframeEffect::detach() |
{ |
if (m_target) |
- m_target->elementAnimations()->players().remove(player()); |
+ m_target->elementAnimations()->animations().remove(animation()); |
if (m_sampledEffect) |
clearEffects(); |
- AnimationNode::detach(); |
+ AnimationEffect::detach(); |
} |
-void Animation::specifiedTimingChanged() |
+void KeyframeEffect::specifiedTimingChanged() |
{ |
- if (player()) { |
+ if (animation()) { |
// FIXME: Needs to consider groups when added. |
- ASSERT(player()->source() == this); |
- player()->setCompositorPending(true); |
+ ASSERT(animation()->source() == this); |
+ animation()->setCompositorPending(true); |
} |
} |
@@ -129,19 +129,19 @@ static AnimationStack& ensureAnimationStack(Element* element) |
return element->ensureElementAnimations().defaultStack(); |
} |
-void Animation::applyEffects() |
+void KeyframeEffect::applyEffects() |
{ |
ASSERT(isInEffect()); |
- ASSERT(player()); |
+ 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() |
- && player()->hasActiveAnimationsOnCompositor() |
- && player()->affects(*m_target, CSSPropertyTransform)) { |
- player()->cancelAnimationOnCompositor(); |
+ && animation()->hasActiveAnimationsOnCompositor() |
+ && animation()->affects(*m_target, CSSPropertyTransform)) { |
+ animation()->cancelAnimationOnCompositor(); |
} |
double iteration = currentIteration(); |
@@ -164,9 +164,9 @@ void Animation::applyEffects() |
m_sampledEffect->applySVGUpdate(toSVGElement(*m_target)); |
} |
-void Animation::clearEffects() |
+void KeyframeEffect::clearEffects() |
{ |
- ASSERT(player()); |
+ ASSERT(animation()); |
ASSERT(m_sampledEffect); |
m_sampledEffect->clear(); |
@@ -176,17 +176,17 @@ void Animation::clearEffects() |
invalidate(); |
} |
-void Animation::updateChildrenAndEffects() const |
+void KeyframeEffect::updateChildrenAndEffects() const |
{ |
if (!m_effect) |
return; |
if (isInEffect()) |
- const_cast<Animation*>(this)->applyEffects(); |
+ const_cast<KeyframeEffect*>(this)->applyEffects(); |
else if (m_sampledEffect) |
- const_cast<Animation*>(this)->clearEffects(); |
+ const_cast<KeyframeEffect*>(this)->clearEffects(); |
} |
-double Animation::calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const |
+double KeyframeEffect::calculateTimeToEffectChange(bool forwards, double localTime, double timeToNextIteration) const |
{ |
const double start = startTimeInternal() + specifiedTiming().startDelay; |
const double end = start + activeDurationInternal(); |
@@ -211,7 +211,7 @@ double Animation::calculateTimeToEffectChange(bool forwards, double localTime, d |
return 0; |
case PhaseAfter: |
ASSERT(localTime >= end); |
- // If this Animation is still in effect then it will need to update |
+ // 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 |
@@ -224,9 +224,9 @@ double Animation::calculateTimeToEffectChange(bool forwards, double localTime, d |
} |
#if !ENABLE(OILPAN) |
-void Animation::notifyElementDestroyed() |
+void KeyframeEffect::notifyElementDestroyed() |
{ |
- // If our player is kept alive just by the sampledEffect, we might get our |
+ // 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; |
@@ -238,45 +238,45 @@ void Animation::notifyElementDestroyed() |
} |
#endif |
-bool Animation::isCandidateForAnimationOnCompositor(double playerPlaybackRate) const |
+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, player(), *effect(), playerPlaybackRate); |
+ return CompositorAnimations::instance()->isCandidateForAnimationOnCompositor(specifiedTiming(), *m_target, animation(), *effect(), animationPlaybackRate); |
} |
-bool Animation::maybeStartAnimationOnCompositor(int group, double startTime, double currentTime, double playerPlaybackRate) |
+bool KeyframeEffect::maybeStartAnimationOnCompositor(int group, double startTime, double currentTime, double animationPlaybackRate) |
{ |
ASSERT(!hasActiveAnimationsOnCompositor()); |
- if (!isCandidateForAnimationOnCompositor(playerPlaybackRate)) |
+ if (!isCandidateForAnimationOnCompositor(animationPlaybackRate)) |
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)) |
+ if (!CompositorAnimations::instance()->startAnimationOnCompositor(*m_target, group, startTime, currentTime, specifiedTiming(), *animation(), *effect(), m_compositorAnimationIds, animationPlaybackRate)) |
return false; |
ASSERT(!m_compositorAnimationIds.isEmpty()); |
return true; |
} |
-bool Animation::hasActiveAnimationsOnCompositor() const |
+bool KeyframeEffect::hasActiveAnimationsOnCompositor() const |
{ |
return !m_compositorAnimationIds.isEmpty(); |
} |
-bool Animation::hasActiveAnimationsOnCompositor(CSSPropertyID property) const |
+bool KeyframeEffect::hasActiveAnimationsOnCompositor(CSSPropertyID property) const |
{ |
return hasActiveAnimationsOnCompositor() && affects(PropertyHandle(property)); |
} |
-bool Animation::affects(PropertyHandle property) const |
+bool KeyframeEffect::affects(PropertyHandle property) const |
{ |
return m_effect && m_effect->affects(property); |
} |
-bool Animation::cancelAnimationOnCompositor() |
+bool KeyframeEffect::cancelAnimationOnCompositor() |
{ |
// FIXME: cancelAnimationOnCompositor is called from withins style recalc. |
// This queries compositingState, which is not necessarily up to date. |
@@ -286,56 +286,56 @@ bool Animation::cancelAnimationOnCompositor() |
return false; |
if (!m_target || !m_target->layoutObject()) |
return false; |
- ASSERT(player()); |
+ ASSERT(animation()); |
for (const auto& compositorAnimationId : m_compositorAnimationIds) |
- CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target, *player(), compositorAnimationId); |
+ CompositorAnimations::instance()->cancelAnimationOnCompositor(*m_target, *animation(), compositorAnimationId); |
m_compositorAnimationIds.clear(); |
return true; |
} |
-void Animation::restartAnimationOnCompositor() |
+void KeyframeEffect::restartAnimationOnCompositor() |
{ |
if (cancelAnimationOnCompositor()) |
- player()->setCompositorPending(true); |
+ animation()->setCompositorPending(true); |
} |
-void Animation::cancelIncompatibleAnimationsOnCompositor() |
+void KeyframeEffect::cancelIncompatibleAnimationsOnCompositor() |
{ |
- if (m_target && player() && effect()) |
- CompositorAnimations::instance()->cancelIncompatibleAnimationsOnCompositor(*m_target, *player(), *effect()); |
+ if (m_target && animation() && effect()) |
+ CompositorAnimations::instance()->cancelIncompatibleAnimationsOnCompositor(*m_target, *animation(), *effect()); |
} |
-void Animation::pauseAnimationForTestingOnCompositor(double pauseTime) |
+void KeyframeEffect::pauseAnimationForTestingOnCompositor(double pauseTime) |
{ |
ASSERT(hasActiveAnimationsOnCompositor()); |
if (!m_target || !m_target->layoutObject()) |
return; |
- ASSERT(player()); |
+ ASSERT(animation()); |
for (const auto& compositorAnimationId : m_compositorAnimationIds) |
- CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*m_target, *player(), compositorAnimationId, pauseTime); |
+ CompositorAnimations::instance()->pauseAnimationForTestingOnCompositor(*m_target, *animation(), compositorAnimationId, pauseTime); |
} |
-bool Animation::canAttachCompositedLayers() const |
+bool KeyframeEffect::canAttachCompositedLayers() const |
{ |
- if (!m_target || !player()) |
+ if (!m_target || !animation()) |
return false; |
- return CompositorAnimations::instance()->canAttachCompositedLayers(*m_target, *player()); |
+ return CompositorAnimations::instance()->canAttachCompositedLayers(*m_target, *animation()); |
} |
-void Animation::attachCompositedLayers() |
+void KeyframeEffect::attachCompositedLayers() |
{ |
ASSERT(m_target); |
- ASSERT(player()); |
- CompositorAnimations::instance()->attachCompositedLayers(*m_target, *player()); |
+ ASSERT(animation()); |
+ CompositorAnimations::instance()->attachCompositedLayers(*m_target, *animation()); |
} |
-DEFINE_TRACE(Animation) |
+DEFINE_TRACE(KeyframeEffect) |
{ |
visitor->trace(m_target); |
visitor->trace(m_effect); |
visitor->trace(m_sampledEffect); |
- AnimationNode::trace(visitor); |
+ AnimationEffect::trace(visitor); |
} |
} // namespace blink |