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/layout/LayoutBox.h" | 11 #include "core/layout/LayoutBox.h" |
12 #include "core/layout/api/LayoutViewItem.h" | 12 #include "core/layout/api/LayoutViewItem.h" |
13 #include "core/layout/compositing/PaintLayerCompositor.h" | |
14 #include "core/paint/PaintLayer.h" | |
13 #include "core/paint/PaintLayerScrollableArea.h" | 15 #include "core/paint/PaintLayerScrollableArea.h" |
14 #include "platform/graphics/GraphicsLayer.h" | 16 #include "platform/graphics/GraphicsLayer.h" |
15 #include "platform/scroll/ScrollableArea.h" | 17 #include "platform/scroll/ScrollableArea.h" |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 | 20 |
19 class RootFrameViewport; | 21 class RootFrameViewport; |
20 | 22 |
21 namespace { | 23 namespace { |
22 | 24 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 83 |
82 void RootScrollerController::didUpdateLayout() | 84 void RootScrollerController::didUpdateLayout() |
83 { | 85 { |
84 recomputeEffectiveRootScroller(); | 86 recomputeEffectiveRootScroller(); |
85 } | 87 } |
86 | 88 |
87 void RootScrollerController::globalRootScrollerMayHaveChanged() | 89 void RootScrollerController::globalRootScrollerMayHaveChanged() |
88 { | 90 { |
89 } | 91 } |
90 | 92 |
93 void RootScrollerController::setNeedsCompositingInputsUpdateOnAncestorChain( | |
94 PaintLayer* layer) | |
95 { | |
96 if (layer) { | |
97 while (layer) { | |
98 layer->setNeedsCompositingInputsUpdate(); | |
bokan
2016/09/09 00:19:03
I set this on all ancestor layers since we need a
chrishtr
2016/09/09 18:21:16
I think it's overkill. PaintLayer::setNeedsComposi
bokan
2016/09/10 00:05:54
My read of that is that it ensures we recursively
chrishtr
2016/09/12 21:01:28
Oh in that case you just need setNeedsGraphicsLaye
bokan
2016/09/13 20:40:51
Ok, I used setNeedsCompositingUpdate since I can't
| |
99 layer = layer->parent(); | |
100 } | |
101 } | |
102 } | |
103 | |
91 void RootScrollerController::recomputeEffectiveRootScroller() | 104 void RootScrollerController::recomputeEffectiveRootScroller() |
92 { | 105 { |
93 bool rootScrollerValid = | 106 bool rootScrollerValid = |
94 m_rootScroller && isValidRootScroller(*m_rootScroller); | 107 m_rootScroller && isValidRootScroller(*m_rootScroller); |
95 | 108 |
96 Element* newEffectiveRootScroller = rootScrollerValid | 109 Element* newEffectiveRootScroller = rootScrollerValid |
97 ? m_rootScroller.get() | 110 ? m_rootScroller.get() |
98 : defaultEffectiveRootScroller(); | 111 : defaultEffectiveRootScroller(); |
99 | 112 |
100 if (m_effectiveRootScroller == newEffectiveRootScroller) | 113 if (m_effectiveRootScroller == newEffectiveRootScroller) |
101 return; | 114 return; |
102 | 115 |
116 PaintLayer* oldRootScrollerLayer = rootScrollerPaintLayer(); | |
117 | |
103 m_effectiveRootScroller = newEffectiveRootScroller; | 118 m_effectiveRootScroller = newEffectiveRootScroller; |
104 | 119 |
120 setNeedsCompositingInputsUpdateOnAncestorChain(oldRootScrollerLayer); | |
121 setNeedsCompositingInputsUpdateOnAncestorChain(rootScrollerPaintLayer()); | |
122 | |
105 m_document->topDocument().rootScrollerController() | 123 m_document->topDocument().rootScrollerController() |
106 ->globalRootScrollerMayHaveChanged(); | 124 ->globalRootScrollerMayHaveChanged(); |
107 } | 125 } |
108 | 126 |
109 ScrollableArea* RootScrollerController::scrollableAreaFor( | 127 ScrollableArea* RootScrollerController::scrollableAreaFor( |
110 const Element& element) const | 128 const Element& element) const |
111 { | 129 { |
112 if (!element.layoutObject() || !element.layoutObject()->isBox()) | 130 if (!element.layoutObject() || !element.layoutObject()->isBox()) |
113 return nullptr; | 131 return nullptr; |
114 | 132 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
165 // no way to get at the ViewportScrollCallback so just return false. | 183 // no way to get at the ViewportScrollCallback so just return false. |
166 // TODO(bokan): Make document.rootScroller work in OOPIF. crbug.com/642378. | 184 // TODO(bokan): Make document.rootScroller work in OOPIF. crbug.com/642378. |
167 if (!m_document->localOwner()) | 185 if (!m_document->localOwner()) |
168 return false; | 186 return false; |
169 | 187 |
170 RootScrollerController* topDocumentController = | 188 RootScrollerController* topDocumentController = |
171 m_document->topDocument().rootScrollerController(); | 189 m_document->topDocument().rootScrollerController(); |
172 return topDocumentController->isViewportScrollCallback(callback); | 190 return topDocumentController->isViewportScrollCallback(callback); |
173 } | 191 } |
174 | 192 |
193 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const | |
194 { | |
195 if (!m_effectiveRootScroller) | |
196 return nullptr; | |
197 | |
198 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); | |
199 if (!box) | |
200 return nullptr; | |
201 | |
202 PaintLayer* layer = box->layer(); | |
203 | |
204 // If the root scroller is the <html> element we do a bit of a fake out beca use | |
205 // while <html> has a PaintLayer, scrolling for it is handled by the #docume nt's | |
206 // PaintLayer (i.e. the PaintLayerCompositor's root layer). The reason the r oot | |
207 // scroller is the <html> layer and not #document is because the latter is a Node | |
208 // but not an Element. | |
209 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) | |
210 return layer->compositor()->rootLayer(); | |
211 | |
212 return layer; | |
213 } | |
214 | |
175 Element* RootScrollerController::defaultEffectiveRootScroller() | 215 Element* RootScrollerController::defaultEffectiveRootScroller() |
176 { | 216 { |
177 DCHECK(m_document); | 217 DCHECK(m_document); |
178 return m_document->documentElement(); | 218 return m_document->documentElement(); |
179 } | 219 } |
180 | 220 |
181 } // namespace blink | 221 } // namespace blink |
OLD | NEW |