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

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

Issue 23416003: Add content::RenderWidgetHost::MouseEventCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/browser/renderer_host/render_process_host_impl.h" 34 #include "content/browser/renderer_host/render_process_host_impl.h"
35 #include "content/browser/renderer_host/render_view_host_impl.h" 35 #include "content/browser/renderer_host/render_view_host_impl.h"
36 #include "content/browser/renderer_host/render_widget_helper.h" 36 #include "content/browser/renderer_host/render_widget_helper.h"
37 #include "content/browser/renderer_host/render_widget_host_delegate.h" 37 #include "content/browser/renderer_host/render_widget_host_delegate.h"
38 #include "content/common/accessibility_messages.h" 38 #include "content/common/accessibility_messages.h"
39 #include "content/common/content_constants_internal.h" 39 #include "content/common/content_constants_internal.h"
40 #include "content/common/gpu/gpu_messages.h" 40 #include "content/common/gpu/gpu_messages.h"
41 #include "content/common/input_messages.h" 41 #include "content/common/input_messages.h"
42 #include "content/common/view_messages.h" 42 #include "content/common/view_messages.h"
43 #include "content/port/browser/render_widget_host_view_port.h" 43 #include "content/port/browser/render_widget_host_view_port.h"
44 #include "content/public/browser/mouse_listener.h"
44 #include "content/public/browser/native_web_keyboard_event.h" 45 #include "content/public/browser/native_web_keyboard_event.h"
45 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/notification_types.h" 47 #include "content/public/browser/notification_types.h"
47 #include "content/public/browser/user_metrics.h" 48 #include "content/public/browser/user_metrics.h"
48 #include "content/public/common/content_constants.h" 49 #include "content/public/common/content_constants.h"
49 #include "content/public/common/content_switches.h" 50 #include "content/public/common/content_switches.h"
50 #include "content/public/common/result_codes.h" 51 #include "content/public/common/result_codes.h"
51 #include "skia/ext/image_operations.h" 52 #include "skia/ext/image_operations.h"
52 #include "skia/ext/platform_canvas.h" 53 #include "skia/ext/platform_canvas.h"
53 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 54 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { 1010 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
1010 ForwardMouseEventWithLatencyInfo( 1011 ForwardMouseEventWithLatencyInfo(
1011 MouseEventWithLatencyInfo(mouse_event, 1012 MouseEventWithLatencyInfo(mouse_event,
1012 CreateRWHLatencyInfoIfNotExist(NULL))); 1013 CreateRWHLatencyInfoIfNotExist(NULL)));
1013 } 1014 }
1014 1015
1015 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( 1016 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
1016 const MouseEventWithLatencyInfo& mouse_event) { 1017 const MouseEventWithLatencyInfo& mouse_event) {
1017 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", 1018 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent",
1018 "x", mouse_event.event.x, "y", mouse_event.event.y); 1019 "x", mouse_event.event.x, "y", mouse_event.event.y);
1020
1021 // First, let mouse listeners take a shot at handling the event. If a
1022 // listener handles the event, it should not be propagated to the renderer.
1023 if (MouseListenersHandleEvent(mouse_event.event))
1024 return;
1025
1019 input_router_->SendMouseEvent(mouse_event); 1026 input_router_->SendMouseEvent(mouse_event);
1020 } 1027 }
1021 1028
1022 void RenderWidgetHostImpl::OnPointerEventActivate() { 1029 void RenderWidgetHostImpl::OnPointerEventActivate() {
1023 } 1030 }
1024 1031
1025 void RenderWidgetHostImpl::ForwardWheelEvent( 1032 void RenderWidgetHostImpl::ForwardWheelEvent(
1026 const WebMouseWheelEvent& wheel_event) { 1033 const WebMouseWheelEvent& wheel_event) {
1027 ForwardWheelEventWithLatencyInfo( 1034 ForwardWheelEventWithLatencyInfo(
1028 MouseWheelEventWithLatencyInfo(wheel_event, 1035 MouseWheelEventWithLatencyInfo(wheel_event,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 keyboard_listeners_.AddObserver(listener); 1134 keyboard_listeners_.AddObserver(listener);
1128 } 1135 }
1129 1136
1130 void RenderWidgetHostImpl::RemoveKeyboardListener( 1137 void RenderWidgetHostImpl::RemoveKeyboardListener(
1131 KeyboardListener* listener) { 1138 KeyboardListener* listener) {
1132 // Ensure that the element is actually an observer. 1139 // Ensure that the element is actually an observer.
1133 DCHECK(keyboard_listeners_.HasObserver(listener)); 1140 DCHECK(keyboard_listeners_.HasObserver(listener));
1134 keyboard_listeners_.RemoveObserver(listener); 1141 keyboard_listeners_.RemoveObserver(listener);
1135 } 1142 }
1136 1143
1144 void RenderWidgetHostImpl::AddMouseListener(MouseListener* listener) {
1145 mouse_listeners_.AddObserver(listener);
1146 }
1147
1148 void RenderWidgetHostImpl::RemoveMouseListener(MouseListener* listener) {
1149 // Ensure that the element is actually an observer.
1150 DCHECK(mouse_listeners_.HasObserver(listener));
1151 mouse_listeners_.RemoveObserver(listener);
1152 }
1153
1137 void RenderWidgetHostImpl::GetWebScreenInfo(WebKit::WebScreenInfo* result) { 1154 void RenderWidgetHostImpl::GetWebScreenInfo(WebKit::WebScreenInfo* result) {
1138 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); 1155 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo");
1139 if (GetView()) 1156 if (GetView())
1140 static_cast<RenderWidgetHostViewPort*>(GetView())->GetScreenInfo(result); 1157 static_cast<RenderWidgetHostViewPort*>(GetView())->GetScreenInfo(result);
1141 else 1158 else
1142 RenderWidgetHostViewPort::GetDefaultScreenInfo(result); 1159 RenderWidgetHostViewPort::GetDefaultScreenInfo(result);
1143 screen_info_out_of_date_ = false; 1160 screen_info_out_of_date_ = false;
1144 } 1161 }
1145 1162
1146 const NativeWebKeyboardEvent* 1163 const NativeWebKeyboardEvent*
(...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1892 ObserverList<KeyboardListener>::Iterator it(keyboard_listeners_); 1909 ObserverList<KeyboardListener>::Iterator it(keyboard_listeners_);
1893 KeyboardListener* listener; 1910 KeyboardListener* listener;
1894 while ((listener = it.GetNext()) != NULL) { 1911 while ((listener = it.GetNext()) != NULL) {
1895 if (listener->HandleKeyPressEvent(event)) 1912 if (listener->HandleKeyPressEvent(event))
1896 return true; 1913 return true;
1897 } 1914 }
1898 1915
1899 return false; 1916 return false;
1900 } 1917 }
1901 1918
1919 bool RenderWidgetHostImpl::MouseListenersHandleEvent(
1920 const WebMouseEvent& event) {
1921 ObserverList<MouseListener>::Iterator it(mouse_listeners_);
1922 MouseListener* listener;
1923 while ((listener = it.GetNext()) != NULL) {
1924 if (listener->HandleMouseEvent(event))
1925 return true;
1926 }
1927
1928 return false;
1929 }
1930
1902 InputEventAckState RenderWidgetHostImpl::FilterInputEvent( 1931 InputEventAckState RenderWidgetHostImpl::FilterInputEvent(
1903 const WebKit::WebInputEvent& event, const ui::LatencyInfo& latency_info) { 1932 const WebKit::WebInputEvent& event, const ui::LatencyInfo& latency_info) {
1904 if (overscroll_controller() && 1933 if (overscroll_controller() &&
1905 !overscroll_controller()->WillDispatchEvent(event, latency_info)) { 1934 !overscroll_controller()->WillDispatchEvent(event, latency_info)) {
1906 return INPUT_EVENT_ACK_STATE_UNKNOWN; 1935 return INPUT_EVENT_ACK_STATE_UNKNOWN;
1907 } 1936 }
1908 1937
1909 return view_ ? view_->FilterInputEvent(event) 1938 return view_ ? view_->FilterInputEvent(event)
1910 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED; 1939 : INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
1911 } 1940 }
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2486 int process_id = (b->first.second >> 32) & 0xffffffff; 2515 int process_id = (b->first.second >> 32) & 0xffffffff;
2487 RenderWidgetHost* rwh = 2516 RenderWidgetHost* rwh =
2488 RenderWidgetHost::FromID(process_id, routing_id); 2517 RenderWidgetHost::FromID(process_id, routing_id);
2489 if (!rwh) 2518 if (!rwh)
2490 continue; 2519 continue;
2491 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2520 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2492 } 2521 }
2493 } 2522 }
2494 2523
2495 } // namespace content 2524 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698