Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 21 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 22 #include "content/browser/gpu/gpu_surface_tracker.h" | 22 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 23 #include "content/browser/renderer_host/backing_store.h" | 23 #include "content/browser/renderer_host/backing_store.h" |
| 24 #include "content/browser/renderer_host/backing_store_manager.h" | 24 #include "content/browser/renderer_host/backing_store_manager.h" |
| 25 #include "content/browser/renderer_host/gesture_event_filter.h" | 25 #include "content/browser/renderer_host/gesture_event_filter.h" |
| 26 #include "content/browser/renderer_host/render_process_host_impl.h" | 26 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 27 #include "content/browser/renderer_host/render_view_host_impl.h" | 27 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 28 #include "content/browser/renderer_host/render_widget_helper.h" | 28 #include "content/browser/renderer_host/render_widget_helper.h" |
| 29 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 29 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 30 #include "content/browser/renderer_host/tap_suppression_controller.h" | 30 #include "content/browser/renderer_host/tap_suppression_controller.h" |
| 31 #include "content/browser/renderer_host/touch_event_queue.h" | |
| 31 #include "content/common/accessibility_messages.h" | 32 #include "content/common/accessibility_messages.h" |
| 32 #include "content/common/gpu/gpu_messages.h" | 33 #include "content/common/gpu/gpu_messages.h" |
| 33 #include "content/common/view_messages.h" | 34 #include "content/common/view_messages.h" |
| 34 #include "content/port/browser/render_widget_host_view_port.h" | 35 #include "content/port/browser/render_widget_host_view_port.h" |
| 35 #include "content/port/browser/smooth_scroll_gesture.h" | 36 #include "content/port/browser/smooth_scroll_gesture.h" |
| 36 #include "content/public/browser/native_web_keyboard_event.h" | 37 #include "content/public/browser/native_web_keyboard_event.h" |
| 37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
| 38 #include "content/public/browser/notification_types.h" | 39 #include "content/public/browser/notification_types.h" |
| 39 #include "content/public/browser/user_metrics.h" | 40 #include "content/public/browser/user_metrics.h" |
| 40 #include "content/public/common/compositor_util.h" | 41 #include "content/public/common/compositor_util.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 ignore_input_events_(false), | 143 ignore_input_events_(false), |
| 143 text_direction_updated_(false), | 144 text_direction_updated_(false), |
| 144 text_direction_(WebKit::WebTextDirectionLeftToRight), | 145 text_direction_(WebKit::WebTextDirectionLeftToRight), |
| 145 text_direction_canceled_(false), | 146 text_direction_canceled_(false), |
| 146 suppress_next_char_events_(false), | 147 suppress_next_char_events_(false), |
| 147 pending_mouse_lock_request_(false), | 148 pending_mouse_lock_request_(false), |
| 148 allow_privileged_mouse_lock_(false), | 149 allow_privileged_mouse_lock_(false), |
| 149 has_touch_handler_(false), | 150 has_touch_handler_(false), |
| 150 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), | 151 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), |
| 151 tick_active_smooth_scroll_gestures_task_posted_(false), | 152 tick_active_smooth_scroll_gestures_task_posted_(false), |
| 153 touch_event_queue_(new TouchEventQueue(this)), | |
| 152 gesture_event_filter_(new GestureEventFilter(this)) { | 154 gesture_event_filter_(new GestureEventFilter(this)) { |
| 153 CHECK(delegate_); | 155 CHECK(delegate_); |
| 154 if (routing_id_ == MSG_ROUTING_NONE) { | 156 if (routing_id_ == MSG_ROUTING_NONE) { |
| 155 routing_id_ = process_->GetNextRoutingID(); | 157 routing_id_ = process_->GetNextRoutingID(); |
| 156 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 158 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
| 157 process_->GetID(), | 159 process_->GetID(), |
| 158 routing_id_); | 160 routing_id_); |
| 159 } else { | 161 } else { |
| 160 // TODO(piman): This is a O(N) lookup, where we could forward the | 162 // TODO(piman): This is a O(N) lookup, where we could forward the |
| 161 // information from the RenderWidgetHelper. The problem is that doing so | 163 // information from the RenderWidgetHelper. The problem is that doing so |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 933 void RenderWidgetHostImpl::ForwardGestureEvent( | 935 void RenderWidgetHostImpl::ForwardGestureEvent( |
| 934 const WebKit::WebGestureEvent& gesture_event) { | 936 const WebKit::WebGestureEvent& gesture_event) { |
| 935 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardGestureEvent"); | 937 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardGestureEvent"); |
| 936 if (ignore_input_events_ || process_->IgnoreInputEvents() || | 938 if (ignore_input_events_ || process_->IgnoreInputEvents() || |
| 937 !gesture_event_filter_->ShouldForward(gesture_event)) | 939 !gesture_event_filter_->ShouldForward(gesture_event)) |
| 938 return; | 940 return; |
| 939 | 941 |
| 940 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); | 942 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); |
| 941 } | 943 } |
| 942 | 944 |
| 945 void RenderWidgetHostImpl::ForwardTouchEventImmediately( | |
| 946 const WebKit::WebTouchEvent& touch_event) { | |
| 947 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | |
| 948 if (ignore_input_events_ || process_->IgnoreInputEvents()) | |
| 949 return; | |
| 950 | |
| 951 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); | |
| 952 } | |
| 953 | |
| 943 void RenderWidgetHostImpl::ForwardGestureEventImmediately( | 954 void RenderWidgetHostImpl::ForwardGestureEventImmediately( |
| 944 const WebKit::WebGestureEvent& gesture_event) { | 955 const WebKit::WebGestureEvent& gesture_event) { |
| 945 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 956 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
| 946 return; | 957 return; |
| 947 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); | 958 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); |
| 948 } | 959 } |
| 949 | 960 |
| 950 void RenderWidgetHostImpl::ForwardKeyboardEvent( | 961 void RenderWidgetHostImpl::ForwardKeyboardEvent( |
| 951 const NativeWebKeyboardEvent& key_event) { | 962 const NativeWebKeyboardEvent& key_event) { |
| 952 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardKeyboardEvent"); | 963 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1040 // after this line. | 1051 // after this line. |
| 1041 next_mouse_move_.reset(); | 1052 next_mouse_move_.reset(); |
| 1042 | 1053 |
| 1043 increment_in_flight_event_count(); | 1054 increment_in_flight_event_count(); |
| 1044 StartHangMonitorTimeout( | 1055 StartHangMonitorTimeout( |
| 1045 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); | 1056 TimeDelta::FromMilliseconds(hung_renderer_delay_ms_)); |
| 1046 } | 1057 } |
| 1047 | 1058 |
| 1048 void RenderWidgetHostImpl::ForwardTouchEvent( | 1059 void RenderWidgetHostImpl::ForwardTouchEvent( |
| 1049 const WebKit::WebTouchEvent& touch_event) { | 1060 const WebKit::WebTouchEvent& touch_event) { |
| 1050 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardTouchEvent"); | 1061 touch_event_queue_->QueueEvent(touch_event); |
|
aelias_OOO_until_Jul13
2012/10/16 23:28:38
RenderWidgetHost is not doing anything here except
sadrul
2012/10/16 23:49:14
I actually considered doing something similar at f
| |
| 1051 if (ignore_input_events_ || process_->IgnoreInputEvents()) | |
| 1052 return; | |
| 1053 | |
| 1054 // TODO(sad): Do touch-event coalescing when appropriate. | |
| 1055 ForwardInputEvent(touch_event, sizeof(WebKit::WebTouchEvent), false); | |
| 1056 } | 1062 } |
| 1057 | 1063 |
| 1058 #if defined(TOOLKIT_GTK) | 1064 #if defined(TOOLKIT_GTK) |
| 1059 bool RenderWidgetHostImpl::KeyPressListenersHandleEvent(GdkEventKey* event) { | 1065 bool RenderWidgetHostImpl::KeyPressListenersHandleEvent(GdkEventKey* event) { |
| 1060 if (event->type != GDK_KEY_PRESS) | 1066 if (event->type != GDK_KEY_PRESS) |
| 1061 return false; | 1067 return false; |
| 1062 | 1068 |
| 1063 for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); | 1069 for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
| 1064 it != keyboard_listeners_.end(); ++it) { | 1070 it != keyboard_listeners_.end(); ++it) { |
| 1065 if ((*it)->HandleKeyPressEvent(event)) | 1071 if ((*it)->HandleKeyPressEvent(event)) |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1727 | 1733 |
| 1728 if (!processed && !is_hidden_ && view_) | 1734 if (!processed && !is_hidden_ && view_) |
| 1729 view_->UnhandledWheelEvent(current_wheel_event_); | 1735 view_->UnhandledWheelEvent(current_wheel_event_); |
| 1730 } | 1736 } |
| 1731 | 1737 |
| 1732 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { | 1738 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { |
| 1733 gesture_event_filter_->ProcessGestureAck(processed, type); | 1739 gesture_event_filter_->ProcessGestureAck(processed, type); |
| 1734 } | 1740 } |
| 1735 | 1741 |
| 1736 void RenderWidgetHostImpl::ProcessTouchAck(bool processed) { | 1742 void RenderWidgetHostImpl::ProcessTouchAck(bool processed) { |
| 1737 if (view_) | 1743 touch_event_queue_->ProcessTouchAck(processed); |
| 1738 view_->ProcessTouchAck(processed); | |
| 1739 } | 1744 } |
| 1740 | 1745 |
| 1741 void RenderWidgetHostImpl::OnMsgFocus() { | 1746 void RenderWidgetHostImpl::OnMsgFocus() { |
| 1742 // Only RenderViewHost can deal with that message. | 1747 // Only RenderViewHost can deal with that message. |
| 1743 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); | 1748 RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); |
| 1744 GetProcess()->ReceivedBadMessage(); | 1749 GetProcess()->ReceivedBadMessage(); |
| 1745 } | 1750 } |
| 1746 | 1751 |
| 1747 void RenderWidgetHostImpl::OnMsgBlur() { | 1752 void RenderWidgetHostImpl::OnMsgBlur() { |
| 1748 // Only RenderViewHost can deal with that message. | 1753 // Only RenderViewHost can deal with that message. |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2125 return; | 2130 return; |
| 2126 | 2131 |
| 2127 OnRenderAutoResized(new_size); | 2132 OnRenderAutoResized(new_size); |
| 2128 } | 2133 } |
| 2129 | 2134 |
| 2130 void RenderWidgetHostImpl::DetachDelegate() { | 2135 void RenderWidgetHostImpl::DetachDelegate() { |
| 2131 delegate_ = NULL; | 2136 delegate_ = NULL; |
| 2132 } | 2137 } |
| 2133 | 2138 |
| 2134 } // namespace content | 2139 } // namespace content |
| OLD | NEW |