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

Side by Side Diff: Source/core/animation/TimedItem.h

Issue 19266007: Web Animations: Introduce ActiveAnimations and AnimationStack (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
29 */ 29 */
30 30
31 #ifndef TimedItem_h 31 #ifndef TimedItem_h
32 #define TimedItem_h 32 #define TimedItem_h
33 33
34 #include "core/animation/Timing.h" 34 #include "core/animation/Timing.h"
35 #include "wtf/RefCounted.h" 35 #include "wtf/RefCounted.h"
36 36
37 namespace WebCore { 37 namespace WebCore {
38 38
39 class Player;
40
39 static inline bool isNull(double value) 41 static inline bool isNull(double value)
40 { 42 {
41 return std::isnan(value); 43 return std::isnan(value);
42 } 44 }
43 45
44 static inline double nullValue() 46 static inline double nullValue()
45 { 47 {
46 return std::numeric_limits<double>::quiet_NaN(); 48 return std::numeric_limits<double>::quiet_NaN();
47 } 49 }
48 50
49 class TimedItem : public RefCounted<TimedItem> { 51 class TimedItem : public RefCounted<TimedItem> {
52 friend class Player; // calls attach/detach
50 public: 53 public:
51 virtual ~TimedItem() { } 54 virtual ~TimedItem() { }
52 55
53 bool isScheduled() const { return ensureCalculated().isScheduled; } 56 bool isScheduled() const { return ensureCalculated().isScheduled; }
54 bool isActive() const { return ensureCalculated().isActive; } 57 bool isActive() const { return ensureCalculated().isActive; }
55 bool isCurrent() const { return ensureCalculated().isCurrent; } 58 bool isCurrent() const { return ensureCalculated().isCurrent; }
56 bool isInEffect() const { return ensureCalculated().isInEffect; } 59 bool isInEffect() const { return ensureCalculated().isInEffect; }
57 60
58 double startTime() const { return m_startTime; } 61 double startTime() const { return m_startTime; }
59 62
60 double currentIteration() const { return ensureCalculated().currentIteration ; } 63 double currentIteration() const { return ensureCalculated().currentIteration ; }
61 double activeDuration() const { return ensureCalculated().activeDuration; } 64 double activeDuration() const { return ensureCalculated().activeDuration; }
62 double timeFraction() const { return ensureCalculated().timeFraction; } 65 double timeFraction() const { return ensureCalculated().timeFraction; }
66 Player* player() const { return m_player; }
63 67
64 protected: 68 protected:
65 TimedItem(const Timing&); 69 TimedItem(const Timing&);
66 70
67 // When TimedItem receives a new inherited time via updateInheritedTime 71 // When TimedItem receives a new inherited time via updateInheritedTime
68 // it will (if necessary) recalculate timings and (if necessary) call 72 // it will (if necessary) recalculate timings and (if necessary) call
69 // updateChildrenAndEffects. 73 // updateChildrenAndEffects.
70 void updateInheritedTime(double inheritedTime) const; 74 void updateInheritedTime(double inheritedTime) const;
71 virtual void updateChildrenAndEffects(bool wasActiveOrInEffect) const = 0; 75 virtual void updateChildrenAndEffects(bool wasActiveOrInEffect) const = 0;
72 virtual double intrinsicIterationDuration() const { return 0; }; 76 virtual double intrinsicIterationDuration() const { return 0; };
77 virtual void willDetach() { };
esprehn 2013/07/17 06:48:01 = 0; or you plan to have ones that do nothing?
dstockwell 2013/07/17 13:10:19 Done.
73 78
74 friend class Player; // Calls updateInheritedTime. 79 friend class Player; // Calls updateInheritedTime.
75 80
76 private: 81 private:
82 void attach(Player* player) { m_player = player; };
83 void detach(Player* player)
84 {
85 ASSERT(m_player == player);
esprehn 2013/07/17 06:48:01 This is really weird, why store it in here if you
dstockwell 2013/07/17 13:10:19 Done.
86 willDetach();
87 m_player = 0;
88 };
89
77 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g roups. 90 // FIXME: m_parent and m_startTime are placeholders, they depend on timing g roups.
78 TimedItem* const m_parent; 91 TimedItem* const m_parent;
79 const double m_startTime; 92 const double m_startTime;
80 93 Player* m_player;
81 Timing m_specified; 94 Timing m_specified;
82 95
83 // FIXME: Should be versioned by monotonic value on player. 96 // FIXME: Should be versioned by monotonic value on player.
84 mutable struct CalculatedTiming { 97 mutable struct CalculatedTiming {
85 CalculatedTiming(); 98 CalculatedTiming();
86 double activeDuration; 99 double activeDuration;
87 double currentIteration; 100 double currentIteration;
88 double timeFraction; 101 double timeFraction;
89 bool isScheduled; 102 bool isScheduled;
90 bool isActive; 103 bool isActive;
91 bool isCurrent; 104 bool isCurrent;
92 bool isInEffect; 105 bool isInEffect;
93 } m_calculated; 106 } m_calculated;
94 107
95 // FIXME: Should check the version and reinherit time if inconsistent. 108 // FIXME: Should check the version and reinherit time if inconsistent.
96 const CalculatedTiming& ensureCalculated() const { return m_calculated; } 109 const CalculatedTiming& ensureCalculated() const { return m_calculated; }
97 }; 110 };
98 111
99 } // namespace WebCore 112 } // namespace WebCore
100 113
101 #endif 114 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698