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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 output_stream_validator_.Validate(input_event); | 350 output_stream_validator_.Validate(input_event); |
351 | 351 |
352 if (OfferToClient(input_event, latency_info)) | 352 if (OfferToClient(input_event, latency_info)) |
353 return; | 353 return; |
354 | 354 |
355 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); | 355 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); |
356 | 356 |
357 // Touch events should always indicate in the event whether they are | 357 // Touch events should always indicate in the event whether they are |
358 // cancelable (respect ACK disposition) or not. | 358 // cancelable (respect ACK disposition) or not. |
359 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); | 359 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); |
360 uint64 unique_touch_event_id = 0; | |
360 if (WebInputEvent::isTouchEventType(input_event.type)) { | 361 if (WebInputEvent::isTouchEventType(input_event.type)) { |
361 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 362 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
363 unique_touch_event_id = touch.uniqueTouchEventId; | |
364 DCHECK_NE(unique_touch_event_id, 0UL); | |
362 DCHECK_NE(ignores_ack, !!touch.cancelable); | 365 DCHECK_NE(ignores_ack, !!touch.cancelable); |
363 } | 366 } |
364 | 367 |
365 // If we don't care about the ack disposition, send the ack immediately. | 368 // If we don't care about the ack disposition, send the ack immediately. |
366 if (ignores_ack) { | 369 if (ignores_ack) { |
367 ProcessInputEventAck(input_event.type, | 370 ProcessInputEventAck(input_event.type, |
368 INPUT_EVENT_ACK_STATE_IGNORED, | 371 INPUT_EVENT_ACK_STATE_IGNORED, |
369 latency_info, | 372 latency_info, |
373 unique_touch_event_id, | |
370 IGNORING_DISPOSITION); | 374 IGNORING_DISPOSITION); |
371 } | 375 } |
372 } | 376 } |
373 | 377 |
374 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, | 378 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, |
375 const ui::LatencyInfo& latency_info) { | 379 const ui::LatencyInfo& latency_info) { |
376 bool consumed = false; | 380 bool consumed = false; |
381 uint64 unique_touch_event_id = 0; | |
377 | 382 |
378 InputEventAckState filter_ack = | 383 InputEventAckState filter_ack = |
379 client_->FilterInputEvent(input_event, latency_info); | 384 client_->FilterInputEvent(input_event, latency_info); |
380 switch (filter_ack) { | 385 switch (filter_ack) { |
381 case INPUT_EVENT_ACK_STATE_CONSUMED: | 386 case INPUT_EVENT_ACK_STATE_CONSUMED: |
382 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: | 387 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: |
383 // Send the ACK and early exit. | 388 // Send the ACK and early exit. |
384 next_mouse_move_.reset(); | 389 next_mouse_move_.reset(); |
385 ProcessInputEventAck(input_event.type, filter_ack, latency_info, CLIENT); | 390 if (WebInputEvent::isTouchEventType(input_event.type)) { |
391 const WebTouchEvent& touch = | |
392 static_cast<const WebTouchEvent&>(input_event); | |
393 unique_touch_event_id = touch.uniqueTouchEventId; | |
394 } | |
395 ProcessInputEventAck(input_event.type, filter_ack, latency_info, | |
396 unique_touch_event_id, CLIENT); | |
386 // WARNING: |this| may be deleted at this point. | 397 // WARNING: |this| may be deleted at this point. |
387 consumed = true; | 398 consumed = true; |
388 break; | 399 break; |
389 case INPUT_EVENT_ACK_STATE_UNKNOWN: | 400 case INPUT_EVENT_ACK_STATE_UNKNOWN: |
390 // Simply drop the event. | 401 // Simply drop the event. |
391 consumed = true; | 402 consumed = true; |
392 break; | 403 break; |
393 default: | 404 default: |
394 break; | 405 break; |
395 } | 406 } |
(...skipping 24 matching lines...) Expand all Loading... | |
420 | 431 |
421 // Log the time delta for processing an input event. | 432 // Log the time delta for processing an input event. |
422 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 433 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
423 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); | 434 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); |
424 | 435 |
425 if (ack.overscroll) { | 436 if (ack.overscroll) { |
426 DCHECK(ack.type == WebInputEvent::MouseWheel || | 437 DCHECK(ack.type == WebInputEvent::MouseWheel || |
427 ack.type == WebInputEvent::GestureScrollUpdate); | 438 ack.type == WebInputEvent::GestureScrollUpdate); |
428 OnDidOverscroll(*ack.overscroll); | 439 OnDidOverscroll(*ack.overscroll); |
429 } | 440 } |
430 | 441 ProcessInputEventAck(ack.type, ack.state, ack.latency, |
431 ProcessInputEventAck(ack.type, ack.state, ack.latency, RENDERER); | 442 ack.unique_touch_event_id, RENDERER); |
432 // WARNING: |this| may be deleted at this point. | 443 // WARNING: |this| may be deleted at this point. |
433 | 444 |
434 // This is used only for testing, and the other end does not use the | 445 // This is used only for testing, and the other end does not use the |
435 // source object. On linux, specifying | 446 // source object. On linux, specifying |
436 // Source<RenderWidgetHost> results in a very strange | 447 // Source<RenderWidgetHost> results in a very strange |
437 // runtime error in the epilogue of the enclosing | 448 // runtime error in the epilogue of the enclosing |
438 // (ProcessInputEventAck) method, but not on other platforms; using | 449 // (ProcessInputEventAck) method, but not on other platforms; using |
439 // 'void' instead is just as safe (since NotificationSource | 450 // 'void' instead is just as safe (since NotificationSource |
440 // is not actually typesafe) and avoids this error. | 451 // is not actually typesafe) and avoids this error. |
441 int type = static_cast<int>(ack.type); | 452 int type = static_cast<int>(ack.type); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 void InputRouterImpl::OnDidStopFlinging() { | 509 void InputRouterImpl::OnDidStopFlinging() { |
499 gesture_event_queue_.DidStopFlinging(); | 510 gesture_event_queue_.DidStopFlinging(); |
500 SignalFlushedIfNecessary(); | 511 SignalFlushedIfNecessary(); |
501 client_->DidStopFlinging(); | 512 client_->DidStopFlinging(); |
502 } | 513 } |
503 | 514 |
504 void InputRouterImpl::ProcessInputEventAck( | 515 void InputRouterImpl::ProcessInputEventAck( |
505 WebInputEvent::Type event_type, | 516 WebInputEvent::Type event_type, |
506 InputEventAckState ack_result, | 517 InputEventAckState ack_result, |
507 const ui::LatencyInfo& latency_info, | 518 const ui::LatencyInfo& latency_info, |
519 uint64 uniqueEventId, | |
tdresser
2015/04/09 12:33:06
unique_touch_event_id
| |
508 AckSource ack_source) { | 520 AckSource ack_source) { |
509 TRACE_EVENT2("input", "InputRouterImpl::ProcessInputEventAck", | 521 TRACE_EVENT2("input", "InputRouterImpl::ProcessInputEventAck", |
510 "type", WebInputEventTraits::GetName(event_type), | 522 "type", WebInputEventTraits::GetName(event_type), |
511 "ack", GetEventAckName(ack_result)); | 523 "ack", GetEventAckName(ack_result)); |
512 | 524 |
513 // Note: The keyboard ack must be treated carefully, as it may result in | 525 // Note: The keyboard ack must be treated carefully, as it may result in |
514 // synchronous destruction of |this|. Handling immediately guards against | 526 // synchronous destruction of |this|. Handling immediately guards against |
515 // future references to |this|, as with |auto_reset_current_ack_source| below. | 527 // future references to |this|, as with |auto_reset_current_ack_source| below. |
516 if (WebInputEvent::isKeyboardEventType(event_type)) { | 528 if (WebInputEvent::isKeyboardEventType(event_type)) { |
517 ProcessKeyboardAck(event_type, ack_result); | 529 ProcessKeyboardAck(event_type, ack_result); |
518 // WARNING: |this| may be deleted at this point. | 530 // WARNING: |this| may be deleted at this point. |
519 return; | 531 return; |
520 } | 532 } |
521 | 533 |
522 base::AutoReset<AckSource> auto_reset_current_ack_source( | 534 base::AutoReset<AckSource> auto_reset_current_ack_source( |
523 ¤t_ack_source_, ack_source); | 535 ¤t_ack_source_, ack_source); |
524 | 536 |
525 if (WebInputEvent::isMouseEventType(event_type)) { | 537 if (WebInputEvent::isMouseEventType(event_type)) { |
526 ProcessMouseAck(event_type, ack_result); | 538 ProcessMouseAck(event_type, ack_result); |
527 } else if (event_type == WebInputEvent::MouseWheel) { | 539 } else if (event_type == WebInputEvent::MouseWheel) { |
528 ProcessWheelAck(ack_result, latency_info); | 540 ProcessWheelAck(ack_result, latency_info); |
529 } else if (WebInputEvent::isTouchEventType(event_type)) { | 541 } else if (WebInputEvent::isTouchEventType(event_type)) { |
530 ProcessTouchAck(ack_result, latency_info); | 542 ProcessTouchAck(ack_result, latency_info, uniqueEventId); |
531 } else if (WebInputEvent::isGestureEventType(event_type)) { | 543 } else if (WebInputEvent::isGestureEventType(event_type)) { |
532 ProcessGestureAck(event_type, ack_result, latency_info); | 544 ProcessGestureAck(event_type, ack_result, latency_info); |
533 } else if (event_type != WebInputEvent::Undefined) { | 545 } else if (event_type != WebInputEvent::Undefined) { |
534 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); | 546 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); |
535 } | 547 } |
536 | 548 |
537 SignalFlushedIfNecessary(); | 549 SignalFlushedIfNecessary(); |
538 } | 550 } |
539 | 551 |
540 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, | 552 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 | 613 |
602 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type, | 614 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type, |
603 InputEventAckState ack_result, | 615 InputEventAckState ack_result, |
604 const ui::LatencyInfo& latency) { | 616 const ui::LatencyInfo& latency) { |
605 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate. | 617 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate. |
606 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency); | 618 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency); |
607 } | 619 } |
608 | 620 |
609 void InputRouterImpl::ProcessTouchAck( | 621 void InputRouterImpl::ProcessTouchAck( |
610 InputEventAckState ack_result, | 622 InputEventAckState ack_result, |
611 const ui::LatencyInfo& latency) { | 623 const ui::LatencyInfo& latency, |
624 uint64 unique_touch_event_id) { | |
612 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. | 625 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. |
613 touch_event_queue_.ProcessTouchAck(ack_result, latency); | 626 touch_event_queue_.ProcessTouchAck(ack_result, latency, |
627 unique_touch_event_id); | |
614 } | 628 } |
615 | 629 |
616 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { | 630 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { |
617 // Mobile sites tend to be well-behaved with respect to touch handling, so | 631 // Mobile sites tend to be well-behaved with respect to touch handling, so |
618 // they have less need for the touch timeout fallback. | 632 // they have less need for the touch timeout fallback. |
619 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; | 633 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; |
620 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; | 634 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; |
621 | 635 |
622 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves | 636 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves |
623 // little purpose. It's also a strong signal that touch handling is critical | 637 // little purpose. It's also a strong signal that touch handling is critical |
(...skipping 12 matching lines...) Expand all Loading... | |
636 return; | 650 return; |
637 | 651 |
638 if (HasPendingEvents()) | 652 if (HasPendingEvents()) |
639 return; | 653 return; |
640 | 654 |
641 flush_requested_ = false; | 655 flush_requested_ = false; |
642 client_->DidFlush(); | 656 client_->DidFlush(); |
643 } | 657 } |
644 | 658 |
645 } // namespace content | 659 } // namespace content |
OLD | NEW |