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

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

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months 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"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 output_stream_validator_.Validate(input_event); 340 output_stream_validator_.Validate(input_event);
341 341
342 if (OfferToClient(input_event, latency_info)) 342 if (OfferToClient(input_event, latency_info))
343 return; 343 return;
344 344
345 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); 345 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut);
346 346
347 // Touch events should always indicate in the event whether they are 347 // Touch events should always indicate in the event whether they are
348 // cancelable (respect ACK disposition) or not. 348 // cancelable (respect ACK disposition) or not.
349 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); 349 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event);
350 uint32 unique_touch_event_id = 0;
350 if (WebInputEvent::isTouchEventType(input_event.type)) { 351 if (WebInputEvent::isTouchEventType(input_event.type)) {
351 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); 352 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event);
353 unique_touch_event_id= touch.uniqueTouchEventId;
tdresser 2015/03/16 12:24:12 add space before =
lanwei 2015/03/16 19:06:07 Done.
352 DCHECK_NE(ignores_ack, !!touch.cancelable); 354 DCHECK_NE(ignores_ack, !!touch.cancelable);
353 } 355 }
354 356
355 // If we don't care about the ack disposition, send the ack immediately. 357 // If we don't care about the ack disposition, send the ack immediately.
356 if (ignores_ack) { 358 if (ignores_ack) {
357 ProcessInputEventAck(input_event.type, 359 ProcessInputEventAck(input_event.type,
358 INPUT_EVENT_ACK_STATE_IGNORED, 360 INPUT_EVENT_ACK_STATE_IGNORED,
359 latency_info, 361 latency_info,
362 unique_touch_event_id,
360 IGNORING_DISPOSITION); 363 IGNORING_DISPOSITION);
361 } 364 }
362 } 365 }
363 366
364 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, 367 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event,
365 const ui::LatencyInfo& latency_info) { 368 const ui::LatencyInfo& latency_info) {
366 bool consumed = false; 369 bool consumed = false;
370 uint32 unique_touch_event_id = 0;
367 371
368 InputEventAckState filter_ack = 372 InputEventAckState filter_ack =
369 client_->FilterInputEvent(input_event, latency_info); 373 client_->FilterInputEvent(input_event, latency_info);
370 switch (filter_ack) { 374 switch (filter_ack) {
371 case INPUT_EVENT_ACK_STATE_CONSUMED: 375 case INPUT_EVENT_ACK_STATE_CONSUMED:
372 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: 376 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS:
373 // Send the ACK and early exit. 377 // Send the ACK and early exit.
374 next_mouse_move_.reset(); 378 next_mouse_move_.reset();
375 ProcessInputEventAck(input_event.type, filter_ack, latency_info, CLIENT); 379 if (WebInputEvent::isTouchEventType(input_event.type)) {
380 const WebTouchEvent& touch =
381 static_cast<const WebTouchEvent&>(input_event);
382 unique_touch_event_id= touch.uniqueTouchEventId;
tdresser 2015/03/16 12:24:12 add space before =
lanwei 2015/03/16 19:06:07 Done.
383 }
384 ProcessInputEventAck(input_event.type, filter_ack, latency_info,
385 unique_touch_event_id, CLIENT);
376 // WARNING: |this| may be deleted at this point. 386 // WARNING: |this| may be deleted at this point.
377 consumed = true; 387 consumed = true;
378 break; 388 break;
379 case INPUT_EVENT_ACK_STATE_UNKNOWN: 389 case INPUT_EVENT_ACK_STATE_UNKNOWN:
380 // Simply drop the event. 390 // Simply drop the event.
381 consumed = true; 391 consumed = true;
382 break; 392 break;
383 default: 393 default:
384 break; 394 break;
385 } 395 }
(...skipping 24 matching lines...) Expand all
410 420
411 // Log the time delta for processing an input event. 421 // Log the time delta for processing an input event.
412 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 422 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
413 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); 423 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta);
414 424
415 if (ack.overscroll) { 425 if (ack.overscroll) {
416 DCHECK(ack.type == WebInputEvent::MouseWheel || 426 DCHECK(ack.type == WebInputEvent::MouseWheel ||
417 ack.type == WebInputEvent::GestureScrollUpdate); 427 ack.type == WebInputEvent::GestureScrollUpdate);
418 OnDidOverscroll(*ack.overscroll); 428 OnDidOverscroll(*ack.overscroll);
419 } 429 }
420 430 ProcessInputEventAck(ack.type, ack.state, ack.latency,
421 ProcessInputEventAck(ack.type, ack.state, ack.latency, RENDERER); 431 ack.unique_touch_event_id, RENDERER);
422 // WARNING: |this| may be deleted at this point. 432 // WARNING: |this| may be deleted at this point.
423 433
424 // This is used only for testing, and the other end does not use the 434 // This is used only for testing, and the other end does not use the
425 // source object. On linux, specifying 435 // source object. On linux, specifying
426 // Source<RenderWidgetHost> results in a very strange 436 // Source<RenderWidgetHost> results in a very strange
427 // runtime error in the epilogue of the enclosing 437 // runtime error in the epilogue of the enclosing
428 // (ProcessInputEventAck) method, but not on other platforms; using 438 // (ProcessInputEventAck) method, but not on other platforms; using
429 // 'void' instead is just as safe (since NotificationSource 439 // 'void' instead is just as safe (since NotificationSource
430 // is not actually typesafe) and avoids this error. 440 // is not actually typesafe) and avoids this error.
431 int type = static_cast<int>(ack.type); 441 int type = static_cast<int>(ack.type);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 touch_action_filter_.OnSetTouchAction(touch_action); 492 touch_action_filter_.OnSetTouchAction(touch_action);
483 493
484 // TOUCH_ACTION_NONE should disable the touch ack timeout. 494 // TOUCH_ACTION_NONE should disable the touch ack timeout.
485 UpdateTouchAckTimeoutEnabled(); 495 UpdateTouchAckTimeoutEnabled();
486 } 496 }
487 497
488 void InputRouterImpl::ProcessInputEventAck( 498 void InputRouterImpl::ProcessInputEventAck(
489 WebInputEvent::Type event_type, 499 WebInputEvent::Type event_type,
490 InputEventAckState ack_result, 500 InputEventAckState ack_result,
491 const ui::LatencyInfo& latency_info, 501 const ui::LatencyInfo& latency_info,
502 uint32 uniqueEventId,
492 AckSource ack_source) { 503 AckSource ack_source) {
493 TRACE_EVENT2("input", "InputRouterImpl::ProcessInputEventAck", 504 TRACE_EVENT2("input", "InputRouterImpl::ProcessInputEventAck",
494 "type", WebInputEventTraits::GetName(event_type), 505 "type", WebInputEventTraits::GetName(event_type),
495 "ack", GetEventAckName(ack_result)); 506 "ack", GetEventAckName(ack_result));
496 507
497 // Note: The keyboard ack must be treated carefully, as it may result in 508 // Note: The keyboard ack must be treated carefully, as it may result in
498 // synchronous destruction of |this|. Handling immediately guards against 509 // synchronous destruction of |this|. Handling immediately guards against
499 // future references to |this|, as with |auto_reset_current_ack_source| below. 510 // future references to |this|, as with |auto_reset_current_ack_source| below.
500 if (WebInputEvent::isKeyboardEventType(event_type)) { 511 if (WebInputEvent::isKeyboardEventType(event_type)) {
501 ProcessKeyboardAck(event_type, ack_result); 512 ProcessKeyboardAck(event_type, ack_result);
502 // WARNING: |this| may be deleted at this point. 513 // WARNING: |this| may be deleted at this point.
503 return; 514 return;
504 } 515 }
505 516
506 base::AutoReset<AckSource> auto_reset_current_ack_source( 517 base::AutoReset<AckSource> auto_reset_current_ack_source(
507 &current_ack_source_, ack_source); 518 &current_ack_source_, ack_source);
508 519
509 if (WebInputEvent::isMouseEventType(event_type)) { 520 if (WebInputEvent::isMouseEventType(event_type)) {
510 ProcessMouseAck(event_type, ack_result); 521 ProcessMouseAck(event_type, ack_result);
511 } else if (event_type == WebInputEvent::MouseWheel) { 522 } else if (event_type == WebInputEvent::MouseWheel) {
512 ProcessWheelAck(ack_result, latency_info); 523 ProcessWheelAck(ack_result, latency_info);
513 } else if (WebInputEvent::isTouchEventType(event_type)) { 524 } else if (WebInputEvent::isTouchEventType(event_type)) {
514 ProcessTouchAck(ack_result, latency_info); 525 ProcessTouchAck(ack_result, latency_info, uniqueEventId);
515 } else if (WebInputEvent::isGestureEventType(event_type)) { 526 } else if (WebInputEvent::isGestureEventType(event_type)) {
516 ProcessGestureAck(event_type, ack_result, latency_info); 527 ProcessGestureAck(event_type, ack_result, latency_info);
517 } else if (event_type != WebInputEvent::Undefined) { 528 } else if (event_type != WebInputEvent::Undefined) {
518 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); 529 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE);
519 } 530 }
520 531
521 SignalFlushedIfNecessary(); 532 SignalFlushedIfNecessary();
522 } 533 }
523 534
524 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, 535 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 596
586 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type, 597 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type,
587 InputEventAckState ack_result, 598 InputEventAckState ack_result,
588 const ui::LatencyInfo& latency) { 599 const ui::LatencyInfo& latency) {
589 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate. 600 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate.
590 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency); 601 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency);
591 } 602 }
592 603
593 void InputRouterImpl::ProcessTouchAck( 604 void InputRouterImpl::ProcessTouchAck(
594 InputEventAckState ack_result, 605 InputEventAckState ack_result,
595 const ui::LatencyInfo& latency) { 606 const ui::LatencyInfo& latency,
607 uint32 unique_touch_event_id) {
596 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 608 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
597 touch_event_queue_.ProcessTouchAck(ack_result, latency); 609 touch_event_queue_.ProcessTouchAck(ack_result, latency,
610 unique_touch_event_id);
598 } 611 }
599 612
600 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { 613 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() {
601 // Mobile sites tend to be well-behaved with respect to touch handling, so 614 // Mobile sites tend to be well-behaved with respect to touch handling, so
602 // they have less need for the touch timeout fallback. 615 // they have less need for the touch timeout fallback.
603 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; 616 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0;
604 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; 617 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0;
605 618
606 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves 619 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves
607 // little purpose. It's also a strong signal that touch handling is critical 620 // little purpose. It's also a strong signal that touch handling is critical
(...skipping 22 matching lines...) Expand all
630 return !touch_event_queue_.empty() || 643 return !touch_event_queue_.empty() ||
631 !gesture_event_queue_.empty() || 644 !gesture_event_queue_.empty() ||
632 !key_queue_.empty() || 645 !key_queue_.empty() ||
633 mouse_move_pending_ || 646 mouse_move_pending_ ||
634 mouse_wheel_pending_ || 647 mouse_wheel_pending_ ||
635 select_message_pending_ || 648 select_message_pending_ ||
636 move_caret_pending_; 649 move_caret_pending_;
637 } 650 }
638 651
639 } // namespace content 652 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698