OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "blimp/client/input/blimp_input_handler_wrapper.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "base/logging.h" |
| 10 #include "blimp/client/input/blimp_input_manager.h" |
| 11 #include "ui/events/gestures/blink/web_gesture_curve_impl.h" |
| 12 |
| 13 namespace blimp { |
| 14 |
| 15 BlimpInputHandlerWrapper::BlimpInputHandlerWrapper( |
| 16 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 17 const base::WeakPtr<BlimpInputManager> input_manager_weak_ptr, |
| 18 cc::InputHandler* input_handler) |
| 19 : main_task_runner_(main_task_runner), |
| 20 input_manager_weak_ptr_(input_manager_weak_ptr) { |
| 21 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 22 DCHECK(input_handler); |
| 23 input_handler_proxy_.reset( |
| 24 new ui::InputHandlerProxy(input_handler, this)); |
| 25 } |
| 26 |
| 27 BlimpInputHandlerWrapper::~BlimpInputHandlerWrapper() { |
| 28 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 29 |
| 30 // The input handler proxy must have been shutdown by the cc::InputHandler |
| 31 // before the InputHandlerWrapper is destroyed. |
| 32 DCHECK(!input_handler_proxy_); |
| 33 } |
| 34 |
| 35 void BlimpInputHandlerWrapper::HandleWebInputEvent( |
| 36 const blink::WebInputEvent& input_event) { |
| 37 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 38 |
| 39 // We might not have the input handler proxy anymore. |
| 40 if (!input_handler_proxy_) |
| 41 return; |
| 42 |
| 43 ui::InputHandlerProxy::EventDisposition disposition = |
| 44 input_handler_proxy_->HandleInputEvent(input_event); |
| 45 |
| 46 bool consumed = disposition == ui::InputHandlerProxy::DID_NOT_HANDLE; |
| 47 |
| 48 main_task_runner_->PostTask( |
| 49 FROM_HERE, |
| 50 base::Bind(&BlimpInputManager::DidHandleWebInputEvent, |
| 51 input_manager_weak_ptr_, input_event, consumed)); |
| 52 } |
| 53 |
| 54 void BlimpInputHandlerWrapper::WillShutdown() { |
| 55 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 56 |
| 57 input_handler_proxy_.reset(); |
| 58 } |
| 59 |
| 60 void BlimpInputHandlerWrapper::TransferActiveWheelFlingAnimation( |
| 61 const blink::WebActiveWheelFlingParameters& params) { |
| 62 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 63 |
| 64 NOTIMPLEMENTED() << |
| 65 "Transferring Fling Animations to the engine is not supported"; |
| 66 } |
| 67 |
| 68 blink::WebGestureCurve* BlimpInputHandlerWrapper::CreateFlingAnimationCurve( |
| 69 blink::WebGestureDevice device_source, |
| 70 const blink::WebFloatPoint& velocity, |
| 71 const blink::WebSize& cumulative_scroll) { |
| 72 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 73 |
| 74 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( |
| 75 gfx::Vector2dF(velocity.x, velocity.y), |
| 76 gfx::Vector2dF(cumulative_scroll.width, |
| 77 cumulative_scroll.height), |
| 78 false /* on_main_thread */).release(); |
| 79 } |
| 80 |
| 81 void BlimpInputHandlerWrapper::DidOverscroll( |
| 82 const gfx::Vector2dF& accumulated_overscroll, |
| 83 const gfx::Vector2dF& latest_overscroll_delta, |
| 84 const gfx::Vector2dF& current_fling_velocity, |
| 85 const gfx::PointF& causal_event_viewport_point) { |
| 86 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 87 } |
| 88 |
| 89 void BlimpInputHandlerWrapper::DidStopFlinging() { |
| 90 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 91 } |
| 92 |
| 93 void BlimpInputHandlerWrapper::DidAnimateForInput() { |
| 94 DCHECK(compositor_thread_checker_.CalledOnValidThread()); |
| 95 } |
| 96 |
| 97 } // namespace blimp |
OLD | NEW |