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

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: fixed unittest failures Created 5 years, 5 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/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 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 // TODO(sataya.m) : The delta in PlatformWheelEvent is negative when scrolli ng the
106 // wheel towards the user, so negate it to get the scroll delta that should be applied
107 // to the page. unusedScrollDelta computed in the ScrollResult is also negat ive. Say
108 // there is WheelEvent({0, -10} and page scroll by 2px and unusedScrollDelta computed
109 // is {0, -8}. Due to which we have to negate the unusedScrollDelta to obtai n the expected
110 // animation.Please address http://crbug.com/504389.
108 DoublePoint oldOffset = visualViewport().scrollPositionDouble(); 111 DoublePoint oldOffset = visualViewport().scrollPositionDouble();
109 DoublePoint locationDelta; 112 DoublePoint locationDelta;
110 if (viewScrollResult.didScroll()) { 113 if (viewScrollResult.didScroll()) {
111 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY); 114 locationDelta = -DoublePoint(viewScrollResult.unusedScrollDeltaX, viewSc rollResult.unusedScrollDeltaY);
112 } else { 115 } else {
113 if (event.railsMode() != PlatformEvent::RailsModeVertical) 116 if (event.railsMode() != PlatformEvent::RailsModeVertical)
114 locationDelta.setX(-event.deltaX()); 117 locationDelta.setX(-event.deltaX());
115 if (event.railsMode() != PlatformEvent::RailsModeHorizontal) 118 if (event.railsMode() != PlatformEvent::RailsModeHorizontal)
116 locationDelta.setY(-event.deltaY()); 119 locationDelta.setY(-event.deltaY());
117 } 120 }
118 121
119 DoublePoint targetPosition = visualViewport().clampScrollPosition( 122 DoublePoint targetPosition = visualViewport().clampScrollPosition(
120 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta)); 123 visualViewport().scrollPositionDouble() + toDoubleSize(locationDelta));
121 visualViewport().setScrollPosition(targetPosition, UserScroll); 124 visualViewport().setScrollPosition(targetPosition, UserScroll);
122 125
123 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset); 126 DoublePoint usedLocationDelta(visualViewport().scrollPositionDouble() - oldO ffset);
124 if (!viewScrollResult.didScroll() && usedLocationDelta == DoublePoint::zero( ))
125 return ScrollResult();
126 127
127 DoubleSize unusedLocationDelta(locationDelta - usedLocationDelta); 128 bool didScrollX = viewScrollResult.didScrollX || usedLocationDelta.x();
128 bool didScrollX = viewScrollResult.didScrollX || unusedLocationDelta.width() ; 129 bool didScrollY = viewScrollResult.didScrollY || usedLocationDelta.y();
129 bool didScrollY = viewScrollResult.didScrollY || unusedLocationDelta.height( ); 130 return ScrollResult(didScrollX, didScrollY, -viewScrollResult.unusedScrollDe ltaX - usedLocationDelta.x(), -viewScrollResult.unusedScrollDeltaY - usedLocatio nDelta.y());
130 return ScrollResult(didScrollX, didScrollY, -unusedLocationDelta.width(), -u nusedLocationDelta.height());
131 } 131 }
132 132
133 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY) 133 LayoutRect RootFrameViewport::scrollIntoView(const LayoutRect& rectInContent, co nst ScrollAlignment& alignX, const ScrollAlignment& alignY)
134 { 134 {
135 // We want to move the rect into the viewport that excludes the scrollbars s o we intersect 135 // 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 136 // 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 137 // 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 138 // FrameView::scrollPositionDouble and construct a LayoutRect from that (the FrameView size
139 // is always integer sized. 139 // is always integer sized.
140 140
(...skipping 182 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 | « no previous file | Source/core/frame/RootFrameViewportTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698