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

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

Issue 23039013: Web Animations: Fix elpasedTime in animation events (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed elapsedTime for negative delay and added a test Created 7 years, 3 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 20 matching lines...) Expand all
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/PassOwnPtr.h" 35 #include "wtf/PassOwnPtr.h"
36 #include "wtf/RefCounted.h" 36 #include "wtf/RefCounted.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 class Player; 40 class Player;
41 class TimedItem;
41 42
42 static inline bool isNull(double value) 43 static inline bool isNull(double value)
43 { 44 {
44 return std::isnan(value); 45 return std::isnan(value);
45 } 46 }
46 47
47 static inline double nullValue() 48 static inline double nullValue()
48 { 49 {
49 return std::numeric_limits<double>::quiet_NaN(); 50 return std::numeric_limits<double>::quiet_NaN();
50 } 51 }
51 52
52 class TimedItem : public RefCounted<TimedItem> { 53 class TimedItem : public RefCounted<TimedItem> {
53 friend class Player; // Calls attach/detach, updateInheritedTime. 54 friend class Player; // Calls attach/detach, updateInheritedTime.
54 public: 55 public:
55 // Note that logic in CSSAnimations depends on the order of these values. 56 // Note that logic in CSSAnimations depends on the order of these values.
56 enum Phase { 57 enum Phase {
57 PhaseBefore, 58 PhaseBefore,
58 PhaseActive, 59 PhaseActive,
59 PhaseAfter, 60 PhaseAfter,
60 PhaseNone, 61 PhaseNone,
61 }; 62 };
62 63
63 class EventDelegate { 64 class EventDelegate {
64 public: 65 public:
65 virtual ~EventDelegate() { }; 66 virtual ~EventDelegate() { };
66 virtual void onEventCondition(bool isFirstSample, Phase previousPhase, P hase currentPhase, double previousIteration, double currentIteration) = 0; 67 virtual void onEventCondition(const TimedItem*, bool isFirstSample, Phas e previousPhase, double previousIteration) = 0;
67 }; 68 };
68 69
69 virtual ~TimedItem() { } 70 virtual ~TimedItem() { }
70 71
71 Phase phase() const { return ensureCalculated().phase; } 72 Phase phase() const { return ensureCalculated().phase; }
72 bool isCurrent() const { return ensureCalculated().isCurrent; } 73 bool isCurrent() const { return ensureCalculated().isCurrent; }
73 bool isInEffect() const { return ensureCalculated().isInEffect; } 74 bool isInEffect() const { return ensureCalculated().isInEffect; }
74 bool isInPlay() const { return ensureCalculated().isInPlay; } 75 bool isInPlay() const { return ensureCalculated().isInPlay; }
75 76
76 double startTime() const { return m_startTime; } 77 double startTime() const { return m_startTime; }
77 78
78 double currentIteration() const { return ensureCalculated().currentIteration ; } 79 double currentIteration() const { return ensureCalculated().currentIteration ; }
79 double activeDuration() const { return ensureCalculated().activeDuration; } 80 double activeDuration() const { return ensureCalculated().activeDuration; }
80 double timeFraction() const { return ensureCalculated().timeFraction; } 81 double timeFraction() const { return ensureCalculated().timeFraction; }
81 Player* player() const { return m_player; } 82 const Player* player() const { return m_player; }
83
84 const Timing& specified() const { return m_specified; }
82 85
83 protected: 86 protected:
84 TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr); 87 TimedItem(const Timing&, PassOwnPtr<EventDelegate> = nullptr);
85 88
86 // When TimedItem receives a new inherited time via updateInheritedTime 89 // When TimedItem receives a new inherited time via updateInheritedTime
87 // it will (if necessary) recalculate timings and (if necessary) call 90 // it will (if necessary) recalculate timings and (if necessary) call
88 // updateChildrenAndEffects. 91 // updateChildrenAndEffects.
89 void updateInheritedTime(double inheritedTime) const; 92 void updateInheritedTime(double inheritedTime) const;
90 virtual void updateChildrenAndEffects(bool wasInEffect) const = 0; 93 virtual void updateChildrenAndEffects(bool wasInEffect) const = 0;
91 virtual double intrinsicIterationDuration() const { return 0; }; 94 virtual double intrinsicIterationDuration() const { return 0; };
(...skipping 27 matching lines...) Expand all
119 } m_calculated; 122 } m_calculated;
120 mutable bool m_isFirstSample; 123 mutable bool m_isFirstSample;
121 124
122 // FIXME: Should check the version and reinherit time if inconsistent. 125 // FIXME: Should check the version and reinherit time if inconsistent.
123 const CalculatedTiming& ensureCalculated() const { return m_calculated; } 126 const CalculatedTiming& ensureCalculated() const { return m_calculated; }
124 }; 127 };
125 128
126 } // namespace WebCore 129 } // namespace WebCore
127 130
128 #endif 131 #endif
OLDNEW
« no previous file with comments | « LayoutTests/animations/negative-delay-events-expected.txt ('k') | Source/core/animation/TimedItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698