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

Side by Side Diff: third_party/WebKit/Source/core/page/PageAnimator.cpp

Issue 2003993002: Disallow throttling while running requestAnimationFrame callbacks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/page/PageAnimator.h" 5 #include "core/page/PageAnimator.h"
6 6
7 #include "core/animation/DocumentAnimations.h" 7 #include "core/animation/DocumentAnimations.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "core/page/ChromeClient.h" 10 #include "core/page/ChromeClient.h"
(...skipping 29 matching lines...) Expand all
40 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) { 40 for (Frame* frame = m_page->mainFrame(); frame; frame = frame->tree().traver seNext()) {
41 if (frame->isLocalFrame()) 41 if (frame->isLocalFrame())
42 documents.append(toLocalFrame(frame)->document()); 42 documents.append(toLocalFrame(frame)->document());
43 } 43 }
44 44
45 for (auto& document : documents) { 45 for (auto& document : documents) {
46 DocumentAnimations::updateAnimationTimingForAnimationFrame(*document); 46 DocumentAnimations::updateAnimationTimingForAnimationFrame(*document);
47 if (document->view()) { 47 if (document->view()) {
48 if (document->view()->shouldThrottleRendering()) 48 if (document->view()->shouldThrottleRendering())
49 continue; 49 continue;
50 // Disallow throttling in case any script needs to do a synchronous
51 // lifecycle update in other frames which are throttled.
52 DocumentLifecycle::DisallowThrottlingScope noThrottlingScope(documen t->lifecycle());
50 document->view()->getScrollableArea()->serviceScrollAnimations(monot onicAnimationStartTime); 53 document->view()->getScrollableArea()->serviceScrollAnimations(monot onicAnimationStartTime);
51 54
52 if (const FrameView::ScrollableAreaSet* animatingScrollableAreas = d ocument->view()->animatingScrollableAreas()) { 55 if (const FrameView::ScrollableAreaSet* animatingScrollableAreas = d ocument->view()->animatingScrollableAreas()) {
53 // Iterate over a copy, since ScrollableAreas may deregister 56 // Iterate over a copy, since ScrollableAreas may deregister
54 // themselves during the iteration. 57 // themselves during the iteration.
55 HeapVector<Member<ScrollableArea>> animatingScrollableAreasCopy; 58 HeapVector<Member<ScrollableArea>> animatingScrollableAreasCopy;
56 copyToVector(*animatingScrollableAreas, animatingScrollableAreas Copy); 59 copyToVector(*animatingScrollableAreas, animatingScrollableAreas Copy);
57 for (ScrollableArea* scrollableArea : animatingScrollableAreasCo py) 60 for (ScrollableArea* scrollableArea : animatingScrollableAreasCo py)
58 scrollableArea->serviceScrollAnimations(monotonicAnimationSt artTime); 61 scrollableArea->serviceScrollAnimations(monotonicAnimationSt artTime);
59 } 62 }
60 SVGDocumentExtensions::serviceOnAnimationFrame(*document); 63 SVGDocumentExtensions::serviceOnAnimationFrame(*document);
61 } 64 }
62 // TODO(skyostil): This function should not run for documents without vi ews. 65 // TODO(skyostil): This function should not run for documents without vi ews.
66 DocumentLifecycle::DisallowThrottlingScope noThrottlingScope(document->l ifecycle());
63 document->serviceScriptedAnimations(monotonicAnimationStartTime); 67 document->serviceScriptedAnimations(monotonicAnimationStartTime);
64 } 68 }
65 69
66 // Oilpan: This is performance optimization to promptly clear the backing 70 // Oilpan: This is performance optimization to promptly clear the backing
67 // storage of the vector and reuse it in the next PageAnimator::serviceScrip tedAnimations. 71 // storage of the vector and reuse it in the next PageAnimator::serviceScrip tedAnimations.
68 documents.clear(); 72 documents.clear();
69 } 73 }
70 74
71 void PageAnimator::scheduleVisualUpdate(LocalFrame* frame) 75 void PageAnimator::scheduleVisualUpdate(LocalFrame* frame)
72 { 76 {
73 if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting) 77 if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting)
74 return; 78 return;
75 m_page->chromeClient().scheduleAnimation(frame->view()); 79 m_page->chromeClient().scheduleAnimation(frame->view());
76 } 80 }
77 81
78 void PageAnimator::updateAllLifecyclePhases(LocalFrame& rootFrame) 82 void PageAnimator::updateAllLifecyclePhases(LocalFrame& rootFrame)
79 { 83 {
80 FrameView* view = rootFrame.view(); 84 FrameView* view = rootFrame.view();
81 TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true); 85 TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true);
82 view->updateAllLifecyclePhases(); 86 view->updateAllLifecyclePhases();
83 } 87 }
84 88
85 } // namespace blink 89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentLifecycle.cpp ('k') | third_party/WebKit/Source/web/tests/FrameThrottlingTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698