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

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

Issue 1195803003: Report accurate Overscroll on handleWheel. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 | « no previous file | Source/core/frame/Settings.in » ('j') | Source/core/frame/Settings.in » ('J')
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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 89
90 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const 90 ScrollBehavior RootFrameViewport::scrollBehaviorStyle() const
91 { 91 {
92 return layoutViewport().scrollBehaviorStyle(); 92 return layoutViewport().scrollBehaviorStyle();
93 } 93 }
94 94
95 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event) 95 ScrollResult RootFrameViewport::handleWheel(const PlatformWheelEvent& event)
96 { 96 {
97 updateScrollAnimator(); 97 updateScrollAnimator();
98 98
99 ScrollResult viewScrollResult; 99 ScrollResult viewScrollResult = layoutViewport().handleWheel(event);
100 if (layoutViewport().isScrollable())
101 viewScrollResult = layoutViewport().handleWheel(event);
102 100
103 // The visual viewport will only accept pixel scrolls. 101 // The visual viewport will only accept pixel scrolls.
104 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent) 102 if (!event.canScroll() || event.granularity() == ScrollByPageWheelEvent)
105 return viewScrollResult; 103 return viewScrollResult;
106 104
107 // Move the location by the negative of the remaining scroll delta. 105 // Move the location by the negative of the remaining scroll delta.
bokan 2015/06/25 17:50:31 Nit: Can you elaborate on this comment so that fut
MuVen 2015/06/26 09:55:44 Done.
108 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); 106 DoublePoint oldOffset = visualViewport().scrollPositionDouble();
109 DoublePoint locationDelta; 107 DoublePoint locationDelta;
110 if (viewScrollResult.didScroll()) { 108 if (viewScrollResult.didScroll()) {
111 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); 109 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY);
112 } else { 110 } else {
113 if (event.railsMode() != PlatformEvent::RailsModeVertical) 111 if (event.railsMode() != PlatformEvent::RailsModeVertical)
114 locationDelta.setX(-event.deltaX()); 112 locationDelta.setX(-event.deltaX());
115 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) 113 if (event.railsMode() != PlatformEvent::RailsModeHorizontal)
116 locationDelta.setY(-event.deltaY()); 114 locationDelta.setY(-event.deltaY());
117 } 115 }
118 116
119 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e( 117 DoublePoint targetPosition = visualViewport().adjustScrollPositionWithinRang e(
120 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); 118 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta));
121 visualViewport().setScrollPosition(targetPosition, UserScroll); 119 visualViewport().setScrollPosition(targetPosition, UserScroll);
122
123 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); 120 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset);
124 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( )) 121 bool didScrollX = viewScrollResult.didScrollX || usedLocationDelta.x();
125 return ScrollResult(); 122 bool didScrollY = viewScrollResult.didScrollY || usedLocationDelta.y();
126 123 return ScrollResult(didScrollX, didScrollY, viewScrollResult.unusedScrollDel taX - usedLocationDelta.x(), viewScrollResult.unusedScrollDeltaY - usedLocationD elta.y());
bokan 2015/06/25 17:50:31 Is this working as expected? AFAICT, the unusedScr
MuVen 2015/06/26 09:55:44 You are right on this. i was negating the unusedDe
127 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta);
128 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ;
129 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( );
130 return ScrollResult(didScrollX, didScrollY, -unusedLocationDelta.width(), -u nusedLocationDelta.height());
131 } 124 }
132 125
133 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) 126 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY)
134 { 127 {
135 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect 128 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect
136 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't 129 // the pinch viewport with the scrollbar-excluded frameView content rect. Ho wever, we don't
137 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use 130 // use visibleContentRect directly since it floors the scroll position. Inst ead, we use
138 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size 131 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size
139 // is always integer sized. 132 // is always integer sized.
140 133
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 316 }
324 317
325 void RootFrameViewport::updateCompositorScrollAnimations() 318 void RootFrameViewport::updateCompositorScrollAnimations()
326 { 319 {
327 ScrollableArea::updateCompositorScrollAnimations(); 320 ScrollableArea::updateCompositorScrollAnimations();
328 layoutViewport().updateCompositorScrollAnimations(); 321 layoutViewport().updateCompositorScrollAnimations();
329 } 322 }
330 323
331 324
332 } // namespace blink 325 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | Source/core/frame/Settings.in » ('j') | Source/core/frame/Settings.in » ('J')

Powered by Google App Engine
This is Rietveld 408576698