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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 ui::EF_RIGHT_MOUSE_BUTTON; | 837 ui::EF_RIGHT_MOUSE_BUTTON; |
837 return (event->flags() & kAllowedButtons) != 0; | 838 return (event->flags() & kAllowedButtons) != 0; |
838 } | 839 } |
839 default: | 840 default: |
840 break; | 841 break; |
841 } | 842 } |
842 #endif | 843 #endif |
843 return true; | 844 return true; |
844 } | 845 } |
845 | 846 |
| 847 bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const { |
| 848 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter(); |
| 849 if (event->IsMouseEvent()) |
| 850 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 851 return result; |
| 852 } |
| 853 |
846 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { | 854 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
847 SnapToPhysicalPixelBoundary(); | 855 SnapToPhysicalPixelBoundary(); |
848 #if defined(OS_WIN) | 856 #if defined(OS_WIN) |
849 if (legacy_render_widget_host_HWND_) { | 857 if (legacy_render_widget_host_HWND_) { |
850 legacy_render_widget_host_HWND_->SetBounds( | 858 legacy_render_widget_host_HWND_->SetBounds( |
851 window_->GetBoundsInRootWindow()); | 859 window_->GetBoundsInRootWindow()); |
852 } | 860 } |
853 #endif | 861 #endif |
854 if (!in_shutdown_) | 862 if (!in_shutdown_) |
855 host_->SendScreenRects(); | 863 host_->SendScreenRects(); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 #endif | 1177 #endif |
1170 | 1178 |
1171 void RenderWidgetHostViewAura::OnSwapCompositorFrame( | 1179 void RenderWidgetHostViewAura::OnSwapCompositorFrame( |
1172 uint32 output_surface_id, | 1180 uint32 output_surface_id, |
1173 scoped_ptr<cc::CompositorFrame> frame) { | 1181 scoped_ptr<cc::CompositorFrame> frame) { |
1174 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1182 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1175 | 1183 |
1176 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1184 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
1177 if (!frame->delegated_frame_data) | 1185 if (!frame->delegated_frame_data) |
1178 return; | 1186 return; |
| 1187 |
1179 delegated_frame_host_->SwapDelegatedFrame( | 1188 delegated_frame_host_->SwapDelegatedFrame( |
1180 output_surface_id, frame->delegated_frame_data.Pass(), | 1189 output_surface_id, frame->delegated_frame_data.Pass(), |
1181 frame->metadata.device_scale_factor, frame->metadata.latency_info, | 1190 frame->metadata.device_scale_factor, frame->metadata.latency_info, |
1182 &frame->metadata.satisfies_sequences); | 1191 &frame->metadata.satisfies_sequences); |
1183 SelectionUpdated(frame->metadata.selection.is_editable, | 1192 SelectionUpdated(frame->metadata.selection.is_editable, |
1184 frame->metadata.selection.is_empty_text_form_control, | 1193 frame->metadata.selection.is_empty_text_form_control, |
1185 ConvertSelectionBound(frame->metadata.selection.start), | 1194 ConvertSelectionBound(frame->metadata.selection.start), |
1186 ConvertSelectionBound(frame->metadata.selection.end)); | 1195 ConvertSelectionBound(frame->metadata.selection.end)); |
1187 } | 1196 } |
1188 | 1197 |
(...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2103 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2112 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
2104 } | 2113 } |
2105 #endif | 2114 #endif |
2106 // The Disambiguation popup does not parent itself from this window, so we | 2115 // The Disambiguation popup does not parent itself from this window, so we |
2107 // manually dismiss it. | 2116 // manually dismiss it. |
2108 HideDisambiguationPopup(); | 2117 HideDisambiguationPopup(); |
2109 | 2118 |
2110 blink::WebMouseWheelEvent mouse_wheel_event = | 2119 blink::WebMouseWheelEvent mouse_wheel_event = |
2111 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2120 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
2112 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { | 2121 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
2113 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2122 if (ShouldRouteEvent(event)) { |
2114 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( | 2123 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
2115 this, &mouse_wheel_event); | 2124 this, &mouse_wheel_event); |
2116 } else { | 2125 } else { |
2117 ProcessMouseWheelEvent(mouse_wheel_event); | 2126 ProcessMouseWheelEvent(mouse_wheel_event); |
2118 } | 2127 } |
2119 } | 2128 } |
2120 } else { | 2129 } else { |
2121 bool is_selection_popup = | 2130 bool is_selection_popup = |
2122 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); | 2131 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
2123 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2132 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
2124 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2133 !(event->flags() & ui::EF_FROM_TOUCH)) { |
2125 // Confirm existing composition text on mouse press, to make sure | 2134 // Confirm existing composition text on mouse press, to make sure |
2126 // the input caret won't be moved with an ongoing composition text. | 2135 // the input caret won't be moved with an ongoing composition text. |
2127 if (event->type() == ui::ET_MOUSE_PRESSED) | 2136 if (event->type() == ui::ET_MOUSE_PRESSED) |
2128 FinishImeCompositionSession(); | 2137 FinishImeCompositionSession(); |
2129 | 2138 |
2130 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2139 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
2131 ModifyEventMovementAndCoords(&mouse_event); | 2140 ModifyEventMovementAndCoords(&mouse_event); |
2132 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 2141 if (ShouldRouteEvent(event)) { |
2133 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, | 2142 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, |
2134 &mouse_event); | 2143 &mouse_event); |
2135 } else { | 2144 } else { |
2136 ProcessMouseEvent(mouse_event); | 2145 ProcessMouseEvent(mouse_event); |
2137 } | 2146 } |
2138 | 2147 |
2139 // Ensure that we get keyboard focus on mouse down as a plugin window may | 2148 // Ensure that we get keyboard focus on mouse down as a plugin window may |
2140 // have grabbed keyboard focus. | 2149 // have grabbed keyboard focus. |
2141 if (event->type() == ui::ET_MOUSE_PRESSED) | 2150 if (event->type() == ui::ET_MOUSE_PRESSED) |
2142 SetKeyboardFocus(); | 2151 SetKeyboardFocus(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 void RenderWidgetHostViewAura::ProcessMouseEvent( | 2195 void RenderWidgetHostViewAura::ProcessMouseEvent( |
2187 const blink::WebMouseEvent& event) { | 2196 const blink::WebMouseEvent& event) { |
2188 host_->ForwardMouseEvent(event); | 2197 host_->ForwardMouseEvent(event); |
2189 } | 2198 } |
2190 | 2199 |
2191 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( | 2200 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( |
2192 const blink::WebMouseWheelEvent& event) { | 2201 const blink::WebMouseWheelEvent& event) { |
2193 host_->ForwardWheelEvent(event); | 2202 host_->ForwardWheelEvent(event); |
2194 } | 2203 } |
2195 | 2204 |
| 2205 void RenderWidgetHostViewAura::ProcessTouchEvent( |
| 2206 const blink::WebTouchEvent& event, |
| 2207 const ui::LatencyInfo& latency) { |
| 2208 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 2209 } |
| 2210 |
2196 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2211 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
2197 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2212 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
2198 | 2213 |
2199 if (event->type() == ui::ET_SCROLL) { | 2214 if (event->type() == ui::ET_SCROLL) { |
2200 #if !defined(OS_WIN) | 2215 #if !defined(OS_WIN) |
2201 // TODO(ananta) | 2216 // TODO(ananta) |
2202 // Investigate if this is true for Windows 8 Metro ASH as well. | 2217 // Investigate if this is true for Windows 8 Metro ASH as well. |
2203 if (event->finger_count() != 2) | 2218 if (event->finger_count() != 2) |
2204 return; | 2219 return; |
2205 #endif | 2220 #endif |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 | 2267 |
2253 // It is important to always mark events as being handled asynchronously when | 2268 // 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 | 2269 // they are forwarded. This ensures that the current event does not get |
2255 // processed by the gesture recognizer before events currently awaiting | 2270 // processed by the gesture recognizer before events currently awaiting |
2256 // dispatch in the touch queue. | 2271 // dispatch in the touch queue. |
2257 event->DisableSynchronousHandling(); | 2272 event->DisableSynchronousHandling(); |
2258 | 2273 |
2259 // Set unchanged touch point to StateStationary for touchmove and | 2274 // Set unchanged touch point to StateStationary for touchmove and |
2260 // touchcancel to make sure only send one ack per WebTouchEvent. | 2275 // touchcancel to make sure only send one ack per WebTouchEvent. |
2261 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | 2276 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); |
2262 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2277 if (ShouldRouteEvent(event)) { |
| 2278 host_->delegate()->GetInputEventRouter()->RouteTouchEvent( |
| 2279 this, &touch_event, *event->latency()); |
| 2280 } else { |
| 2281 ProcessTouchEvent(touch_event, *event->latency()); |
| 2282 } |
2263 } | 2283 } |
2264 | 2284 |
2265 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2285 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2266 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2286 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2267 | 2287 |
2268 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2288 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2269 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2289 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2270 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2290 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2271 event->SetHandled(); | 2291 event->SetHandled(); |
2272 return; | 2292 return; |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2899 | 2919 |
2900 //////////////////////////////////////////////////////////////////////////////// | 2920 //////////////////////////////////////////////////////////////////////////////// |
2901 // RenderWidgetHostViewBase, public: | 2921 // RenderWidgetHostViewBase, public: |
2902 | 2922 |
2903 // static | 2923 // static |
2904 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2924 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2905 GetScreenInfoForWindow(results, NULL); | 2925 GetScreenInfoForWindow(results, NULL); |
2906 } | 2926 } |
2907 | 2927 |
2908 } // namespace content | 2928 } // namespace content |
OLD | NEW |