| 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/FrameView.h" | 9 #include "core/frame/FrameView.h" |
| 10 #include "core/layout/LayoutBox.h" | 10 #include "core/layout/LayoutBox.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 // to kick the global root scroller to recompute itself. We can remove this | 98 // to kick the global root scroller to recompute itself. We can remove this |
| 99 // if ScrollCustomization is moved to the Node rather than Element. | 99 // if ScrollCustomization is moved to the Node rather than Element. |
| 100 bool oldHasDocumentElement = m_documentHasDocumentElement; | 100 bool oldHasDocumentElement = m_documentHasDocumentElement; |
| 101 m_documentHasDocumentElement = m_document->documentElement(); | 101 m_documentHasDocumentElement = m_document->documentElement(); |
| 102 | 102 |
| 103 if (oldHasDocumentElement || !m_documentHasDocumentElement) { | 103 if (oldHasDocumentElement || !m_documentHasDocumentElement) { |
| 104 if (m_effectiveRootScroller == newEffectiveRootScroller) | 104 if (m_effectiveRootScroller == newEffectiveRootScroller) |
| 105 return; | 105 return; |
| 106 } | 106 } |
| 107 | 107 |
| 108 PaintLayer* oldRootScrollerLayer = rootScrollerPaintLayer(); | |
| 109 | |
| 110 m_effectiveRootScroller = newEffectiveRootScroller; | 108 m_effectiveRootScroller = newEffectiveRootScroller; |
| 111 | 109 |
| 112 // This change affects both the old and new layers. | |
| 113 if (oldRootScrollerLayer) | |
| 114 oldRootScrollerLayer->setNeedsCompositingInputsUpdate(); | |
| 115 if (rootScrollerPaintLayer()) | |
| 116 rootScrollerPaintLayer()->setNeedsCompositingInputsUpdate(); | |
| 117 | |
| 118 // The above may not be enough as we need to update existing ancestor | |
| 119 // GraphicsLayers. This will force us to rebuild the GraphicsLayer tree. | |
| 120 if (LayoutView* layoutView = m_document->layoutView()) { | |
| 121 layoutView->compositor()->setNeedsCompositingUpdate( | |
| 122 CompositingUpdateRebuildTree); | |
| 123 } | |
| 124 | |
| 125 if (Page* page = m_document->page()) | 110 if (Page* page = m_document->page()) |
| 126 page->globalRootScrollerController().didChangeRootScroller(); | 111 page->globalRootScrollerController().didChangeRootScroller(); |
| 127 } | 112 } |
| 128 | 113 |
| 129 bool RootScrollerController::isValidRootScroller(const Element& element) const { | 114 bool RootScrollerController::isValidRootScroller(const Element& element) const { |
| 130 if (!element.layoutObject()) | 115 if (!element.layoutObject()) |
| 131 return false; | 116 return false; |
| 132 | 117 |
| 133 if (!RootScrollerUtil::scrollableAreaForRootScroller(&element)) | 118 if (!RootScrollerUtil::scrollableAreaForRootScroller(&element)) |
| 134 return false; | 119 return false; |
| 135 | 120 |
| 136 if (!fillsViewport(element)) | 121 if (!fillsViewport(element)) |
| 137 return false; | 122 return false; |
| 138 | 123 |
| 139 return true; | 124 return true; |
| 140 } | 125 } |
| 141 | 126 |
| 142 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const { | 127 PaintLayer* RootScrollerController::rootScrollerPaintLayer() const { |
| 143 return RootScrollerUtil::paintLayerForRootScroller(m_effectiveRootScroller); | 128 return RootScrollerUtil::paintLayerForRootScroller(m_effectiveRootScroller); |
| 144 } | 129 } |
| 145 | 130 |
| 146 bool RootScrollerController::scrollsViewport(const Element& element) const { | 131 bool RootScrollerController::scrollsViewport(const Element& element) const { |
| 147 if (m_effectiveRootScroller->isDocumentNode()) | 132 if (m_effectiveRootScroller->isDocumentNode()) |
| 148 return element.isSameNode(m_document->documentElement()); | 133 return element.isSameNode(m_document->documentElement()); |
| 149 | 134 |
| 150 return element.isSameNode(m_effectiveRootScroller); | 135 return element.isSameNode(m_effectiveRootScroller); |
| 151 } | 136 } |
| 152 | 137 |
| 153 } // namespace blink | 138 } // namespace blink |
| OLD | NEW |