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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 RenderWidgetHostViewBase* common_ancestor = nullptr; | 476 RenderWidgetHostViewBase* common_ancestor = nullptr; |
477 while (entered_views.size() > 0 && exited_views.size() > 0 && | 477 while (entered_views.size() > 0 && exited_views.size() > 0 && |
478 entered_views.back() == exited_views.back()) { | 478 entered_views.back() == exited_views.back()) { |
479 common_ancestor = entered_views.back(); | 479 common_ancestor = entered_views.back(); |
480 entered_views.pop_back(); | 480 entered_views.pop_back(); |
481 exited_views.pop_back(); | 481 exited_views.pop_back(); |
482 } | 482 } |
483 | 483 |
484 gfx::Point transformed_point; | 484 gfx::Point transformed_point; |
485 // Send MouseLeaves. | 485 // Send MouseLeaves. |
486 for (auto view : exited_views) { | 486 for (auto* view : exited_views) { |
487 blink::WebMouseEvent mouse_leave(*event); | 487 blink::WebMouseEvent mouse_leave(*event); |
488 mouse_leave.setType(blink::WebInputEvent::MouseLeave); | 488 mouse_leave.setType(blink::WebInputEvent::MouseLeave); |
489 // There is a chance of a race if the last target has recently created a | 489 // There is a chance of a race if the last target has recently created a |
490 // new compositor surface. The SurfaceID for that might not have | 490 // new compositor surface. The SurfaceID for that might not have |
491 // propagated to its embedding surface, which makes it impossible to | 491 // propagated to its embedding surface, which makes it impossible to |
492 // compute the transformation for it | 492 // compute the transformation for it |
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_leave.x = transformed_point.x(); | 496 mouse_leave.x = transformed_point.x(); |
497 mouse_leave.y = transformed_point.y(); | 497 mouse_leave.y = transformed_point.y(); |
498 view->ProcessMouseEvent(mouse_leave, ui::LatencyInfo()); | 498 view->ProcessMouseEvent(mouse_leave, ui::LatencyInfo()); |
499 } | 499 } |
500 | 500 |
501 // The ancestor might need to trigger MouseOut handlers. | 501 // The ancestor might need to trigger MouseOut handlers. |
502 if (common_ancestor && common_ancestor != target) { | 502 if (common_ancestor && common_ancestor != target) { |
503 blink::WebMouseEvent mouse_move(*event); | 503 blink::WebMouseEvent mouse_move(*event); |
504 mouse_move.setType(blink::WebInputEvent::MouseMove); | 504 mouse_move.setType(blink::WebInputEvent::MouseMove); |
505 if (!root_view->TransformPointToCoordSpaceForView( | 505 if (!root_view->TransformPointToCoordSpaceForView( |
506 gfx::Point(event->x, event->y), common_ancestor, | 506 gfx::Point(event->x, event->y), common_ancestor, |
507 &transformed_point)) | 507 &transformed_point)) |
508 transformed_point = gfx::Point(); | 508 transformed_point = gfx::Point(); |
509 mouse_move.x = transformed_point.x(); | 509 mouse_move.x = transformed_point.x(); |
510 mouse_move.y = transformed_point.y(); | 510 mouse_move.y = transformed_point.y(); |
511 common_ancestor->ProcessMouseEvent(mouse_move, ui::LatencyInfo()); | 511 common_ancestor->ProcessMouseEvent(mouse_move, ui::LatencyInfo()); |
512 } | 512 } |
513 | 513 |
514 // Send MouseMoves to trigger MouseEnter handlers. | 514 // Send MouseMoves to trigger MouseEnter handlers. |
515 for (auto view : entered_views) { | 515 for (auto* view : entered_views) { |
516 if (view == target) | 516 if (view == target) |
517 continue; | 517 continue; |
518 blink::WebMouseEvent mouse_enter(*event); | 518 blink::WebMouseEvent mouse_enter(*event); |
519 mouse_enter.setType(blink::WebInputEvent::MouseMove); | 519 mouse_enter.setType(blink::WebInputEvent::MouseMove); |
520 if (!root_view->TransformPointToCoordSpaceForView( | 520 if (!root_view->TransformPointToCoordSpaceForView( |
521 gfx::Point(event->x, event->y), view, &transformed_point)) | 521 gfx::Point(event->x, event->y), view, &transformed_point)) |
522 transformed_point = gfx::Point(); | 522 transformed_point = gfx::Point(); |
523 mouse_enter.x = transformed_point.x(); | 523 mouse_enter.x = transformed_point.x(); |
524 mouse_enter.y = transformed_point.y(); | 524 mouse_enter.y = transformed_point.y(); |
525 view->ProcessMouseEvent(mouse_enter, ui::LatencyInfo()); | 525 view->ProcessMouseEvent(mouse_enter, ui::LatencyInfo()); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
695 const ui::LatencyInfo& latency) { | 695 const ui::LatencyInfo& latency) { |
696 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); | 696 DCHECK_EQ(blink::WebGestureDeviceTouchscreen, event->sourceDevice); |
697 | 697 |
698 if (event->type() == blink::WebInputEvent::GesturePinchBegin) { | 698 if (event->type() == blink::WebInputEvent::GesturePinchBegin) { |
699 in_touchscreen_gesture_pinch_ = true; | 699 in_touchscreen_gesture_pinch_ = true; |
700 // If the root view wasn't already receiving the gesture stream, then we | 700 // If the root view wasn't already receiving the gesture stream, then we |
701 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | 701 // need to wrap the diverted pinch events in a GestureScrollBegin/End. |
702 // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can | 702 // TODO(wjmaclean,kenrb,tdresser): When scroll latching lands, we can |
703 // revisit how this code should work. | 703 // revisit how this code should work. |
704 // https://crbug.com/526463 | 704 // https://crbug.com/526463 |
705 auto rwhi = | 705 auto* rwhi = |
706 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); | 706 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); |
707 // If the root view is the current gesture target, then we explicitly don't | 707 // If the root view is the current gesture target, then we explicitly don't |
708 // send a GestureScrollBegin, as by the time we see GesturePinchBegin there | 708 // send a GestureScrollBegin, as by the time we see GesturePinchBegin there |
709 // should have been one. | 709 // should have been one. |
710 if (root_view != touchscreen_gesture_target_.target && | 710 if (root_view != touchscreen_gesture_target_.target && |
711 !rwhi->is_in_touchscreen_gesture_scroll()) { | 711 !rwhi->is_in_touchscreen_gesture_scroll()) { |
712 gesture_pinch_did_send_scroll_begin_ = true; | 712 gesture_pinch_did_send_scroll_begin_ = true; |
713 SendGestureScrollBegin(root_view, *event); | 713 SendGestureScrollBegin(root_view, *event); |
714 } | 714 } |
715 } | 715 } |
716 | 716 |
717 if (in_touchscreen_gesture_pinch_) { | 717 if (in_touchscreen_gesture_pinch_) { |
718 root_view->ProcessGestureEvent(*event, latency); | 718 root_view->ProcessGestureEvent(*event, latency); |
719 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { | 719 if (event->type() == blink::WebInputEvent::GesturePinchEnd) { |
720 in_touchscreen_gesture_pinch_ = false; | 720 in_touchscreen_gesture_pinch_ = false; |
721 // If the root view wasn't already receiving the gesture stream, then we | 721 // If the root view wasn't already receiving the gesture stream, then we |
722 // need to wrap the diverted pinch events in a GestureScrollBegin/End. | 722 // need to wrap the diverted pinch events in a GestureScrollBegin/End. |
723 auto rwhi = | 723 auto* rwhi = |
724 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); | 724 static_cast<RenderWidgetHostImpl*>(root_view->GetRenderWidgetHost()); |
725 if (root_view != touchscreen_gesture_target_.target && | 725 if (root_view != touchscreen_gesture_target_.target && |
726 gesture_pinch_did_send_scroll_begin_ && | 726 gesture_pinch_did_send_scroll_begin_ && |
727 rwhi->is_in_touchscreen_gesture_scroll()) { | 727 rwhi->is_in_touchscreen_gesture_scroll()) { |
728 SendGestureScrollEnd(root_view, *event); | 728 SendGestureScrollEnd(root_view, *event); |
729 } | 729 } |
730 gesture_pinch_did_send_scroll_begin_ = false; | 730 gesture_pinch_did_send_scroll_begin_ = false; |
731 } | 731 } |
732 return; | 732 return; |
733 } | 733 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (!touchpad_gesture_target_.target) | 806 if (!touchpad_gesture_target_.target) |
807 return; | 807 return; |
808 | 808 |
809 // TODO(mohsen): Add tests to check event location. | 809 // TODO(mohsen): Add tests to check event location. |
810 event->x += touchpad_gesture_target_.delta.x(); | 810 event->x += touchpad_gesture_target_.delta.x(); |
811 event->y += touchpad_gesture_target_.delta.y(); | 811 event->y += touchpad_gesture_target_.delta.y(); |
812 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); | 812 touchpad_gesture_target_.target->ProcessGestureEvent(*event, latency); |
813 } | 813 } |
814 | 814 |
815 } // namespace content | 815 } // namespace content |
OLD | NEW |