| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "sky/engine/core/page/PageAnimator.h" | |
| 6 | |
| 7 #include "sky/engine/core/animation/DocumentAnimations.h" | |
| 8 #include "sky/engine/core/dom/Document.h" | |
| 9 #include "sky/engine/core/frame/FrameView.h" | |
| 10 #include "sky/engine/core/frame/LocalFrame.h" | |
| 11 #include "sky/engine/core/page/ChromeClient.h" | |
| 12 #include "sky/engine/core/page/Page.h" | |
| 13 #include "sky/engine/core/painting/PaintingTasks.h" | |
| 14 #include "sky/engine/platform/Logging.h" | |
| 15 | |
| 16 namespace blink { | |
| 17 | |
| 18 PageAnimator::PageAnimator(Page* page) | |
| 19 : m_page(page) | |
| 20 , m_servicingAnimations(false) | |
| 21 , m_updatingLayoutAndStyleForPainting(false) | |
| 22 { | |
| 23 } | |
| 24 | |
| 25 void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime) | |
| 26 { | |
| 27 TemporaryChange<bool> servicing(m_servicingAnimations, true); | |
| 28 | |
| 29 RefPtr<Document> document = m_page->mainFrame()->document(); | |
| 30 | |
| 31 DocumentAnimations::updateAnimationTimingForAnimationFrame(*document, monoto
nicAnimationStartTime); | |
| 32 document->serviceScriptedAnimations(monotonicAnimationStartTime); | |
| 33 } | |
| 34 | |
| 35 void PageAnimator::scheduleVisualUpdate() | |
| 36 { | |
| 37 if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting) | |
| 38 return; | |
| 39 m_page->scheduleVisualUpdate(); | |
| 40 } | |
| 41 | |
| 42 void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame) | |
| 43 { | |
| 44 RefPtr<FrameView> view = rootFrame->view(); | |
| 45 | |
| 46 TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true); | |
| 47 | |
| 48 view->setFrameRect(view->frameRect()); | |
| 49 view->updateLayoutAndStyleForPainting(); | |
| 50 | |
| 51 // TODO(abarth): Remove these calls to updateLayoutAndStyleForPainting | |
| 52 // once requestPaint callbacks can't dirty layout. | |
| 53 while (PaintingTasks::serviceRequests()) | |
| 54 view->updateLayoutAndStyleForPainting(); | |
| 55 | |
| 56 PaintingTasks::drainCommits(); | |
| 57 | |
| 58 ASSERT(m_page->mainFrame()->document()->lifecycle().state() == DocumentLifec
ycle::StyleAndLayoutClean); | |
| 59 } | |
| 60 | |
| 61 } | |
| OLD | NEW |