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

Side by Side 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: Fix null pointer deref when guest is terminated. 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 unified diff | Download patch
OLDNEW
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_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 26 matching lines...) Expand all
37 #include "content/browser/renderer_host/render_view_host_delegate.h" 37 #include "content/browser/renderer_host/render_view_host_delegate.h"
38 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 38 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
39 #include "content/browser/renderer_host/render_view_host_impl.h" 39 #include "content/browser/renderer_host/render_view_host_impl.h"
40 #include "content/browser/renderer_host/render_widget_host_delegate.h" 40 #include "content/browser/renderer_host/render_widget_host_delegate.h"
41 #include "content/browser/renderer_host/render_widget_host_impl.h" 41 #include "content/browser/renderer_host/render_widget_host_impl.h"
42 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 42 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
43 #include "content/browser/renderer_host/ui_events_helper.h" 43 #include "content/browser/renderer_host/ui_events_helper.h"
44 #include "content/browser/renderer_host/web_input_event_aura.h" 44 #include "content/browser/renderer_host/web_input_event_aura.h"
45 #include "content/common/gpu/client/gl_helper.h" 45 #include "content/common/gpu/client/gl_helper.h"
46 #include "content/common/gpu/gpu_messages.h" 46 #include "content/common/gpu/gpu_messages.h"
47 #include "content/common/site_isolation_policy.h"
47 #include "content/common/view_messages.h" 48 #include "content/common/view_messages.h"
48 #include "content/public/browser/content_browser_client.h" 49 #include "content/public/browser/content_browser_client.h"
49 #include "content/public/browser/overscroll_configuration.h" 50 #include "content/public/browser/overscroll_configuration.h"
50 #include "content/public/browser/render_view_host.h" 51 #include "content/public/browser/render_view_host.h"
51 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 52 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
52 #include "content/public/browser/user_metrics.h" 53 #include "content/public/browser/user_metrics.h"
53 #include "content/public/common/content_switches.h" 54 #include "content/public/common/content_switches.h"
54 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 55 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
55 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 56 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
56 #include "third_party/WebKit/public/web/WebInputEvent.h" 57 #include "third_party/WebKit/public/web/WebInputEvent.h"
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 ui::EF_RIGHT_MOUSE_BUTTON; 855 ui::EF_RIGHT_MOUSE_BUTTON;
855 return (event->flags() & kAllowedButtons) != 0; 856 return (event->flags() & kAllowedButtons) != 0;
856 } 857 }
857 default: 858 default:
858 break; 859 break;
859 } 860 }
860 #endif 861 #endif
861 return true; 862 return true;
862 } 863 }
863 864
865 bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const {
866 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter();
867 if (event->IsMouseEvent())
868 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible();
kenrb 2015/11/25 19:33:06 I think we also need this change for RenderWidgetH
wjmaclean 2015/11/26 13:01:03 Done.
869 return result;
870 }
871
864 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { 872 void RenderWidgetHostViewAura::HandleParentBoundsChanged() {
865 SnapToPhysicalPixelBoundary(); 873 SnapToPhysicalPixelBoundary();
866 #if defined(OS_WIN) 874 #if defined(OS_WIN)
867 if (legacy_render_widget_host_HWND_) { 875 if (legacy_render_widget_host_HWND_) {
868 legacy_render_widget_host_HWND_->SetBounds( 876 legacy_render_widget_host_HWND_->SetBounds(
869 window_->GetBoundsInRootWindow()); 877 window_->GetBoundsInRootWindow());
870 } 878 }
871 #endif 879 #endif
872 if (!in_shutdown_) 880 if (!in_shutdown_)
873 host_->SendScreenRects(); 881 host_->SendScreenRects();
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 reinterpret_cast<LPARAM>(toplevel_hwnd)); 2132 reinterpret_cast<LPARAM>(toplevel_hwnd));
2125 } 2133 }
2126 #endif 2134 #endif
2127 // The Disambiguation popup does not parent itself from this window, so we 2135 // The Disambiguation popup does not parent itself from this window, so we
2128 // manually dismiss it. 2136 // manually dismiss it.
2129 HideDisambiguationPopup(); 2137 HideDisambiguationPopup();
2130 2138
2131 blink::WebMouseWheelEvent mouse_wheel_event = 2139 blink::WebMouseWheelEvent mouse_wheel_event =
2132 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 2140 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
2133 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { 2141 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
2134 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 2142 if (ShouldRouteEvent(event)) {
2135 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( 2143 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
2136 this, &mouse_wheel_event); 2144 this, &mouse_wheel_event);
2137 } else { 2145 } else {
2138 ProcessMouseWheelEvent(mouse_wheel_event); 2146 ProcessMouseWheelEvent(mouse_wheel_event);
2139 } 2147 }
2140 } 2148 }
2141 } else { 2149 } else {
2142 bool is_selection_popup = 2150 bool is_selection_popup =
2143 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); 2151 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
2144 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 2152 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
2145 !(event->flags() & ui::EF_FROM_TOUCH)) { 2153 !(event->flags() & ui::EF_FROM_TOUCH)) {
2146 // Confirm existing composition text on mouse press, to make sure 2154 // Confirm existing composition text on mouse press, to make sure
2147 // the input caret won't be moved with an ongoing composition text. 2155 // the input caret won't be moved with an ongoing composition text.
2148 if (event->type() == ui::ET_MOUSE_PRESSED) 2156 if (event->type() == ui::ET_MOUSE_PRESSED)
2149 FinishImeCompositionSession(); 2157 FinishImeCompositionSession();
2150 2158
2151 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); 2159 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event);
2152 ModifyEventMovementAndCoords(&mouse_event); 2160 ModifyEventMovementAndCoords(&mouse_event);
2153 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 2161 if (ShouldRouteEvent(event)) {
2154 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, 2162 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
2155 &mouse_event); 2163 &mouse_event);
2156 } else { 2164 } else {
2157 ProcessMouseEvent(mouse_event); 2165 ProcessMouseEvent(mouse_event);
2158 } 2166 }
2159 2167
2160 // Ensure that we get keyboard focus on mouse down as a plugin window may 2168 // Ensure that we get keyboard focus on mouse down as a plugin window may
2161 // have grabbed keyboard focus. 2169 // have grabbed keyboard focus.
2162 if (event->type() == ui::ET_MOUSE_PRESSED) 2170 if (event->type() == ui::ET_MOUSE_PRESSED)
2163 SetKeyboardFocus(); 2171 SetKeyboardFocus();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 void RenderWidgetHostViewAura::ProcessMouseEvent( 2224 void RenderWidgetHostViewAura::ProcessMouseEvent(
2217 const blink::WebMouseEvent& event) { 2225 const blink::WebMouseEvent& event) {
2218 host_->ForwardMouseEvent(event); 2226 host_->ForwardMouseEvent(event);
2219 } 2227 }
2220 2228
2221 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( 2229 void RenderWidgetHostViewAura::ProcessMouseWheelEvent(
2222 const blink::WebMouseWheelEvent& event) { 2230 const blink::WebMouseWheelEvent& event) {
2223 host_->ForwardWheelEvent(event); 2231 host_->ForwardWheelEvent(event);
2224 } 2232 }
2225 2233
2234 void RenderWidgetHostViewAura::ProcessTouchEvent(
2235 const blink::WebTouchEvent& event,
2236 const ui::LatencyInfo& latency) {
2237 host_->ForwardTouchEventWithLatencyInfo(event, latency);
2238 }
2239
2226 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2240 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2227 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2241 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2228 2242
2229 if (event->type() == ui::ET_SCROLL) { 2243 if (event->type() == ui::ET_SCROLL) {
2230 #if !defined(OS_WIN) 2244 #if !defined(OS_WIN)
2231 // TODO(ananta) 2245 // TODO(ananta)
2232 // Investigate if this is true for Windows 8 Metro ASH as well. 2246 // Investigate if this is true for Windows 8 Metro ASH as well.
2233 if (event->finger_count() != 2) 2247 if (event->finger_count() != 2)
2234 return; 2248 return;
2235 #endif 2249 #endif
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 2296
2283 // It is important to always mark events as being handled asynchronously when 2297 // It is important to always mark events as being handled asynchronously when
2284 // they are forwarded. This ensures that the current event does not get 2298 // they are forwarded. This ensures that the current event does not get
2285 // processed by the gesture recognizer before events currently awaiting 2299 // processed by the gesture recognizer before events currently awaiting
2286 // dispatch in the touch queue. 2300 // dispatch in the touch queue.
2287 event->DisableSynchronousHandling(); 2301 event->DisableSynchronousHandling();
2288 2302
2289 // Set unchanged touch point to StateStationary for touchmove and 2303 // Set unchanged touch point to StateStationary for touchmove and
2290 // touchcancel to make sure only send one ack per WebTouchEvent. 2304 // touchcancel to make sure only send one ack per WebTouchEvent.
2291 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); 2305 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2292 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2306 if (ShouldRouteEvent(event)) {
2307 host_->delegate()->GetInputEventRouter()->RouteTouchEvent(
2308 this, &touch_event, *event->latency());
2309 } else {
2310 ProcessTouchEvent(touch_event, *event->latency());
2311 }
2293 } 2312 }
2294 2313
2295 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2314 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2296 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2315 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2297 2316
2298 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2317 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2299 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2318 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2300 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2319 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2301 event->SetHandled(); 2320 event->SetHandled();
2302 return; 2321 return;
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 2993
2975 //////////////////////////////////////////////////////////////////////////////// 2994 ////////////////////////////////////////////////////////////////////////////////
2976 // RenderWidgetHostViewBase, public: 2995 // RenderWidgetHostViewBase, public:
2977 2996
2978 // static 2997 // static
2979 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2998 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2980 GetScreenInfoForWindow(results, NULL); 2999 GetScreenInfoForWindow(results, NULL);
2981 } 3000 }
2982 3001
2983 } // namespace content 3002 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698