| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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.h" | 5 #include "content/browser/renderer_host/render_widget_host.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 &coalesced_mouse_wheel_events_.back(); | 547 &coalesced_mouse_wheel_events_.back(); |
| 548 last_wheel_event->deltaX += wheel_event.deltaX; | 548 last_wheel_event->deltaX += wheel_event.deltaX; |
| 549 last_wheel_event->deltaY += wheel_event.deltaY; | 549 last_wheel_event->deltaY += wheel_event.deltaY; |
| 550 DCHECK_GE(wheel_event.timeStampSeconds, | 550 DCHECK_GE(wheel_event.timeStampSeconds, |
| 551 last_wheel_event->timeStampSeconds); | 551 last_wheel_event->timeStampSeconds); |
| 552 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds; | 552 last_wheel_event->timeStampSeconds = wheel_event.timeStampSeconds; |
| 553 } | 553 } |
| 554 return; | 554 return; |
| 555 } | 555 } |
| 556 mouse_wheel_pending_ = true; | 556 mouse_wheel_pending_ = true; |
| 557 current_wheel_event_ = wheel_event; |
| 557 | 558 |
| 558 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", | 559 HISTOGRAM_COUNTS_100("MPArch.RWH_WheelQueueSize", |
| 559 coalesced_mouse_wheel_events_.size()); | 560 coalesced_mouse_wheel_events_.size()); |
| 560 | 561 |
| 561 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false); | 562 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false); |
| 562 } | 563 } |
| 563 | 564 |
| 564 void RenderWidgetHost::ForwardGestureEvent( | 565 void RenderWidgetHost::ForwardGestureEvent( |
| 565 const WebKit::WebGestureEvent& gesture_event) { | 566 const WebKit::WebGestureEvent& gesture_event) { |
| 566 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); | 567 TRACE_EVENT0("renderer_host", "RenderWidgetHost::ForwardWheelEvent"); |
| (...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 1007 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
| 1007 process()->ReceivedBadMessage(); | 1008 process()->ReceivedBadMessage(); |
| 1008 } else if (type == WebInputEvent::MouseMove) { | 1009 } else if (type == WebInputEvent::MouseMove) { |
| 1009 mouse_move_pending_ = false; | 1010 mouse_move_pending_ = false; |
| 1010 | 1011 |
| 1011 // now, we can send the next mouse move event | 1012 // now, we can send the next mouse move event |
| 1012 if (next_mouse_move_.get()) { | 1013 if (next_mouse_move_.get()) { |
| 1013 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); | 1014 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); |
| 1014 ForwardMouseEvent(*next_mouse_move_); | 1015 ForwardMouseEvent(*next_mouse_move_); |
| 1015 } | 1016 } |
| 1016 } else if (type == WebInputEvent::MouseWheel) { | |
| 1017 ProcessWheelAck(); | |
| 1018 } else if (WebInputEvent::isKeyboardEventType(type)) { | 1017 } else if (WebInputEvent::isKeyboardEventType(type)) { |
| 1019 bool processed = false; | 1018 bool processed = false; |
| 1020 if (!message.ReadBool(&iter, &processed)) { | 1019 if (!message.ReadBool(&iter, &processed)) { |
| 1021 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3")); | 1020 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH3")); |
| 1022 process()->ReceivedBadMessage(); | 1021 process()->ReceivedBadMessage(); |
| 1023 } | 1022 } |
| 1024 | 1023 |
| 1025 ProcessKeyboardEventAck(type, processed); | 1024 ProcessKeyboardEventAck(type, processed); |
| 1025 } else if (type == WebInputEvent::MouseWheel) { |
| 1026 bool processed = false; |
| 1027 if (!message.ReadBool(&iter, &processed)) { |
| 1028 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); |
| 1029 process()->ReceivedBadMessage(); |
| 1030 } |
| 1031 |
| 1032 ProcessWheelAck(processed); |
| 1026 } else if (type == WebInputEvent::TouchMove) { | 1033 } else if (type == WebInputEvent::TouchMove) { |
| 1027 touch_move_pending_ = false; | 1034 touch_move_pending_ = false; |
| 1028 if (touch_event_is_queued_) { | 1035 if (touch_event_is_queued_) { |
| 1029 touch_event_is_queued_ = false; | 1036 touch_event_is_queued_ = false; |
| 1030 ForwardTouchEvent(queued_touch_event_); | 1037 ForwardTouchEvent(queued_touch_event_); |
| 1031 } | 1038 } |
| 1032 } | 1039 } |
| 1033 // This is used only for testing. | 1040 // This is used only for testing. |
| 1034 NotificationService::current()->Notify( | 1041 NotificationService::current()->Notify( |
| 1035 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 1042 content::NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
| 1036 Source<RenderWidgetHost>(this), | 1043 Source<RenderWidgetHost>(this), |
| 1037 Details<int>(&type)); | 1044 Details<int>(&type)); |
| 1038 } | 1045 } |
| 1039 | 1046 |
| 1040 void RenderWidgetHost::ProcessWheelAck() { | 1047 void RenderWidgetHost::ProcessWheelAck(bool processed) { |
| 1041 mouse_wheel_pending_ = false; | 1048 mouse_wheel_pending_ = false; |
| 1042 | 1049 |
| 1043 // Now send the next (coalesced) mouse wheel event. | 1050 // Now send the next (coalesced) mouse wheel event. |
| 1044 if (!coalesced_mouse_wheel_events_.empty()) { | 1051 if (!coalesced_mouse_wheel_events_.empty()) { |
| 1045 WebMouseWheelEvent next_wheel_event = | 1052 WebMouseWheelEvent next_wheel_event = |
| 1046 coalesced_mouse_wheel_events_.front(); | 1053 coalesced_mouse_wheel_events_.front(); |
| 1047 coalesced_mouse_wheel_events_.pop_front(); | 1054 coalesced_mouse_wheel_events_.pop_front(); |
| 1048 ForwardWheelEvent(next_wheel_event); | 1055 ForwardWheelEvent(next_wheel_event); |
| 1049 } | 1056 } |
| 1057 |
| 1058 if (!processed && !is_hidden_ && view_) |
| 1059 view_->UnhandledWheelEvent(current_wheel_event_); |
| 1050 } | 1060 } |
| 1051 | 1061 |
| 1052 void RenderWidgetHost::OnMsgFocus() { | 1062 void RenderWidgetHost::OnMsgFocus() { |
| 1053 // Only RenderViewHost can deal with that message. | 1063 // Only RenderViewHost can deal with that message. |
| 1054 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); | 1064 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RWH4")); |
| 1055 process()->ReceivedBadMessage(); | 1065 process()->ReceivedBadMessage(); |
| 1056 } | 1066 } |
| 1057 | 1067 |
| 1058 void RenderWidgetHost::OnMsgBlur() { | 1068 void RenderWidgetHost::OnMsgBlur() { |
| 1059 // Only RenderViewHost can deal with that message. | 1069 // Only RenderViewHost can deal with that message. |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 view_->CreatePluginContainer(deferred_plugin_handles_[i]); | 1225 view_->CreatePluginContainer(deferred_plugin_handles_[i]); |
| 1216 #endif | 1226 #endif |
| 1217 } | 1227 } |
| 1218 | 1228 |
| 1219 deferred_plugin_handles_.clear(); | 1229 deferred_plugin_handles_.clear(); |
| 1220 } | 1230 } |
| 1221 | 1231 |
| 1222 void RenderWidgetHost::StartUserGesture() { | 1232 void RenderWidgetHost::StartUserGesture() { |
| 1223 OnUserGesture(); | 1233 OnUserGesture(); |
| 1224 } | 1234 } |
| OLD | NEW |