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/RootScrollerController.h" | 5 #include "core/page/scrolling/RootScrollerController.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" |
11 #include "core/frame/TopControls.h" | 11 #include "core/frame/TopControls.h" |
| 12 #include "core/frame/VisualViewport.h" |
12 #include "core/layout/LayoutBox.h" | 13 #include "core/layout/LayoutBox.h" |
| 14 #include "core/page/ChromeClient.h" |
13 #include "core/page/Page.h" | 15 #include "core/page/Page.h" |
14 #include "core/page/scrolling/OverscrollController.h" | 16 #include "core/page/scrolling/OverscrollController.h" |
15 #include "core/page/scrolling/ViewportScrollCallback.h" | 17 #include "core/page/scrolling/ViewportScrollCallback.h" |
16 #include "core/paint/PaintLayerScrollableArea.h" | 18 #include "core/paint/PaintLayerScrollableArea.h" |
| 19 #include "platform/graphics/GraphicsLayer.h" |
17 #include "platform/scroll/ScrollableArea.h" | 20 #include "platform/scroll/ScrollableArea.h" |
18 | 21 |
19 namespace blink { | 22 namespace blink { |
20 | 23 |
21 namespace { | 24 namespace { |
22 | 25 |
23 ScrollableArea* scrollableAreaFor(const Element& element) | 26 ScrollableArea* scrollableAreaFor(const Element& element) |
24 { | 27 { |
25 if (!element.layoutObject() || !element.layoutObject()->isBox()) | 28 if (!element.layoutObject() || !element.layoutObject()->isBox()) |
26 return nullptr; | 29 return nullptr; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // Ideally, scroll customization would pass the current element to scroll to | 156 // Ideally, scroll customization would pass the current element to scroll to |
154 // the apply scroll callback but this doesn't happen today so we set it | 157 // the apply scroll callback but this doesn't happen today so we set it |
155 // through a back door here. This is also needed by the | 158 // through a back door here. This is also needed by the |
156 // RootViewportScrollCallback to swap the target into the layout viewport | 159 // RootViewportScrollCallback to swap the target into the layout viewport |
157 // in RootFrameViewport. | 160 // in RootFrameViewport. |
158 m_viewportApplyScroll->setScroller(targetScroller); | 161 m_viewportApplyScroll->setScroller(targetScroller); |
159 | 162 |
160 return true; | 163 return true; |
161 } | 164 } |
162 | 165 |
| 166 void RootScrollerController::didUpdateCompositing() |
| 167 { |
| 168 FrameHost& frameHost = *m_document->frameHost(); |
| 169 |
| 170 // Let the compositor-side counterpart know about this change. |
| 171 if (m_document->isInMainFrame()) |
| 172 frameHost.chromeClient().registerViewportLayers(); |
| 173 } |
| 174 |
| 175 GraphicsLayer* RootScrollerController::rootScrollerLayer() |
| 176 { |
| 177 if (!m_effectiveRootScroller) |
| 178 return nullptr; |
| 179 |
| 180 ScrollableArea* area = scrollableAreaFor(*m_effectiveRootScroller); |
| 181 |
| 182 if (!area) |
| 183 return nullptr; |
| 184 |
| 185 GraphicsLayer* graphicsLayer = area->layerForScrolling(); |
| 186 |
| 187 // TODO(bokan): We should assert graphicsLayer here and |
| 188 // RootScrollerController should do whatever needs to happen to ensure |
| 189 // the root scroller gets composited. |
| 190 |
| 191 return graphicsLayer; |
| 192 } |
| 193 |
163 Element* RootScrollerController::defaultEffectiveRootScroller() | 194 Element* RootScrollerController::defaultEffectiveRootScroller() |
164 { | 195 { |
165 DCHECK(m_document); | 196 DCHECK(m_document); |
166 return m_document->documentElement(); | 197 return m_document->documentElement(); |
167 } | 198 } |
168 | 199 |
169 } // namespace blink | 200 } // namespace blink |
OLD | NEW |