Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Side by Side Diff: content/browser/renderer_host/input/input_router_impl.cc

Issue 1440923002: Convert the coordinates in WebInputEvent To Viewport in InputRouter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/renderer_host/input/input_router_impl.h" 5 #include "content/browser/renderer_host/input/input_router_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "content/browser/renderer_host/input/gesture_event_queue.h" 13 #include "content/browser/renderer_host/input/gesture_event_queue.h"
14 #include "content/browser/renderer_host/input/input_ack_handler.h" 14 #include "content/browser/renderer_host/input/input_ack_handler.h"
15 #include "content/browser/renderer_host/input/input_router_client.h" 15 #include "content/browser/renderer_host/input/input_router_client.h"
16 #include "content/browser/renderer_host/input/touch_event_queue.h" 16 #include "content/browser/renderer_host/input/touch_event_queue.h"
17 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h" 17 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h"
18 #include "content/browser/renderer_host/input/web_input_event_util.h"
18 #include "content/common/content_constants_internal.h" 19 #include "content/common/content_constants_internal.h"
19 #include "content/common/edit_command.h" 20 #include "content/common/edit_command.h"
20 #include "content/common/input/input_event_ack_state.h" 21 #include "content/common/input/input_event_ack_state.h"
21 #include "content/common/input/touch_action.h" 22 #include "content/common/input/touch_action.h"
22 #include "content/common/input/web_touch_event_traits.h" 23 #include "content/common/input/web_touch_event_traits.h"
23 #include "content/common/input_messages.h" 24 #include "content/common/input_messages.h"
24 #include "content/common/view_messages.h" 25 #include "content/common/view_messages.h"
25 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_types.h" 27 #include "content/public/browser/notification_types.h"
27 #include "content/public/browser/user_metrics.h" 28 #include "content/public/browser/user_metrics.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 ack_handler_(ack_handler), 71 ack_handler_(ack_handler),
71 routing_id_(routing_id), 72 routing_id_(routing_id),
72 select_message_pending_(false), 73 select_message_pending_(false),
73 move_caret_pending_(false), 74 move_caret_pending_(false),
74 mouse_move_pending_(false), 75 mouse_move_pending_(false),
75 mouse_wheel_pending_(false), 76 mouse_wheel_pending_(false),
76 current_ack_source_(ACK_SOURCE_NONE), 77 current_ack_source_(ACK_SOURCE_NONE),
77 flush_requested_(false), 78 flush_requested_(false),
78 active_renderer_fling_count_(0), 79 active_renderer_fling_count_(0),
79 touch_event_queue_(this, config.touch_config), 80 touch_event_queue_(this, config.touch_config),
80 gesture_event_queue_(this, this, config.gesture_config) { 81 gesture_event_queue_(this, this, config.gesture_config),
82 device_scale_factor_(1.f) {
81 DCHECK(sender); 83 DCHECK(sender);
82 DCHECK(client); 84 DCHECK(client);
83 DCHECK(ack_handler); 85 DCHECK(ack_handler);
84 UpdateTouchAckTimeoutEnabled(); 86 UpdateTouchAckTimeoutEnabled();
85 } 87 }
86 88
87 InputRouterImpl::~InputRouterImpl() { 89 InputRouterImpl::~InputRouterImpl() {
88 STLDeleteElements(&pending_select_messages_); 90 STLDeleteElements(&pending_select_messages_);
89 } 91 }
90 92
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 return !touch_event_queue_.empty() || 253 return !touch_event_queue_.empty() ||
252 !gesture_event_queue_.empty() || 254 !gesture_event_queue_.empty() ||
253 !key_queue_.empty() || 255 !key_queue_.empty() ||
254 mouse_move_pending_ || 256 mouse_move_pending_ ||
255 mouse_wheel_pending_ || 257 mouse_wheel_pending_ ||
256 select_message_pending_ || 258 select_message_pending_ ||
257 move_caret_pending_ || 259 move_caret_pending_ ||
258 active_renderer_fling_count_ > 0; 260 active_renderer_fling_count_ > 0;
259 } 261 }
260 262
263 void InputRouterImpl::SetDeviceScaleFactor(float device_scale_factor) {
264 device_scale_factor_ = device_scale_factor;
265 }
266
261 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { 267 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) {
262 bool handled = true; 268 bool handled = true;
263 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) 269 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message)
264 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) 270 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck)
265 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) 271 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll)
266 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) 272 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck)
267 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) 273 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck)
268 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, 274 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK,
269 OnSelectMessageAck) 275 OnSelectMessageAck)
270 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, 276 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers,
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 break; 411 break;
406 default: 412 default:
407 break; 413 break;
408 } 414 }
409 415
410 return consumed; 416 return consumed;
411 } 417 }
412 418
413 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, 419 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event,
414 const ui::LatencyInfo& latency_info) { 420 const ui::LatencyInfo& latency_info) {
415 if (Send(new InputMsg_HandleInputEvent(routing_id(), &input_event, 421 scoped_ptr<blink::WebInputEvent> event_in_viewport =
422 ConvertWebInputEventToViewport(input_event, device_scale_factor_);
423 const WebInputEvent* event_to_send =
424 event_in_viewport ? event_in_viewport.get() : &input_event;
425
426 if (Send(new InputMsg_HandleInputEvent(routing_id(), event_to_send,
416 latency_info))) { 427 latency_info))) {
417 // Ack messages for ignored ack event types should never be sent by the 428 // Ack messages for ignored ack event types should never be sent by the
418 // renderer. Consequently, such event types should not affect event time 429 // renderer. Consequently, such event types should not affect event time
419 // or in-flight event count metrics. 430 // or in-flight event count metrics.
420 if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event)) { 431 if (WebInputEventTraits::WillReceiveAckFromRenderer(*event_to_send)) {
421 input_event_start_time_ = TimeTicks::Now(); 432 input_event_start_time_ = TimeTicks::Now();
422 client_->IncrementInFlightEventCount(); 433 client_->IncrementInFlightEventCount();
423 } 434 }
424 return true; 435 return true;
425 } 436 }
426 return false; 437 return false;
427 } 438 }
428 439
429 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) { 440 void InputRouterImpl::OnInputEventAck(const InputEventAck& ack) {
430 client_->DecrementInFlightEventCount(); 441 client_->DecrementInFlightEventCount();
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 return; 650 return;
640 651
641 if (HasPendingEvents()) 652 if (HasPendingEvents())
642 return; 653 return;
643 654
644 flush_requested_ = false; 655 flush_requested_ = false;
645 client_->DidFlush(); 656 client_->DidFlush();
646 } 657 }
647 658
648 } // namespace content 659 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698