| OLD | NEW |
| 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 "sky/engine/config.h" | 5 #include "sky/engine/config.h" |
| 6 #include "sky/engine/core/page/PageAnimator.h" | 6 #include "sky/engine/core/page/PageAnimator.h" |
| 7 | 7 |
| 8 #include "sky/engine/core/animation/DocumentAnimations.h" | 8 #include "sky/engine/core/animation/DocumentAnimations.h" |
| 9 #include "sky/engine/core/frame/FrameView.h" | 9 #include "sky/engine/core/frame/FrameView.h" |
| 10 #include "sky/engine/core/frame/LocalFrame.h" | 10 #include "sky/engine/core/frame/LocalFrame.h" |
| 11 #include "sky/engine/core/page/Chrome.h" | 11 #include "sky/engine/core/page/Chrome.h" |
| 12 #include "sky/engine/core/page/ChromeClient.h" | 12 #include "sky/engine/core/page/ChromeClient.h" |
| 13 #include "sky/engine/core/page/Page.h" | 13 #include "sky/engine/core/page/Page.h" |
| 14 #include "sky/engine/platform/Logging.h" | 14 #include "sky/engine/platform/Logging.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 PageAnimator::PageAnimator(Page* page) | 18 PageAnimator::PageAnimator(Page* page) |
| 19 : m_page(page) | 19 : m_page(page) |
| 20 , m_animationFramePending(false) | |
| 21 , m_servicingAnimations(false) | 20 , m_servicingAnimations(false) |
| 22 , m_updatingLayoutAndStyleForPainting(false) | 21 , m_updatingLayoutAndStyleForPainting(false) |
| 23 { | 22 { |
| 24 } | 23 } |
| 25 | 24 |
| 26 void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime) | 25 void PageAnimator::serviceScriptedAnimations(double monotonicAnimationStartTime) |
| 27 { | 26 { |
| 28 m_animationFramePending = false; | |
| 29 TemporaryChange<bool> servicing(m_servicingAnimations, true); | 27 TemporaryChange<bool> servicing(m_servicingAnimations, true); |
| 30 | 28 |
| 31 Vector<RefPtr<Document> > documents; | 29 Vector<RefPtr<Document> > documents; |
| 32 documents.append(m_page->mainFrame()->document()); | 30 documents.append(m_page->mainFrame()->document()); |
| 33 | 31 |
| 34 WTF_LOG(ScriptedAnimationController, "PageAnimator::serviceScriptedAnimation
s: #documents = %d", | 32 WTF_LOG(ScriptedAnimationController, "PageAnimator::serviceScriptedAnimation
s: #documents = %d", |
| 35 static_cast<int>(documents.size())); | 33 static_cast<int>(documents.size())); |
| 36 | 34 |
| 37 for (size_t i = 0; i < documents.size(); ++i) | 35 for (size_t i = 0; i < documents.size(); ++i) |
| 38 DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i]
, monotonicAnimationStartTime); | 36 DocumentAnimations::updateAnimationTimingForAnimationFrame(*documents[i]
, monotonicAnimationStartTime); |
| 39 | 37 |
| 40 for (size_t i = 0; i < documents.size(); ++i) | 38 for (size_t i = 0; i < documents.size(); ++i) |
| 41 documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); | 39 documents[i]->serviceScriptedAnimations(monotonicAnimationStartTime); |
| 42 } | 40 } |
| 43 | 41 |
| 44 void PageAnimator::scheduleVisualUpdate() | 42 void PageAnimator::scheduleVisualUpdate() |
| 45 { | 43 { |
| 46 // FIXME: also include m_animationFramePending here. It is currently not the
re due to crbug.com/353756. | |
| 47 if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting) | 44 if (m_servicingAnimations || m_updatingLayoutAndStyleForPainting) |
| 48 return; | 45 return; |
| 49 m_page->chrome().scheduleAnimation(); | 46 m_page->chrome().scheduleVisualUpdate(); |
| 50 } | 47 } |
| 51 | 48 |
| 52 void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame) | 49 void PageAnimator::updateLayoutAndStyleForPainting(LocalFrame* rootFrame) |
| 53 { | 50 { |
| 54 RefPtr<FrameView> view = rootFrame->view(); | 51 RefPtr<FrameView> view = rootFrame->view(); |
| 55 | 52 |
| 56 TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true); | 53 TemporaryChange<bool> servicing(m_updatingLayoutAndStyleForPainting, true); |
| 57 | 54 |
| 58 // In order for our child HWNDs (NativeWindowWidgets) to update properly, | 55 // In order for our child HWNDs (NativeWindowWidgets) to update properly, |
| 59 // they need to be told that we are updating the screen. The problem is that | 56 // they need to be told that we are updating the screen. The problem is that |
| 60 // the native widgets need to recalculate their clip region and not overlap | 57 // the native widgets need to recalculate their clip region and not overlap |
| 61 // any of our non-native widgets. To force the resizing, call | 58 // any of our non-native widgets. To force the resizing, call |
| 62 // setFrameRect(). This will be a quick operation for most frames, but the | 59 // setFrameRect(). This will be a quick operation for most frames, but the |
| 63 // NativeWindowWidgets will update a proper clipping region. | 60 // NativeWindowWidgets will update a proper clipping region. |
| 64 view->setFrameRect(view->frameRect()); | 61 view->setFrameRect(view->frameRect()); |
| 65 | 62 |
| 66 // setFrameRect may have the side-effect of causing existing page layout to | 63 // setFrameRect may have the side-effect of causing existing page layout to |
| 67 // be invalidated, so layout needs to be called last. | 64 // be invalidated, so layout needs to be called last. |
| 68 view->updateLayoutAndStyleForPainting(); | 65 view->updateLayoutAndStyleForPainting(); |
| 69 } | 66 } |
| 70 | 67 |
| 71 } | 68 } |
| OLD | NEW |