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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_event_handler.cc

Issue 2592243002: Perform direct routing of mouse events when the pointer is locked. (Closed)
Patch Set: transform event, add tests Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_view_event_handler.h" 5 #include "content/browser/renderer_host/render_widget_host_view_event_handler.h"
6 6
7 #include "base/metrics/user_metrics_action.h" 7 #include "base/metrics/user_metrics_action.h"
8 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h" 8 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
9 #include "content/browser/renderer_host/overscroll_controller.h" 9 #include "content/browser/renderer_host/overscroll_controller.h"
10 #include "content/browser/renderer_host/render_view_host_delegate.h" 10 #include "content/browser/renderer_host/render_view_host_delegate.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 ui::MouseEvent* event) { 683 ui::MouseEvent* event) {
684 aura::client::CursorClient* cursor_client = 684 aura::client::CursorClient* cursor_client =
685 aura::client::GetCursorClient(window_->GetRootWindow()); 685 aura::client::GetCursorClient(window_->GetRootWindow());
686 686
687 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 687 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
688 688
689 if (event->type() == ui::ET_MOUSEWHEEL) { 689 if (event->type() == ui::ET_MOUSEWHEEL) {
690 blink::WebMouseWheelEvent mouse_wheel_event = 690 blink::WebMouseWheelEvent mouse_wheel_event =
691 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), 691 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event),
692 base::Bind(&GetScreenLocationFromEvent)); 692 base::Bind(&GetScreenLocationFromEvent));
693 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 693 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
694 host_->ForwardWheelEvent(mouse_wheel_event); 694 if (ShouldRouteEvent(event)) {
695 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
696 host_view_, &mouse_wheel_event, *event->latency());
697 } else {
698 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency());
699 }
700 }
695 return; 701 return;
696 } 702 }
697 703
698 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); 704 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint());
699 705
700 // If we receive non client mouse messages while we are in the locked state 706 // If we receive non client mouse messages while we are in the locked state
701 // it probably means that the mouse left the borders of our window and 707 // it probably means that the mouse left the borders of our window and
702 // needs to be moved back to the center. 708 // needs to be moved back to the center.
703 if (event->flags() & ui::EF_IS_NON_CLIENT) { 709 if (event->flags() & ui::EF_IS_NON_CLIENT) {
704 // TODO(jonross): ideally this would not be done for mus (crbug.com/621412) 710 // TODO(jonross): ideally this would not be done for mus (crbug.com/621412)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } else { 748 } else {
743 // Check if the mouse has reached the border and needs to be centered. 749 // Check if the mouse has reached the border and needs to be centered.
744 if (ShouldMoveToCenter()) { 750 if (ShouldMoveToCenter()) {
745 synthetic_move_sent_ = true; 751 synthetic_move_sent_ = true;
746 window_->MoveCursorTo(center); 752 window_->MoveCursorTo(center);
747 } 753 }
748 bool is_selection_popup = NeedsInputGrab(popup_child_host_view_); 754 bool is_selection_popup = NeedsInputGrab(popup_child_host_view_);
749 // Forward event to renderer. 755 // Forward event to renderer.
750 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 756 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
751 !(event->flags() & ui::EF_FROM_TOUCH)) { 757 !(event->flags() & ui::EF_FROM_TOUCH)) {
752 host_->ForwardMouseEvent(mouse_event); 758 if (ShouldRouteEvent(event)) {
759 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(
760 host_view_, &mouse_event, *event->latency());
761 } else {
762 ProcessMouseEvent(mouse_event, *event->latency());
763 }
753 // Ensure that we get keyboard focus on mouse down as a plugin window 764 // Ensure that we get keyboard focus on mouse down as a plugin window
754 // may have grabbed keyboard focus. 765 // may have grabbed keyboard focus.
755 if (event->type() == ui::ET_MOUSE_PRESSED) 766 if (event->type() == ui::ET_MOUSE_PRESSED)
756 SetKeyboardFocus(); 767 SetKeyboardFocus();
757 } 768 }
758 } 769 }
759 } 770 }
760 771
761 void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords( 772 void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords(
762 const ui::MouseEvent& ui_mouse_event, 773 const ui::MouseEvent& ui_mouse_event,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 host_->ForwardWheelEventWithLatencyInfo(event, latency); 868 host_->ForwardWheelEventWithLatencyInfo(event, latency);
858 } 869 }
859 870
860 void RenderWidgetHostViewEventHandler::ProcessTouchEvent( 871 void RenderWidgetHostViewEventHandler::ProcessTouchEvent(
861 const blink::WebTouchEvent& event, 872 const blink::WebTouchEvent& event,
862 const ui::LatencyInfo& latency) { 873 const ui::LatencyInfo& latency) {
863 host_->ForwardTouchEventWithLatencyInfo(event, latency); 874 host_->ForwardTouchEventWithLatencyInfo(event, latency);
864 } 875 }
865 876
866 } // namespace content 877 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698