| 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. TODO(wjmaclean): At present, this doesn't work for OOPIF, but |
| 870 // it should be a simple extension to modify RenderWidgetHostViewChildFrame |
| 871 // in a similar manner to RenderWidgetHostViewGuest. |
| 872 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter(); |
| 873 if (event->IsMouseEvent()) |
| 874 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 875 return result; |
| 876 } |
| 877 |
| 860 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { | 878 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
| 861 SnapToPhysicalPixelBoundary(); | 879 SnapToPhysicalPixelBoundary(); |
| 862 #if defined(OS_WIN) | 880 #if defined(OS_WIN) |
| 863 if (legacy_render_widget_host_HWND_) { | 881 if (legacy_render_widget_host_HWND_) { |
| 864 legacy_render_widget_host_HWND_->SetBounds( | 882 legacy_render_widget_host_HWND_->SetBounds( |
| 865 window_->GetBoundsInRootWindow()); | 883 window_->GetBoundsInRootWindow()); |
| 866 } | 884 } |
| 867 #endif | 885 #endif |
| 868 if (!in_shutdown_) | 886 if (!in_shutdown_) |
| 869 host_->SendScreenRects(); | 887 host_->SendScreenRects(); |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2120 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2138 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
| 2121 } | 2139 } |
| 2122 #endif | 2140 #endif |
| 2123 // The Disambiguation popup does not parent itself from this window, so we | 2141 // The Disambiguation popup does not parent itself from this window, so we |
| 2124 // manually dismiss it. | 2142 // manually dismiss it. |
| 2125 HideDisambiguationPopup(); | 2143 HideDisambiguationPopup(); |
| 2126 | 2144 |
| 2127 blink::WebMouseWheelEvent mouse_wheel_event = | 2145 blink::WebMouseWheelEvent mouse_wheel_event = |
| 2128 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2146 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
| 2129 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 2147 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
| 2130 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2148 if (ShouldRouteEvent(event)) { |
| 2131 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2149 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
| 2132 this, &mouse_wheel_event); | 2150 this, &mouse_wheel_event); |
| 2133 } else { | 2151 } else { |
| 2134 ProcessMouseWheelEvent(mouse_wheel_event); | 2152 ProcessMouseWheelEvent(mouse_wheel_event); |
| 2135 } | 2153 } |
| 2136 } | 2154 } |
| 2137 } else { | 2155 } else { |
| 2138 bool is_selection_popup = | 2156 bool is_selection_popup = |
| 2139 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 2157 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
| 2140 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2158 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
| 2141 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2159 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 2142 // Confirm existing composition text on mouse press, to make sure | 2160 // Confirm existing composition text on mouse press, to make sure |
| 2143 // the input caret won't be moved with an ongoing composition text. | 2161 // the input caret won't be moved with an ongoing composition text. |
| 2144 if (event->type() == ui::ET_MOUSE_PRESSED) | 2162 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2145 FinishImeCompositionSession(); | 2163 FinishImeCompositionSession(); |
| 2146 | 2164 |
| 2147 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2165 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
| 2148 ModifyEventMovementAndCoords(&mouse_event); | 2166 ModifyEventMovementAndCoords(&mouse_event); |
| 2149 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2167 if (ShouldRouteEvent(event)) { |
| 2150 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 2168 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, |
| 2151 &mouse_event); | 2169 &mouse_event); |
| 2152 } else { | 2170 } else { |
| 2153 ProcessMouseEvent(mouse_event); | 2171 ProcessMouseEvent(mouse_event); |
| 2154 } | 2172 } |
| 2155 | 2173 |
| 2156 // Ensure that we get keyboard focus on mouse down as a plugin window may | 2174 // Ensure that we get keyboard focus on mouse down as a plugin window may |
| 2157 // have grabbed keyboard focus. | 2175 // have grabbed keyboard focus. |
| 2158 if (event->type() == ui::ET_MOUSE_PRESSED) | 2176 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2159 SetKeyboardFocus(); | 2177 SetKeyboardFocus(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 void RenderWidgetHostViewAura::ProcessMouseEvent( | 2230 void RenderWidgetHostViewAura::ProcessMouseEvent( |
| 2213 const blink::WebMouseEvent& event) { | 2231 const blink::WebMouseEvent& event) { |
| 2214 host_->ForwardMouseEvent(event); | 2232 host_->ForwardMouseEvent(event); |
| 2215 } | 2233 } |
| 2216 | 2234 |
| 2217 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( | 2235 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( |
| 2218 const blink::WebMouseWheelEvent& event) { | 2236 const blink::WebMouseWheelEvent& event) { |
| 2219 host_->ForwardWheelEvent(event); | 2237 host_->ForwardWheelEvent(event); |
| 2220 } | 2238 } |
| 2221 | 2239 |
| 2240 void RenderWidgetHostViewAura::ProcessTouchEvent( |
| 2241 const blink::WebTouchEvent& event, |
| 2242 const ui::LatencyInfo& latency) { |
| 2243 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 2244 } |
| 2245 |
| 2222 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( | 2246 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( |
| 2223 const gfx::Point& point, | 2247 const gfx::Point& point, |
| 2224 cc::SurfaceId original_surface, | 2248 cc::SurfaceId original_surface, |
| 2225 gfx::Point* transformed_point) { | 2249 gfx::Point* transformed_point) { |
| 2226 delegated_frame_host_->TransformPointToLocalCoordSpace( | 2250 delegated_frame_host_->TransformPointToLocalCoordSpace( |
| 2227 point, original_surface, transformed_point); | 2251 point, original_surface, transformed_point); |
| 2228 } | 2252 } |
| 2229 | 2253 |
| 2230 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2254 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 2231 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2255 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2286 | 2310 |
| 2287 // It is important to always mark events as being handled asynchronously when | 2311 // 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 | 2312 // they are forwarded. This ensures that the current event does not get |
| 2289 // processed by the gesture recognizer before events currently awaiting | 2313 // processed by the gesture recognizer before events currently awaiting |
| 2290 // dispatch in the touch queue. | 2314 // dispatch in the touch queue. |
| 2291 event->DisableSynchronousHandling(); | 2315 event->DisableSynchronousHandling(); |
| 2292 | 2316 |
| 2293 // Set unchanged touch point to StateStationary for touchmove and | 2317 // Set unchanged touch point to StateStationary for touchmove and |
| 2294 // touchcancel to make sure only send one ack per WebTouchEvent. | 2318 // touchcancel to make sure only send one ack per WebTouchEvent. |
| 2295 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | 2319 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); |
| 2296 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2320 if (ShouldRouteEvent(event)) { |
| 2321 host_->delegate()->GetInputEventRouter()->RouteTouchEvent( |
| 2322 this, &touch_event, *event->latency()); |
| 2323 } else { |
| 2324 ProcessTouchEvent(touch_event, *event->latency()); |
| 2325 } |
| 2297 } | 2326 } |
| 2298 | 2327 |
| 2299 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2328 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
| 2300 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2329 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
| 2301 | 2330 |
| 2302 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2331 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 2303 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2332 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 2304 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2333 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
| 2305 event->SetHandled(); | 2334 event->SetHandled(); |
| 2306 return; | 2335 return; |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2990 | 3019 |
| 2991 //////////////////////////////////////////////////////////////////////////////// | 3020 //////////////////////////////////////////////////////////////////////////////// |
| 2992 // RenderWidgetHostViewBase, public: | 3021 // RenderWidgetHostViewBase, public: |
| 2993 | 3022 |
| 2994 // static | 3023 // static |
| 2995 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3024 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2996 GetScreenInfoForWindow(results, NULL); | 3025 GetScreenInfoForWindow(results, NULL); |
| 2997 } | 3026 } |
| 2998 | 3027 |
| 2999 } // namespace content | 3028 } // namespace content |
| OLD | NEW |