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

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: Created 3 years, 12 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 ui::MouseEvent* event) { 690 ui::MouseEvent* event) {
691 aura::client::CursorClient* cursor_client = 691 aura::client::CursorClient* cursor_client =
692 aura::client::GetCursorClient(window_->GetRootWindow()); 692 aura::client::GetCursorClient(window_->GetRootWindow());
693 693
694 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 694 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
695 695
696 if (event->type() == ui::ET_MOUSEWHEEL) { 696 if (event->type() == ui::ET_MOUSEWHEEL) {
697 blink::WebMouseWheelEvent mouse_wheel_event = 697 blink::WebMouseWheelEvent mouse_wheel_event =
698 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event), 698 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event),
699 base::Bind(&GetScreenLocationFromEvent)); 699 base::Bind(&GetScreenLocationFromEvent));
700 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 700 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
701 host_->ForwardWheelEvent(mouse_wheel_event); 701 if (ShouldRouteEvent(event)) {
702 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
703 host_view_, &mouse_wheel_event, *event->latency());
704 } else {
705 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency());
706 }
707 }
702 return; 708 return;
703 } 709 }
704 710
705 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); 711 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint());
706 712
707 // If we receive non client mouse messages while we are in the locked state 713 // If we receive non client mouse messages while we are in the locked state
708 // it probably means that the mouse left the borders of our window and 714 // it probably means that the mouse left the borders of our window and
709 // needs to be moved back to the center. 715 // needs to be moved back to the center.
710 if (event->flags() & ui::EF_IS_NON_CLIENT) { 716 if (event->flags() & ui::EF_IS_NON_CLIENT) {
711 // TODO(jonross): ideally this would not be done for mus (crbug.com/621412) 717 // 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
749 } else { 755 } else {
750 // Check if the mouse has reached the border and needs to be centered. 756 // Check if the mouse has reached the border and needs to be centered.
751 if (ShouldMoveToCenter()) { 757 if (ShouldMoveToCenter()) {
752 synthetic_move_sent_ = true; 758 synthetic_move_sent_ = true;
753 window_->MoveCursorTo(center); 759 window_->MoveCursorTo(center);
754 } 760 }
755 bool is_selection_popup = NeedsInputGrab(popup_child_host_view_); 761 bool is_selection_popup = NeedsInputGrab(popup_child_host_view_);
756 // Forward event to renderer. 762 // Forward event to renderer.
757 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 763 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
758 !(event->flags() & ui::EF_FROM_TOUCH)) { 764 !(event->flags() & ui::EF_FROM_TOUCH)) {
759 host_->ForwardMouseEvent(mouse_event); 765 if (ShouldRouteEvent(event)) {
766 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(
767 host_view_, &mouse_event, *event->latency());
768 } else {
769 ProcessMouseEvent(mouse_event, *event->latency());
770 }
760 // Ensure that we get keyboard focus on mouse down as a plugin window 771 // Ensure that we get keyboard focus on mouse down as a plugin window
761 // may have grabbed keyboard focus. 772 // may have grabbed keyboard focus.
762 if (event->type() == ui::ET_MOUSE_PRESSED) 773 if (event->type() == ui::ET_MOUSE_PRESSED)
763 SetKeyboardFocus(); 774 SetKeyboardFocus();
764 } 775 }
765 } 776 }
766 } 777 }
767 778
768 void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords( 779 void RenderWidgetHostViewEventHandler::ModifyEventMovementAndCoords(
769 const ui::MouseEvent& ui_mouse_event, 780 const ui::MouseEvent& ui_mouse_event,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 host_->ForwardWheelEventWithLatencyInfo(event, latency); 875 host_->ForwardWheelEventWithLatencyInfo(event, latency);
865 } 876 }
866 877
867 void RenderWidgetHostViewEventHandler::ProcessTouchEvent( 878 void RenderWidgetHostViewEventHandler::ProcessTouchEvent(
868 const blink::WebTouchEvent& event, 879 const blink::WebTouchEvent& event,
869 const ui::LatencyInfo& latency) { 880 const ui::LatencyInfo& latency) {
870 host_->ForwardTouchEventWithLatencyInfo(event, latency); 881 host_->ForwardTouchEventWithLatencyInfo(event, latency);
871 } 882 }
872 883
873 } // namespace content 884 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698