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

Unified Diff: blimp/client/input/blimp_input_manager.cc

Issue 1430623004: blimp: Add support for input handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years 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 | « blimp/client/input/blimp_input_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: blimp/client/input/blimp_input_manager.cc
diff --git a/blimp/client/input/blimp_input_manager.cc b/blimp/client/input/blimp_input_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5544ba91a8bb2b3db6f7d62ed0cd6855c8f24f09
--- /dev/null
+++ b/blimp/client/input/blimp_input_manager.cc
@@ -0,0 +1,182 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "blimp/client/input/blimp_input_manager.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "ui/events/blink/blink_event_util.h"
+#include "ui/events/gesture_detection/gesture_provider_config_helper.h"
+#include "ui/events/gestures/blink/web_gesture_curve_impl.h"
+
+namespace blimp {
+
+scoped_ptr<BlimpInputManager> BlimpInputManager::Create(
+ BlimpInputManagerClient* client,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ const base::WeakPtr<cc::InputHandler>& input_handler) {
+ return make_scoped_ptr(new BlimpInputManager(client,
+ main_task_runner,
+ compositor_task_runner,
+ input_handler));
+}
+
+BlimpInputManager::BlimpInputManager(
+ BlimpInputManagerClient* client,
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
+ scoped_refptr<base::SingleThreadTaskRunner> compositor_task_runner,
+ const base::WeakPtr<cc::InputHandler>& input_handler)
+ : client_(client),
+ main_task_runner_(main_task_runner),
+ compositor_task_runner_(compositor_task_runner),
+ gesture_provider_(ui::GetGestureProviderConfig(
+ ui::GestureProviderConfigType::CURRENT_PLATFORM),
+ this) {
+ DCHECK(IsMainThread());
+ DCHECK(client_);
+ compositor_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &BlimpInputManager::CreateInputHandlerProxyOnCompositorThread,
+ base::Unretained(this), input_handler));
David Trainor- moved to gerrit 2015/12/02 03:49:06 Are we sure we want unretained for this? Unretain
Khushal 2015/12/03 11:31:38 You're right, its not safe to use Unretained for t
Khushal 2015/12/03 12:44:30 Looking at this again, we'll still need to post a
+}
+
+BlimpInputManager::~BlimpInputManager() {
+ DCHECK(IsMainThread());
+}
+
+bool BlimpInputManager::OnTouchEvent(const ui::MotionEvent& motion_event) {
+ DCHECK(IsMainThread());
+
+ ui::FilteredGestureProvider::TouchHandlingResult result =
+ gesture_provider_.OnTouchEvent(motion_event);
+ if (!result.succeeded)
+ return false;
+
+ blink::WebTouchEvent touch =
+ ui::CreateWebTouchEventFromMotionEvent(motion_event,
+ result.did_generate_scroll);
+
+ // Touch events are queued in the Gesture Provider until acknowledged to
+ // allow them to be consumed by the touch event handlers in blink which can
+ // prevent-default on the event. Since we currently do not support touch
+ // handlers the event is always acknowledged as not consumed.
+ gesture_provider_.OnTouchEventAck(touch.uniqueTouchEventId, false);
+
+ return true;
+}
+
+void BlimpInputManager::WillShutdown() {
+ DCHECK(IsCompositorThread());
+
+ input_handler_proxy_.reset();
+}
+
+void BlimpInputManager::TransferActiveWheelFlingAnimation(
+ const blink::WebActiveWheelFlingParameters& params) {
+ DCHECK(IsCompositorThread());
+
+ NOTIMPLEMENTED()<<
David Trainor- moved to gerrit 2015/12/02 03:49:06 space between () and <<?
Khushal 2015/12/03 11:31:38 Done.
+ "Transferring Fling Animations to the engine is not supported";
+}
+
+blink::WebGestureCurve* BlimpInputManager::CreateFlingAnimationCurve(
+ blink::WebGestureDevice device_source,
+ const blink::WebFloatPoint& velocity,
+ const blink::WebSize& cumulative_scroll) {
+ DCHECK(IsCompositorThread());
+
+ return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
+ gfx::Vector2dF(velocity.x, velocity.y),
+ gfx::Vector2dF(cumulative_scroll.width,
+ cumulative_scroll.height),
+ false /* on_main_thread */).release();
+}
+
+void BlimpInputManager::DidOverscroll(
+ const gfx::Vector2dF& accumulated_overscroll,
+ const gfx::Vector2dF& latest_overscroll_delta,
+ const gfx::Vector2dF& current_fling_velocity,
+ const gfx::PointF& causal_event_viewport_point) {
+ DCHECK(IsCompositorThread());
+}
+
+void BlimpInputManager::DidStopFlinging() {
+ DCHECK(IsCompositorThread());
+}
+
+void BlimpInputManager::DidAnimateForInput() {
+ DCHECK(IsCompositorThread());
+}
+
+void BlimpInputManager::OnGestureEvent(const ui::GestureEventData& gesture) {
+ DCHECK(IsMainThread());
+
+ blink::WebGestureEvent web_gesture =
+ ui::CreateWebGestureEventFromGestureEventData(gesture);
+ // TODO(jdduke): Remove this workaround after Android fixes UiAutomator to
+ // stop providing shift meta values to synthetic MotionEvents. This prevents
+ // unintended shift+click interpretation of all accessibility clicks.
+ // See crbug.com/443247.
+ if (web_gesture.type == blink::WebInputEvent::GestureTap &&
+ web_gesture.modifiers == blink::WebInputEvent::ShiftKey) {
+ web_gesture.modifiers = 0;
+ }
+
+ compositor_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &BlimpInputManager::HandleWebInputEventOnCompositorThread,
+ base::Unretained(this), web_gesture));
+}
+
+void BlimpInputManager::CreateInputHandlerProxyOnCompositorThread(
+ const base::WeakPtr<cc::InputHandler>& input_handler) {
+ DCHECK(IsCompositorThread());
+
+ // The input_handler might have been destroyed at this point.
+ if (!input_handler)
+ return;
+
+ DCHECK(!input_handler_proxy_);
+ input_handler_proxy_ =
+ make_scoped_ptr(new ui::InputHandlerProxy(input_handler.get(), this));
+}
+
+void BlimpInputManager::HandleWebInputEventOnCompositorThread(
+ const blink::WebInputEvent& input_event) {
+ DCHECK(IsCompositorThread());
+
+ // We might not have the input handler proxy anymore.
+ if (!input_handler_proxy_)
+ return;
+
+ ui::InputHandlerProxy::EventDisposition disposition =
+ input_handler_proxy_->HandleInputEvent(input_event);
+
+ if (disposition == ui::InputHandlerProxy::DID_NOT_HANDLE) {
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&BlimpInputManager::SendWebInputEvent,
+ base::Unretained(this), input_event));
+ }
+}
+
+void BlimpInputManager::SendWebInputEvent(
+ const blink::WebInputEvent& input_event) {
+ DCHECK(IsMainThread());
+
+ client_->SendWebInputEvent(input_event);
+}
+
+bool BlimpInputManager::IsMainThread() const {
+ return main_task_runner_->BelongsToCurrentThread();
+}
+
+bool BlimpInputManager::IsCompositorThread() const {
+ return compositor_task_runner_->BelongsToCurrentThread();
+}
+
+} // namespace blimp
« no previous file with comments | « blimp/client/input/blimp_input_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698