Commit d1ddc17a authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

content: don't constantly recreate injector

This changes SyntheticGestureTargetAura to have an aura::EventInjector
rather than constantly creating one. In mash, EventInjector sends
events to the window service for dispatch. EventInjector establishes the
connection as necessary, but as SyntheticGestureTargetAura continually
recreates EventInjector the connection must be brough up (and destroyed) for
each event. This is non-trivially and adds unnecessary latency to perf
tests.

BUG=none
TEST=none

Change-Id: I22cc6ffe37808586ccd8904b75637e14f2532aea
Reviewed-on: https://chromium-review.googlesource.com/c/1311536Reviewed-by: default avatarJun Mukai <mukai@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604449}
parent 3533f575
......@@ -12,7 +12,6 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_aura.h"
#include "content/browser/renderer_host/ui_events_helper.h"
#include "ui/aura/event_injector.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/events/blink/blink_event_util.h"
......@@ -48,7 +47,6 @@ void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform(
aura::Window* window = GetWindow();
aura::WindowTreeHost* host = window->GetHost();
aura::EventInjector injector;
for (const auto& event : events) {
event->ConvertLocationToTarget(window, host->window());
......@@ -60,7 +58,8 @@ void SyntheticGestureTargetAura::DispatchWebTouchEventToPlatform(
gfx::ScalePoint(event->root_location_f(), device_scale_factor_);
event->set_location_f(device_location);
event->set_root_location_f(device_root_location);
ui::EventDispatchDetails details = injector.Inject(host, event.get());
ui::EventDispatchDetails details =
event_injector_.Inject(host, event.get());
if (details.dispatcher_destroyed)
break;
}
......@@ -98,9 +97,8 @@ void SyntheticGestureTargetAura::DispatchWebMouseWheelEventToPlatform(
aura::Window* window = GetWindow();
wheel_event.ConvertLocationToTarget(window, window->GetRootWindow());
aura::EventInjector injector;
ui::EventDispatchDetails details =
injector.Inject(window->GetHost(), &wheel_event);
event_injector_.Inject(window->GetHost(), &wheel_event);
if (details.dispatcher_destroyed)
return;
}
......@@ -113,7 +111,6 @@ void SyntheticGestureTargetAura::DispatchWebGestureEventToPlatform(
ui::EventType event_type = ui::WebEventTypeToEventType(web_gesture.GetType());
int flags = ui::WebEventModifiersToEventFlags(web_gesture.GetModifiers());
aura::Window* window = GetWindow();
aura::EventInjector injector;
if (blink::WebInputEvent::IsPinchGestureEventType(web_gesture.GetType())) {
ui::GestureEventDetails pinch_details(event_type);
......@@ -128,7 +125,7 @@ void SyntheticGestureTargetAura::DispatchWebGestureEventToPlatform(
pinch_event.ConvertLocationToTarget(window, window->GetRootWindow());
injector.Inject(window->GetHost(), &pinch_event);
event_injector_.Inject(window->GetHost(), &pinch_event);
return;
}
......@@ -145,7 +142,7 @@ void SyntheticGestureTargetAura::DispatchWebGestureEventToPlatform(
scroll_event.set_location_f(location);
scroll_event.set_root_location_f(location);
scroll_event.ConvertLocationToTarget(window, window->GetRootWindow());
injector.Inject(window->GetHost(), &scroll_event);
event_injector_.Inject(window->GetHost(), &scroll_event);
}
void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform(
......@@ -167,9 +164,8 @@ void SyntheticGestureTargetAura::DispatchWebMouseEventToPlatform(
aura::Window* window = GetWindow();
mouse_event.ConvertLocationToTarget(window, window->GetRootWindow());
aura::EventInjector injector;
ui::EventDispatchDetails details =
injector.Inject(window->GetHost(), &mouse_event);
event_injector_.Inject(window->GetHost(), &mouse_event);
if (details.dispatcher_destroyed)
return;
}
......
......@@ -9,6 +9,7 @@
#include "base/time/time.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
#include "content/common/input/synthetic_gesture_params.h"
#include "ui/aura/event_injector.h"
namespace aura {
class Window;
......@@ -55,6 +56,8 @@ class SyntheticGestureTargetAura : public SyntheticGestureTargetBase {
// before dispatching it into platform.
float device_scale_factor_;
aura::EventInjector event_injector_;
DISALLOW_COPY_AND_ASSIGN(SyntheticGestureTargetAura);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment