| 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 2c57a2b78d543dafaff3170cf9d2447cc2ce5d62..c2f16549947fbf7a12099539d429fbbb6376bc16 100644
|
| --- a/content/browser/renderer_host/render_widget_host_impl.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
| @@ -857,9 +857,11 @@ void RenderWidgetHostImpl::ForwardMouseEventWithLatencyInfo(
|
| const ui::LatencyInfo& ui_latency) {
|
| TRACE_EVENT2("input", "RenderWidgetHostImpl::ForwardMouseEvent",
|
| "x", mouse_event.x, "y", mouse_event.y);
|
| + ui::LatencyInfo::InputCoordinates logical_coordinates = {
|
| + {mouse_event.x, mouse_event.y}};
|
|
|
| - ui::LatencyInfo latency_info =
|
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, mouse_event.type);
|
| + ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
|
| + &ui_latency, mouse_event.type, logical_coordinates, 1);
|
|
|
| for (size_t i = 0; i < mouse_event_callbacks_.size(); ++i) {
|
| if (mouse_event_callbacks_[i].Run(mouse_event))
|
| @@ -889,8 +891,11 @@ void RenderWidgetHostImpl::ForwardWheelEventWithLatencyInfo(
|
| const ui::LatencyInfo& ui_latency) {
|
| TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardWheelEvent");
|
|
|
| - ui::LatencyInfo latency_info =
|
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, wheel_event.type);
|
| + ui::LatencyInfo::InputCoordinates logical_coordinates = {
|
| + {wheel_event.x, wheel_event.y}};
|
| +
|
| + ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
|
| + &ui_latency, wheel_event.type, logical_coordinates, 1);
|
|
|
| if (IgnoreInputEvents())
|
| return;
|
| @@ -918,8 +923,11 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
|
| if (delegate_->PreHandleGestureEvent(gesture_event))
|
| return;
|
|
|
| - ui::LatencyInfo latency_info =
|
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, gesture_event.type);
|
| + ui::LatencyInfo::InputCoordinates logical_coordinates = {
|
| + {gesture_event.x, gesture_event.y}};
|
| +
|
| + ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
|
| + &ui_latency, gesture_event.type, logical_coordinates, 1);
|
|
|
| if (gesture_event.type == blink::WebInputEvent::GestureScrollUpdate) {
|
| latency_info.AddLatencyNumber(
|
| @@ -950,8 +958,18 @@ void RenderWidgetHostImpl::ForwardGestureEventWithLatencyInfo(
|
| void RenderWidgetHostImpl::ForwardEmulatedTouchEvent(
|
| const blink::WebTouchEvent& touch_event) {
|
| TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent");
|
| - ui::LatencyInfo latency_info =
|
| - CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type);
|
| +
|
| + ui::LatencyInfo::InputCoordinates logical_coordinates;
|
| + size_t logical_coordinates_size =
|
| + std::min(static_cast<size_t>(ui::LatencyInfo::kMaxInputCoordinates),
|
| + static_cast<size_t>(touch_event.touchesLength));
|
| + for (size_t i = 0; i < logical_coordinates_size; i++) {
|
| + logical_coordinates[i][0] = touch_event.touches[i].position.x;
|
| + logical_coordinates[i][1] = touch_event.touches[i].position.y;
|
| + }
|
| +
|
| + ui::LatencyInfo latency_info = CreateRWHLatencyInfoIfNotExist(
|
| + NULL, touch_event.type, logical_coordinates, logical_coordinates_size);
|
| TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
|
| input_router_->SendTouchEvent(touch_with_latency);
|
| }
|
| @@ -964,8 +982,20 @@ void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo(
|
| // Always forward TouchEvents for touch stream consistency. They will be
|
| // ignored if appropriate in FilterInputEvent().
|
|
|
| + ui::LatencyInfo::InputCoordinates logical_coordinates;
|
| + size_t logical_coordinates_size =
|
| + std::min(static_cast<size_t>(ui::LatencyInfo::kMaxInputCoordinates),
|
| + static_cast<size_t>(touch_event.touchesLength));
|
| + for (size_t i = 0; i < logical_coordinates_size; i++) {
|
| + logical_coordinates[i][0] = touch_event.touches[i].position.x;
|
| + logical_coordinates[i][1] = touch_event.touches[i].position.y;
|
| + }
|
| +
|
| ui::LatencyInfo latency_info =
|
| - CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type);
|
| + CreateRWHLatencyInfoIfNotExist(&ui_latency,
|
| + touch_event.type,
|
| + logical_coordinates,
|
| + logical_coordinates_size);
|
| TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info);
|
|
|
| if (touch_emulator_ &&
|
| @@ -1044,9 +1074,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, 0),
|
| is_shortcut);
|
| }
|
|
|
| @@ -1089,10 +1123,14 @@ 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,
|
| + size_t logical_coordinates_size) {
|
| 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,
|
| @@ -1102,7 +1140,21 @@ 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.
|
| + float device_scale_factor =
|
| + screen_info_ ? screen_info_->deviceScaleFactor : 1;
|
| + DCHECK(logical_coordinates_size <= ui::LatencyInfo::kMaxInputCoordinates);
|
| + info.input_coordinates_size = logical_coordinates_size;
|
| + for (size_t i = 0; i < info.input_coordinates_size; i++) {
|
| + for (size_t j = 0; j < arraysize(logical_coordinates[i]); j++) {
|
| + info.input_coordinates[i][j] =
|
| + logical_coordinates[i][j] * device_scale_factor;
|
| + }
|
| + }
|
| }
|
| +
|
| return info;
|
| }
|
|
|
|
|