| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 if (m_globalRootScroller) | 127 if (m_globalRootScroller) |
| 128 m_globalRootScroller->removeApplyScroll(); | 128 m_globalRootScroller->removeApplyScroll(); |
| 129 | 129 |
| 130 // Use disable-native-scroll since the ViewportScrollCallback needs to | 130 // Use disable-native-scroll since the ViewportScrollCallback needs to |
| 131 // apply scroll actions both before (BrowserControls) and after (overscroll) | 131 // apply scroll actions both before (BrowserControls) and after (overscroll) |
| 132 // scrolling the element so it will apply scroll to the element itself. | 132 // scrolling the element so it will apply scroll to the element itself. |
| 133 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll"); | 133 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll"); |
| 134 | 134 |
| 135 // A change in global root scroller requires a compositing inputs update to | |
| 136 // the new and old global root scroller since it might change how the | |
| 137 // ancestor layers are clipped. e.g. An iframe that's the global root | |
| 138 // scroller clips its layers like the root frame. Normally this is set | |
| 139 // when the local effective root scroller changes but the global root | |
| 140 // scroller can change because the parent's effective root scroller | |
| 141 // changes. | |
| 142 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | |
| 143 | |
| 144 ScrollableArea* oldRootScrollerArea = | 135 ScrollableArea* oldRootScrollerArea = |
| 145 RootScrollerUtil::scrollableAreaForRootScroller(m_globalRootScroller); | 136 RootScrollerUtil::scrollableAreaForRootScroller(m_globalRootScroller); |
| 146 | 137 |
| 147 m_globalRootScroller = target; | 138 m_globalRootScroller = target; |
| 148 | 139 |
| 149 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | |
| 150 | |
| 151 // Ideally, scroll customization would pass the current element to scroll to | 140 // Ideally, scroll customization would pass the current element to scroll to |
| 152 // the apply scroll callback but this doesn't happen today so we set it | 141 // the apply scroll callback but this doesn't happen today so we set it |
| 153 // through a back door here. This is also needed by the | 142 // through a back door here. This is also needed by the |
| 154 // ViewportScrollCallback to swap the target into the layout viewport | 143 // ViewportScrollCallback to swap the target into the layout viewport |
| 155 // in RootFrameViewport. | 144 // in RootFrameViewport. |
| 156 m_viewportApplyScroll->setScroller(targetScroller); | 145 m_viewportApplyScroll->setScroller(targetScroller); |
| 157 | 146 |
| 158 // The scrollers may need to stop using their own scrollbars as Android | 147 // The scrollers may need to stop using their own scrollbars as Android |
| 159 // Chrome's VisualViewport provides the scrollbars for the root scroller. | 148 // Chrome's VisualViewport provides the scrollbars for the root scroller. |
| 160 if (oldRootScrollerArea) | 149 if (oldRootScrollerArea) |
| 161 oldRootScrollerArea->didChangeGlobalRootScroller(); | 150 oldRootScrollerArea->didChangeGlobalRootScroller(); |
| 162 | 151 |
| 163 targetScroller->didChangeGlobalRootScroller(); | 152 targetScroller->didChangeGlobalRootScroller(); |
| 164 } | 153 } |
| 165 | 154 |
| 166 Document* TopDocumentRootScrollerController::topDocument() const { | 155 Document* TopDocumentRootScrollerController::topDocument() const { |
| 167 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame()) | 156 if (!m_page || !m_page->mainFrame() || !m_page->mainFrame()->isLocalFrame()) |
| 168 return nullptr; | 157 return nullptr; |
| 169 | 158 |
| 170 return toLocalFrame(m_page->mainFrame())->document(); | 159 return toLocalFrame(m_page->mainFrame())->document(); |
| 171 } | 160 } |
| 172 | 161 |
| 173 void TopDocumentRootScrollerController:: | |
| 174 setNeedsCompositingInputsUpdateOnGlobalRootScroller() { | |
| 175 if (!m_globalRootScroller) | |
| 176 return; | |
| 177 | |
| 178 PaintLayer* layer = m_globalRootScroller->document() | |
| 179 .rootScrollerController() | |
| 180 .rootScrollerPaintLayer(); | |
| 181 | |
| 182 if (layer) | |
| 183 layer->setNeedsCompositingInputsUpdate(); | |
| 184 | |
| 185 if (LayoutView* view = m_globalRootScroller->document().layoutView()) { | |
| 186 view->compositor()->setNeedsCompositingUpdate(CompositingUpdateRebuildTree); | |
| 187 } | |
| 188 } | |
| 189 | |
| 190 void TopDocumentRootScrollerController::didUpdateCompositing() { | 162 void TopDocumentRootScrollerController::didUpdateCompositing() { |
| 191 if (!m_page) | 163 if (!m_page) |
| 192 return; | 164 return; |
| 193 | 165 |
| 194 // Let the compositor-side counterpart know about this change. | 166 // Let the compositor-side counterpart know about this change. |
| 195 m_page->chromeClient().registerViewportLayers(); | 167 m_page->chromeClient().registerViewportLayers(); |
| 196 } | 168 } |
| 197 | 169 |
| 198 void TopDocumentRootScrollerController::didDisposeScrollableArea( | 170 void TopDocumentRootScrollerController::didDisposeScrollableArea( |
| 199 ScrollableArea& area) { | 171 ScrollableArea& area) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 223 |
| 252 PaintLayer* TopDocumentRootScrollerController::rootScrollerPaintLayer() const { | 224 PaintLayer* TopDocumentRootScrollerController::rootScrollerPaintLayer() const { |
| 253 return RootScrollerUtil::paintLayerForRootScroller(m_globalRootScroller); | 225 return RootScrollerUtil::paintLayerForRootScroller(m_globalRootScroller); |
| 254 } | 226 } |
| 255 | 227 |
| 256 Element* TopDocumentRootScrollerController::globalRootScroller() const { | 228 Element* TopDocumentRootScrollerController::globalRootScroller() const { |
| 257 return m_globalRootScroller.get(); | 229 return m_globalRootScroller.get(); |
| 258 } | 230 } |
| 259 | 231 |
| 260 } // namespace blink | 232 } // namespace blink |
| OLD | NEW |