Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(612)

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/RootScrollerController.cpp

Issue 2281603002: Make document.rootScroller work properly across iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@splitRootScrollerController
Patch Set: ASSERT->EXPECT in tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
89
90 void RootScrollerController::recomputeEffectiveRootScroller()
87 { 91 {
88 bool rootScrollerValid = 92 bool rootScrollerValid =
89 m_rootScroller && isValidRootScroller(*m_rootScroller); 93 m_rootScroller && isValidRootScroller(*m_rootScroller);
90 94
91 Element* newEffectiveRootScroller = rootScrollerValid 95 Element* newEffectiveRootScroller = rootScrollerValid
92 ? m_rootScroller.get() 96 ? m_rootScroller.get()
93 : defaultEffectiveRootScroller(); 97 : defaultEffectiveRootScroller();
94 98
95 if (m_effectiveRootScroller == newEffectiveRootScroller) 99 if (m_effectiveRootScroller == newEffectiveRootScroller)
96 return; 100 return;
97 101
98 m_effectiveRootScroller = newEffectiveRootScroller; 102 m_effectiveRootScroller = newEffectiveRootScroller;
103
104 m_document->topDocument().rootScrollerController()
105 ->globalRootScrollerMayHaveChanged();
99 } 106 }
100 107
101 ScrollableArea* RootScrollerController::scrollableAreaFor( 108 ScrollableArea* RootScrollerController::scrollableAreaFor(
102 const Element& element) const 109 const Element& element) const
103 { 110 {
104 if (!element.layoutObject() || !element.layoutObject()->isBox()) 111 if (!element.layoutObject() || !element.layoutObject()->isBox())
105 return nullptr; 112 return nullptr;
106 113
107 LayoutBox* box = toLayoutBox(element.layoutObject()); 114 LayoutBox* box = toLayoutBox(element.layoutObject());
108 115
(...skipping 25 matching lines...) Expand all
134 void RootScrollerController::didUpdateCompositing() 141 void RootScrollerController::didUpdateCompositing()
135 { 142 {
136 } 143 }
137 144
138 void RootScrollerController::didAttachDocument() 145 void RootScrollerController::didAttachDocument()
139 { 146 {
140 } 147 }
141 148
142 GraphicsLayer* RootScrollerController::rootScrollerLayer() 149 GraphicsLayer* RootScrollerController::rootScrollerLayer()
143 { 150 {
144 if (!m_effectiveRootScroller) 151 NOTREACHED();
145 return nullptr; 152 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 } 153 }
160 154
161 bool RootScrollerController::isViewportScrollCallback( 155 bool RootScrollerController::isViewportScrollCallback(
162 const ScrollStateCallback* callback) const 156 const ScrollStateCallback* callback) const
163 { 157 {
164 // TopDocumentRootScrollerController must override this method to actually 158 // TopDocumentRootScrollerController must override this method to actually
165 // do the comparison. 159 // do the comparison.
166 DCHECK(!m_document->isInMainFrame()); 160 DCHECK(!m_document->isInMainFrame());
167 161
168 RootScrollerController* topDocumentController = 162 RootScrollerController* topDocumentController =
169 m_document->topDocument().rootScrollerController(); 163 m_document->topDocument().rootScrollerController();
170 return topDocumentController->isViewportScrollCallback(callback); 164 return topDocumentController->isViewportScrollCallback(callback);
171 } 165 }
172 166
173 Element* RootScrollerController::defaultEffectiveRootScroller() 167 Element* RootScrollerController::defaultEffectiveRootScroller()
174 { 168 {
175 DCHECK(m_document); 169 DCHECK(m_document);
176 return m_document->documentElement(); 170 return m_document->documentElement();
177 } 171 }
178 172
179 } // namespace blink 173 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698