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

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

Issue 1056983004: OverscrollGlow for mainThread-{BLINK CHANGES} (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased to latest 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/RootFrameViewport.h ('k') | Source/core/frame/RootFrameViewportTest.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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return; 84 return;
85 85
86 DoublePoint clampedPosition = clampScrollPosition(position); 86 DoublePoint clampedPosition = clampScrollPosition(position);
87 scrollToOffsetWithoutAnimation(toFloatPoint(clampedPosition)); 87 scrollToOffsetWithoutAnimation(toFloatPoint(clampedPosition));
88 } 88 }
89 89
90 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) 90 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event)
91 { 91 {
92 updateScrollAnimator(); 92 updateScrollAnimator();
93 93
94 ScrollResult viewScrollResult(false); 94 ScrollResult viewScrollResult;
95 if (layoutViewport().isScrollable()) 95 if (layoutViewport().isScrollable())
96 viewScrollResult = layoutViewport().handleWheel(event); 96 viewScrollResult = layoutViewport().handleWheel(event);
97 97
98 // The visual viewport will only accept pixel scrolls. 98 // The visual viewport will only accept pixel scrolls.
99 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) 99 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent)
100 return viewScrollResult; 100 return viewScrollResult;
101 101
102 // Move the location by the negative of the remaining scroll delta. 102 // Move the location by the negative of the remaining scroll delta.
103 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); 103 DoublePoint oldOffset = visualViewport().scrollPositionDouble();
104 DoublePoint locationDelta; 104 DoublePoint locationDelta;
105 if (viewScrollResult.didScroll) { 105 if (viewScrollResult.didScroll()) {
106 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); 106 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY);
107 } else { 107 } else {
108 if (event.railsMode() != PlatformEvent::RailsModeVertical) 108 if (event.railsMode() != PlatformEvent::RailsModeVertical)
109 locationDelta.setX(-event.deltaX()); 109 locationDelta.setX(-event.deltaX());
110 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) 110 if (event.railsMode() != PlatformEvent::RailsModeHorizontal)
111 locationDelta.setY(-event.deltaY()); 111 locationDelta.setY(-event.deltaY());
112 } 112 }
113 113
114 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( 114 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e(
115 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); 115 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta));
116 visualViewport().scrollToOffsetWithoutAnimation(FloatPoint(targetPosition)); 116 visualViewport().scrollToOffsetWithoutAnimation(FloatPoint(targetPosition));
117 117
118 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); 118 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset);
119 if (!viewScrollResult.didScroll && usedLocationDelta == DoublePoint::zero()) 119 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( ))
120 return ScrollResult(false); 120 return ScrollResult();
121 121
122 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); 122 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta);
123 return ScrollResult(true, -unusedLocationDelta.width(), -unusedLocationDelta .height()); 123 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ;
124 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( );
125 return ScrollResult(didScrollX, didScrollY, -unusedLocationDelta.width(), -u nusedLocationDelta.height());
124 } 126 }
125 127
126 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) 128 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY)
127 { 129 {
128 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect 130 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect
129 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't 131 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't
130 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use 132 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use
131 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size 133 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size
132 // is always integer sized. 134 // is always integer sized.
133 135
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const 271 GraphicsLayer* RootFrameViewport::layerForHorizontalScrollbar() const
270 { 272 {
271 return layoutViewport().layerForHorizontalScrollbar(); 273 return layoutViewport().layerForHorizontalScrollbar();
272 } 274 }
273 275
274 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const 276 GraphicsLayer* RootFrameViewport::layerForVerticalScrollbar() const
275 { 277 {
276 return layoutViewport().layerForVerticalScrollbar(); 278 return layoutViewport().layerForVerticalScrollbar();
277 } 279 }
278 280
279 bool RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGran ularity granularity, float delta) 281 ScrollResultOneDimensional RootFrameViewport::userScroll(ScrollDirectionPhysical direction, ScrollGranularity granularity, float delta)
280 { 282 {
281 updateScrollAnimator(); 283 updateScrollAnimator();
282 284
283 ScrollbarOrientation orientation; 285 ScrollbarOrientation orientation;
284 286
285 if (direction == ScrollUp || direction == ScrollDown) 287 if (direction == ScrollUp || direction == ScrollDown)
286 orientation = VerticalScrollbar; 288 orientation = VerticalScrollbar;
287 else 289 else
288 orientation = HorizontalScrollbar; 290 orientation = HorizontalScrollbar;
289 291
290 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation)) 292 if (layoutViewport().userInputScrollable(orientation) && visualViewport().us erInputScrollable(orientation))
291 return ScrollableArea::userScroll(direction, granularity, delta); 293 return ScrollableArea::userScroll(direction, granularity, delta);
292 294
293 if (visualViewport().userInputScrollable(orientation)) 295 if (visualViewport().userInputScrollable(orientation))
294 return visualViewport().userScroll(direction, granularity, delta); 296 return visualViewport().userScroll(direction, granularity, delta);
295 297
296 if (layoutViewport().userInputScrollable(orientation)) 298 if (layoutViewport().userInputScrollable(orientation))
297 return layoutViewport().userScroll(direction, granularity, delta); 299 return layoutViewport().userScroll(direction, granularity, delta);
298 300
299 return false; 301 return ScrollResultOneDimensional(false, delta);
300 } 302 }
301 303
302 bool RootFrameViewport::scrollAnimatorEnabled() const 304 bool RootFrameViewport::scrollAnimatorEnabled() const
303 { 305 {
304 return layoutViewport().scrollAnimatorEnabled(); 306 return layoutViewport().scrollAnimatorEnabled();
305 } 307 }
306 308
307 HostWindow* RootFrameViewport::hostWindow() const 309 HostWindow* RootFrameViewport::hostWindow() const
308 { 310 {
309 return layoutViewport().hostWindow(); 311 return layoutViewport().hostWindow();
310 } 312 }
311 313
312 void RootFrameViewport::serviceScrollAnimations(double monotonicTime) 314 void RootFrameViewport::serviceScrollAnimations(double monotonicTime)
313 { 315 {
314 ScrollableArea::serviceScrollAnimations(monotonicTime); 316 ScrollableArea::serviceScrollAnimations(monotonicTime);
315 layoutViewport().serviceScrollAnimations(monotonicTime); 317 layoutViewport().serviceScrollAnimations(monotonicTime);
316 } 318 }
317 319
318 void RootFrameViewport::updateCompositorScrollAnimations() 320 void RootFrameViewport::updateCompositorScrollAnimations()
319 { 321 {
320 ScrollableArea::updateCompositorScrollAnimations(); 322 ScrollableArea::updateCompositorScrollAnimations();
321 layoutViewport().updateCompositorScrollAnimations(); 323 layoutViewport().updateCompositorScrollAnimations();
322 } 324 }
323 325
324 326
325 } // namespace blink 327 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/frame/RootFrameViewport.h ('k') | Source/core/frame/RootFrameViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698