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/compositing/CompositedLayerMapping.h" | |
chrishtr
2016/09/01 23:42:57
Do you need this include?
bokan
2016/09/09 00:19:02
Nope, removed.
| |
13 #include "core/layout/compositing/PaintLayerCompositor.h" | |
14 #include "core/paint/PaintLayer.h" | |
12 #include "core/paint/PaintLayerScrollableArea.h" | 15 #include "core/paint/PaintLayerScrollableArea.h" |
13 #include "platform/graphics/GraphicsLayer.h" | 16 #include "platform/graphics/GraphicsLayer.h" |
14 #include "platform/scroll/ScrollableArea.h" | 17 #include "platform/scroll/ScrollableArea.h" |
15 | 18 |
16 namespace blink { | 19 namespace blink { |
17 | 20 |
18 class RootFrameViewport; | 21 class RootFrameViewport; |
19 | 22 |
20 namespace { | 23 namespace { |
21 | 24 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 97 |
95 Element* newEffectiveRootScroller = rootScrollerValid | 98 Element* newEffectiveRootScroller = rootScrollerValid |
96 ? m_rootScroller.get() | 99 ? m_rootScroller.get() |
97 : defaultEffectiveRootScroller(); | 100 : defaultEffectiveRootScroller(); |
98 | 101 |
99 if (m_effectiveRootScroller == newEffectiveRootScroller) | 102 if (m_effectiveRootScroller == newEffectiveRootScroller) |
100 return; | 103 return; |
101 | 104 |
102 m_effectiveRootScroller = newEffectiveRootScroller; | 105 m_effectiveRootScroller = newEffectiveRootScroller; |
103 | 106 |
107 if (PaintLayer* layer = rootScrollerPaintLayer()) | |
108 layer->setNeedsCompositingInputsUpdate(); | |
109 | |
104 m_document->topDocument().rootScrollerController() | 110 m_document->topDocument().rootScrollerController() |
105 ->globalRootScrollerMayHaveChanged(); | 111 ->globalRootScrollerMayHaveChanged(); |
106 } | 112 } |
107 | 113 |
108 ScrollableArea* RootScrollerController::scrollableAreaFor( | 114 ScrollableArea* RootScrollerController::scrollableAreaFor( |
109 const Element& element) const | 115 const Element& element) const |
110 { | 116 { |
111 if (!element.layoutObject() || !element.layoutObject()->isBox()) | 117 if (!element.layoutObject() || !element.layoutObject()->isBox()) |
112 return nullptr; | 118 return nullptr; |
113 | 119 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 { | 163 { |
158 // TopDocumentRootScrollerController must override this method to actually | 164 // TopDocumentRootScrollerController must override this method to actually |
159 // do the comparison. | 165 // do the comparison. |
160 DCHECK(!m_document->isInMainFrame()); | 166 DCHECK(!m_document->isInMainFrame()); |
161 | 167 |
162 RootScrollerController* topDocumentController = | 168 RootScrollerController* topDocumentController = |
163 m_document->topDocument().rootScrollerController(); | 169 m_document->topDocument().rootScrollerController(); |
164 return topDocumentController->isViewportScrollCallback(callback); | 170 return topDocumentController->isViewportScrollCallback(callback); |
165 } | 171 } |
166 | 172 |
173 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const | |
174 { | |
175 if (!m_effectiveRootScroller) | |
176 return nullptr; | |
177 | |
178 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); | |
179 if (!box) | |
180 return nullptr; | |
181 | |
182 PaintLayer* layer = box->layer(); | |
183 | |
184 // If the root scroller is the <html> element we do a bit of a fake out beca use | |
185 // while <html> has a PaintLayer, scrolling for it is handled by the #docume nt's | |
186 // PaintLayer (i.e. the PaintLayerCompositor's root layer). The reason the r oot | |
187 // scroller is the <html> layer and not #document is because the latter is a Node | |
188 // but not an Element. | |
189 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) | |
190 return layer->compositor()->rootLayer(); | |
191 | |
192 return layer; | |
193 } | |
194 | |
167 Element* RootScrollerController::defaultEffectiveRootScroller() | 195 Element* RootScrollerController::defaultEffectiveRootScroller() |
168 { | 196 { |
169 DCHECK(m_document); | 197 DCHECK(m_document); |
170 return m_document->documentElement(); | 198 return m_document->documentElement(); |
171 } | 199 } |
172 | 200 |
173 } // namespace blink | 201 } // namespace blink |
OLD | NEW |