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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 #include "content/browser/renderer_host/render_view_host_delegate.h" | 38 #include "content/browser/renderer_host/render_view_host_delegate.h" |
39 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 39 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
40 #include "content/browser/renderer_host/render_view_host_impl.h" | 40 #include "content/browser/renderer_host/render_view_host_impl.h" |
41 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 41 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
42 #include "content/browser/renderer_host/render_widget_host_impl.h" | 42 #include "content/browser/renderer_host/render_widget_host_impl.h" |
43 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" | 43 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" |
44 #include "content/browser/renderer_host/ui_events_helper.h" | 44 #include "content/browser/renderer_host/ui_events_helper.h" |
45 #include "content/browser/renderer_host/web_input_event_aura.h" | 45 #include "content/browser/renderer_host/web_input_event_aura.h" |
46 #include "content/common/gpu/client/gl_helper.h" | 46 #include "content/common/gpu/client/gl_helper.h" |
47 #include "content/common/gpu/gpu_messages.h" | 47 #include "content/common/gpu/gpu_messages.h" |
48 #include "content/common/site_isolation_policy.h" | |
48 #include "content/common/view_messages.h" | 49 #include "content/common/view_messages.h" |
49 #include "content/public/browser/content_browser_client.h" | 50 #include "content/public/browser/content_browser_client.h" |
50 #include "content/public/browser/overscroll_configuration.h" | 51 #include "content/public/browser/overscroll_configuration.h" |
51 #include "content/public/browser/render_view_host.h" | 52 #include "content/public/browser/render_view_host.h" |
52 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 53 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
53 #include "content/public/browser/user_metrics.h" | 54 #include "content/public/browser/user_metrics.h" |
54 #include "content/public/common/content_switches.h" | 55 #include "content/public/common/content_switches.h" |
55 #include "third_party/WebKit/public/platform/WebScreenInfo.h" | 56 #include "third_party/WebKit/public/platform/WebScreenInfo.h" |
56 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 57 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
57 #include "third_party/WebKit/public/web/WebInputEvent.h" | 58 #include "third_party/WebKit/public/web/WebInputEvent.h" |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
850 ui::EF_RIGHT_MOUSE_BUTTON; | 851 ui::EF_RIGHT_MOUSE_BUTTON; |
851 return (event->flags() & kAllowedButtons) != 0; | 852 return (event->flags() & kAllowedButtons) != 0; |
852 } | 853 } |
853 default: | 854 default: |
854 break; | 855 break; |
855 } | 856 } |
856 #endif | 857 #endif |
857 return true; | 858 return true; |
858 } | 859 } |
859 | 860 |
861 bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const { | |
862 // We should route an event in two cases: | |
863 // 1) Mouse events are routed only if cross-process frames are possible. | |
864 // 2) Touch events are always routed. In the absence of a BrowserPlugin | |
865 // we expect the routing to always send the event to this view. If | |
866 // one or more BrowserPlugins are present, then the event may be targeted | |
867 // to one of them, or this view. This allows GuestViews to have access to | |
868 // them while still forcing pinch-zoom to be handled by the top-level | |
869 // frame. | |
Charlie Reis
2015/12/11 21:32:52
Thanks-- this comment is so much clearer!
Are the
wjmaclean
2015/12/14 14:17:40
Done.
| |
870 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter(); | |
871 if (event->IsMouseEvent()) | |
872 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); | |
873 return result; | |
874 } | |
875 | |
860 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { | 876 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
861 SnapToPhysicalPixelBoundary(); | 877 SnapToPhysicalPixelBoundary(); |
862 #if defined(OS_WIN) | 878 #if defined(OS_WIN) |
863 if (legacy_render_widget_host_HWND_) { | 879 if (legacy_render_widget_host_HWND_) { |
864 legacy_render_widget_host_HWND_->SetBounds( | 880 legacy_render_widget_host_HWND_->SetBounds( |
865 window_->GetBoundsInRootWindow()); | 881 window_->GetBoundsInRootWindow()); |
866 } | 882 } |
867 #endif | 883 #endif |
868 if (!in_shutdown_) | 884 if (!in_shutdown_) |
869 host_->SendScreenRects(); | 885 host_->SendScreenRects(); |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2120 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2136 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
2121 } | 2137 } |
2122 #endif | 2138 #endif |
2123 // The Disambiguation popup does not parent itself from this window, so we | 2139 // The Disambiguation popup does not parent itself from this window, so we |
2124 // manually dismiss it. | 2140 // manually dismiss it. |
2125 HideDisambiguationPopup(); | 2141 HideDisambiguationPopup(); |
2126 | 2142 |
2127 blink::WebMouseWheelEvent mouse_wheel_event = | 2143 blink::WebMouseWheelEvent mouse_wheel_event = |
2128 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2144 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
2129 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 2145 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
2130 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2146 if (ShouldRouteEvent(event)) { |
2131 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2147 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
2132 this, &mouse_wheel_event); | 2148 this, &mouse_wheel_event); |
2133 } else { | 2149 } else { |
2134 ProcessMouseWheelEvent(mouse_wheel_event); | 2150 ProcessMouseWheelEvent(mouse_wheel_event); |
2135 } | 2151 } |
2136 } | 2152 } |
2137 } else { | 2153 } else { |
2138 bool is_selection_popup = | 2154 bool is_selection_popup = |
2139 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 2155 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
2140 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2156 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
2141 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2157 !(event->flags() & ui::EF_FROM_TOUCH)) { |
2142 // Confirm existing composition text on mouse press, to make sure | 2158 // Confirm existing composition text on mouse press, to make sure |
2143 // the input caret won't be moved with an ongoing composition text. | 2159 // the input caret won't be moved with an ongoing composition text. |
2144 if (event->type() == ui::ET_MOUSE_PRESSED) | 2160 if (event->type() == ui::ET_MOUSE_PRESSED) |
2145 FinishImeCompositionSession(); | 2161 FinishImeCompositionSession(); |
2146 | 2162 |
2147 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2163 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
2148 ModifyEventMovementAndCoords(&mouse_event); | 2164 ModifyEventMovementAndCoords(&mouse_event); |
2149 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2165 if (ShouldRouteEvent(event)) { |
2150 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 2166 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, |
2151 &mouse_event); | 2167 &mouse_event); |
2152 } else { | 2168 } else { |
2153 ProcessMouseEvent(mouse_event); | 2169 ProcessMouseEvent(mouse_event); |
2154 } | 2170 } |
2155 | 2171 |
2156 // Ensure that we get keyboard focus on mouse down as a plugin window may | 2172 // Ensure that we get keyboard focus on mouse down as a plugin window may |
2157 // have grabbed keyboard focus. | 2173 // have grabbed keyboard focus. |
2158 if (event->type() == ui::ET_MOUSE_PRESSED) | 2174 if (event->type() == ui::ET_MOUSE_PRESSED) |
2159 SetKeyboardFocus(); | 2175 SetKeyboardFocus(); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2212 void RenderWidgetHostViewAura::ProcessMouseEvent( | 2228 void RenderWidgetHostViewAura::ProcessMouseEvent( |
2213 const blink::WebMouseEvent& event) { | 2229 const blink::WebMouseEvent& event) { |
2214 host_->ForwardMouseEvent(event); | 2230 host_->ForwardMouseEvent(event); |
2215 } | 2231 } |
2216 | 2232 |
2217 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( | 2233 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( |
2218 const blink::WebMouseWheelEvent& event) { | 2234 const blink::WebMouseWheelEvent& event) { |
2219 host_->ForwardWheelEvent(event); | 2235 host_->ForwardWheelEvent(event); |
2220 } | 2236 } |
2221 | 2237 |
2238 void RenderWidgetHostViewAura::ProcessTouchEvent( | |
2239 const blink::WebTouchEvent& event, | |
2240 const ui::LatencyInfo& latency) { | |
2241 host_->ForwardTouchEventWithLatencyInfo(event, latency); | |
2242 } | |
2243 | |
2222 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( | 2244 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( |
2223 const gfx::Point& point, | 2245 const gfx::Point& point, |
2224 cc::SurfaceId original_surface, | 2246 cc::SurfaceId original_surface, |
2225 gfx::Point* transformed_point) { | 2247 gfx::Point* transformed_point) { |
2226 delegated_frame_host_->TransformPointToLocalCoordSpace( | 2248 delegated_frame_host_->TransformPointToLocalCoordSpace( |
2227 point, original_surface, transformed_point); | 2249 point, original_surface, transformed_point); |
2228 } | 2250 } |
2229 | 2251 |
2230 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2252 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
2231 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2253 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2286 | 2308 |
2287 // It is important to always mark events as being handled asynchronously when | 2309 // It is important to always mark events as being handled asynchronously when |
2288 // they are forwarded. This ensures that the current event does not get | 2310 // they are forwarded. This ensures that the current event does not get |
2289 // processed by the gesture recognizer before events currently awaiting | 2311 // processed by the gesture recognizer before events currently awaiting |
2290 // dispatch in the touch queue. | 2312 // dispatch in the touch queue. |
2291 event->DisableSynchronousHandling(); | 2313 event->DisableSynchronousHandling(); |
2292 | 2314 |
2293 // Set unchanged touch point to StateStationary for touchmove and | 2315 // Set unchanged touch point to StateStationary for touchmove and |
2294 // touchcancel to make sure only send one ack per WebTouchEvent. | 2316 // touchcancel to make sure only send one ack per WebTouchEvent. |
2295 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | 2317 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); |
2296 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2318 if (ShouldRouteEvent(event)) { |
2319 host_->delegate()->GetInputEventRouter()->RouteTouchEvent( | |
2320 this, &touch_event, *event->latency()); | |
2321 } else { | |
2322 ProcessTouchEvent(touch_event, *event->latency()); | |
2323 } | |
2297 } | 2324 } |
2298 | 2325 |
2299 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2326 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2300 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2327 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2301 | 2328 |
2302 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2329 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2303 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2330 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2304 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2331 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2305 event->SetHandled(); | 2332 event->SetHandled(); |
2306 return; | 2333 return; |
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2990 | 3017 |
2991 //////////////////////////////////////////////////////////////////////////////// | 3018 //////////////////////////////////////////////////////////////////////////////// |
2992 // RenderWidgetHostViewBase, public: | 3019 // RenderWidgetHostViewBase, public: |
2993 | 3020 |
2994 // static | 3021 // static |
2995 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3022 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2996 GetScreenInfoForWindow(results, NULL); | 3023 GetScreenInfoForWindow(results, NULL); |
2997 } | 3024 } |
2998 | 3025 |
2999 } // namespace content | 3026 } // namespace content |
OLD | NEW |