OLD | NEW |
---|---|
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" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 mouse_move_pending_ || | 250 mouse_move_pending_ || |
251 mouse_wheel_pending_ || | 251 mouse_wheel_pending_ || |
252 select_message_pending_ || | 252 select_message_pending_ || |
253 move_caret_pending_; | 253 move_caret_pending_; |
254 } | 254 } |
255 | 255 |
256 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 256 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
257 bool handled = true; | 257 bool handled = true; |
258 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 258 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
259 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 259 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
260 IPC_MESSAGE_HANDLER(InputHostMsg_HandleUncancelableTouchMoveEvent_ACK, | |
261 OnUncancelableTouchMoveAck) | |
260 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) | 262 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
261 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 263 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
262 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) | 264 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) |
263 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, | 265 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, |
264 OnSelectMessageAck) | 266 OnSelectMessageAck) |
265 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 267 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
266 OnHasTouchEventHandlers) | 268 OnHasTouchEventHandlers) |
267 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, | 269 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, |
268 OnSetTouchAction) | 270 OnSetTouchAction) |
269 IPC_MESSAGE_HANDLER(InputHostMsg_DidStopFlinging, OnDidStopFlinging) | 271 IPC_MESSAGE_HANDLER(InputHostMsg_DidStopFlinging, OnDidStopFlinging) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
349 bool is_keyboard_shortcut) { | 351 bool is_keyboard_shortcut) { |
350 output_stream_validator_.Validate(input_event); | 352 output_stream_validator_.Validate(input_event); |
351 | 353 |
352 if (OfferToClient(input_event, latency_info)) | 354 if (OfferToClient(input_event, latency_info)) |
353 return; | 355 return; |
354 | 356 |
355 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); | 357 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); |
356 | 358 |
357 // Touch events should always indicate in the event whether they are | 359 // Touch events should always indicate in the event whether they are |
358 // cancelable (respect ACK disposition) or not. | 360 // cancelable (respect ACK disposition) or not. |
359 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); | 361 bool ignores_ack = |
jdduke (slow)
2015/04/15 17:14:53
Let's change this to read:
|bool needs_synthetic_
lanwei
2015/04/17 20:49:00
Done.
| |
360 if (WebInputEvent::isTouchEventType(input_event.type)) { | 362 !WebInputEventTraits::WillReceiveAckFromRenderer(input_event); |
363 if (WebInputEvent::isTouchEventType(input_event.type) && | |
364 input_event.type != WebInputEvent::TouchMove) { | |
361 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 365 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
362 DCHECK_NE(ignores_ack, !!touch.cancelable); | 366 DCHECK_NE(ignores_ack, touch.cancelable); |
363 } | 367 } |
364 | 368 |
365 // If we don't care about the ack disposition, send the ack immediately. | 369 // If we don't care about the ack disposition, send the ack immediately. |
366 if (ignores_ack) { | 370 if (ignores_ack) { |
367 ProcessInputEventAck(input_event.type, | 371 ProcessInputEventAck(input_event.type, |
368 INPUT_EVENT_ACK_STATE_IGNORED, | 372 INPUT_EVENT_ACK_STATE_IGNORED, |
369 latency_info, | 373 latency_info, |
370 IGNORING_DISPOSITION); | 374 IGNORING_DISPOSITION); |
371 } | 375 } |
372 } | 376 } |
(...skipping 25 matching lines...) Expand all Loading... | |
398 } | 402 } |
399 | 403 |
400 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 404 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
401 const ui::LatencyInfo& latency_info, | 405 const ui::LatencyInfo& latency_info, |
402 bool is_keyboard_shortcut) { | 406 bool is_keyboard_shortcut) { |
403 if (Send(new InputMsg_HandleInputEvent( | 407 if (Send(new InputMsg_HandleInputEvent( |
404 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { | 408 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { |
405 // Ack messages for ignored ack event types should never be sent by the | 409 // Ack messages for ignored ack event types should never be sent by the |
406 // renderer. Consequently, such event types should not affect event time | 410 // renderer. Consequently, such event types should not affect event time |
407 // or in-flight event count metrics. | 411 // or in-flight event count metrics. |
408 if (!WebInputEventTraits::IgnoresAckDisposition(input_event)) { | 412 if (WebInputEventTraits::WillReceiveAckFromRenderer(input_event)) { |
409 input_event_start_time_ = TimeTicks::Now(); | 413 input_event_start_time_ = TimeTicks::Now(); |
410 client_->IncrementInFlightEventCount(); | 414 client_->IncrementInFlightEventCount(); |
411 } | 415 } |
412 return true; | 416 return true; |
413 } | 417 } |
414 return false; | 418 return false; |
415 } | 419 } |
416 | 420 |
417 void InputRouterImpl::OnInputEventAck( | 421 void InputRouterImpl::OnInputEventAck( |
418 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { | 422 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { |
419 client_->DecrementInFlightEventCount(); | 423 client_->DecrementInFlightEventCount(); |
420 | 424 |
421 // Log the time delta for processing an input event. | 425 // Log the time delta for processing an input event. |
422 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 426 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
423 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); | 427 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); |
424 | 428 |
425 if (ack.overscroll) { | 429 if (ack.overscroll) { |
426 DCHECK(ack.type == WebInputEvent::MouseWheel || | 430 DCHECK(ack.type == WebInputEvent::MouseWheel || |
427 ack.type == WebInputEvent::GestureScrollUpdate); | 431 ack.type == WebInputEvent::GestureScrollUpdate); |
428 OnDidOverscroll(*ack.overscroll); | 432 OnDidOverscroll(*ack.overscroll); |
429 } | 433 } |
430 | 434 |
431 ProcessInputEventAck(ack.type, ack.state, ack.latency, RENDERER); | 435 ProcessInputEventAck(ack.type, ack.state, ack.latency, RENDERER); |
432 // WARNING: |this| may be deleted at this point. | 436 // WARNING: |this| may be deleted at this point. |
433 | 437 |
434 // This is used only for testing, and the other end does not use the | 438 // This is used only for testing, and the other end does not use the |
435 // source object. On linux, specifying | 439 // source object. On linux, specifying |
436 // Source<RenderWidgetHost> results in a very strange | 440 // Source<RenderWidgetHost> results in a very strange |
437 // runtime error in the epilogue of the enclosing | 441 // runtime error in the epilogue of the enclosing |
438 // (ProcessInputEventAck) method, but not on other platforms; using | 442 // (ProcessInputEventAck) method, but not on other platforms; using |
jdduke (slow)
2015/04/15 17:14:53
Let's kill all of this NotificationService code, I
lanwei
2015/04/17 20:49:00
Done.
| |
439 // 'void' instead is just as safe (since NotificationSource | 443 // 'void' instead is just as safe (since NotificationSource |
440 // is not actually typesafe) and avoids this error. | 444 // is not actually typesafe) and avoids this error. |
441 int type = static_cast<int>(ack.type); | 445 int type = static_cast<int>(ack.type); |
442 NotificationService::current()->Notify( | 446 NotificationService::current()->Notify( |
443 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 447 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
444 Source<void>(this), | 448 Source<void>(this), |
445 Details<int>(&type)); | 449 Details<int>(&type)); |
446 } | 450 } |
447 | 451 |
452 void InputRouterImpl::OnUncancelableTouchMoveAck() { | |
453 touch_event_queue_.ProcessUncancelableTouchMoveAck(); | |
jdduke (slow)
2015/04/15 17:14:53
We also need:
client_->DecrementInFlightEventCoun
lanwei
2015/04/17 20:49:00
Done.
| |
454 } | |
455 | |
448 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { | 456 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { |
449 client_->DidOverscroll(params); | 457 client_->DidOverscroll(params); |
450 } | 458 } |
451 | 459 |
452 void InputRouterImpl::OnMsgMoveCaretAck() { | 460 void InputRouterImpl::OnMsgMoveCaretAck() { |
453 move_caret_pending_ = false; | 461 move_caret_pending_ = false; |
454 if (next_move_caret_) | 462 if (next_move_caret_) |
455 SendMoveCaret(next_move_caret_.Pass()); | 463 SendMoveCaret(next_move_caret_.Pass()); |
456 } | 464 } |
457 | 465 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 return; | 644 return; |
637 | 645 |
638 if (HasPendingEvents()) | 646 if (HasPendingEvents()) |
639 return; | 647 return; |
640 | 648 |
641 flush_requested_ = false; | 649 flush_requested_ = false; |
642 client_->DidFlush(); | 650 client_->DidFlush(); |
643 } | 651 } |
644 | 652 |
645 } // namespace content | 653 } // namespace content |
OLD | NEW |