| 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 "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "cc/input/input_handler.h" | 10 #include "cc/input/input_handler.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 TRACE_EVENT1("input", | 87 TRACE_EVENT1("input", |
| 88 "InputHandlerManager::AddInputHandlerOnCompositorThread", | 88 "InputHandlerManager::AddInputHandlerOnCompositorThread", |
| 89 "result", "AddingRoute"); | 89 "result", "AddingRoute"); |
| 90 client_->DidAddInputHandler(routing_id, input_handler.get()); | 90 client_->DidAddInputHandler(routing_id, input_handler.get()); |
| 91 input_handlers_[routing_id] = | 91 input_handlers_[routing_id] = |
| 92 make_scoped_refptr(new InputHandlerWrapper(this, | 92 make_scoped_refptr(new InputHandlerWrapper(this, |
| 93 routing_id, main_loop, input_handler, render_view_impl)); | 93 routing_id, main_loop, input_handler, render_view_impl)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void InputHandlerManager::SetInputEventRewriter( |
| 97 int routing_id, |
| 98 scoped_ptr<InputEventRewriter> rewriter) { |
| 99 message_loop_proxy_->PostTask( |
| 100 FROM_HERE, |
| 101 base::Bind(&InputHandlerManager::SetInputEventRewriterOnCompositorThread, |
| 102 base::Unretained(this), |
| 103 routing_id, |
| 104 base::Passed(&rewriter))); |
| 105 } |
| 106 |
| 107 void InputHandlerManager::SetInputEventRewriterOnCompositorThread( |
| 108 int routing_id, |
| 109 scoped_ptr<InputEventRewriter> rewriter) { |
| 110 InputHandlerMap::iterator it = input_handlers_.find(routing_id); |
| 111 if (it != input_handlers_.end()) |
| 112 it->second->SetRewriter(rewriter.Pass()); |
| 113 } |
| 114 |
| 96 void InputHandlerManager::RemoveInputHandler(int routing_id) { | 115 void InputHandlerManager::RemoveInputHandler(int routing_id) { |
| 97 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 116 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 98 | 117 |
| 99 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); | 118 TRACE_EVENT0("input", "InputHandlerManager::RemoveInputHandler"); |
| 100 | 119 |
| 101 client_->DidRemoveInputHandler(routing_id); | 120 client_->DidRemoveInputHandler(routing_id); |
| 102 input_handlers_.erase(routing_id); | 121 input_handlers_.erase(routing_id); |
| 103 } | 122 } |
| 104 | 123 |
| 105 InputEventAckState InputHandlerManager::HandleInputEvent( | 124 InputEventAckState InputHandlerManager::HandleInputEvent( |
| 106 int routing_id, | 125 int routing_id, |
| 107 const WebInputEvent* input_event, | 126 const WebInputEvent* input_event, |
| 108 const ui::LatencyInfo& latency_info) { | 127 const ui::LatencyInfo& latency_info) { |
| 109 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); | 128 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); |
| 110 | 129 |
| 111 InputHandlerMap::iterator it = input_handlers_.find(routing_id); | 130 InputHandlerMap::iterator it = input_handlers_.find(routing_id); |
| 112 if (it == input_handlers_.end()) { | 131 if (it == input_handlers_.end()) { |
| 113 TRACE_EVENT1("input", "InputHandlerManager::HandleInputEvent", | 132 TRACE_EVENT1("input", "InputHandlerManager::HandleInputEvent", |
| 114 "result", "NoInputHandlerFound"); | 133 "result", "NoInputHandlerFound"); |
| 115 // Oops, we no longer have an interested input handler.. | 134 // Oops, we no longer have an interested input handler.. |
| 116 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; | 135 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 117 } | 136 } |
| 118 | 137 |
| 138 scoped_ptr<WebInputEvent> rewritten_event_owner; |
| 139 InputEventRewriter* rewriter = it->second->rewriter(); |
| 140 if (rewriter) { |
| 141 WebInputEvent* rewritten = rewriter->RewriteInputEvent(input_event); |
| 142 if (rewritten) { |
| 143 rewritten_event_owner.reset(rewritten); |
| 144 input_event = rewritten; |
| 145 } |
| 146 } |
| 147 |
| 119 InputHandlerProxy* proxy = it->second->input_handler_proxy(); | 148 InputHandlerProxy* proxy = it->second->input_handler_proxy(); |
| 120 return InputEventDispositionToAck( | 149 return InputEventDispositionToAck( |
| 121 proxy->HandleInputEventWithLatencyInfo(*input_event, latency_info)); | 150 proxy->HandleInputEventWithLatencyInfo(*input_event, latency_info)); |
| 122 } | 151 } |
| 123 | 152 |
| 124 void InputHandlerManager::DidOverscroll(int routing_id, | 153 void InputHandlerManager::DidOverscroll(int routing_id, |
| 125 const cc::DidOverscrollParams& params) { | 154 const cc::DidOverscrollParams& params) { |
| 126 client_->DidOverscroll(routing_id, params); | 155 client_->DidOverscroll(routing_id, params); |
| 127 } | 156 } |
| 128 | 157 |
| 129 | 158 |
| 130 | 159 |
| 131 } // namespace content | 160 } // namespace content |
| OLD | NEW |