Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 DEFINE_TRACE(RootScrollerController) | 58 DEFINE_TRACE(RootScrollerController) |
| 59 { | 59 { |
| 60 visitor->trace(m_document); | 60 visitor->trace(m_document); |
| 61 visitor->trace(m_rootScroller); | 61 visitor->trace(m_rootScroller); |
| 62 visitor->trace(m_effectiveRootScroller); | 62 visitor->trace(m_effectiveRootScroller); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void RootScrollerController::set(Element* newRootScroller) | 65 void RootScrollerController::set(Element* newRootScroller) |
| 66 { | 66 { |
| 67 m_rootScroller = newRootScroller; | 67 m_rootScroller = newRootScroller; |
| 68 updateEffectiveRootScroller(); | 68 recomputeEffectiveRootScroller(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 Element* RootScrollerController::get() const | 71 Element* RootScrollerController::get() const |
| 72 { | 72 { |
| 73 return m_rootScroller; | 73 return m_rootScroller; |
| 74 } | 74 } |
| 75 | 75 |
| 76 Element* RootScrollerController::effectiveRootScroller() const | 76 Element* RootScrollerController::effectiveRootScroller() const |
| 77 { | 77 { |
| 78 return m_effectiveRootScroller; | 78 return m_effectiveRootScroller; |
| 79 } | 79 } |
| 80 | 80 |
| 81 void RootScrollerController::didUpdateLayout() | 81 void RootScrollerController::didUpdateLayout() |
| 82 { | 82 { |
| 83 updateEffectiveRootScroller(); | 83 recomputeEffectiveRootScroller(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void RootScrollerController::updateEffectiveRootScroller() | 86 void RootScrollerController::globalRootScrollerMayHaveChanged() |
| 87 { | |
| 88 NOTREACHED(); | |
|
bokan
2016/08/29 13:27:10
This gets tripped in tests that use a remote main
| |
| 89 } | |
| 90 | |
| 91 void RootScrollerController::recomputeEffectiveRootScroller() | |
| 87 { | 92 { |
| 88 bool rootScrollerValid = | 93 bool rootScrollerValid = |
| 89 m_rootScroller && isValidRootScroller(*m_rootScroller); | 94 m_rootScroller && isValidRootScroller(*m_rootScroller); |
| 90 | 95 |
| 91 Element* newEffectiveRootScroller = rootScrollerValid | 96 Element* newEffectiveRootScroller = rootScrollerValid |
| 92 ? m_rootScroller.get() | 97 ? m_rootScroller.get() |
| 93 : defaultEffectiveRootScroller(); | 98 : defaultEffectiveRootScroller(); |
| 94 | 99 |
| 95 if (m_effectiveRootScroller == newEffectiveRootScroller) | 100 if (m_effectiveRootScroller == newEffectiveRootScroller) |
| 96 return; | 101 return; |
| 97 | 102 |
| 98 m_effectiveRootScroller = newEffectiveRootScroller; | 103 m_effectiveRootScroller = newEffectiveRootScroller; |
| 104 | |
| 105 m_document->topDocument().rootScrollerController() | |
| 106 ->globalRootScrollerMayHaveChanged(); | |
| 99 } | 107 } |
| 100 | 108 |
| 101 ScrollableArea* RootScrollerController::scrollableAreaFor( | 109 ScrollableArea* RootScrollerController::scrollableAreaFor( |
| 102 const Element& element) const | 110 const Element& element) const |
| 103 { | 111 { |
| 104 if (!element.layoutObject() || !element.layoutObject()->isBox()) | 112 if (!element.layoutObject() || !element.layoutObject()->isBox()) |
| 105 return nullptr; | 113 return nullptr; |
| 106 | 114 |
| 107 LayoutBox* box = toLayoutBox(element.layoutObject()); | 115 LayoutBox* box = toLayoutBox(element.layoutObject()); |
| 108 | 116 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 134 void RootScrollerController::didUpdateCompositing() | 142 void RootScrollerController::didUpdateCompositing() |
| 135 { | 143 { |
| 136 } | 144 } |
| 137 | 145 |
| 138 void RootScrollerController::didAttachDocument() | 146 void RootScrollerController::didAttachDocument() |
| 139 { | 147 { |
| 140 } | 148 } |
| 141 | 149 |
| 142 GraphicsLayer* RootScrollerController::rootScrollerLayer() | 150 GraphicsLayer* RootScrollerController::rootScrollerLayer() |
| 143 { | 151 { |
| 144 if (!m_effectiveRootScroller) | 152 NOTREACHED(); |
| 145 return nullptr; | 153 return nullptr; |
| 146 | |
| 147 ScrollableArea* area = scrollableAreaFor(*m_effectiveRootScroller); | |
| 148 | |
| 149 if (!area) | |
| 150 return nullptr; | |
| 151 | |
| 152 GraphicsLayer* graphicsLayer = area->layerForScrolling(); | |
| 153 | |
| 154 // TODO(bokan): We should assert graphicsLayer here and | |
| 155 // RootScrollerController should do whatever needs to happen to ensure | |
| 156 // the root scroller gets composited. | |
| 157 | |
| 158 return graphicsLayer; | |
| 159 } | 154 } |
| 160 | 155 |
| 161 bool RootScrollerController::isViewportScrollCallback( | 156 bool RootScrollerController::isViewportScrollCallback( |
| 162 const ScrollStateCallback* callback) const | 157 const ScrollStateCallback* callback) const |
| 163 { | 158 { |
| 164 // TopDocumentRootScrollerController must override this method to actually | 159 // TopDocumentRootScrollerController must override this method to actually |
| 165 // do the comparison. | 160 // do the comparison. |
| 166 DCHECK(!m_document->isInMainFrame()); | 161 DCHECK(!m_document->isInMainFrame()); |
| 167 | 162 |
| 168 RootScrollerController* topDocumentController = | 163 RootScrollerController* topDocumentController = |
| 169 m_document->topDocument().rootScrollerController(); | 164 m_document->topDocument().rootScrollerController(); |
| 170 return topDocumentController->isViewportScrollCallback(callback); | 165 return topDocumentController->isViewportScrollCallback(callback); |
| 171 } | 166 } |
| 172 | 167 |
| 173 Element* RootScrollerController::defaultEffectiveRootScroller() | 168 Element* RootScrollerController::defaultEffectiveRootScroller() |
| 174 { | 169 { |
| 175 DCHECK(m_document); | 170 DCHECK(m_document); |
| 176 return m_document->documentElement(); | 171 return m_document->documentElement(); |
| 177 } | 172 } |
| 178 | 173 |
| 179 } // namespace blink | 174 } // namespace blink |
| OLD | NEW |