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" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 119 } |
120 | 120 |
121 if (FrameHost* frameHost = m_document->frameHost()) | 121 if (FrameHost* frameHost = m_document->frameHost()) |
122 frameHost->globalRootScrollerController().didChangeRootScroller(); | 122 frameHost->globalRootScrollerController().didChangeRootScroller(); |
123 } | 123 } |
124 | 124 |
125 bool RootScrollerController::isValidRootScroller(const Element& element) const { | 125 bool RootScrollerController::isValidRootScroller(const Element& element) const { |
126 if (!element.layoutObject()) | 126 if (!element.layoutObject()) |
127 return false; | 127 return false; |
128 | 128 |
129 if (!RootScrollerUtil::scrollableAreaFor(element)) | 129 if (!RootScrollerUtil::scrollableAreaForRootScroller(element)) |
130 return false; | 130 return false; |
131 | 131 |
132 if (!fillsViewport(element)) | 132 if (!fillsViewport(element)) |
133 return false; | 133 return false; |
134 | 134 |
135 return true; | 135 return true; |
136 } | 136 } |
137 | 137 |
138 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const { | 138 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const { |
139 if (!m_effectiveRootScroller || !m_effectiveRootScroller->layoutObject() || | 139 return RootScrollerUtil::paintLayerForRootScroller(m_effectiveRootScroller); |
140 !m_effectiveRootScroller->layoutObject()->isBox()) | |
141 return nullptr; | |
142 | |
143 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); | |
144 PaintLayer* layer = box->layer(); | |
145 | |
146 // If the root scroller is the <html> element we do a bit of a fake out | |
147 // because while <html> has a PaintLayer, scrolling for it is handled by the | |
148 // #document's PaintLayer (i.e. the PaintLayerCompositor's root layer). The | |
149 // reason the root scroller is the <html> layer and not #document is because | |
150 // the latter is a Node but not an Element. | |
151 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) { | |
152 if (!layer || !layer->compositor()) | |
153 return nullptr; | |
154 return layer->compositor()->rootLayer(); | |
155 } | |
156 | |
157 return layer; | |
158 } | 140 } |
159 | 141 |
160 Element* RootScrollerController::defaultEffectiveRootScroller() { | 142 Element* RootScrollerController::defaultEffectiveRootScroller() { |
161 DCHECK(m_document); | 143 DCHECK(m_document); |
162 return m_document->documentElement(); | 144 return m_document->documentElement(); |
163 } | 145 } |
164 | 146 |
165 } // namespace blink | 147 } // namespace blink |
OLD | NEW |