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

Unified Diff: content/renderer/gpu/input_handler_proxy.cc

Issue 52663003: Remove all fling related stuff from the renderer assuming that browser side Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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 | « content/renderer/gpu/input_handler_proxy.h ('k') | content/renderer/gpu/input_handler_proxy_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/gpu/input_handler_proxy.cc
diff --git a/content/renderer/gpu/input_handler_proxy.cc b/content/renderer/gpu/input_handler_proxy.cc
index 77dd0f0af8472559f704120c5ad6618f4c2ec418..7dcf656bbd2569c7a6d75851c6a0d751c6b8c00c 100644
--- a/content/renderer/gpu/input_handler_proxy.cc
+++ b/content/renderer/gpu/input_handler_proxy.cc
@@ -8,7 +8,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "content/renderer/gpu/input_handler_proxy_client.h"
-#include "third_party/WebKit/public/platform/Platform.h"
+#include "third_party/WebKit/public/platform/WebFloatSize.h"
#include "third_party/WebKit/public/web/WebInputEvent.h"
#include "ui/events/latency_info.h"
@@ -60,10 +60,7 @@ InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler)
expect_pinch_update_end_(false),
#endif
gesture_scroll_on_impl_thread_(false),
- gesture_pinch_on_impl_thread_(false),
- fling_may_be_active_on_main_thread_(false),
- fling_overscrolled_horizontally_(false),
- fling_overscrolled_vertically_(false) {
+ gesture_pinch_on_impl_thread_(false) {
input_handler_->BindToClient(this);
}
@@ -208,22 +205,15 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
gfx::Point(gesture_event.x, gesture_event.y));
return DID_HANDLE;
} else if (event.type == WebInputEvent::GestureFlingStart) {
- const WebGestureEvent& gesture_event =
- *static_cast<const WebGestureEvent*>(&event);
- return HandleGestureFling(gesture_event);
+ NOTREACHED();
} else if (event.type == WebInputEvent::GestureFlingCancel) {
- if (CancelCurrentFling())
- return DID_HANDLE;
- else if (!fling_may_be_active_on_main_thread_)
- return DROP_EVENT;
+ NOTREACHED();
} else if (event.type == WebInputEvent::TouchStart) {
const WebTouchEvent& touch_event =
*static_cast<const WebTouchEvent*>(&event);
if (!input_handler_->HaveTouchEventHandlersAt(touch_event.touches[0]
.position))
return DROP_EVENT;
- } else if (WebInputEvent::isKeyboardEventType(event.type)) {
- CancelCurrentFling();
} else if (event.type == WebInputEvent::MouseMove) {
const WebMouseEvent& mouse_event =
*static_cast<const WebMouseEvent*>(&event);
@@ -234,229 +224,12 @@ InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent(
return DID_NOT_HANDLE;
}
-InputHandlerProxy::EventDisposition
-InputHandlerProxy::HandleGestureFling(
- const WebGestureEvent& gesture_event) {
- cc::InputHandler::ScrollStatus scroll_status;
-
- if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) {
- scroll_status = input_handler_->ScrollBegin(
- gfx::Point(gesture_event.x, gesture_event.y),
- cc::InputHandler::NonBubblingGesture);
- } else {
- if (!gesture_scroll_on_impl_thread_)
- scroll_status = cc::InputHandler::ScrollOnMainThread;
- else
- scroll_status = input_handler_->FlingScrollBegin();
- }
-
-#ifndef NDEBUG
- expect_scroll_update_end_ = false;
-#endif
-
- switch (scroll_status) {
- case cc::InputHandler::ScrollStarted: {
- if (gesture_event.sourceDevice == WebGestureEvent::Touchpad)
- input_handler_->ScrollEnd();
-
- fling_curve_.reset(client_->CreateFlingAnimationCurve(
- gesture_event.sourceDevice,
- WebFloatPoint(gesture_event.data.flingStart.velocityX,
- gesture_event.data.flingStart.velocityY),
- WebKit::WebSize()));
- fling_overscrolled_horizontally_ = false;
- fling_overscrolled_vertically_ = false;
- TRACE_EVENT_ASYNC_BEGIN0(
- "renderer",
- "InputHandlerProxy::HandleGestureFling::started",
- this);
- fling_parameters_.delta =
- WebFloatPoint(gesture_event.data.flingStart.velocityX,
- gesture_event.data.flingStart.velocityY);
- fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y);
- fling_parameters_.globalPoint =
- WebPoint(gesture_event.globalX, gesture_event.globalY);
- fling_parameters_.modifiers = gesture_event.modifiers;
- fling_parameters_.sourceDevice = gesture_event.sourceDevice;
- input_handler_->ScheduleAnimation();
- return DID_HANDLE;
- }
- case cc::InputHandler::ScrollOnMainThread: {
- TRACE_EVENT_INSTANT0("renderer",
- "InputHandlerProxy::HandleGestureFling::"
- "scroll_on_main_thread",
- TRACE_EVENT_SCOPE_THREAD);
- fling_may_be_active_on_main_thread_ = true;
- return DID_NOT_HANDLE;
- }
- case cc::InputHandler::ScrollIgnored: {
- TRACE_EVENT_INSTANT0(
- "renderer",
- "InputHandlerProxy::HandleGestureFling::ignored",
- TRACE_EVENT_SCOPE_THREAD);
- if (gesture_event.sourceDevice == WebGestureEvent::Touchpad) {
- // We still pass the curve to the main thread if there's nothing
- // scrollable, in case something
- // registers a handler before the curve is over.
- return DID_NOT_HANDLE;
- }
- return DROP_EVENT;
- }
- }
- return DID_NOT_HANDLE;
-}
-
void InputHandlerProxy::Animate(base::TimeTicks time) {
- if (!fling_curve_)
- return;
-
- double monotonic_time_sec = (time - base::TimeTicks()).InSecondsF();
- if (!fling_parameters_.startTime) {
- fling_parameters_.startTime = monotonic_time_sec;
- input_handler_->ScheduleAnimation();
- return;
- }
-
- if (fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime,
- this)) {
- input_handler_->ScheduleAnimation();
- } else {
- TRACE_EVENT_INSTANT0("renderer",
- "InputHandlerProxy::animate::flingOver",
- TRACE_EVENT_SCOPE_THREAD);
- CancelCurrentFling();
- }
-}
-
-void InputHandlerProxy::MainThreadHasStoppedFlinging() {
- fling_may_be_active_on_main_thread_ = false;
}
void InputHandlerProxy::DidOverscroll(const cc::DidOverscrollParams& params) {
DCHECK(client_);
- if (fling_curve_) {
- static const int kFlingOverscrollThreshold = 1;
- fling_overscrolled_horizontally_ |=
- std::abs(params.accumulated_overscroll.x()) >=
- kFlingOverscrollThreshold;
- fling_overscrolled_vertically_ |=
- std::abs(params.accumulated_overscroll.y()) >=
- kFlingOverscrollThreshold;
- }
-
client_->DidOverscroll(params);
}
-bool InputHandlerProxy::CancelCurrentFling() {
- bool had_fling_animation = fling_curve_;
- if (had_fling_animation &&
- fling_parameters_.sourceDevice == WebGestureEvent::Touchscreen) {
- input_handler_->ScrollEnd();
- TRACE_EVENT_ASYNC_END0(
- "renderer",
- "InputHandlerProxy::HandleGestureFling::started",
- this);
- }
-
- TRACE_EVENT_INSTANT1("renderer",
- "InputHandlerProxy::CancelCurrentFling",
- TRACE_EVENT_SCOPE_THREAD,
- "had_fling_animation",
- had_fling_animation);
- fling_curve_.reset();
- gesture_scroll_on_impl_thread_ = false;
- fling_parameters_ = WebKit::WebActiveWheelFlingParameters();
- return had_fling_animation;
-}
-
-bool InputHandlerProxy::TouchpadFlingScroll(
- const WebFloatSize& increment) {
- WebMouseWheelEvent synthetic_wheel;
- synthetic_wheel.type = WebInputEvent::MouseWheel;
- synthetic_wheel.deltaX = increment.width;
- synthetic_wheel.deltaY = increment.height;
- synthetic_wheel.hasPreciseScrollingDeltas = true;
- synthetic_wheel.x = fling_parameters_.point.x;
- synthetic_wheel.y = fling_parameters_.point.y;
- synthetic_wheel.globalX = fling_parameters_.globalPoint.x;
- synthetic_wheel.globalY = fling_parameters_.globalPoint.y;
- synthetic_wheel.modifiers = fling_parameters_.modifiers;
-
- InputHandlerProxy::EventDisposition disposition =
- HandleInputEvent(synthetic_wheel);
- switch (disposition) {
- case DID_HANDLE:
- return true;
- case DROP_EVENT:
- break;
- case DID_NOT_HANDLE:
- TRACE_EVENT_INSTANT0("renderer",
- "InputHandlerProxy::scrollBy::AbortFling",
- TRACE_EVENT_SCOPE_THREAD);
- // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the
- // main thread. In this case we need to schedule a commit and transfer the
- // fling curve over to the main thread and run the rest of the wheels from
- // there. This can happen when flinging a page that contains a scrollable
- // subarea that we can't scroll on the thread if the fling starts outside
- // the subarea but then is flung "under" the pointer.
- client_->TransferActiveWheelFlingAnimation(fling_parameters_);
- fling_may_be_active_on_main_thread_ = true;
- CancelCurrentFling();
- break;
- }
-
- return false;
-}
-
-static gfx::Vector2dF ToClientScrollIncrement(const WebFloatSize& increment) {
- return gfx::Vector2dF(-increment.width, -increment.height);
-}
-
-void InputHandlerProxy::scrollBy(const WebFloatSize& increment) {
- WebFloatSize clipped_increment;
- if (!fling_overscrolled_horizontally_)
- clipped_increment.width = increment.width;
- if (!fling_overscrolled_vertically_)
- clipped_increment.height = increment.height;
-
- if (clipped_increment == WebFloatSize())
- return;
-
- TRACE_EVENT2("renderer",
- "InputHandlerProxy::scrollBy",
- "x",
- clipped_increment.width,
- "y",
- clipped_increment.height);
-
- bool did_scroll = false;
-
- switch (fling_parameters_.sourceDevice) {
- case WebGestureEvent::Touchpad:
- did_scroll = TouchpadFlingScroll(clipped_increment);
- break;
- case WebGestureEvent::Touchscreen:
- clipped_increment = ToClientScrollIncrement(clipped_increment);
- did_scroll = input_handler_->ScrollBy(fling_parameters_.point,
- clipped_increment);
- break;
- }
-
- if (did_scroll) {
- fling_parameters_.cumulativeScroll.width += clipped_increment.width;
- fling_parameters_.cumulativeScroll.height += clipped_increment.height;
- }
-}
-
-void InputHandlerProxy::notifyCurrentFlingVelocity(
- const WebFloatSize& velocity) {
- TRACE_EVENT2("renderer",
- "InputHandlerProxy::notifyCurrentFlingVelocity",
- "vx",
- velocity.width,
- "vy",
- velocity.height);
- input_handler_->NotifyCurrentFlingVelocity(ToClientScrollIncrement(velocity));
-}
-
} // namespace content
« no previous file with comments | « content/renderer/gpu/input_handler_proxy.h ('k') | content/renderer/gpu/input_handler_proxy_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698