Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/TopDocumentRootScrollerController.cpp

Issue 2289833002: Disable clipping on root scroller's ancestors. (Closed)
Patch Set: Also setNeedsCompositingUpdate from TopDocumentRootScrollerController Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/layout/LayoutView.h"
13 #include "core/layout/compositing/PaintLayerCompositor.h"
12 #include "core/page/ChromeClient.h" 14 #include "core/page/ChromeClient.h"
13 #include "core/page/scrolling/OverscrollController.h" 15 #include "core/page/scrolling/OverscrollController.h"
14 #include "core/page/scrolling/ViewportScrollCallback.h" 16 #include "core/page/scrolling/ViewportScrollCallback.h"
17 #include "core/paint/PaintLayer.h"
15 #include "platform/scroll/ScrollableArea.h" 18 #include "platform/scroll/ScrollableArea.h"
16 19
17 namespace blink { 20 namespace blink {
18 21
19 // static 22 // static
20 TopDocumentRootScrollerController* TopDocumentRootScrollerController::create( 23 TopDocumentRootScrollerController* TopDocumentRootScrollerController::create(
21 Document& document) 24 Document& document)
22 { 25 {
23 return new TopDocumentRootScrollerController(document); 26 return new TopDocumentRootScrollerController(document);
24 } 27 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return; 78 return;
76 79
77 if (m_globalRootScroller) 80 if (m_globalRootScroller)
78 m_globalRootScroller->removeApplyScroll(); 81 m_globalRootScroller->removeApplyScroll();
79 82
80 // Use disable-native-scroll since the ViewportScrollCallback needs to 83 // Use disable-native-scroll since the ViewportScrollCallback needs to
81 // apply scroll actions both before (TopControls) and after (overscroll) 84 // apply scroll actions both before (TopControls) and after (overscroll)
82 // scrolling the element so it will apply scroll to the element itself. 85 // scrolling the element so it will apply scroll to the element itself.
83 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll"); 86 target->setApplyScroll(m_viewportApplyScroll, "disable-native-scroll");
84 87
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
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
92 // when the local effective root scroller changes but the global root
93 // scroller can change because the parent's effective root scroller
94 // changes.
95 setNeedsCompositingInputsUpdateOnGlobalRootScroller();
96
85 m_globalRootScroller = target; 97 m_globalRootScroller = target;
86 98
99 setNeedsCompositingInputsUpdateOnGlobalRootScroller();
100
87 // Ideally, scroll customization would pass the current element to scroll to 101 // 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 102 // 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 103 // through a back door here. This is also needed by the
90 // ViewportScrollCallback to swap the target into the layout viewport 104 // ViewportScrollCallback to swap the target into the layout viewport
91 // in RootFrameViewport. 105 // in RootFrameViewport.
92 m_viewportApplyScroll->setScroller(targetScroller); 106 m_viewportApplyScroll->setScroller(targetScroller);
93 } 107 }
94 108
109 void TopDocumentRootScrollerController
110 ::setNeedsCompositingInputsUpdateOnGlobalRootScroller()
111 {
112 if (!m_globalRootScroller)
113 return;
114
115 PaintLayer* layer = m_globalRootScroller->document()
116 .rootScrollerController()->rootScrollerPaintLayer();
117
118 if (layer)
119 layer->setNeedsCompositingInputsUpdate();
120
121 if (LayoutView* view = m_globalRootScroller->document().layoutView()) {
122 view->compositor()
123 ->setNeedsCompositingUpdate(CompositingUpdateRebuildTree);
124 }
125 }
126
95 void TopDocumentRootScrollerController::didUpdateCompositing() 127 void TopDocumentRootScrollerController::didUpdateCompositing()
96 { 128 {
97 FrameHost* frameHost = m_document->frameHost(); 129 RootScrollerController::didUpdateCompositing();
98 130
99 // Let the compositor-side counterpart know about this change. 131 // Let the compositor-side counterpart know about this change.
100 if (frameHost) 132 if (FrameHost* frameHost = m_document->frameHost())
101 frameHost->chromeClient().registerViewportLayers(); 133 frameHost->chromeClient().registerViewportLayers();
102 } 134 }
103 135
104 void TopDocumentRootScrollerController::didAttachDocument() 136 void TopDocumentRootScrollerController::didAttachDocument()
105 { 137 {
106 FrameHost* frameHost = m_document->frameHost(); 138 FrameHost* frameHost = m_document->frameHost();
107 FrameView* frameView = m_document->view(); 139 FrameView* frameView = m_document->view();
108 140
109 if (!frameHost || !frameView) 141 if (!frameHost || !frameView)
110 return; 142 return;
(...skipping 30 matching lines...) Expand all
141 173
142 GraphicsLayer* graphicsLayer = area->layerForScrolling(); 174 GraphicsLayer* graphicsLayer = area->layerForScrolling();
143 175
144 // TODO(bokan): We should assert graphicsLayer here and 176 // TODO(bokan): We should assert graphicsLayer here and
145 // RootScrollerController should do whatever needs to happen to ensure 177 // RootScrollerController should do whatever needs to happen to ensure
146 // the root scroller gets composited. 178 // the root scroller gets composited.
147 179
148 return graphicsLayer; 180 return graphicsLayer;
149 } 181 }
150 182
183 Element* TopDocumentRootScrollerController::globalRootScroller() const
184 {
185 return m_globalRootScroller.get();
186 }
187
151 } // namespace blink 188 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698