Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_impl.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
| index 759d6526d4c410bab7c55a45e972ed62fe351007..1db2db1bcd09c0db1fc31e446543e371c54dacf7 100644 |
| --- a/content/browser/renderer_host/render_widget_host_impl.cc |
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc |
| @@ -852,8 +852,12 @@ void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo( |
| TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent", |
| "x", mouse_event.x, "y", mouse_event.y); |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + logical_coordinates.push_back(gfx::PointF(mouse_event.x, mouse_event.y)); |
| + |
| ui::LatencyInfo latency_info = |
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, mouse_event.type); |
| + CreateRWHLatencyInfoIfNotExist(&ui_latency, mouse_event.type, |
| + logical_coordinates); |
| for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) { |
| if (mouse_event_callbacks_[i].Run(mouse_event)) |
| @@ -883,8 +887,12 @@ void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo( |
| const ui::LatencyInfo& ui_latency) { |
| TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent"); |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + logical_coordinates.push_back(gfx::PointF(wheel_event.x, wheel_event.y)); |
| + |
| ui::LatencyInfo latency_info = |
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, wheel_event.type); |
| + CreateRWHLatencyInfoIfNotExist(&ui_latency, wheel_event.type, |
| + logical_coordinates); |
| if (IgnoreInputEvents()) |
| return; |
| @@ -912,8 +920,12 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
| if (delegate_->PreHandleGestureEvent(gesture_event)) |
| return; |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + logical_coordinates.push_back(gfx::PointF(gesture_event.x, gesture_event.y)); |
| + |
| ui::LatencyInfo latency_info = |
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, gesture_event.type); |
| + CreateRWHLatencyInfoIfNotExist(&ui_latency, gesture_event.type, |
| + logical_coordinates); |
| if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate) { |
| latency_info.AddLatencyNumber( |
| @@ -944,8 +956,17 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo( |
| void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
| const blink::WebTouchEvent& touch_event) { |
| TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
| + |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + for (size_t i = 0; i < touch_event.touchesLength; i++) { |
| + logical_coordinates.push_back(gfx::PointF( |
| + touch_event.touches[i].position.x, |
| + touch_event.touches[i].position.y)); |
| + } |
| + |
| ui::LatencyInfo latency_info = |
| - CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type); |
| + CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type, |
| + logical_coordinates); |
| TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
| input_router_->SendTouchEvent(touch_with_latency); |
| } |
| @@ -957,9 +978,17 @@ void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
| // Always forward TouchEvents for touch stream consistency. They will be |
| // ignored if appropriate in FilterInputEvent(). |
| + // |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + for (size_t i = 0; i < touch_event.touchesLength; i++) { |
| + logical_coordinates.push_back(gfx::PointF( |
| + touch_event.touches[i].position.x, |
| + touch_event.touches[i].position.y)); |
| + } |
| ui::LatencyInfo latency_info = |
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type); |
| + CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type, |
| + logical_coordinates); |
| TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
| if (touch_emulator_ && |
| @@ -1038,9 +1067,13 @@ void RenderWidgetHostImpl::ForwardKeyboardEvent( |
| if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
| return; |
| + // Keyboard events have no coordinates attached. |
| + ui::LatencyInfo::InputCoordinates logical_coordinates; |
| + |
| input_router_->SendKeyboardEvent( |
| key_event, |
| - CreateRWHLatencyInfoIfNotExist(NULL, key_event.type), |
| + CreateRWHLatencyInfoIfNotExist(NULL, key_event.type, |
| + logical_coordinates), |
| is_shortcut); |
| } |
| @@ -1083,10 +1116,12 @@ void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { |
| } |
| ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist( |
| - const ui::LatencyInfo* original, WebInputEvent::Type type) { |
| + const ui::LatencyInfo* original, WebInputEvent::Type type, |
| + const ui::LatencyInfo::InputCoordinates& logical_coordinates) { |
| ui::LatencyInfo info; |
| if (original) |
| info = *original; |
| + |
| // In Aura, gesture event will already carry its original touch event's |
| // INPUT_EVENT_LATENCY_RWH_COMPONENT. |
| if (!info.FindLatency(ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, |
| @@ -1096,7 +1131,15 @@ ui::LatencyInfo RenderWidgetHostImpl::CreateRWHLatencyInfoIfNotExist( |
| GetLatencyComponentId(), |
| ++last_input_number_); |
| info.TraceEventType(WebInputEventTraits::GetName(type)); |
| + |
| + // Convert logical coordinates to physical coordinates, based on the |
| + // device scale factor. |
| + ui::LatencyInfo::InputCoordinates physical_coordinates(logical_coordinates); |
| + for (size_t i = 0; i < physical_coordinates.size(); i++) |
| + physical_coordinates[i].Scale(screen_info_->deviceScaleFactor); |
| + info.coordinates = physical_coordinates; |
|
Sami
2014/09/05 17:26:02
Clear & append this directly.
|
| } |
| + |
| return info; |
| } |