OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/scrolling/TopDocumentRootScrollerController.h" | 5 #include "core/page/scrolling/TopDocumentRootScrollerController.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/Element.h" | 8 #include "core/dom/Element.h" |
9 #include "core/frame/FrameHost.h" | 9 #include "core/frame/FrameHost.h" |
10 #include "core/frame/FrameView.h" | 10 #include "core/frame/FrameView.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 // A change in global root scroller requires a compositing inputs update to | 88 // A change in global root scroller requires a compositing inputs update to |
89 // the new and old global root scroller since it might change how the | 89 // the new and old global root scroller since it might change how the |
90 // ancestor layers are clipped. e.g. An iframe that's the global root | 90 // ancestor layers are clipped. e.g. An iframe that's the global root |
91 // scroller clips its layers like the root frame. Normally this is set | 91 // scroller clips its layers like the root frame. Normally this is set |
92 // when the local effective root scroller changes but the global root | 92 // when the local effective root scroller changes but the global root |
93 // scroller can change because the parent's effective root scroller | 93 // scroller can change because the parent's effective root scroller |
94 // changes. | 94 // changes. |
95 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | 95 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); |
96 | 96 |
| 97 ScrollableArea* oldRootScrollerArea = |
| 98 m_globalRootScroller |
| 99 ? RootScrollerUtil::scrollableAreaFor(*m_globalRootScroller.get()) |
| 100 : nullptr; |
| 101 |
97 m_globalRootScroller = target; | 102 m_globalRootScroller = target; |
98 | 103 |
99 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | 104 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); |
100 | 105 |
101 // Ideally, scroll customization would pass the current element to scroll to | 106 // Ideally, scroll customization would pass the current element to scroll to |
102 // the apply scroll callback but this doesn't happen today so we set it | 107 // the apply scroll callback but this doesn't happen today so we set it |
103 // through a back door here. This is also needed by the | 108 // through a back door here. This is also needed by the |
104 // ViewportScrollCallback to swap the target into the layout viewport | 109 // ViewportScrollCallback to swap the target into the layout viewport |
105 // in RootFrameViewport. | 110 // in RootFrameViewport. |
106 m_viewportApplyScroll->setScroller(targetScroller); | 111 m_viewportApplyScroll->setScroller(targetScroller); |
| 112 |
| 113 // The scrollers may need to stop using their own scrollbars as Android |
| 114 // Chrome's VisualViewport provides the scrollbars for the root scroller. |
| 115 if (oldRootScrollerArea) |
| 116 oldRootScrollerArea->didChangeGlobalRootScroller(); |
| 117 |
| 118 targetScroller->didChangeGlobalRootScroller(); |
107 } | 119 } |
108 | 120 |
109 Document* TopDocumentRootScrollerController::topDocument() const { | 121 Document* TopDocumentRootScrollerController::topDocument() const { |
110 if (!m_frameHost) | 122 if (!m_frameHost) |
111 return nullptr; | 123 return nullptr; |
112 | 124 |
113 if (!m_frameHost->page().mainFrame() || | 125 if (!m_frameHost->page().mainFrame() || |
114 !m_frameHost->page().mainFrame()->isLocalFrame()) | 126 !m_frameHost->page().mainFrame()->isLocalFrame()) |
115 return nullptr; | 127 return nullptr; |
116 | 128 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // the root scroller gets composited. | 189 // the root scroller gets composited. |
178 | 190 |
179 return graphicsLayer; | 191 return graphicsLayer; |
180 } | 192 } |
181 | 193 |
182 Element* TopDocumentRootScrollerController::globalRootScroller() const { | 194 Element* TopDocumentRootScrollerController::globalRootScroller() const { |
183 return m_globalRootScroller.get(); | 195 return m_globalRootScroller.get(); |
184 } | 196 } |
185 | 197 |
186 } // namespace blink | 198 } // namespace blink |
OLD | NEW |