Chromium Code Reviews| 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) If cross-process frames are possible, then we route the event. | |
|
Charlie Reis
2015/12/10 21:58:14
This doesn't seem to be what the code below is doi
wjmaclean
2015/12/10 22:44:14
Perhaps I've badly worded the comment. Prior to th
| |
| 864 // 2) Even if (1) is not satisfied, we still route the event if we have | |
| 865 // an input event router: at present this only happens for touch events, | |
| 866 // and is required in order that pinch-zoom works properly for | |
| 867 // WebViews. | |
| 868 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter(); | |
|
Charlie Reis
2015/12/10 21:58:15
This looks like it will almost always be true (unl
wjmaclean
2015/12/10 22:44:14
Yes. But |result| can be set false if we are deali
| |
| 869 if (event->IsMouseEvent()) | |
| 870 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); | |
|
Charlie Reis
2015/12/10 21:58:15
On a related note, we should confirm whether AreCr
wjmaclean
2015/12/10 22:44:14
OK. This code is based on the existing logic, so i
| |
| 871 return result; | |
| 872 } | |
| 873 | |
| 860 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { | 874 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
| 861 SnapToPhysicalPixelBoundary(); | 875 SnapToPhysicalPixelBoundary(); |
| 862 #if defined(OS_WIN) | 876 #if defined(OS_WIN) |
| 863 if (legacy_render_widget_host_HWND_) { | 877 if (legacy_render_widget_host_HWND_) { |
| 864 legacy_render_widget_host_HWND_->SetBounds( | 878 legacy_render_widget_host_HWND_->SetBounds( |
| 865 window_->GetBoundsInRootWindow()); | 879 window_->GetBoundsInRootWindow()); |
| 866 } | 880 } |
| 867 #endif | 881 #endif |
| 868 if (!in_shutdown_) | 882 if (!in_shutdown_) |
| 869 host_->SendScreenRects(); | 883 host_->SendScreenRects(); |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2120 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2134 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
| 2121 } | 2135 } |
| 2122 #endif | 2136 #endif |
| 2123 // The Disambiguation popup does not parent itself from this window, so we | 2137 // The Disambiguation popup does not parent itself from this window, so we |
| 2124 // manually dismiss it. | 2138 // manually dismiss it. |
| 2125 HideDisambiguationPopup(); | 2139 HideDisambiguationPopup(); |
| 2126 | 2140 |
| 2127 blink::WebMouseWheelEvent mouse_wheel_event = | 2141 blink::WebMouseWheelEvent mouse_wheel_event = |
| 2128 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2142 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
| 2129 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 2143 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
| 2130 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2144 if (ShouldRouteEvent(event)) { |
| 2131 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2145 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
| 2132 this, &mouse_wheel_event); | 2146 this, &mouse_wheel_event); |
| 2133 } else { | 2147 } else { |
| 2134 ProcessMouseWheelEvent(mouse_wheel_event); | 2148 ProcessMouseWheelEvent(mouse_wheel_event); |
| 2135 } | 2149 } |
| 2136 } | 2150 } |
| 2137 } else { | 2151 } else { |
| 2138 bool is_selection_popup = | 2152 bool is_selection_popup = |
| 2139 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 2153 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
| 2140 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2154 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
| 2141 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2155 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 2142 // Confirm existing composition text on mouse press, to make sure | 2156 // Confirm existing composition text on mouse press, to make sure |
| 2143 // the input caret won't be moved with an ongoing composition text. | 2157 // the input caret won't be moved with an ongoing composition text. |
| 2144 if (event->type() == ui::ET_MOUSE_PRESSED) | 2158 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2145 FinishImeCompositionSession(); | 2159 FinishImeCompositionSession(); |
| 2146 | 2160 |
| 2147 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2161 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
| 2148 ModifyEventMovementAndCoords(&mouse_event); | 2162 ModifyEventMovementAndCoords(&mouse_event); |
| 2149 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2163 if (ShouldRouteEvent(event)) { |
| 2150 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 2164 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, |
| 2151 &mouse_event); | 2165 &mouse_event); |
| 2152 } else { | 2166 } else { |
| 2153 ProcessMouseEvent(mouse_event); | 2167 ProcessMouseEvent(mouse_event); |
| 2154 } | 2168 } |
| 2155 | 2169 |
| 2156 // Ensure that we get keyboard focus on mouse down as a plugin window may | 2170 // Ensure that we get keyboard focus on mouse down as a plugin window may |
| 2157 // have grabbed keyboard focus. | 2171 // have grabbed keyboard focus. |
| 2158 if (event->type() == ui::ET_MOUSE_PRESSED) | 2172 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2159 SetKeyboardFocus(); | 2173 SetKeyboardFocus(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2212 void RenderWidgetHostViewAura::ProcessMouseEvent( | 2226 void RenderWidgetHostViewAura::ProcessMouseEvent( |
| 2213 const blink::WebMouseEvent& event) { | 2227 const blink::WebMouseEvent& event) { |
| 2214 host_->ForwardMouseEvent(event); | 2228 host_->ForwardMouseEvent(event); |
| 2215 } | 2229 } |
| 2216 | 2230 |
| 2217 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( | 2231 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( |
| 2218 const blink::WebMouseWheelEvent& event) { | 2232 const blink::WebMouseWheelEvent& event) { |
| 2219 host_->ForwardWheelEvent(event); | 2233 host_->ForwardWheelEvent(event); |
| 2220 } | 2234 } |
| 2221 | 2235 |
| 2236 void RenderWidgetHostViewAura::ProcessTouchEvent( | |
| 2237 const blink::WebTouchEvent& event, | |
| 2238 const ui::LatencyInfo& latency) { | |
| 2239 host_->ForwardTouchEventWithLatencyInfo(event, latency); | |
| 2240 } | |
| 2241 | |
| 2222 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( | 2242 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( |
| 2223 const gfx::Point& point, | 2243 const gfx::Point& point, |
| 2224 cc::SurfaceId original_surface, | 2244 cc::SurfaceId original_surface, |
| 2225 gfx::Point* transformed_point) { | 2245 gfx::Point* transformed_point) { |
| 2226 delegated_frame_host_->TransformPointToLocalCoordSpace( | 2246 delegated_frame_host_->TransformPointToLocalCoordSpace( |
| 2227 point, original_surface, transformed_point); | 2247 point, original_surface, transformed_point); |
| 2228 } | 2248 } |
| 2229 | 2249 |
| 2230 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2250 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 2231 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2251 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2286 | 2306 |
| 2287 // It is important to always mark events as being handled asynchronously when | 2307 // 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 | 2308 // they are forwarded. This ensures that the current event does not get |
| 2289 // processed by the gesture recognizer before events currently awaiting | 2309 // processed by the gesture recognizer before events currently awaiting |
| 2290 // dispatch in the touch queue. | 2310 // dispatch in the touch queue. |
| 2291 event->DisableSynchronousHandling(); | 2311 event->DisableSynchronousHandling(); |
| 2292 | 2312 |
| 2293 // Set unchanged touch point to StateStationary for touchmove and | 2313 // Set unchanged touch point to StateStationary for touchmove and |
| 2294 // touchcancel to make sure only send one ack per WebTouchEvent. | 2314 // touchcancel to make sure only send one ack per WebTouchEvent. |
| 2295 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | 2315 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); |
| 2296 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2316 if (ShouldRouteEvent(event)) { |
| 2317 host_->delegate()->GetInputEventRouter()->RouteTouchEvent( | |
| 2318 this, &touch_event, *event->latency()); | |
| 2319 } else { | |
| 2320 ProcessTouchEvent(touch_event, *event->latency()); | |
| 2321 } | |
| 2297 } | 2322 } |
| 2298 | 2323 |
| 2299 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2324 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
| 2300 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2325 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
| 2301 | 2326 |
| 2302 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2327 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 2303 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2328 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 2304 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2329 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
| 2305 event->SetHandled(); | 2330 event->SetHandled(); |
| 2306 return; | 2331 return; |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2990 | 3015 |
| 2991 //////////////////////////////////////////////////////////////////////////////// | 3016 //////////////////////////////////////////////////////////////////////////////// |
| 2992 // RenderWidgetHostViewBase, public: | 3017 // RenderWidgetHostViewBase, public: |
| 2993 | 3018 |
| 2994 // static | 3019 // static |
| 2995 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3020 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2996 GetScreenInfoForWindow(results, NULL); | 3021 GetScreenInfoForWindow(results, NULL); |
| 2997 } | 3022 } |
| 2998 | 3023 |
| 2999 } // namespace content | 3024 } // namespace content |
| OLD | NEW |