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 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { | 1009 void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) { |
1010 ForwardMouseEventWithLatencyInfo( | 1010 ForwardMouseEventWithLatencyInfo( |
1011 MouseEventWithLatencyInfo(mouse_event, | 1011 MouseEventWithLatencyInfo(mouse_event, |
1012 CreateRWHLatencyInfoIfNotExist(NULL))); | 1012 CreateRWHLatencyInfoIfNotExist(NULL))); |
1013 } | 1013 } |
1014 | 1014 |
1015 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( | 1015 void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
1016 const MouseEventWithLatencyInfo& mouse_event) { | 1016 const MouseEventWithLatencyInfo& mouse_event) { |
1017 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", | 1017 TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
1018 "x", mouse_event.event.x, "y", mouse_event.event.y); | 1018 "x", mouse_event.event.x, "y", mouse_event.event.y); |
| 1019 |
| 1020 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
| 1021 if (mouse_event_callbacks_[i].Run(mouse_event.event)) |
| 1022 return; |
| 1023 } |
| 1024 |
1019 input_router_->SendMouseEvent(mouse_event); | 1025 input_router_->SendMouseEvent(mouse_event); |
1020 } | 1026 } |
1021 | 1027 |
1022 void RenderWidgetHostImpl::OnPointerEventActivate() { | 1028 void RenderWidgetHostImpl::OnPointerEventActivate() { |
1023 } | 1029 } |
1024 | 1030 |
1025 void RenderWidgetHostImpl::ForwardWheelEvent( | 1031 void RenderWidgetHostImpl::ForwardWheelEvent( |
1026 const WebMouseWheelEvent& wheel_event) { | 1032 const WebMouseWheelEvent& wheel_event) { |
1027 ForwardWheelEventWithLatencyInfo( | 1033 ForwardWheelEventWithLatencyInfo( |
1028 MouseWheelEventWithLatencyInfo(wheel_event, | 1034 MouseWheelEventWithLatencyInfo(wheel_event, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1132 const KeyPressEventCallback& callback) { | 1138 const KeyPressEventCallback& callback) { |
1133 for (size_t i = 0; i < key_press_event_callbacks_.size(); ++i) { | 1139 for (size_t i = 0; i < key_press_event_callbacks_.size(); ++i) { |
1134 if (key_press_event_callbacks_[i].Equals(callback)) { | 1140 if (key_press_event_callbacks_[i].Equals(callback)) { |
1135 key_press_event_callbacks_.erase( | 1141 key_press_event_callbacks_.erase( |
1136 key_press_event_callbacks_.begin() + i); | 1142 key_press_event_callbacks_.begin() + i); |
1137 return; | 1143 return; |
1138 } | 1144 } |
1139 } | 1145 } |
1140 } | 1146 } |
1141 | 1147 |
| 1148 void RenderWidgetHostImpl::AddMouseEventCallback( |
| 1149 const MouseEventCallback& callback) { |
| 1150 mouse_event_callbacks_.push_back(callback); |
| 1151 } |
| 1152 |
| 1153 void RenderWidgetHostImpl::RemoveMouseEventCallback( |
| 1154 const MouseEventCallback& callback) { |
| 1155 for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
| 1156 if (mouse_event_callbacks_[i].Equals(callback)) { |
| 1157 mouse_event_callbacks_.erase(mouse_event_callbacks_.begin() + i); |
| 1158 return; |
| 1159 } |
| 1160 } |
| 1161 } |
| 1162 |
1142 void RenderWidgetHostImpl::GetWebScreenInfo(WebKit::WebScreenInfo* result) { | 1163 void RenderWidgetHostImpl::GetWebScreenInfo(WebKit::WebScreenInfo* result) { |
1143 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); | 1164 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::GetWebScreenInfo"); |
1144 if (GetView()) | 1165 if (GetView()) |
1145 static_cast<RenderWidgetHostViewPort*>(GetView())->GetScreenInfo(result); | 1166 static_cast<RenderWidgetHostViewPort*>(GetView())->GetScreenInfo(result); |
1146 else | 1167 else |
1147 RenderWidgetHostViewPort::GetDefaultScreenInfo(result); | 1168 RenderWidgetHostViewPort::GetDefaultScreenInfo(result); |
1148 screen_info_out_of_date_ = false; | 1169 screen_info_out_of_date_ = false; |
1149 } | 1170 } |
1150 | 1171 |
1151 const NativeWebKeyboardEvent* | 1172 const NativeWebKeyboardEvent* |
(...skipping 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 int process_id = (b->first.second >> 32) & 0xffffffff; | 2510 int process_id = (b->first.second >> 32) & 0xffffffff; |
2490 RenderWidgetHost* rwh = | 2511 RenderWidgetHost* rwh = |
2491 RenderWidgetHost::FromID(process_id, routing_id); | 2512 RenderWidgetHost::FromID(process_id, routing_id); |
2492 if (!rwh) | 2513 if (!rwh) |
2493 continue; | 2514 continue; |
2494 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); | 2515 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); |
2495 } | 2516 } |
2496 } | 2517 } |
2497 | 2518 |
2498 } // namespace content | 2519 } // namespace content |
OLD | NEW |