diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h')
-rw-r--r-- | chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h | 146 |
1 files changed, 97 insertions, 49 deletions
diff --git a/chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h b/chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h index fb553d96232..31159f908ec 100644 --- a/chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h +++ b/chromium/third_party/WebKit/Source/core/animation/css/CSSAnimations.h @@ -32,11 +32,11 @@ #define CSSAnimations_h #include "core/animation/Animation.h" +#include "core/animation/AnimationPlayer.h" #include "core/animation/InertAnimation.h" -#include "core/animation/Player.h" +#include "core/animation/interpolation/Interpolation.h" #include "core/css/StylePropertySet.h" #include "core/dom/Document.h" -#include "core/platform/animation/CSSAnimationData.h" #include "core/rendering/style/RenderStyleConstants.h" #include "wtf/HashMap.h" #include "wtf/Vector.h" @@ -44,39 +44,40 @@ namespace WebCore { +class CSSTransitionData; class Element; class StylePropertyShorthand; class StyleResolver; class StyleRuleKeyframes; // This class stores the CSS Animations/Transitions information we use during a style recalc. -// This includes updates to animations/transitions as well as the CompositableValueMaps to be applied. -class CSSAnimationUpdate FINAL { +// This includes updates to animations/transitions as well as the Interpolations to be applied. +class CSSAnimationUpdate FINAL : public NoBaseWillBeGarbageCollectedFinalized<CSSAnimationUpdate> { public: - void startAnimation(AtomicString& animationName, const HashSet<RefPtr<InertAnimation> >& animations) + void startAnimation(AtomicString& animationName, PassRefPtrWillBeRawPtr<InertAnimation> animation) { NewAnimation newAnimation; newAnimation.name = animationName; - newAnimation.animations = animations; + newAnimation.animation = animation; m_newAnimations.append(newAnimation); } // Returns whether player has been cancelled and should be filtered during style application. - bool isCancelledAnimation(const Player* player) const { return m_cancelledAnimationPlayers.contains(player); } - void cancelAnimation(const AtomicString& name, const HashSet<RefPtr<Player> >& players) + bool isCancelledAnimation(const AnimationPlayer* player) const { return m_cancelledAnimationPlayers.contains(player); } + void cancelAnimation(const AtomicString& name, AnimationPlayer& player) { m_cancelledAnimationNames.append(name); - for (HashSet<RefPtr<Player> >::const_iterator iter = players.begin(); iter != players.end(); ++iter) - m_cancelledAnimationPlayers.add(iter->get()); + m_cancelledAnimationPlayers.add(&player); } void toggleAnimationPaused(const AtomicString& name) { m_animationsWithPauseToggled.append(name); } - void startTransition(CSSPropertyID id, const AnimatableValue* from, const AnimatableValue* to, PassRefPtr<InertAnimation> animation) + void startTransition(CSSPropertyID id, CSSPropertyID eventId, const AnimatableValue* from, const AnimatableValue* to, PassRefPtrWillBeRawPtr<InertAnimation> animation) { NewTransition newTransition; newTransition.id = id; + newTransition.eventId = eventId; newTransition.from = from; newTransition.to = to; newTransition.animation = animation; @@ -86,29 +87,46 @@ public: void cancelTransition(CSSPropertyID id) { m_cancelledTransitions.add(id); } struct NewAnimation { + ALLOW_ONLY_INLINE_ALLOCATION(); + public: + void trace(Visitor* visitor) + { + visitor->trace(animation); + } + AtomicString name; - HashSet<RefPtr<InertAnimation> > animations; + RefPtrWillBeMember<InertAnimation> animation; }; - const Vector<NewAnimation>& newAnimations() const { return m_newAnimations; } + const WillBeHeapVector<NewAnimation>& newAnimations() const { return m_newAnimations; } const Vector<AtomicString>& cancelledAnimationNames() const { return m_cancelledAnimationNames; } - const HashSet<const Player*>& cancelledAnimationPlayers() const { return m_cancelledAnimationPlayers; } + const WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> >& cancelledAnimationAnimationPlayers() const { return m_cancelledAnimationPlayers; } const Vector<AtomicString>& animationsWithPauseToggled() const { return m_animationsWithPauseToggled; } struct NewTransition { + ALLOW_ONLY_INLINE_ALLOCATION(); + public: + void trace(Visitor* visitor) + { + visitor->trace(from); + visitor->trace(to); + visitor->trace(animation); + } + CSSPropertyID id; - const AnimatableValue* from; - const AnimatableValue* to; - RefPtr<InertAnimation> animation; + CSSPropertyID eventId; + RawPtrWillBeMember<const AnimatableValue> from; + RawPtrWillBeMember<const AnimatableValue> to; + RefPtrWillBeMember<InertAnimation> animation; }; - typedef HashMap<CSSPropertyID, NewTransition> NewTransitionMap; + typedef WillBeHeapHashMap<CSSPropertyID, NewTransition> NewTransitionMap; const NewTransitionMap& newTransitions() const { return m_newTransitions; } const HashSet<CSSPropertyID>& cancelledTransitions() const { return m_cancelledTransitions; } - void adoptCompositableValuesForAnimations(AnimationEffect::CompositableValueMap& newMap) { newMap.swap(m_compositableValuesForAnimations); } - void adoptCompositableValuesForTransitions(AnimationEffect::CompositableValueMap& newMap) { newMap.swap(m_compositableValuesForTransitions); } - const AnimationEffect::CompositableValueMap& compositableValuesForAnimations() const { return m_compositableValuesForAnimations; } - const AnimationEffect::CompositableValueMap& compositableValuesForTransitions() const { return m_compositableValuesForTransitions; } - AnimationEffect::CompositableValueMap& compositableValuesForAnimations() { return m_compositableValuesForAnimations; } + void adoptActiveInterpolationsForAnimations(WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolationsForAnimations); } + void adoptActiveInterpolationsForTransitions(WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& newMap) { newMap.swap(m_activeInterpolationsForTransitions); } + const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations() const { return m_activeInterpolationsForAnimations; } + const WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForTransitions() const { return m_activeInterpolationsForTransitions; } + WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> >& activeInterpolationsForAnimations() { return m_activeInterpolationsForAnimations; } bool isEmpty() const { @@ -118,28 +136,35 @@ public: && m_animationsWithPauseToggled.isEmpty() && m_newTransitions.isEmpty() && m_cancelledTransitions.isEmpty() - && m_compositableValuesForAnimations.isEmpty() - && m_compositableValuesForTransitions.isEmpty(); + && m_activeInterpolationsForAnimations.isEmpty() + && m_activeInterpolationsForTransitions.isEmpty(); } + + void trace(Visitor*); + private: // Order is significant since it defines the order in which new animations // will be started. Note that there may be multiple animations present // with the same name, due to the way in which we split up animations with // incomplete keyframes. - Vector<NewAnimation> m_newAnimations; + WillBeHeapVector<NewAnimation> m_newAnimations; Vector<AtomicString> m_cancelledAnimationNames; - HashSet<const Player*> m_cancelledAnimationPlayers; + WillBeHeapHashSet<RawPtrWillBeMember<const AnimationPlayer> > m_cancelledAnimationPlayers; Vector<AtomicString> m_animationsWithPauseToggled; NewTransitionMap m_newTransitions; HashSet<CSSPropertyID> m_cancelledTransitions; - AnimationEffect::CompositableValueMap m_compositableValuesForAnimations; - AnimationEffect::CompositableValueMap m_compositableValuesForTransitions; + WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activeInterpolationsForAnimations; + WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_activeInterpolationsForTransitions; }; class CSSAnimations FINAL { + WTF_MAKE_NONCOPYABLE(CSSAnimations); + DISALLOW_ALLOCATION(); public: + CSSAnimations(); + // FIXME: This method is only used here and in the legacy animations // implementation. It should be made private or file-scope when the legacy // engine is removed. @@ -147,68 +172,91 @@ public: static bool isAnimatableProperty(CSSPropertyID); static const StylePropertyShorthand& animatableProperties(); + static bool isAllowedAnimation(CSSPropertyID); // FIXME: This should take a const ScopedStyleTree instead of a StyleResolver. // We should also change the Element* to a const Element* - static PassOwnPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Element& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolver*); + static PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> calculateUpdate(Element*, const Element& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolver*); - void setPendingUpdate(PassOwnPtr<CSSAnimationUpdate> update) { m_pendingUpdate = update; } + void setPendingUpdate(PassOwnPtrWillBeRawPtr<CSSAnimationUpdate> update) { m_pendingUpdate = update; } void maybeApplyPendingUpdate(Element*); bool isEmpty() const { return m_animations.isEmpty() && m_transitions.isEmpty() && !m_pendingUpdate; } void cancel(); + void trace(Visitor*); + private: - // Note that a single animation name may map to multiple players due to - // the way in which we split up animations with incomplete keyframes. - // FIXME: Once the Web Animations model supports groups, we could use a - // ParGroup to drive multiple animations from a single Player. - typedef HashMap<AtomicString, HashSet<RefPtr<Player> > > AnimationMap; struct RunningTransition { - Animation* transition; // The TransitionTimeline keeps the Players alive - const AnimatableValue* from; - const AnimatableValue* to; + ALLOW_ONLY_INLINE_ALLOCATION(); + public: + void trace(Visitor* visitor) + { + visitor->trace(from); + visitor->trace(to); + visitor->trace(player); + } + + RefPtrWillBeMember<AnimationPlayer> player; + RawPtrWillBeMember<const AnimatableValue> from; + RawPtrWillBeMember<const AnimatableValue> to; }; - typedef HashMap<CSSPropertyID, RunningTransition > TransitionMap; + + typedef WillBeHeapHashMap<AtomicString, RefPtrWillBeMember<AnimationPlayer> > AnimationMap; AnimationMap m_animations; + + typedef WillBeHeapHashMap<CSSPropertyID, RunningTransition> TransitionMap; TransitionMap m_transitions; - OwnPtr<CSSAnimationUpdate> m_pendingUpdate; - AnimationEffect::CompositableValueMap m_previousCompositableValuesForAnimations; + OwnPtrWillBeMember<CSSAnimationUpdate> m_pendingUpdate; + + WillBeHeapHashMap<CSSPropertyID, RefPtrWillBeMember<Interpolation> > m_previousActiveInterpolationsForAnimations; static void calculateAnimationUpdate(CSSAnimationUpdate*, Element*, const Element& parentElement, const RenderStyle&, RenderStyle* parentStyle, StyleResolver*); static void calculateTransitionUpdate(CSSAnimationUpdate*, const Element*, const RenderStyle&); - static void calculateTransitionUpdateForProperty(CSSPropertyID, const CSSAnimationData*, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimationUpdate*, const Element*); + static void calculateTransitionUpdateForProperty(CSSPropertyID, CSSPropertyID eventId, const CSSTransitionData&, size_t transitionIndex, const RenderStyle& oldStyle, const RenderStyle&, const TransitionMap* activeTransitions, CSSAnimationUpdate*, const Element*); - static void calculateAnimationCompositableValues(CSSAnimationUpdate*, const Element*); - static void calculateTransitionCompositableValues(CSSAnimationUpdate*, const Element*); + static void calculateAnimationActiveInterpolations(CSSAnimationUpdate*, const Element*, double timelineCurrentTime); + static void calculateTransitionActiveInterpolations(CSSAnimationUpdate*, const Element*, double timelineCurrentTime); - class AnimationEventDelegate FINAL : public TimedItem::EventDelegate { + class AnimationEventDelegate FINAL : public AnimationNode::EventDelegate { public: AnimationEventDelegate(Element* target, const AtomicString& name) : m_target(target) , m_name(name) + , m_previousPhase(AnimationNode::PhaseNone) + , m_previousIteration(nullValue()) { } - virtual void onEventCondition(const TimedItem*, bool isFirstSample, TimedItem::Phase previousPhase, double previousIteration) OVERRIDE; + virtual void onEventCondition(const AnimationNode*) OVERRIDE; private: void maybeDispatch(Document::ListenerType, const AtomicString& eventName, double elapsedTime); Element* m_target; const AtomicString m_name; + AnimationNode::Phase m_previousPhase; + double m_previousIteration; }; - class TransitionEventDelegate FINAL : public TimedItem::EventDelegate { + class TransitionEventDelegate FINAL : public AnimationNode::EventDelegate { public: TransitionEventDelegate(Element* target, CSSPropertyID property) : m_target(target) , m_property(property) + , m_previousPhase(AnimationNode::PhaseNone) { } - virtual void onEventCondition(const TimedItem*, bool isFirstSample, TimedItem::Phase previousPhase, double previousIteration) OVERRIDE; + virtual void onEventCondition(const AnimationNode*) OVERRIDE; private: Element* m_target; const CSSPropertyID m_property; + AnimationNode::Phase m_previousPhase; }; }; } // namespace WebCore +namespace WTF { +template<> struct VectorTraits<WebCore::CSSAnimationUpdate::NewAnimation> : VectorTraitsBase<WebCore::CSSAnimationUpdate::NewAnimation> { + static const bool canInitializeWithMemset = true; +}; +} + #endif |