Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(814)

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1412923009: Route touch-events for WebViewGuest directly to guest renderer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comments (saving first this time). Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index fd2a94cc979e71b8b871e920f7832448e75735c9..83d7118a115b62419f9396d5bdaa3195bf663fc7 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -45,6 +45,7 @@
#include "content/browser/renderer_host/web_input_event_aura.h"
#include "content/common/gpu/client/gl_helper.h"
#include "content/common/gpu/gpu_messages.h"
+#include "content/common/site_isolation_policy.h"
#include "content/common/view_messages.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/overscroll_configuration.h"
@@ -857,6 +858,23 @@ bool RenderWidgetHostViewAura::CanRendererHandleEvent(
return true;
}
+bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const {
+ // We should route an event in two cases:
+ // 1) Mouse events are routed only if cross-process frames are possible.
+ // 2) Touch events are always routed. In the absence of a BrowserPlugin
+ // we expect the routing to always send the event to this view. If
+ // one or more BrowserPlugins are present, then the event may be targeted
+ // to one of them, or this view. This allows GuestViews to have access to
+ // them while still forcing pinch-zoom to be handled by the top-level
+ // frame. TODO(wjmaclean): At present, this doesn't work for OOPIF, but
+ // it should be a simple extension to modify RenderWidgetHostViewChildFrame
+ // in a similar manner to RenderWidgetHostViewGuest.
+ bool result = host_->delegate() && host_->delegate()->GetInputEventRouter();
+ if (event->IsMouseEvent())
+ result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible();
+ return result;
+}
+
void RenderWidgetHostViewAura::HandleParentBoundsChanged() {
SnapToPhysicalPixelBoundary();
#if defined(OS_WIN)
@@ -2127,7 +2145,7 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
blink::WebMouseWheelEvent mouse_wheel_event =
MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
- if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
+ if (ShouldRouteEvent(event)) {
host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
this, &mouse_wheel_event);
} else {
@@ -2146,7 +2164,7 @@ void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event);
ModifyEventMovementAndCoords(&mouse_event);
- if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
+ if (ShouldRouteEvent(event)) {
host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
&mouse_event);
} else {
@@ -2219,6 +2237,12 @@ void RenderWidgetHostViewAura::ProcessMouseWheelEvent(
host_->ForwardWheelEvent(event);
}
+void RenderWidgetHostViewAura::ProcessTouchEvent(
+ const blink::WebTouchEvent& event,
+ const ui::LatencyInfo& latency) {
+ host_->ForwardTouchEventWithLatencyInfo(event, latency);
+}
+
void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace(
const gfx::Point& point,
cc::SurfaceId original_surface,
@@ -2293,7 +2317,12 @@ void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
// Set unchanged touch point to StateStationary for touchmove and
// touchcancel to make sure only send one ack per WebTouchEvent.
MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
- host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
+ if (ShouldRouteEvent(event)) {
+ host_->delegate()->GetInputEventRouter()->RouteTouchEvent(
+ this, &touch_event, *event->latency());
+ } else {
+ ProcessTouchEvent(touch_event, *event->latency());
+ }
}
void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {

Powered by Google App Engine
This is Rietveld 408576698