Chromium Code Reviews| 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" |
| 11 #include "core/html/HTMLFrameOwnerElement.h" | 11 #include "core/html/HTMLFrameOwnerElement.h" |
| 12 #include "core/page/ChromeClient.h" | 12 #include "core/page/ChromeClient.h" |
| 13 #include "core/page/scrolling/OverscrollController.h" | 13 #include "core/page/scrolling/OverscrollController.h" |
| 14 #include "core/page/scrolling/ViewportScrollCallback.h" | 14 #include "core/page/scrolling/ViewportScrollCallback.h" |
| 15 #include "core/paint/PaintLayer.h" | |
| 15 #include "platform/scroll/ScrollableArea.h" | 16 #include "platform/scroll/ScrollableArea.h" |
| 16 | 17 |
| 17 namespace blink { | 18 namespace blink { |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 TopDocumentRootScrollerController* TopDocumentRootScrollerController::create( | 21 TopDocumentRootScrollerController* TopDocumentRootScrollerController::create( |
| 21 Document& document) | 22 Document& document) |
| 22 { | 23 { |
| 23 return new TopDocumentRootScrollerController(document); | 24 return new TopDocumentRootScrollerController(document); |
| 24 } | 25 } |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 return; | 76 return; |
| 76 | 77 |
| 77 if (m_globalRootScroller) | 78 if (m_globalRootScroller) |
| 78 m_globalRootScroller->removeApplyScroll(); | 79 m_globalRootScroller->removeApplyScroll(); |
| 79 | 80 |
| 80 // Use disable-native-scroll since the ViewportScrollCallback needs to | 81 // Use disable-native-scroll since the ViewportScrollCallback needs to |
| 81 // apply scroll actions both before (TopControls) and after (overscroll) | 82 // apply scroll actions both before (TopControls) and after (overscroll) |
| 82 // scrolling the element so it will apply scroll to the element itself. | 83 // scrolling the element so it will apply scroll to the element itself. |
| 83 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll"); | 84 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll"); |
| 84 | 85 |
| 86 // A change in global root scroller requires a compositing inputs update to | |
| 87 // the new and old global root scroller since it might change how the | |
| 88 // ancestor layers are clipped. e.g. An iframe that's the global root | |
| 89 // scroller clips its layers like the root frame. Normally this is set | |
| 90 // when the local effective root scroller changes but the global root | |
| 91 // scroller can change because the parent's effective root scroller | |
| 92 // changes. | |
| 93 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | |
| 94 | |
| 85 m_globalRootScroller = target; | 95 m_globalRootScroller = target; |
| 86 | 96 |
| 97 setNeedsCompositingInputsUpdateOnGlobalRootScroller(); | |
| 98 | |
| 87 // Ideally, scroll customization would pass the current element to scroll to | 99 // Ideally, scroll customization would pass the current element to scroll to |
| 88 // the apply scroll callback but this doesn't happen today so we set it | 100 // the apply scroll callback but this doesn't happen today so we set it |
| 89 // through a back door here. This is also needed by the | 101 // through a back door here. This is also needed by the |
| 90 // ViewportScrollCallback to swap the target into the layout viewport | 102 // ViewportScrollCallback to swap the target into the layout viewport |
| 91 // in RootFrameViewport. | 103 // in RootFrameViewport. |
| 92 m_viewportApplyScroll->setScroller(targetScroller); | 104 m_viewportApplyScroll->setScroller(targetScroller); |
| 93 } | 105 } |
| 94 | 106 |
| 107 void TopDocumentRootScrollerController | |
| 108 ::setNeedsCompositingInputsUpdateOnGlobalRootScroller() | |
| 109 { | |
| 110 if (!m_globalRootScroller) | |
| 111 return; | |
| 112 | |
| 113 PaintLayer* layer = m_globalRootScroller->document() | |
| 114 .rootScrollerController()->rootScrollerPaintLayer(); | |
| 115 | |
| 116 if (layer) | |
| 117 layer->setNeedsCompositingInputsUpdate(); | |
|
chrishtr
2016/09/14 17:16:41
I think you're going to need
compositor()->setNee
bokan
2016/09/14 17:25:46
Ah, yes, you're right, thanks for catching that. D
| |
| 118 } | |
| 119 | |
| 95 void TopDocumentRootScrollerController::didUpdateCompositing() | 120 void TopDocumentRootScrollerController::didUpdateCompositing() |
| 96 { | 121 { |
| 97 FrameHost* frameHost = m_document->frameHost(); | 122 RootScrollerController::didUpdateCompositing(); |
| 98 | 123 |
| 99 // Let the compositor-side counterpart know about this change. | 124 // Let the compositor-side counterpart know about this change. |
| 100 if (frameHost) | 125 if (FrameHost* frameHost = m_document->frameHost()) |
| 101 frameHost->chromeClient().registerViewportLayers(); | 126 frameHost->chromeClient().registerViewportLayers(); |
| 102 } | 127 } |
| 103 | 128 |
| 104 void TopDocumentRootScrollerController::didAttachDocument() | 129 void TopDocumentRootScrollerController::didAttachDocument() |
| 105 { | 130 { |
| 106 FrameHost* frameHost = m_document->frameHost(); | 131 FrameHost* frameHost = m_document->frameHost(); |
| 107 FrameView* frameView = m_document->view(); | 132 FrameView* frameView = m_document->view(); |
| 108 | 133 |
| 109 if (!frameHost || !frameView) | 134 if (!frameHost || !frameView) |
| 110 return; | 135 return; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 141 | 166 |
| 142 GraphicsLayer* graphicsLayer = area->layerForScrolling(); | 167 GraphicsLayer* graphicsLayer = area->layerForScrolling(); |
| 143 | 168 |
| 144 // TODO(bokan): We should assert graphicsLayer here and | 169 // TODO(bokan): We should assert graphicsLayer here and |
| 145 // RootScrollerController should do whatever needs to happen to ensure | 170 // RootScrollerController should do whatever needs to happen to ensure |
| 146 // the root scroller gets composited. | 171 // the root scroller gets composited. |
| 147 | 172 |
| 148 return graphicsLayer; | 173 return graphicsLayer; |
| 149 } | 174 } |
| 150 | 175 |
| 176 Element* TopDocumentRootScrollerController::globalRootScroller() const | |
| 177 { | |
| 178 return m_globalRootScroller.get(); | |
| 179 } | |
| 180 | |
| 151 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |