| 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 the document is being torn down we'll skip a bunch of notifications |
| 95 // so recomputing the effective root scroller could touch dead objects. |
| 96 // (e.g. ScrollAnchor keeps a pointer to dead LayoutObjects). |
| 97 if (!m_effectiveRootScroller || area.box().documentBeingDestroyed()) |
| 98 return; |
| 99 |
| 100 if (&area.box() == m_effectiveRootScroller->layoutObject()) |
| 101 recomputeEffectiveRootScroller(); |
| 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) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 return nullptr; | 156 return nullptr; |
| 144 | 157 |
| 145 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); | 158 LayoutBox* box = toLayoutBox(m_effectiveRootScroller->layoutObject()); |
| 146 PaintLayer* layer = box->layer(); | 159 PaintLayer* layer = box->layer(); |
| 147 | 160 |
| 148 // If the root scroller is the <html> element we do a bit of a fake out beca
use | 161 // 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 | 162 // 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 | 163 // 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 | 164 // scroller is the <html> layer and not #document is because the latter is a
Node |
| 152 // but not an Element. | 165 // but not an Element. |
| 153 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) | 166 if (m_effectiveRootScroller->isSameNode(m_document->documentElement())) { |
| 167 if (!layer || !layer->compositor()) |
| 168 return nullptr; |
| 154 return layer->compositor()->rootLayer(); | 169 return layer->compositor()->rootLayer(); |
| 170 } |
| 155 | 171 |
| 156 return layer; | 172 return layer; |
| 157 } | 173 } |
| 158 | 174 |
| 159 Element* RootScrollerController::defaultEffectiveRootScroller() | 175 Element* RootScrollerController::defaultEffectiveRootScroller() |
| 160 { | 176 { |
| 161 DCHECK(m_document); | 177 DCHECK(m_document); |
| 162 return m_document->documentElement(); | 178 return m_document->documentElement(); |
| 163 } | 179 } |
| 164 | 180 |
| 165 } // namespace blink | 181 } // namespace blink |
| OLD | NEW |