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

Unified Diff: ui/events/blink/input_handler_proxy.cc

Issue 2767213003: First Implementation of Snapped Points
Patch Set: Rebase and format Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/android/scroller.cc ('k') | ui/events/gesture_curve.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/blink/input_handler_proxy.cc
diff --git a/ui/events/blink/input_handler_proxy.cc b/ui/events/blink/input_handler_proxy.cc
index 6ff1983d7139c16be4b7604726a8c80db40dea7f..1522746a3a1133057a110da432b1115f2270cd5f 100644
--- a/ui/events/blink/input_handler_proxy.cc
+++ b/ui/events/blink/input_handler_proxy.cc
@@ -925,6 +925,9 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd(
DCHECK(expect_scroll_update_end_);
expect_scroll_update_end_ = false;
#endif
+ input_handler_->SnapAfterGestureScroll(
+ gfx::Point(gesture_event.x, gesture_event.y));
+
if (ShouldAnimate(gesture_event.data.scroll_end.delta_units !=
blink::WebGestureEvent::ScrollUnits::kPixels)) {
// Do nothing if the scroll is being animated; the scroll animation will
@@ -933,6 +936,7 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd(
cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event);
input_handler_->ScrollEnd(&scroll_state);
}
+
if (!gesture_scroll_on_impl_thread_)
return DID_NOT_HANDLE;
@@ -1009,7 +1013,10 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart(
WebPoint(gesture_event.global_x, gesture_event.global_y);
fling_parameters_.modifiers = gesture_event.GetModifiers();
fling_parameters_.source_device = gesture_event.source_device;
- RequestAnimation();
+ if (AdjustFlingCurveToSnapPoints())
+ RequestAnimation();
+ else
+ fling_curve_.reset();
return DID_HANDLE;
}
case cc::InputHandler::SCROLL_UNKNOWN:
@@ -1291,6 +1298,14 @@ void InputHandlerProxy::ExtendBoostedFlingTimeout(
last_fling_boost_event_ = event;
}
+bool InputHandlerProxy::AdjustFlingCurveToSnapPoints() {
+ gfx::Vector2dF original_offset;
+ fling_curve_->ComputeTotalScrollOffset(original_offset);
+ gfx::Vector2dF snapped_offset;
+ input_handler_->FindSnappedOffset(&snapped_offset, original_offset);
+ return fling_curve_->ResetCurveBySnappedOffset(snapped_offset);
+}
+
void InputHandlerProxy::Animate(base::TimeTicks time) {
// If using synchronous animate, then only expect Animate attempts started by
// the synchronous system. Don't let the InputHandler try to Animate also.
« no previous file with comments | « ui/events/android/scroller.cc ('k') | ui/events/gesture_curve.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698