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

Side by Side Diff: third_party/WebKit/Source/core/frame/RootFrameViewport.cpp

Issue 2383113003: Refactor ScrollableArea::setScrollPosition. (Closed)
Patch Set: Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/frame/RootFrameViewport.h" 5 #include "core/frame/RootFrameViewport.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/ScrollAlignment.h" 8 #include "core/layout/ScrollAlignment.h"
9 #include "core/layout/ScrollAnchor.h" 9 #include "core/layout/ScrollAnchor.h"
10 #include "platform/geometry/DoubleRect.h" 10 #include "platform/geometry/DoubleRect.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 viewRectInContent, rectInContent, alignX, alignY); 200 viewRectInContent, rectInContent, alignX, alignY);
201 if (targetViewport != viewRectInContent) 201 if (targetViewport != viewRectInContent)
202 setScrollPosition(DoublePoint(targetViewport.x(), targetViewport.y()), 202 setScrollPosition(DoublePoint(targetViewport.x(), targetViewport.y()),
203 scrollType); 203 scrollType);
204 204
205 // RootFrameViewport only changes the viewport relative to the document so we can't change the input 205 // RootFrameViewport only changes the viewport relative to the document so we can't change the input
206 // rect's location relative to the document origin. 206 // rect's location relative to the document origin.
207 return rectInContent; 207 return rectInContent;
208 } 208 }
209 209
210 void RootFrameViewport::setScrollOffset(const DoublePoint& offset, 210 void RootFrameViewport::updateScrollPosition(const DoublePoint& position,
211 ScrollType scrollType) { 211 ScrollType scrollType) {
212 distributeScrollBetweenViewports(DoublePoint(offset), scrollType, 212 distributeScrollBetweenViewports(DoublePoint(position), scrollType,
213 ScrollBehaviorInstant, VisualViewport); 213 ScrollBehaviorInstant, VisualViewport);
214 } 214 }
215 215
216 void RootFrameViewport::distributeScrollBetweenViewports( 216 void RootFrameViewport::distributeScrollBetweenViewports(
217 const DoublePoint& offset, 217 const DoublePoint& position,
218 ScrollType scrollType, 218 ScrollType scrollType,
219 ScrollBehavior behavior, 219 ScrollBehavior behavior,
220 ViewportToScrollFirst scrollFirst) { 220 ViewportToScrollFirst scrollFirst) {
221 // Make sure we use the scroll positions as reported by each viewport's Scroll AnimatorBase, since its 221 // Make sure we use the scroll positions as reported by each viewport's Scroll AnimatorBase, since its
222 // ScrollableArea's position may have the fractional part truncated off. 222 // ScrollableArea's position may have the fractional part truncated off.
223 DoublePoint oldPosition = scrollOffsetFromScrollAnimators(); 223 DoublePoint oldPosition = scrollOffsetFromScrollAnimators();
224 224
225 DoubleSize delta = offset - oldPosition; 225 DoubleSize delta = position - oldPosition;
226 226
227 if (delta.isZero()) 227 if (delta.isZero())
228 return; 228 return;
229 229
230 ScrollableArea& primary = 230 ScrollableArea& primary =
231 scrollFirst == VisualViewport ? visualViewport() : layoutViewport(); 231 scrollFirst == VisualViewport ? visualViewport() : layoutViewport();
232 ScrollableArea& secondary = 232 ScrollableArea& secondary =
233 scrollFirst == VisualViewport ? layoutViewport() : visualViewport(); 233 scrollFirst == VisualViewport ? layoutViewport() : visualViewport();
234 234
235 DoublePoint targetPosition = primary.clampScrollPosition( 235 DoublePoint targetPosition = primary.clampScrollPosition(
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 visualViewport().clearScrollAnimators(); 424 visualViewport().clearScrollAnimators();
425 } 425 }
426 426
427 DEFINE_TRACE(RootFrameViewport) { 427 DEFINE_TRACE(RootFrameViewport) {
428 visitor->trace(m_visualViewport); 428 visitor->trace(m_visualViewport);
429 visitor->trace(m_layoutViewport); 429 visitor->trace(m_layoutViewport);
430 ScrollableArea::trace(visitor); 430 ScrollableArea::trace(visitor);
431 } 431 }
432 432
433 } // namespace blink 433 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698