OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1169 #endif | 1163 #endif |
1170 | 1164 |
1171 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1165 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
1172 uint32 output_surface_id, | 1166 uint32 output_surface_id, |
1173 scoped_ptr<cc::CompositorFrame> frame) { | 1167 scoped_ptr<cc::CompositorFrame> frame) { |
1174 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1168 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1175 | 1169 |
1176 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1170 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
1177 if (!frame->delegated_frame_data) | 1171 if (!frame->delegated_frame_data) |
1178 return; | 1172 return; |
1173 | |
1174 if (!has_started_rendering_) { | |
1175 // Let the page-level input event router know about our surface ID | |
1176 // namespace for surface-based hit testing. | |
1177 if (UseSurfacesEnabled() && host_->delegate() && | |
1178 host_->delegate()->GetInputEventRouter()) { | |
1179 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( | |
1180 GetSurfaceIdNamespace(), this); | |
1181 } | |
1182 has_started_rendering_ = true; | |
1183 } | |
1184 | |
1179 delegated_frame_host_->SwapDelegatedFrame( | 1185 delegated_frame_host_->SwapDelegatedFrame( |
1180 output_surface_id, frame->delegated_frame_data.Pass(), | 1186 output_surface_id, frame->delegated_frame_data.Pass(), |
1181 frame->metadata.device_scale_factor, frame->metadata.latency_info, | 1187 frame->metadata.device_scale_factor, frame->metadata.latency_info, |
1182 &frame->metadata.satisfies_sequences); | 1188 &frame->metadata.satisfies_sequences); |
1183 SelectionUpdated(frame->metadata.selection.is_editable, | 1189 SelectionUpdated(frame->metadata.selection.is_editable, |
1184 frame->metadata.selection.is_empty_text_form_control, | 1190 frame->metadata.selection.is_empty_text_form_control, |
1185 ConvertSelectionBound(frame->metadata.selection.start), | 1191 ConvertSelectionBound(frame->metadata.selection.start), |
1186 ConvertSelectionBound(frame->metadata.selection.end)); | 1192 ConvertSelectionBound(frame->metadata.selection.end)); |
1187 } | 1193 } |
1188 | 1194 |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2103 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2109 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
2104 } | 2110 } |
2105 #endif | 2111 #endif |
2106 // The Disambiguation popup does not parent itself from this window, so we | 2112 // The Disambiguation popup does not parent itself from this window, so we |
2107 // manually dismiss it. | 2113 // manually dismiss it. |
2108 HideDisambiguationPopup(); | 2114 HideDisambiguationPopup(); |
2109 | 2115 |
2110 blink::WebMouseWheelEvent mouse_wheel_event = | 2116 blink::WebMouseWheelEvent mouse_wheel_event = |
2111 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2117 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
2112 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 2118 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
2113 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2119 // TODO(wjmaclean); if AreCrossProcessFramesPossible() returns true, |
2120 // can we safely assume that any existing delegate will have an | |
2121 // InputEventRouter? Also, is the call to AreCrossProcessFramesPossible() | |
2122 // expensive? If so, can the result be stored in a bool? | |
kenrb
2015/11/02 16:04:22
I don't think we can assume a non-null return from
wjmaclean
2015/11/02 19:23:10
Ok, good to know.
| |
2123 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | |
2124 host_->delegate() && host_->delegate()->GetInputEventRouter()) { | |
2114 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2125 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
2115 this, &mouse_wheel_event); | 2126 this, &mouse_wheel_event); |
tdresser
2015/11/02 15:38:25
Could we refactor this into
ShouldRouteEvent and R
wjmaclean
2015/11/02 19:23:10
ShouldRouteEvent() was fairly easy, since we can k
tdresser
2015/11/02 21:10:19
This looks good to me.
| |
2116 } else { | 2127 } else { |
2117 ProcessMouseWheelEvent(mouse_wheel_event); | 2128 ProcessMouseWheelEvent(mouse_wheel_event); |
2118 } | 2129 } |
2119 } | 2130 } |
2120 } else { | 2131 } else { |
2121 bool is_selection_popup = | 2132 bool is_selection_popup = |
2122 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 2133 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
2123 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2134 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
2124 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2135 !(event->flags() & ui::EF_FROM_TOUCH)) { |
2125 // Confirm existing composition text on mouse press, to make sure | 2136 // Confirm existing composition text on mouse press, to make sure |
2126 // the input caret won't be moved with an ongoing composition text. | 2137 // the input caret won't be moved with an ongoing composition text. |
2127 if (event->type() == ui::ET_MOUSE_PRESSED) | 2138 if (event->type() == ui::ET_MOUSE_PRESSED) |
2128 FinishImeCompositionSession(); | 2139 FinishImeCompositionSession(); |
2129 | 2140 |
2130 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2141 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
2131 ModifyEventMovementAndCoords(&mouse_event); | 2142 ModifyEventMovementAndCoords(&mouse_event); |
2132 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2143 // TODO(wjmaclean): ditto the TODO above. |
2144 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | |
2145 host_->delegate() && host_->delegate()->GetInputEventRouter()) { | |
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 Loading... | |
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 Loading... | |
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 (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
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 Loading... | |
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 |
OLD | NEW |