OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/render_widget_host_input_event_router.h" | 5 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 | 10 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 RenderWidgetHostViewBase* common_ancestor = nullptr; | 449 RenderWidgetHostViewBase* common_ancestor = nullptr; |
450 while (entered_views.size() > 0 && exited_views.size() > 0 && | 450 while (entered_views.size() > 0 && exited_views.size() > 0 && |
451 entered_views.back() == exited_views.back()) { | 451 entered_views.back() == exited_views.back()) { |
452 common_ancestor = entered_views.back(); | 452 common_ancestor = entered_views.back(); |
453 entered_views.pop_back(); | 453 entered_views.pop_back(); |
454 exited_views.pop_back(); | 454 exited_views.pop_back(); |
455 } | 455 } |
456 | 456 |
457 gfx::Point transformed_point; | 457 gfx::Point transformed_point; |
458 // Send MouseLeaves. | 458 // Send MouseLeaves. |
459 for (auto view : exited_views) { | 459 for (auto* view : exited_views) { |
460 blink::WebMouseEvent mouse_leave(*event); | 460 blink::WebMouseEvent mouse_leave(*event); |
461 mouse_leave.setType(blink::WebInputEvent::MouseLeave); | 461 mouse_leave.setType(blink::WebInputEvent::MouseLeave); |
462 // There is a chance of a race if the last target has recently created a | 462 // There is a chance of a race if the last target has recently created a |
463 // new compositor surface. The SurfaceID for that might not have | 463 // new compositor surface. The SurfaceID for that might not have |
464 // propagated to its embedding surface, which makes it impossible to | 464 // propagated to its embedding surface, which makes it impossible to |
465 // compute the transformation for it | 465 // compute the transformation for it |
466 if (!root_view->TransformPointToCoordSpaceForView( | 466 if (!root_view->TransformPointToCoordSpaceForView( |
467 gfx::Point(event->x, event->y), view, &transformed_point)) | 467 gfx::Point(event->x, event->y), view, &transformed_point)) |
468 transformed_point = gfx::Point(); | 468 transformed_point = gfx::Point(); |
469 mouse_leave.x = transformed_point.x(); | 469 mouse_leave.x = transformed_point.x(); |
470 mouse_leave.y = transformed_point.y(); | 470 mouse_leave.y = transformed_point.y(); |
471 view->ProcessMouseEvent(mouse_leave, ui::LatencyInfo()); | 471 view->ProcessMouseEvent(mouse_leave, ui::LatencyInfo()); |
472 } | 472 } |
473 | 473 |
474 // The ancestor might need to trigger MouseOut handlers. | 474 // The ancestor might need to trigger MouseOut handlers. |
475 if (common_ancestor && common_ancestor != target) { | 475 if (common_ancestor && common_ancestor != target) { |
476 blink::WebMouseEvent mouse_move(*event); | 476 blink::WebMouseEvent mouse_move(*event); |
477 mouse_move.setType(blink::WebInputEvent::MouseMove); | 477 mouse_move.setType(blink::WebInputEvent::MouseMove); |
478 if (!root_view->TransformPointToCoordSpaceForView( | 478 if (!root_view->TransformPointToCoordSpaceForView( |
479 gfx::Point(event->x, event->y), common_ancestor, | 479 gfx::Point(event->x, event->y), common_ancestor, |
480 &transformed_point)) | 480 &transformed_point)) |
481 transformed_point = gfx::Point(); | 481 transformed_point = gfx::Point(); |
482 mouse_move.x = transformed_point.x(); | 482 mouse_move.x = transformed_point.x(); |
483 mouse_move.y = transformed_point.y(); | 483 mouse_move.y = transformed_point.y(); |
484 common_ancestor->ProcessMouseEvent(mouse_move, ui::LatencyInfo()); | 484 common_ancestor->ProcessMouseEvent(mouse_move, ui::LatencyInfo()); |
485 } | 485 } |
486 | 486 |
487 // Send MouseMoves to trigger MouseEnter handlers. | 487 // Send MouseMoves to trigger MouseEnter handlers. |
488 for (auto view : entered_views) { | 488 for (auto* view : entered_views) { |
489 if (view == target) | 489 if (view == target) |
490 continue; | 490 continue; |
491 blink::WebMouseEvent mouse_enter(*event); | 491 blink::WebMouseEvent mouse_enter(*event); |
492 mouse_enter.setType(blink::WebInputEvent::MouseMove); | 492 mouse_enter.setType(blink::WebInputEvent::MouseMove); |
493 if (!root_view->TransformPointToCoordSpaceForView( | 493 if (!root_view->TransformPointToCoordSpaceForView( |
494 gfx::Point(event->x, event->y), view, &transformed_point)) | 494 gfx::Point(event->x, event->y), view, &transformed_point)) |
495 transformed_point = gfx::Point(); | 495 transformed_point = gfx::Point(); |
496 mouse_enter.x = transformed_point.x(); | 496 mouse_enter.x = transformed_point.x(); |
497 mouse_enter.y = transformed_point.y(); | 497 mouse_enter.y = transformed_point.y(); |
498 view->ProcessMouseEvent(mouse_enter, ui::LatencyInfo()); | 498 view->ProcessMouseEvent(mouse_enter, ui::LatencyInfo()); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 const ui::LatencyInfo& latency) { | 668 const ui::LatencyInfo& latency) { |
669 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); | 669 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); |
670 | 670 |
671 if (event->type() == blink::WebInputEvent::GesturePinchBegin) { | 671 if (event->type() == blink::WebInputEvent::GesturePinchBegin) { |
672 in_touchscreen_gesture_pinch_ = true; | 672 in_touchscreen_gesture_pinch_ = true; |
673 // If the root view wasn't already receiving the gesture stream, then we | 673 // If the root view wasn't already receiving the gesture stream, then we |
674 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | 674 // need to wrap the diverted pinch events in a GestureScrollBegin/End. |
675 // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can | 675 // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can |
676 // revisit how this code should work. | 676 // revisit how this code should work. |
677 // https://crbug.com/526463 | 677 // https://crbug.com/526463 |
678 auto rwhi = | 678 auto* rwhi = |
679 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); | 679 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); |
680 // If the root view is the current gesture target, then we explicitly don't | 680 // If the root view is the current gesture target, then we explicitly don't |
681 // send a GestureScrollBegin, as by the time we see GesturePinchBegin there | 681 // send a GestureScrollBegin, as by the time we see GesturePinchBegin there |
682 // should have been one. | 682 // should have been one. |
683 if (root_view != touchscreen_gesture_target_.target && | 683 if (root_view != touchscreen_gesture_target_.target && |
684 !rwhi->is_in_touchscreen_gesture_scroll()) { | 684 !rwhi->is_in_touchscreen_gesture_scroll()) { |
685 gesture_pinch_did_send_scroll_begin_ = true; | 685 gesture_pinch_did_send_scroll_begin_ = true; |
686 SendGestureScrollBegin(root_view, *event); | 686 SendGestureScrollBegin(root_view, *event); |
687 } | 687 } |
688 } | 688 } |
689 | 689 |
690 if (in_touchscreen_gesture_pinch_) { | 690 if (in_touchscreen_gesture_pinch_) { |
691 root_view->ProcessGestureEvent(*event, latency); | 691 root_view->ProcessGestureEvent(*event, latency); |
692 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { | 692 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { |
693 in_touchscreen_gesture_pinch_ = false; | 693 in_touchscreen_gesture_pinch_ = false; |
694 // If the root view wasn't already receiving the gesture stream, then we | 694 // If the root view wasn't already receiving the gesture stream, then we |
695 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | 695 // need to wrap the diverted pinch events in a GestureScrollBegin/End. |
696 auto rwhi = | 696 auto* rwhi = |
697 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); | 697 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); |
698 if (root_view != touchscreen_gesture_target_.target && | 698 if (root_view != touchscreen_gesture_target_.target && |
699 gesture_pinch_did_send_scroll_begin_ && | 699 gesture_pinch_did_send_scroll_begin_ && |
700 rwhi->is_in_touchscreen_gesture_scroll()) { | 700 rwhi->is_in_touchscreen_gesture_scroll()) { |
701 SendGestureScrollEnd(root_view, *event); | 701 SendGestureScrollEnd(root_view, *event); |
702 } | 702 } |
703 gesture_pinch_did_send_scroll_begin_ = false; | 703 gesture_pinch_did_send_scroll_begin_ = false; |
704 } | 704 } |
705 return; | 705 return; |
706 } | 706 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 if (!touchpad_gesture_target_.target) | 779 if (!touchpad_gesture_target_.target) |
780 return; | 780 return; |
781 | 781 |
782 // TODO(mohsen): Add tests to check event location. | 782 // TODO(mohsen): Add tests to check event location. |
783 event->x += touchpad_gesture_target_.delta.x(); | 783 event->x += touchpad_gesture_target_.delta.x(); |
784 event->y += touchpad_gesture_target_.delta.y(); | 784 event->y += touchpad_gesture_target_.delta.y(); |
785 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); | 785 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); |
786 } | 786 } |
787 | 787 |
788 } // namespace content | 788 } // namespace content |
OLD | NEW |