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 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::HandleWebInputEvent( | |
37 scoped_ptr<blink::WebInputEvent> input_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(*input_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_NOT_HANDLE: | |
55 consumed = false; | |
56 break; | |
57 } | |
58 | |
59 main_task_runner_->PostTask( | |
60 FROM_HERE, | |
61 base::Bind(&BlimpInputManager::DidHandleWebInputEvent, | |
62 input_manager_weak_ptr_, | |
63 base::Passed(&input_event), consumed)); | |
64 } | |
65 | |
66 void BlimpInputHandlerWrapper::WillShutdown() { | |
67 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
68 | |
69 input_handler_proxy_.reset(); | |
70 } | |
71 | |
72 void BlimpInputHandlerWrapper::TransferActiveWheelFlingAnimation( | |
73 const blink::WebActiveWheelFlingParameters& params) { | |
74 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
75 | |
76 NOTIMPLEMENTED() << | |
77 "Transferring Fling Animations to the engine is not supported"; | |
78 } | |
79 | |
80 blink::WebGestureCurve* BlimpInputHandlerWrapper::CreateFlingAnimationCurve( | |
81 blink::WebGestureDevice device_source, | |
82 const blink::WebFloatPoint& velocity, | |
83 const blink::WebSize& cumulative_scroll) { | |
84 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
85 | |
86 return ui::WebGestureCurveImpl::CreateFromDefaultPlatformCurve( | |
87 gfx::Vector2dF(velocity.x, velocity.y), | |
88 gfx::Vector2dF(cumulative_scroll.width, | |
89 cumulative_scroll.height), | |
90 false /* on_main_thread */).release(); | |
91 } | |
92 | |
93 void BlimpInputHandlerWrapper::DidOverscroll( | |
94 const gfx::Vector2dF& accumulated_overscroll, | |
95 const gfx::Vector2dF& latest_overscroll_delta, | |
96 const gfx::Vector2dF& current_fling_velocity, | |
97 const gfx::PointF& causal_event_viewport_point) { | |
98 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
99 } | |
100 | |
101 void BlimpInputHandlerWrapper::DidStopFlinging() { | |
102 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
103 } | |
104 | |
105 void BlimpInputHandlerWrapper::DidAnimateForInput() { | |
106 DCHECK(compositor_thread_checker_.CalledOnValidThread()); | |
107 } | |
108 | |
109 } // namespace client | |
110 } // namespace blimp | |
OLD | NEW |