| 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 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 cursor_visibility_state_in_renderer_(UNKNOWN), | 474 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 475 #if defined(OS_WIN) | 475 #if defined(OS_WIN) |
| 476 legacy_render_widget_host_HWND_(NULL), | 476 legacy_render_widget_host_HWND_(NULL), |
| 477 legacy_window_destroyed_(false), | 477 legacy_window_destroyed_(false), |
| 478 #endif | 478 #endif |
| 479 has_snapped_to_boundary_(false), | 479 has_snapped_to_boundary_(false), |
| 480 is_guest_view_hack_(is_guest_view_hack), | 480 is_guest_view_hack_(is_guest_view_hack), |
| 481 begin_frame_observer_proxy_(this), | 481 begin_frame_observer_proxy_(this), |
| 482 set_focus_on_mouse_down_or_key_event_(false), | 482 set_focus_on_mouse_down_or_key_event_(false), |
| 483 device_scale_factor_(0.0f), | 483 device_scale_factor_(0.0f), |
| 484 disable_input_event_router_for_testing_(false), |
| 484 weak_ptr_factory_(this) { | 485 weak_ptr_factory_(this) { |
| 485 if (!is_guest_view_hack_) | 486 if (!is_guest_view_hack_) |
| 486 host_->SetView(this); | 487 host_->SetView(this); |
| 487 | 488 |
| 488 // Let the page-level input event router know about our surface ID | 489 // Let the page-level input event router know about our surface ID |
| 489 // namespace for surface-based hit testing. | 490 // namespace for surface-based hit testing. |
| 490 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | 491 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 491 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( | 492 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( |
| 492 GetSurfaceIdNamespace(), this); | 493 GetSurfaceIdNamespace(), this); |
| 493 } | 494 } |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 // We should route an event in two cases: | 863 // We should route an event in two cases: |
| 863 // 1) Mouse events are routed only if cross-process frames are possible. | 864 // 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 // 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 // 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 // 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 // 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 // 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 // frame. TODO(wjmaclean): At present, this doesn't work for OOPIF, but |
| 870 // it should be a simple extension to modify RenderWidgetHostViewChildFrame | 871 // it should be a simple extension to modify RenderWidgetHostViewChildFrame |
| 871 // in a similar manner to RenderWidgetHostViewGuest. | 872 // in a similar manner to RenderWidgetHostViewGuest. |
| 872 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter(); | 873 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter() && |
| 874 !disable_input_event_router_for_testing_; |
| 873 if (event->IsMouseEvent()) | 875 if (event->IsMouseEvent()) |
| 874 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); | 876 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible(); |
| 875 return result; | 877 return result; |
| 876 } | 878 } |
| 877 | 879 |
| 878 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { | 880 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { |
| 879 SnapToPhysicalPixelBoundary(); | 881 SnapToPhysicalPixelBoundary(); |
| 880 #if defined(OS_WIN) | 882 #if defined(OS_WIN) |
| 881 if (legacy_render_widget_host_HWND_) { | 883 if (legacy_render_widget_host_HWND_) { |
| 882 legacy_render_widget_host_HWND_->SetBounds( | 884 legacy_render_widget_host_HWND_->SetBounds( |
| (...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 const blink::WebMouseWheelEvent& event) { | 2255 const blink::WebMouseWheelEvent& event) { |
| 2254 host_->ForwardWheelEvent(event); | 2256 host_->ForwardWheelEvent(event); |
| 2255 } | 2257 } |
| 2256 | 2258 |
| 2257 void RenderWidgetHostViewAura::ProcessTouchEvent( | 2259 void RenderWidgetHostViewAura::ProcessTouchEvent( |
| 2258 const blink::WebTouchEvent& event, | 2260 const blink::WebTouchEvent& event, |
| 2259 const ui::LatencyInfo& latency) { | 2261 const ui::LatencyInfo& latency) { |
| 2260 host_->ForwardTouchEventWithLatencyInfo(event, latency); | 2262 host_->ForwardTouchEventWithLatencyInfo(event, latency); |
| 2261 } | 2263 } |
| 2262 | 2264 |
| 2265 void RenderWidgetHostViewAura::ProcessGestureEvent( |
| 2266 const blink::WebGestureEvent& event, |
| 2267 const ui::LatencyInfo& latency) { |
| 2268 host_->ForwardGestureEventWithLatencyInfo(event, latency); |
| 2269 } |
| 2270 |
| 2263 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( | 2271 void RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( |
| 2264 const gfx::Point& point, | 2272 const gfx::Point& point, |
| 2265 cc::SurfaceId original_surface, | 2273 cc::SurfaceId original_surface, |
| 2266 gfx::Point* transformed_point) { | 2274 gfx::Point* transformed_point) { |
| 2267 delegated_frame_host_->TransformPointToLocalCoordSpace( | 2275 delegated_frame_host_->TransformPointToLocalCoordSpace( |
| 2268 point, original_surface, transformed_point); | 2276 point, original_surface, transformed_point); |
| 2269 } | 2277 } |
| 2270 | 2278 |
| 2271 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2279 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 2272 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2280 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2361 if (event->type() == ui::ET_GESTURE_TAP) | 2369 if (event->type() == ui::ET_GESTURE_TAP) |
| 2362 FinishImeCompositionSession(); | 2370 FinishImeCompositionSession(); |
| 2363 | 2371 |
| 2364 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); | 2372 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); |
| 2365 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 2373 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 2366 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 2374 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
| 2367 // event to stop any in-progress flings. | 2375 // event to stop any in-progress flings. |
| 2368 blink::WebGestureEvent fling_cancel = gesture; | 2376 blink::WebGestureEvent fling_cancel = gesture; |
| 2369 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; | 2377 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; |
| 2370 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; | 2378 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 2371 host_->ForwardGestureEvent(fling_cancel); | 2379 if (ShouldRouteEvent(event)) { |
| 2380 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2381 this, &fling_cancel, ui::LatencyInfo()); |
| 2382 } else { |
| 2383 host_->ForwardGestureEvent(fling_cancel); |
| 2384 } |
| 2372 } | 2385 } |
| 2373 | 2386 |
| 2374 if (gesture.type != blink::WebInputEvent::Undefined) { | 2387 if (gesture.type != blink::WebInputEvent::Undefined) { |
| 2375 host_->ForwardGestureEventWithLatencyInfo(gesture, *event->latency()); | 2388 if (ShouldRouteEvent(event)) { |
| 2389 host_->delegate()->GetInputEventRouter()->RouteGestureEvent( |
| 2390 this, &gesture, *event->latency()); |
| 2391 } else { |
| 2392 host_->ForwardGestureEventWithLatencyInfo(gesture, *event->latency()); |
| 2393 } |
| 2376 | 2394 |
| 2377 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 2395 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
| 2378 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 2396 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 2379 event->type() == ui::ET_GESTURE_SCROLL_END) { | 2397 event->type() == ui::ET_GESTURE_SCROLL_END) { |
| 2380 RecordAction(base::UserMetricsAction("TouchscreenScroll")); | 2398 RecordAction(base::UserMetricsAction("TouchscreenScroll")); |
| 2381 } else if (event->type() == ui::ET_SCROLL_FLING_START) { | 2399 } else if (event->type() == ui::ET_SCROLL_FLING_START) { |
| 2382 RecordAction(base::UserMetricsAction("TouchscreenScrollFling")); | 2400 RecordAction(base::UserMetricsAction("TouchscreenScrollFling")); |
| 2383 } | 2401 } |
| 2384 } | 2402 } |
| 2385 | 2403 |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2731 return false; | 2749 return false; |
| 2732 } | 2750 } |
| 2733 #endif | 2751 #endif |
| 2734 return true; | 2752 return true; |
| 2735 } | 2753 } |
| 2736 | 2754 |
| 2737 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( | 2755 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( |
| 2738 scoped_ptr<TouchSelectionControllerClientAura> client) { | 2756 scoped_ptr<TouchSelectionControllerClientAura> client) { |
| 2739 selection_controller_client_.swap(client); | 2757 selection_controller_client_.swap(client); |
| 2740 CreateSelectionController(); | 2758 CreateSelectionController(); |
| 2759 disable_input_event_router_for_testing_ = true; |
| 2741 } | 2760 } |
| 2742 | 2761 |
| 2743 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2762 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
| 2744 SnapToPhysicalPixelBoundary(); | 2763 SnapToPhysicalPixelBoundary(); |
| 2745 // Don't recursively call SetBounds if this bounds update is the result of | 2764 // Don't recursively call SetBounds if this bounds update is the result of |
| 2746 // a Window::SetBoundsInternal call. | 2765 // a Window::SetBoundsInternal call. |
| 2747 if (!in_bounds_changed_) | 2766 if (!in_bounds_changed_) |
| 2748 window_->SetBounds(rect); | 2767 window_->SetBounds(rect); |
| 2749 host_->WasResized(); | 2768 host_->WasResized(); |
| 2750 delegated_frame_host_->WasResized(); | 2769 delegated_frame_host_->WasResized(); |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3110 | 3129 |
| 3111 //////////////////////////////////////////////////////////////////////////////// | 3130 //////////////////////////////////////////////////////////////////////////////// |
| 3112 // RenderWidgetHostViewBase, public: | 3131 // RenderWidgetHostViewBase, public: |
| 3113 | 3132 |
| 3114 // static | 3133 // static |
| 3115 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3134 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3116 GetScreenInfoForWindow(results, NULL); | 3135 GetScreenInfoForWindow(results, NULL); |
| 3117 } | 3136 } |
| 3118 | 3137 |
| 3119 } // namespace content | 3138 } // namespace content |
| OLD | NEW |