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