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

Side by Side Diff: Source/core/dom/ScriptedAnimationController.cpp

Issue 1093803002: ScriptedAnimationController: factor out has-schedulable items predicate. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « Source/core/dom/ScriptedAnimationController.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All Rights Reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void ScriptedAnimationController::callMediaQueryListListeners() 144 void ScriptedAnimationController::callMediaQueryListListeners()
145 { 145 {
146 MediaQueryListListeners listeners; 146 MediaQueryListListeners listeners;
147 listeners.swap(m_mediaQueryListListeners); 147 listeners.swap(m_mediaQueryListListeners);
148 148
149 for (const auto& listener : listeners) { 149 for (const auto& listener : listeners) {
150 listener->notifyMediaQueryChanged(); 150 listener->notifyMediaQueryChanged();
151 } 151 }
152 } 152 }
153 153
154 bool ScriptedAnimationController::hasScheduledItems() const
155 {
156 if (m_suspendCount)
157 return false;
158
159 return !m_callbackCollection.isEmpty() || !m_eventQueue.isEmpty() || !m_medi aQueryListListeners.isEmpty();
160 }
161
154 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime Now) 162 void ScriptedAnimationController::serviceScriptedAnimations(double monotonicTime Now)
155 { 163 {
156 if (m_callbackCollection.isEmpty() && !m_eventQueue.size() && !m_mediaQueryL istListeners.size()) 164 if (!hasScheduledItems())
157 return;
158
159 if (m_suspendCount)
160 return; 165 return;
161 166
162 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this); 167 RefPtrWillBeRawPtr<ScriptedAnimationController> protect(this);
163 168
164 callMediaQueryListListeners(); 169 callMediaQueryListListeners();
165 dispatchEvents(); 170 dispatchEvents();
166 executeCallbacks(monotonicTimeNow); 171 executeCallbacks(monotonicTimeNow);
167 172
168 scheduleAnimationIfNeeded(); 173 scheduleAnimationIfNeeded();
169 } 174 }
(...skipping 15 matching lines...) Expand all
185 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec tor<RefPtrWillBeMember<MediaQueryListListener>>& listeners) 190 void ScriptedAnimationController::enqueueMediaQueryChangeListeners(WillBeHeapVec tor<RefPtrWillBeMember<MediaQueryListListener>>& listeners)
186 { 191 {
187 for (size_t i = 0; i < listeners.size(); ++i) { 192 for (size_t i = 0; i < listeners.size(); ++i) {
188 m_mediaQueryListListeners.add(listeners[i]); 193 m_mediaQueryListListeners.add(listeners[i]);
189 } 194 }
190 scheduleAnimationIfNeeded(); 195 scheduleAnimationIfNeeded();
191 } 196 }
192 197
193 void ScriptedAnimationController::scheduleAnimationIfNeeded() 198 void ScriptedAnimationController::scheduleAnimationIfNeeded()
194 { 199 {
200 if (!hasScheduledItems())
201 return;
202
195 if (!m_document) 203 if (!m_document)
196 return; 204 return;
197 205
198 if (m_suspendCount)
199 return;
200
201 if (m_callbackCollection.isEmpty() && !m_eventQueue.size() && !m_mediaQueryL istListeners.size())
202 return;
203
204 if (FrameView* frameView = m_document->view()) 206 if (FrameView* frameView = m_document->view())
205 frameView->scheduleAnimation(); 207 frameView->scheduleAnimation();
206 } 208 }
207 209
208 } 210 }
OLDNEW
« no previous file with comments | « Source/core/dom/ScriptedAnimationController.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698