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

Side by Side Diff: ui/events/blink/input_scroll_elasticity_controller.cc

Issue 1749343004: Implement Wheel Gesture Scrolling on OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/blink/input_scroll_elasticity_controller.h" 5 #include "ui/events/blink/input_scroll_elasticity_controller.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 blink::WebMouseWheelEvent::PhaseEnded) { 160 blink::WebMouseWheelEvent::PhaseEnded) {
161 EnterStateInactive(); 161 EnterStateInactive();
162 } 162 }
163 case kStateMomentumAnimated: 163 case kStateMomentumAnimated:
164 // The PhaseMayBegin and PhaseBegan cases are handled at the top of the 164 // The PhaseMayBegin and PhaseBegan cases are handled at the top of the
165 // function. 165 // function.
166 break; 166 break;
167 } 167 }
168 } 168 }
169 169
170 void InputScrollElasticityController::ObserveGestureEventAndResult(
171 const blink::WebGestureEvent& gesture_event,
172 const cc::InputHandlerScrollResult& scroll_result) {
173 base::TimeTicks event_timestamp =
174 base::TimeTicks() +
175 base::TimeDelta::FromSecondsD(gesture_event.timeStampSeconds);
176
177 switch (gesture_event.type) {
tdresser 2016/03/08 14:28:53 Considering ordering this switch Begin, Update, En
dtapuska 2016/03/08 20:31:49 Done.
178 case blink::WebInputEvent::GestureScrollBegin: {
179 if (gesture_event.data.scrollBegin.synthetic)
180 return;
181 if (gesture_event.data.scrollBegin.inertial) {
182 if (state_ == kStateInactive)
183 state_ = kStateMomentumScroll;
184 } else {
185 scroll_velocity = gfx::Vector2dF();
186 last_scroll_event_timestamp_ = base::TimeTicks();
187 state_ = kStateActiveScroll;
188 pending_overscroll_delta_ = gfx::Vector2dF();
189 }
190 break;
191 }
192 case blink::WebInputEvent::GestureScrollEnd: {
193 if (gesture_event.data.scrollEnd.synthetic)
194 return;
195 switch (state_) {
196 case kStateMomentumAnimated:
197 case kStateInactive:
198 break;
199 case kStateActiveScroll:
200 case kStateMomentumScroll:
201 if (helper_->StretchAmount().IsZero()) {
202 EnterStateInactive();
203 } else {
204 EnterStateMomentumAnimated(event_timestamp);
205 }
206 break;
207 }
208 break;
209 }
210 case blink::WebInputEvent::GestureScrollUpdate: {
211 gfx::Vector2dF event_delta(-gesture_event.data.scrollUpdate.deltaX,
212 -gesture_event.data.scrollUpdate.deltaY);
213 switch (state_) {
214 case kStateMomentumAnimated:
215 case kStateInactive:
216 break;
217 case kStateActiveScroll:
218 case kStateMomentumScroll:
219 UpdateVelocity(event_delta, event_timestamp);
220 Overscroll(event_delta, scroll_result.unused_scroll_delta);
221 if (gesture_event.data.scrollUpdate.inertial &&
222 !helper_->StretchAmount().IsZero()) {
223 EnterStateMomentumAnimated(event_timestamp);
224 }
225 break;
226 }
227 break;
228 }
229 default:
230 break;
231 }
232 }
233
170 void InputScrollElasticityController::UpdateVelocity( 234 void InputScrollElasticityController::UpdateVelocity(
171 const gfx::Vector2dF& event_delta, 235 const gfx::Vector2dF& event_delta,
172 const base::TimeTicks& event_timestamp) { 236 const base::TimeTicks& event_timestamp) {
173 float time_delta = 237 float time_delta =
174 (event_timestamp - last_scroll_event_timestamp_).InSecondsF(); 238 (event_timestamp - last_scroll_event_timestamp_).InSecondsF();
175 if (time_delta < kScrollVelocityZeroingTimeout && time_delta > 0) { 239 if (time_delta < kScrollVelocityZeroingTimeout && time_delta > 0) {
176 scroll_velocity = gfx::Vector2dF(event_delta.x() / time_delta, 240 scroll_velocity = gfx::Vector2dF(event_delta.x() / time_delta,
177 event_delta.y() / time_delta); 241 event_delta.y() / time_delta);
178 } else { 242 } else {
179 scroll_velocity = gfx::Vector2dF(); 243 scroll_velocity = gfx::Vector2dF();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 break; 473 break;
410 default: 474 default:
411 // These cases should not be hit because the stretch must be zero in the 475 // These cases should not be hit because the stretch must be zero in the
412 // Inactive and MomentumScroll states. 476 // Inactive and MomentumScroll states.
413 NOTREACHED(); 477 NOTREACHED();
414 break; 478 break;
415 } 479 }
416 } 480 }
417 481
418 } // namespace ui 482 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698