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

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

Issue 1208433002: Replaced adjustScrollPositionWithinRange with clampScrollPosition (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Unremoved DoublePoint version of FrameView::setScrollOffset Created 5 years, 6 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
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/frame/RootFrameViewport.h" 6 #include "core/frame/RootFrameViewport.h"
7 7
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/layout/ScrollAlignment.h" 9 #include "core/layout/ScrollAlignment.h"
10 #include "platform/geometry/DoubleRect.h" 10 #include "platform/geometry/DoubleRect.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 DoublePoint locationDelta; 109 DoublePoint locationDelta;
110 if (viewScrollResult.didScroll()) { 110 if (viewScrollResult.didScroll()) {
111 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); 111 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY);
112 } else { 112 } else {
113 if (event.railsMode() != PlatformEvent::RailsModeVertical) 113 if (event.railsMode() != PlatformEvent::RailsModeVertical)
114 locationDelta.setX(-event.deltaX()); 114 locationDelta.setX(-event.deltaX());
115 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) 115 if (event.railsMode() != PlatformEvent::RailsModeHorizontal)
116 locationDelta.setY(-event.deltaY()); 116 locationDelta.setY(-event.deltaY());
117 } 117 }
118 118
119 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( 119 DoublePoint targetPosition = visualViewport().clampScrollPosition(
120 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); 120 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta));
121 visualViewport().setScrollPosition(targetPosition, UserScroll); 121 visualViewport().setScrollPosition(targetPosition, UserScroll);
122 122
123 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); 123 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset);
124 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( )) 124 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( ))
125 return ScrollResult(); 125 return ScrollResult();
126 126
127 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); 127 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta);
128 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ; 128 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ;
129 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( ); 129 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( );
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 { 183 {
184 // Make sure we use the scroll positions as reported by each viewport's Scro llAnimator, since its 184 // Make sure we use the scroll positions as reported by each viewport's Scro llAnimator, since its
185 // ScrollableArea's position may have the fractional part truncated off. 185 // ScrollableArea's position may have the fractional part truncated off.
186 DoublePoint oldPosition = scrollOffsetFromScrollAnimators(); 186 DoublePoint oldPosition = scrollOffsetFromScrollAnimators();
187 187
188 DoubleSize delta = offset - oldPosition; 188 DoubleSize delta = offset - oldPosition;
189 189
190 if (delta.isZero()) 190 if (delta.isZero())
191 return; 191 return;
192 192
193 DoublePoint targetPosition = layoutViewport().adjustScrollPositionWithinRang e(layoutViewport().scrollAnimator()->currentPosition() + delta); 193 DoublePoint targetPosition = layoutViewport().clampScrollPosition(layoutView port().scrollAnimator()->currentPosition() + delta);
194 layoutViewport().setScrollPosition(targetPosition, scrollType); 194 layoutViewport().setScrollPosition(targetPosition, scrollType);
195 195
196 DoubleSize applied = scrollOffsetFromScrollAnimators() - oldPosition; 196 DoubleSize applied = scrollOffsetFromScrollAnimators() - oldPosition;
197 delta -= applied; 197 delta -= applied;
198 198
199 if (delta.isZero()) 199 if (delta.isZero())
200 return; 200 return;
201 201
202 targetPosition = visualViewport().adjustScrollPositionWithinRange(visualView port().scrollAnimator()->currentPosition() + delta); 202 targetPosition = visualViewport().clampScrollPosition(visualViewport().scrol lAnimator()->currentPosition() + delta);
203 visualViewport().setScrollPosition(targetPosition, scrollType); 203 visualViewport().setScrollPosition(targetPosition, scrollType);
204 } 204 }
205 205
206 IntPoint RootFrameViewport::scrollPosition() const 206 IntPoint RootFrameViewport::scrollPosition() const
207 { 207 {
208 return flooredIntPoint(scrollPositionDouble()); 208 return flooredIntPoint(scrollPositionDouble());
209 } 209 }
210 210
211 DoublePoint RootFrameViewport::scrollPositionDouble() const 211 DoublePoint RootFrameViewport::scrollPositionDouble() const
212 { 212 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 void RootFrameViewport::updateCompositorScrollAnimations() 325 void RootFrameViewport::updateCompositorScrollAnimations()
326 { 326 {
327 ScrollableArea::updateCompositorScrollAnimations(); 327 ScrollableArea::updateCompositorScrollAnimations();
328 layoutViewport().updateCompositorScrollAnimations(); 328 layoutViewport().updateCompositorScrollAnimations();
329 } 329 }
330 330
331 331
332 } // namespace blink 332 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/FrameView.cpp ('k') | Source/core/loader/FrameLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698