| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef DocumentTimeline_h | 31 #ifndef DocumentTimeline_h |
| 32 #define DocumentTimeline_h | 32 #define DocumentTimeline_h |
| 33 | 33 |
| 34 #include "core/animation/AnimationEffect.h" | 34 #include "core/animation/AnimationEffect.h" |
| 35 #include "core/animation/AnimationPlayer.h" | 35 #include "core/animation/AnimationPlayer.h" |
| 36 #include "core/dom/Element.h" | 36 #include "core/dom/Element.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "platform/Timer.h" | 38 #include "platform/Timer.h" |
| 39 #include "platform/heap/Handle.h" |
| 39 #include "wtf/RefCounted.h" | 40 #include "wtf/RefCounted.h" |
| 40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
| 41 #include "wtf/Vector.h" | 42 #include "wtf/Vector.h" |
| 42 | 43 |
| 43 namespace WebCore { | 44 namespace WebCore { |
| 44 | 45 |
| 45 class Document; | 46 class Document; |
| 46 class TimedItem; | 47 class TimedItem; |
| 47 | 48 |
| 48 // DocumentTimeline is constructed and owned by Document, and tied to its lifecy
cle. | 49 // DocumentTimeline is constructed and owned by Document, and tied to its lifecy
cle. |
| 49 class DocumentTimeline : public RefCounted<DocumentTimeline> { | 50 class DocumentTimeline : public RefCountedWillBeGarbageCollectedFinalized<Docume
ntTimeline> { |
| 50 public: | 51 public: |
| 51 class PlatformTiming { | 52 class PlatformTiming : public NoBaseWillBeGarbageCollectedFinalized<Platform
Timing> { |
| 52 | 53 |
| 53 public: | 54 public: |
| 54 // Calls DocumentTimeline's wake() method after duration seconds. | 55 // Calls DocumentTimeline's wake() method after duration seconds. |
| 55 virtual void wakeAfter(double duration) = 0; | 56 virtual void wakeAfter(double duration) = 0; |
| 56 virtual void cancelWake() = 0; | 57 virtual void cancelWake() = 0; |
| 57 virtual void serviceOnNextFrame() = 0; | 58 virtual void serviceOnNextFrame() = 0; |
| 58 virtual ~PlatformTiming() { } | 59 virtual ~PlatformTiming() { } |
| 59 | 60 virtual void trace(Visitor*) = 0; |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 static PassRefPtr<DocumentTimeline> create(Document*, PassOwnPtr<PlatformTim
ing> = nullptr); | 63 static PassRefPtrWillBeRawPtr<DocumentTimeline> create(Document*, PassOwnPtr
WillBeRawPtr<PlatformTiming> = nullptr); |
| 63 ~DocumentTimeline(); | 64 ~DocumentTimeline(); |
| 64 | 65 |
| 65 void serviceAnimations(AnimationPlayer::UpdateReason); | 66 void serviceAnimations(AnimationPlayer::UpdateReason); |
| 66 | 67 |
| 67 // Creates a player attached to this timeline, but without a start time. | 68 // Creates a player attached to this timeline, but without a start time. |
| 68 AnimationPlayer* createAnimationPlayer(TimedItem*); | 69 AnimationPlayer* createAnimationPlayer(TimedItem*); |
| 69 AnimationPlayer* play(TimedItem*); | 70 AnimationPlayer* play(TimedItem*); |
| 70 | 71 |
| 72 #if !ENABLE(OILPAN) |
| 71 void playerDestroyed(AnimationPlayer* player) | 73 void playerDestroyed(AnimationPlayer* player) |
| 72 { | 74 { |
| 73 ASSERT(m_players.contains(player)); | 75 ASSERT(m_players.contains(player)); |
| 74 m_players.remove(player); | 76 m_players.remove(player); |
| 75 } | 77 } |
| 78 #endif |
| 76 | 79 |
| 77 // Called from setReadyState() in Document.cpp to set m_zeroTime to | 80 // Called from setReadyState() in Document.cpp to set m_zeroTime to |
| 78 // performance.timing.domInteractive | 81 // performance.timing.domInteractive |
| 79 void setZeroTime(double); | 82 void setZeroTime(double); |
| 80 bool hasStarted() const { return !isNull(m_zeroTime); } | 83 bool hasStarted() const { return !isNull(m_zeroTime); } |
| 81 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } | 84 bool hasPendingUpdates() const { return !m_playersNeedingUpdate.isEmpty(); } |
| 82 double zeroTime() const { return m_zeroTime; } | 85 double zeroTime() const { return m_zeroTime; } |
| 83 double currentTime(bool& isNull); | 86 double currentTime(bool& isNull); |
| 84 double currentTime(); | 87 double currentTime(); |
| 85 double effectiveTime(); | 88 double effectiveTime(); |
| 86 void pauseAnimationsForTesting(double); | 89 void pauseAnimationsForTesting(double); |
| 87 size_t numberOfActiveAnimationsForTesting() const; | 90 size_t numberOfActiveAnimationsForTesting() const; |
| 88 | 91 |
| 89 void setOutdatedAnimationPlayer(AnimationPlayer*); | 92 void setOutdatedAnimationPlayer(AnimationPlayer*); |
| 90 bool hasOutdatedAnimationPlayer() const { return m_hasOutdatedAnimationPlaye
r; } | 93 bool hasOutdatedAnimationPlayer() const { return m_hasOutdatedAnimationPlaye
r; } |
| 91 | 94 |
| 92 Document* document() { return m_document; } | 95 Document* document() { return m_document; } |
| 93 void detachFromDocument(); | 96 void detachFromDocument(); |
| 94 | 97 |
| 98 void trace(Visitor*); |
| 99 |
| 95 protected: | 100 protected: |
| 96 DocumentTimeline(Document*, PassOwnPtr<PlatformTiming>); | 101 DocumentTimeline(Document*, PassOwnPtrWillBeRawPtr<PlatformTiming>); |
| 97 | 102 |
| 98 private: | 103 private: |
| 99 double m_zeroTime; | 104 double m_zeroTime; |
| 105 // FIXME: oilpan: This should be a Member once the Document is moved to the
heap. |
| 106 // DocumentTimeline should keep the Document alive. |
| 100 Document* m_document; | 107 Document* m_document; |
| 101 // AnimationPlayers which will be updated on the next frame | 108 // AnimationPlayers which will be updated on the next frame |
| 102 // i.e. current, in effect, or had timing changed | 109 // i.e. current, in effect, or had timing changed |
| 103 HashSet<RefPtr<AnimationPlayer> > m_playersNeedingUpdate; | 110 WillBeHeapHashSet<RefPtrWillBeMember<AnimationPlayer> > m_playersNeedingUpda
te; |
| 104 HashSet<AnimationPlayer*> m_players; | 111 WillBeHeapHashSet<RawPtrWillBeWeakMember<AnimationPlayer> > m_players; |
| 105 bool m_hasOutdatedAnimationPlayer; | 112 bool m_hasOutdatedAnimationPlayer; |
| 106 | 113 |
| 107 void wake(); | 114 void wake(); |
| 108 | 115 |
| 109 friend class SMILTimeContainer; | 116 friend class SMILTimeContainer; |
| 110 static const double s_minimumDelay; | 117 static const double s_minimumDelay; |
| 111 | 118 |
| 112 OwnPtr<PlatformTiming> m_timing; | 119 OwnPtrWillBeMember<PlatformTiming> m_timing; |
| 113 | 120 |
| 114 class DocumentTimelineTiming FINAL : public PlatformTiming { | 121 class DocumentTimelineTiming FINAL : public PlatformTiming { |
| 115 public: | 122 public: |
| 116 DocumentTimelineTiming(DocumentTimeline* documentTimeline) | 123 DocumentTimelineTiming(DocumentTimeline* documentTimeline) |
| 117 : m_timeline(documentTimeline) | 124 : m_timeline(documentTimeline) |
| 118 , m_timer(this, &DocumentTimelineTiming::timerFired) | 125 , m_timer(this, &DocumentTimelineTiming::timerFired) |
| 119 { | 126 { |
| 120 ASSERT(m_timeline); | 127 ASSERT(m_timeline); |
| 121 } | 128 } |
| 122 | 129 |
| 123 virtual void wakeAfter(double duration) OVERRIDE; | 130 virtual void wakeAfter(double duration) OVERRIDE; |
| 124 virtual void cancelWake() OVERRIDE; | 131 virtual void cancelWake() OVERRIDE; |
| 125 virtual void serviceOnNextFrame() OVERRIDE; | 132 virtual void serviceOnNextFrame() OVERRIDE; |
| 126 | 133 |
| 127 void timerFired(Timer<DocumentTimelineTiming>*) { m_timeline->wake(); } | 134 void timerFired(Timer<DocumentTimelineTiming>*) { m_timeline->wake(); } |
| 128 | 135 |
| 136 virtual void trace(Visitor*) OVERRIDE; |
| 137 |
| 129 private: | 138 private: |
| 130 DocumentTimeline* m_timeline; | 139 RawPtrWillBeMember<DocumentTimeline> m_timeline; |
| 131 Timer<DocumentTimelineTiming> m_timer; | 140 Timer<DocumentTimelineTiming> m_timer; |
| 132 | |
| 133 }; | 141 }; |
| 134 | 142 |
| 135 friend class AnimationDocumentTimelineTest; | 143 friend class AnimationDocumentTimelineTest; |
| 136 }; | 144 }; |
| 137 | 145 |
| 138 } // namespace | 146 } // namespace |
| 139 | 147 |
| 140 #endif | 148 #endif |
| OLD | NEW |