Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/gpu/input_handler_manager.h" | 5 #include "content/renderer/gpu/input_handler_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "cc/input/input_handler.h" | 9 #include "cc/input/input_handler.h" |
| 10 #include "content/renderer/gpu/input_event_filter.h" | 10 #include "content/renderer/gpu/input_event_filter.h" |
| 11 #include "content/renderer/gpu/input_handler_wrapper.h" | 11 #include "content/renderer/gpu/input_handler_wrapper.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa rameters.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebActiveWheelFlingPa rameters.h" |
| 13 | 13 |
| 14 using WebKit::WebInputEvent; | 14 using WebKit::WebInputEvent; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 namespace { | |
| 19 | |
| 20 InputEventAckState InputEventDispositionToAck( | |
| 21 InputHandlerProxy::EventDisposition disposition) { | |
| 22 switch (disposition) { | |
| 23 case InputHandlerProxy::DidHandle: | |
| 24 return INPUT_EVENT_ACK_STATE_CONSUMED; | |
| 25 case InputHandlerProxy::DidNotHandle: | |
| 26 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | |
| 27 case InputHandlerProxy::DropEvent: | |
| 28 return INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | |
| 29 default: | |
|
jamesr
2013/06/03 20:45:59
i would omit the default: so the compiler yells at
jdduke (slow)
2013/06/03 21:40:42
I like it, done.
| |
| 30 NOTREACHED(); | |
| 31 return INPUT_EVENT_ACK_STATE_UNKNOWN; | |
| 32 } | |
| 33 } | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 18 InputHandlerManager::InputHandlerManager( | 37 InputHandlerManager::InputHandlerManager( |
| 19 IPC::Listener* main_listener, | 38 IPC::Listener* main_listener, |
| 20 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy) | 39 const scoped_refptr<base::MessageLoopProxy>& message_loop_proxy) |
| 21 : message_loop_proxy_(message_loop_proxy) { | 40 : message_loop_proxy_(message_loop_proxy) { |
| 22 filter_ = | 41 filter_ = |
| 23 new InputEventFilter(main_listener, | 42 new InputEventFilter(main_listener, |
| 24 message_loop_proxy, | 43 message_loop_proxy, |
| 25 base::Bind(&InputHandlerManager::HandleInputEvent, | 44 base::Bind(&InputHandlerManager::HandleInputEvent, |
| 26 base::Unretained(this))); | 45 base::Unretained(this))); |
| 27 } | 46 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 | 93 |
| 75 void InputHandlerManager::RemoveInputHandler(int routing_id) { | 94 void InputHandlerManager::RemoveInputHandler(int routing_id) { |
| 76 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 95 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 77 | 96 |
| 78 TRACE_EVENT0("InputHandlerManager::RemoveInputHandler", "RemovingRoute"); | 97 TRACE_EVENT0("InputHandlerManager::RemoveInputHandler", "RemovingRoute"); |
| 79 | 98 |
| 80 filter_->RemoveRoute(routing_id); | 99 filter_->RemoveRoute(routing_id); |
| 81 input_handlers_.erase(routing_id); | 100 input_handlers_.erase(routing_id); |
| 82 } | 101 } |
| 83 | 102 |
| 84 void InputHandlerManager::HandleInputEvent( | 103 InputEventAckState InputHandlerManager::HandleInputEvent( |
| 85 int routing_id, | 104 int routing_id, |
| 86 const WebInputEvent* input_event) { | 105 const WebInputEvent* input_event) { |
| 87 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 106 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 88 | 107 |
| 89 InputHandlerMap::iterator it = input_handlers_.find(routing_id); | 108 InputHandlerMap::iterator it = input_handlers_.find(routing_id); |
| 90 if (it == input_handlers_.end()) { | 109 if (it == input_handlers_.end()) { |
| 91 TRACE_EVENT0("InputHandlerManager::HandleInputEvent", | 110 TRACE_EVENT0("InputHandlerManager::HandleInputEvent", |
| 92 "NoInputHandlerFound"); | 111 "NoInputHandlerFound"); |
| 93 // Oops, we no longer have an interested input handler.. | 112 // Oops, we no longer have an interested input handler.. |
| 94 filter_->DidNotHandleInputEvent(true); | 113 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 95 return; | |
| 96 } | 114 } |
| 97 | 115 |
| 98 it->second->input_handler_proxy()->HandleInputEvent(*input_event); | 116 return InputEventDispositionToAck( |
| 117 it->second->input_handler_proxy()->HandleInputEvent(*input_event)); | |
| 99 } | 118 } |
| 100 | 119 |
| 101 } // namespace content | 120 } // namespace content |
| OLD | NEW |