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

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: Top Controls Work From Iframes 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 updateEffectiveRootScroller();
84 } 84 }
85 85
86 void RootScrollerController::globalRootScrollerMayHaveChanged()
87 {
88 NOTREACHED();
89 }
90
86 void RootScrollerController::updateEffectiveRootScroller() 91 void RootScrollerController::updateEffectiveRootScroller()
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 23 matching lines...) Expand all
132 } 140 }
133 141
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()
tdresser 2016/08/25 19:46:37 Move to TopDocumentRootScrollerController only?
bokan 2016/08/26 19:35:04 Will do in follow up.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698