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

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: Address comments. Created 5 years, 1 month 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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 }; 444 };
444 445
445 //////////////////////////////////////////////////////////////////////////////// 446 ////////////////////////////////////////////////////////////////////////////////
446 // RenderWidgetHostViewAura, public: 447 // RenderWidgetHostViewAura, public:
447 448
448 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, 449 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host,
449 bool is_guest_view_hack) 450 bool is_guest_view_hack)
450 : host_(RenderWidgetHostImpl::From(host)), 451 : host_(RenderWidgetHostImpl::From(host)),
451 window_(new aura::Window(this)), 452 window_(new aura::Window(this)),
452 delegated_frame_host_(new DelegatedFrameHost(this)), 453 delegated_frame_host_(new DelegatedFrameHost(this)),
454 has_started_rendering_(false),
453 in_shutdown_(false), 455 in_shutdown_(false),
454 in_bounds_changed_(false), 456 in_bounds_changed_(false),
455 is_fullscreen_(false), 457 is_fullscreen_(false),
456 popup_parent_host_view_(NULL), 458 popup_parent_host_view_(NULL),
457 popup_child_host_view_(NULL), 459 popup_child_host_view_(NULL),
458 is_loading_(false), 460 is_loading_(false),
459 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 461 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
460 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 462 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
461 text_input_flags_(0), 463 text_input_flags_(0),
462 can_compose_inline_(true), 464 can_compose_inline_(true),
(...skipping 17 matching lines...) Expand all
480 host_->SetView(this); 482 host_->SetView(this);
481 483
482 window_observer_.reset(new WindowObserver(this)); 484 window_observer_.reset(new WindowObserver(this));
483 485
484 aura::client::SetTooltipText(window_, &tooltip_); 486 aura::client::SetTooltipText(window_, &tooltip_);
485 aura::client::SetActivationDelegate(window_, this); 487 aura::client::SetActivationDelegate(window_, this);
486 aura::client::SetFocusChangeObserver(window_, this); 488 aura::client::SetFocusChangeObserver(window_, this);
487 window_->set_layer_owner_delegate(delegated_frame_host_.get()); 489 window_->set_layer_owner_delegate(delegated_frame_host_.get());
488 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 490 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
489 491
490 // Let the page-level input event router know about our surface ID
491 // namespace for surface-based hit testing.
492 if (UseSurfacesEnabled() && host_->delegate() &&
493 host_->delegate()->GetInputEventRouter()) {
494 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner(
495 GetSurfaceIdNamespace(), this);
496 }
497
498 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 492 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
499 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 493 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
500 SetOverscrollControllerEnabled(overscroll_enabled); 494 SetOverscrollControllerEnabled(overscroll_enabled);
501 495
502 selection_controller_client_.reset( 496 selection_controller_client_.reset(
503 new TouchSelectionControllerClientAura(this)); 497 new TouchSelectionControllerClientAura(this));
504 CreateSelectionController(); 498 CreateSelectionController();
505 } 499 }
506 500
507 //////////////////////////////////////////////////////////////////////////////// 501 ////////////////////////////////////////////////////////////////////////////////
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 ui::EF_RIGHT_MOUSE_BUTTON; 830 ui::EF_RIGHT_MOUSE_BUTTON;
837 return (event->flags() & kAllowedButtons) != 0; 831 return (event->flags() & kAllowedButtons) != 0;
838 } 832 }
839 default: 833 default:
840 break; 834 break;
841 } 835 }
842 #endif 836 #endif
843 return true; 837 return true;
844 } 838 }
845 839
840 bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const {
841 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter();
842 if (event->IsMouseEvent())
843 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible();
844 return result;
845 }
846
846 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { 847 void RenderWidgetHostViewAura::HandleParentBoundsChanged() {
847 SnapToPhysicalPixelBoundary(); 848 SnapToPhysicalPixelBoundary();
848 #if defined(OS_WIN) 849 #if defined(OS_WIN)
849 if (legacy_render_widget_host_HWND_) { 850 if (legacy_render_widget_host_HWND_) {
850 legacy_render_widget_host_HWND_->SetBounds( 851 legacy_render_widget_host_HWND_->SetBounds(
851 window_->GetBoundsInRootWindow()); 852 window_->GetBoundsInRootWindow());
852 } 853 }
853 #endif 854 #endif
854 if (!in_shutdown_) 855 if (!in_shutdown_)
855 host_->SendScreenRects(); 856 host_->SendScreenRects();
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1169 #endif 1170 #endif
1170 1171
1171 void RenderWidgetHostViewAura::OnSwapCompositorFrame( 1172 void RenderWidgetHostViewAura::OnSwapCompositorFrame(
1172 uint32 output_surface_id, 1173 uint32 output_surface_id,
1173 scoped_ptr<cc::CompositorFrame> frame) { 1174 scoped_ptr<cc::CompositorFrame> frame) {
1174 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1175 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1175 1176
1176 last_scroll_offset_ = frame->metadata.root_scroll_offset; 1177 last_scroll_offset_ = frame->metadata.root_scroll_offset;
1177 if (!frame->delegated_frame_data) 1178 if (!frame->delegated_frame_data)
1178 return; 1179 return;
1180
1181 if (!has_started_rendering_) {
1182 // Let the page-level input event router know about our surface ID
1183 // namespace for surface-based hit testing.
1184 if (UseSurfacesEnabled() && host_->delegate() &&
1185 host_->delegate()->GetInputEventRouter()) {
1186 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner(
1187 GetSurfaceIdNamespace(), this);
1188 }
1189 has_started_rendering_ = true;
1190 }
1191
1179 delegated_frame_host_->SwapDelegatedFrame( 1192 delegated_frame_host_->SwapDelegatedFrame(
1180 output_surface_id, frame->delegated_frame_data.Pass(), 1193 output_surface_id, frame->delegated_frame_data.Pass(),
1181 frame->metadata.device_scale_factor, frame->metadata.latency_info, 1194 frame->metadata.device_scale_factor, frame->metadata.latency_info,
1182 &frame->metadata.satisfies_sequences); 1195 &frame->metadata.satisfies_sequences);
1183 SelectionUpdated(frame->metadata.selection.is_editable, 1196 SelectionUpdated(frame->metadata.selection.is_editable,
1184 frame->metadata.selection.is_empty_text_form_control, 1197 frame->metadata.selection.is_empty_text_form_control,
1185 ConvertSelectionBound(frame->metadata.selection.start), 1198 ConvertSelectionBound(frame->metadata.selection.start),
1186 ConvertSelectionBound(frame->metadata.selection.end)); 1199 ConvertSelectionBound(frame->metadata.selection.end));
1187 } 1200 }
1188 1201
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2103 reinterpret_cast<LPARAM>(toplevel_hwnd)); 2116 reinterpret_cast<LPARAM>(toplevel_hwnd));
2104 } 2117 }
2105 #endif 2118 #endif
2106 // The Disambiguation popup does not parent itself from this window, so we 2119 // The Disambiguation popup does not parent itself from this window, so we
2107 // manually dismiss it. 2120 // manually dismiss it.
2108 HideDisambiguationPopup(); 2121 HideDisambiguationPopup();
2109 2122
2110 blink::WebMouseWheelEvent mouse_wheel_event = 2123 blink::WebMouseWheelEvent mouse_wheel_event =
2111 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 2124 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
2112 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { 2125 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
2113 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 2126 if (ShouldRouteEvent(event)) {
2114 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( 2127 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
2115 this, &mouse_wheel_event); 2128 this, &mouse_wheel_event);
2116 } else { 2129 } else {
2117 ProcessMouseWheelEvent(mouse_wheel_event); 2130 ProcessMouseWheelEvent(mouse_wheel_event);
2118 } 2131 }
2119 } 2132 }
2120 } else { 2133 } else {
2121 bool is_selection_popup = 2134 bool is_selection_popup =
2122 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); 2135 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
2123 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 2136 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
2124 !(event->flags() & ui::EF_FROM_TOUCH)) { 2137 !(event->flags() & ui::EF_FROM_TOUCH)) {
2125 // Confirm existing composition text on mouse press, to make sure 2138 // Confirm existing composition text on mouse press, to make sure
2126 // the input caret won't be moved with an ongoing composition text. 2139 // the input caret won't be moved with an ongoing composition text.
2127 if (event->type() == ui::ET_MOUSE_PRESSED) 2140 if (event->type() == ui::ET_MOUSE_PRESSED)
2128 FinishImeCompositionSession(); 2141 FinishImeCompositionSession();
2129 2142
2130 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); 2143 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event);
2131 ModifyEventMovementAndCoords(&mouse_event); 2144 ModifyEventMovementAndCoords(&mouse_event);
2132 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 2145 if (ShouldRouteEvent(event)) {
2133 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, 2146 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
2134 &mouse_event); 2147 &mouse_event);
2135 } else { 2148 } else {
2136 ProcessMouseEvent(mouse_event); 2149 ProcessMouseEvent(mouse_event);
2137 } 2150 }
2138 2151
2139 // Ensure that we get keyboard focus on mouse down as a plugin window may 2152 // Ensure that we get keyboard focus on mouse down as a plugin window may
2140 // have grabbed keyboard focus. 2153 // have grabbed keyboard focus.
2141 if (event->type() == ui::ET_MOUSE_PRESSED) 2154 if (event->type() == ui::ET_MOUSE_PRESSED)
2142 SetKeyboardFocus(); 2155 SetKeyboardFocus();
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2186 void RenderWidgetHostViewAura::ProcessMouseEvent( 2199 void RenderWidgetHostViewAura::ProcessMouseEvent(
2187 const blink::WebMouseEvent& event) { 2200 const blink::WebMouseEvent& event) {
2188 host_->ForwardMouseEvent(event); 2201 host_->ForwardMouseEvent(event);
2189 } 2202 }
2190 2203
2191 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( 2204 void RenderWidgetHostViewAura::ProcessMouseWheelEvent(
2192 const blink::WebMouseWheelEvent& event) { 2205 const blink::WebMouseWheelEvent& event) {
2193 host_->ForwardWheelEvent(event); 2206 host_->ForwardWheelEvent(event);
2194 } 2207 }
2195 2208
2209 void RenderWidgetHostViewAura::ProcessTouchEvent(
2210 const blink::WebTouchEvent& event,
2211 const ui::LatencyInfo& latency) {
2212 host_->ForwardTouchEventWithLatencyInfo(event, latency);
2213 }
2214
2196 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2215 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2197 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2216 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2198 2217
2199 if (event->type() == ui::ET_SCROLL) { 2218 if (event->type() == ui::ET_SCROLL) {
2200 #if !defined(OS_WIN) 2219 #if !defined(OS_WIN)
2201 // TODO(ananta) 2220 // TODO(ananta)
2202 // Investigate if this is true for Windows 8 Metro ASH as well. 2221 // Investigate if this is true for Windows 8 Metro ASH as well.
2203 if (event->finger_count() != 2) 2222 if (event->finger_count() != 2)
2204 return; 2223 return;
2205 #endif 2224 #endif
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2252 2271
2253 // It is important to always mark events as being handled asynchronously when 2272 // It is important to always mark events as being handled asynchronously when
2254 // they are forwarded. This ensures that the current event does not get 2273 // they are forwarded. This ensures that the current event does not get
2255 // processed by the gesture recognizer before events currently awaiting 2274 // processed by the gesture recognizer before events currently awaiting
2256 // dispatch in the touch queue. 2275 // dispatch in the touch queue.
2257 event->DisableSynchronousHandling(); 2276 event->DisableSynchronousHandling();
2258 2277
2259 // Set unchanged touch point to StateStationary for touchmove and 2278 // Set unchanged touch point to StateStationary for touchmove and
2260 // touchcancel to make sure only send one ack per WebTouchEvent. 2279 // touchcancel to make sure only send one ack per WebTouchEvent.
2261 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); 2280 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2262 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2281 if (ShouldRouteEvent(event)) {
2282 host_->delegate()->GetInputEventRouter()->RouteTouchEvent(
2283 this, &touch_event, *event->latency());
2284 } else {
2285 ProcessTouchEvent(touch_event, *event->latency());
2286 }
2263 } 2287 }
2264 2288
2265 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2289 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2266 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2290 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2267 2291
2268 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2292 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2269 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2293 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2270 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2294 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2271 event->SetHandled(); 2295 event->SetHandled();
2272 return; 2296 return;
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 2923
2900 //////////////////////////////////////////////////////////////////////////////// 2924 ////////////////////////////////////////////////////////////////////////////////
2901 // RenderWidgetHostViewBase, public: 2925 // RenderWidgetHostViewBase, public:
2902 2926
2903 // static 2927 // static
2904 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2928 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2905 GetScreenInfoForWindow(results, NULL); 2929 GetScreenInfoForWindow(results, NULL);
2906 } 2930 }
2907 2931
2908 } // namespace content 2932 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698