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