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

Side by Side Diff: Source/core/animation/DocumentTimeline.cpp

Issue 30813004: Revert r160071 "Web Animations: Implement AnimationClock and fix start time of animations" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/animation/DocumentTimeline.h" 32 #include "core/animation/DocumentTimeline.h"
33 33
34 #include "core/animation/AnimationClock.h"
35 #include "core/animation/Player.h" 34 #include "core/animation/Player.h"
36 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
37 #include "core/frame/FrameView.h" 36 #include "core/frame/FrameView.h"
38 37
39 namespace WebCore { 38 namespace WebCore {
40 39
41 PassRefPtr<DocumentTimeline> DocumentTimeline::create(Document* document) 40 PassRefPtr<DocumentTimeline> DocumentTimeline::create(Document* document)
42 { 41 {
43 return adoptRef(new DocumentTimeline(document)); 42 return adoptRef(new DocumentTimeline(document));
44 } 43 }
45 44
46 DocumentTimeline::DocumentTimeline(Document* document) 45 DocumentTimeline::DocumentTimeline(Document* document)
47 : m_document(document) 46 : m_currentTime(nullValue())
47 , m_document(document)
48 , m_zeroTimeAsPerfTime(nullValue()) 48 , m_zeroTimeAsPerfTime(nullValue())
49 { 49 {
50 ASSERT(document); 50 ASSERT(document);
51 } 51 }
52 52
53 PassRefPtr<Player> DocumentTimeline::play(TimedItem* child) 53 PassRefPtr<Player> DocumentTimeline::play(TimedItem* child)
54 { 54 {
55 RefPtr<Player> player = Player::create(this, child); 55 RefPtr<Player> player = Player::create(this, child);
56 m_players.append(player); 56 m_players.append(player);
57 57
58 if (m_document->view()) 58 if (m_document->view())
59 m_document->view()->scheduleAnimation(); 59 m_document->view()->scheduleAnimation();
60 60
61 return player.release(); 61 return player.release();
62 } 62 }
63 63
64 void DocumentTimeline::serviceAnimations(double monotonicAnimationStartTime) 64 void DocumentTimeline::serviceAnimations(double monotonicAnimationStartTime)
65 { 65 {
66 { 66 {
67 TRACE_EVENT0("webkit", "DocumentTimeline::serviceAnimations"); 67 TRACE_EVENT0("webkit", "DocumentTimeline::serviceAnimations");
68 68 // FIXME: The below ASSERT fires on Windows when running chrome.exe.
69 m_document->animationClock().updateTime(monotonicAnimationStartTime); 69 // Does not fire with --single-process, or on Linux, or in
70 // content_shell.exe. The assert condition has been moved up into the
71 // outer 'if' to work around this. http://crbug.com/280439.
72 if (!isNull(m_zeroTimeAsPerfTime) && (m_currentTime <= monotonicAnimatio nStartTime - m_zeroTimeAsPerfTime)) {
73 ASSERT(m_currentTime <= monotonicAnimationStartTime - m_zeroTimeAsPe rfTime);
74 m_currentTime = monotonicAnimationStartTime - m_zeroTimeAsPerfTime;
75 }
70 76
71 double timeToNextEffect = -1; 77 double timeToNextEffect = -1;
72 for (int i = m_players.size() - 1; i >= 0; --i) { 78 for (int i = m_players.size() - 1; i >= 0; --i) {
73 if (!m_players[i]->update(&timeToNextEffect)) 79 if (!m_players[i]->update(&timeToNextEffect))
74 m_players.remove(i); 80 m_players.remove(i);
75 } 81 }
76 82
77 if (m_document->view() && !m_players.isEmpty()) 83 if (m_document->view() && !m_players.isEmpty())
78 m_document->view()->scheduleAnimation(); 84 m_document->view()->scheduleAnimation();
79 } 85 }
80 86
81 dispatchEvents(); 87 dispatchEvents();
82 } 88 }
83 89
84 void DocumentTimeline::setZeroTimeAsPerfTime(double zeroTime) 90 void DocumentTimeline::setZeroTimeAsPerfTime(double zeroTime)
85 { 91 {
86 ASSERT(isNull(m_zeroTimeAsPerfTime)); 92 ASSERT(isNull(m_zeroTimeAsPerfTime));
87 m_zeroTimeAsPerfTime = zeroTime; 93 m_zeroTimeAsPerfTime = zeroTime;
88 ASSERT(!isNull(m_zeroTimeAsPerfTime)); 94 ASSERT(!isNull(m_zeroTimeAsPerfTime));
89 } 95 m_currentTime = 0;
90
91 double DocumentTimeline::currentTime()
92 {
93 return m_document->animationClock().currentTime() - m_zeroTimeAsPerfTime;
94 } 96 }
95 97
96 void DocumentTimeline::pauseAnimationsForTesting(double pauseTime) 98 void DocumentTimeline::pauseAnimationsForTesting(double pauseTime)
97 { 99 {
98 for (size_t i = 0; i < m_players.size(); i++) { 100 for (size_t i = 0; i < m_players.size(); i++) {
99 m_players[i]->setPaused(true); 101 m_players[i]->setPaused(true);
100 m_players[i]->setCurrentTime(pauseTime); 102 m_players[i]->setCurrentTime(pauseTime);
101 } 103 }
102 } 104 }
103 105
104 void DocumentTimeline::dispatchEvents() 106 void DocumentTimeline::dispatchEvents()
105 { 107 {
106 Vector<EventToDispatch> events = m_events; 108 Vector<EventToDispatch> events = m_events;
107 m_events.clear(); 109 m_events.clear();
108 for (size_t i = 0; i < events.size(); i++) 110 for (size_t i = 0; i < events.size(); i++)
109 events[i].target->dispatchEvent(events[i].event.release()); 111 events[i].target->dispatchEvent(events[i].event.release());
110 } 112 }
111 113
112 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const 114 size_t DocumentTimeline::numberOfActiveAnimationsForTesting() const
113 { 115 {
114 // Includes all players whose directly associated timed items 116 // Includes all players whose directly associated timed items
115 // are current or in effect. 117 // are current or in effect.
116 return isNull(m_zeroTimeAsPerfTime) ? 0 : m_players.size(); 118 return isNull(m_currentTime) ? 0 : m_players.size();
117 } 119 }
118 120
119 } // namespace 121 } // namespace
OLDNEW
« no previous file with comments | « Source/core/animation/DocumentTimeline.h ('k') | Source/core/animation/DocumentTimelineTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698