| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 Element* RootScrollerController::effectiveRootScroller() const | 81 Element* RootScrollerController::effectiveRootScroller() const |
| 82 { | 82 { |
| 83 return m_effectiveRootScroller; | 83 return m_effectiveRootScroller; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RootScrollerController::didUpdateLayout() | 86 void RootScrollerController::didUpdateLayout() |
| 87 { | 87 { |
| 88 recomputeEffectiveRootScroller(); | 88 recomputeEffectiveRootScroller(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void RootScrollerController::didDisposePaintLayerScrollableArea( |
| 92 PaintLayerScrollableArea& area) |
| 93 { |
| 94 if (!m_effectiveRootScroller) |
| 95 return; |
| 96 |
| 97 if (&area.box() == m_effectiveRootScroller->layoutObject()) |
| 98 recomputeEffectiveRootScroller(); |
| 99 } |
| 100 |
| 91 void RootScrollerController::recomputeEffectiveRootScroller() | 101 void RootScrollerController::recomputeEffectiveRootScroller() |
| 92 { | 102 { |
| 93 bool rootScrollerValid = | 103 bool rootScrollerValid = |
| 94 m_rootScroller && isValidRootScroller(*m_rootScroller); | 104 m_rootScroller && isValidRootScroller(*m_rootScroller); |
| 95 | 105 |
| 96 Element* newEffectiveRootScroller = rootScrollerValid | 106 Element* newEffectiveRootScroller = rootScrollerValid |
| 97 ? m_rootScroller.get() | 107 ? m_rootScroller.get() |
| 98 : defaultEffectiveRootScroller(); | 108 : defaultEffectiveRootScroller(); |
| 99 | 109 |
| 100 if (m_effectiveRootScroller == newEffectiveRootScroller) | 110 if (m_effectiveRootScroller == newEffectiveRootScroller) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return nullptr; | 153 return nullptr; |
| 144 | 154 |
| 145 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); | 155 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); |
| 146 PaintLayer* layer = box->layer(); | 156 PaintLayer* layer = box->layer(); |
| 147 | 157 |
| 148 // If the root scroller is the <html> element we do a bit of a fake out beca
use | 158 // If the root scroller is the <html> element we do a bit of a fake out beca
use |
| 149 // while <html> has a PaintLayer, scrolling for it is handled by the #docume
nt's | 159 // while <html> has a PaintLayer, scrolling for it is handled by the #docume
nt's |
| 150 // PaintLayer (i.e. the PaintLayerCompositor's root layer). The reason the r
oot | 160 // PaintLayer (i.e. the PaintLayerCompositor's root layer). The reason the r
oot |
| 151 // scroller is the <html> layer and not #document is because the latter is a
Node | 161 // scroller is the <html> layer and not #document is because the latter is a
Node |
| 152 // but not an Element. | 162 // but not an Element. |
| 153 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) | 163 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) { |
| 164 if (!layer || !layer->compositor()) |
| 165 return nullptr; |
| 154 return layer->compositor()->rootLayer(); | 166 return layer->compositor()->rootLayer(); |
| 167 } |
| 155 | 168 |
| 156 return layer; | 169 return layer; |
| 157 } | 170 } |
| 158 | 171 |
| 159 Element* RootScrollerController::defaultEffectiveRootScroller() | 172 Element* RootScrollerController::defaultEffectiveRootScroller() |
| 160 { | 173 { |
| 161 DCHECK(m_document); | 174 DCHECK(m_document); |
| 162 return m_document->documentElement(); | 175 return m_document->documentElement(); |
| 163 } | 176 } |
| 164 | 177 |
| 165 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |