| 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 19 matching lines...) Expand all Loading... |
| 30 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" | 30 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" |
| 31 #include "content/browser/renderer_host/dip_util.h" | 31 #include "content/browser/renderer_host/dip_util.h" |
| 32 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" | 32 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
| 33 #include "content/browser/renderer_host/input/touch_selection_controller_client_
aura.h" | 33 #include "content/browser/renderer_host/input/touch_selection_controller_client_
aura.h" |
| 34 #include "content/browser/renderer_host/input/ui_touch_selection_helper.h" | 34 #include "content/browser/renderer_host/input/ui_touch_selection_helper.h" |
| 35 #include "content/browser/renderer_host/input/web_input_event_util.h" | 35 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 36 #include "content/browser/renderer_host/overscroll_controller.h" | 36 #include "content/browser/renderer_host/overscroll_controller.h" |
| 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_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" |
| 41 #include "content/browser/renderer_host/ui_events_helper.h" | 43 #include "content/browser/renderer_host/ui_events_helper.h" |
| 42 #include "content/browser/renderer_host/web_input_event_aura.h" | 44 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 43 #include "content/common/gpu/client/gl_helper.h" | 45 #include "content/common/gpu/client/gl_helper.h" |
| 44 #include "content/common/gpu/gpu_messages.h" | 46 #include "content/common/gpu/gpu_messages.h" |
| 45 #include "content/common/view_messages.h" | 47 #include "content/common/view_messages.h" |
| 46 #include "content/public/browser/content_browser_client.h" | 48 #include "content/public/browser/content_browser_client.h" |
| 47 #include "content/public/browser/overscroll_configuration.h" | 49 #include "content/public/browser/overscroll_configuration.h" |
| 48 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 49 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 51 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
| 50 #include "content/public/browser/user_metrics.h" | 52 #include "content/public/browser/user_metrics.h" |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 host_->SetView(this); | 480 host_->SetView(this); |
| 479 | 481 |
| 480 window_observer_.reset(new WindowObserver(this)); | 482 window_observer_.reset(new WindowObserver(this)); |
| 481 | 483 |
| 482 aura::client::SetTooltipText(window_, &tooltip_); | 484 aura::client::SetTooltipText(window_, &tooltip_); |
| 483 aura::client::SetActivationDelegate(window_, this); | 485 aura::client::SetActivationDelegate(window_, this); |
| 484 aura::client::SetFocusChangeObserver(window_, this); | 486 aura::client::SetFocusChangeObserver(window_, this); |
| 485 window_->set_layer_owner_delegate(delegated_frame_host_.get()); | 487 window_->set_layer_owner_delegate(delegated_frame_host_.get()); |
| 486 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 488 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| 487 | 489 |
| 490 // Let the page-level input event router know about our surface ID |
| 491 // namespace for surface-based hit testing. |
| 492 if (UseSurfacesEnabled() && host_->delegate() && |
| 493 host_->delegate()->GetInputEventRouter()) { |
| 494 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner( |
| 495 GetSurfaceIdNamespace(), this); |
| 496 } |
| 497 |
| 488 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 498 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
| 489 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 499 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
| 490 SetOverscrollControllerEnabled(overscroll_enabled); | 500 SetOverscrollControllerEnabled(overscroll_enabled); |
| 491 | 501 |
| 492 selection_controller_client_.reset( | 502 selection_controller_client_.reset( |
| 493 new TouchSelectionControllerClientAura(this)); | 503 new TouchSelectionControllerClientAura(this)); |
| 494 CreateSelectionController(); | 504 CreateSelectionController(); |
| 495 } | 505 } |
| 496 | 506 |
| 497 //////////////////////////////////////////////////////////////////////////////// | 507 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2083 DismissOwnedPopups, | 2093 DismissOwnedPopups, |
| 2084 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2094 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
| 2085 } | 2095 } |
| 2086 #endif | 2096 #endif |
| 2087 // The Disambiguation popup does not parent itself from this window, so we | 2097 // The Disambiguation popup does not parent itself from this window, so we |
| 2088 // manually dismiss it. | 2098 // manually dismiss it. |
| 2089 HideDisambiguationPopup(); | 2099 HideDisambiguationPopup(); |
| 2090 | 2100 |
| 2091 blink::WebMouseWheelEvent mouse_wheel_event = | 2101 blink::WebMouseWheelEvent mouse_wheel_event = |
| 2092 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2102 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
| 2093 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 2103 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) { |
| 2094 host_->ForwardWheelEvent(mouse_wheel_event); | 2104 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 2105 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent( |
| 2106 this, &mouse_wheel_event); |
| 2107 } else { |
| 2108 ProcessMouseWheelEvent(mouse_wheel_event); |
| 2109 } |
| 2110 } |
| 2095 } else { | 2111 } else { |
| 2096 bool is_selection_popup = popup_child_host_view_ && | 2112 bool is_selection_popup = |
| 2097 popup_child_host_view_->NeedsInputGrab(); | 2113 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab(); |
| 2098 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && | 2114 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && |
| 2099 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2115 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 2100 // Confirm existing composition text on mouse press, to make sure | 2116 // Confirm existing composition text on mouse press, to make sure |
| 2101 // the input caret won't be moved with an ongoing composition text. | 2117 // the input caret won't be moved with an ongoing composition text. |
| 2102 if (event->type() == ui::ET_MOUSE_PRESSED) | 2118 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2103 FinishImeCompositionSession(); | 2119 FinishImeCompositionSession(); |
| 2104 | 2120 |
| 2105 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 2121 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
| 2106 ModifyEventMovementAndCoords(&mouse_event); | 2122 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 2107 host_->ForwardMouseEvent(mouse_event); | 2123 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this, |
| 2124 &mouse_event); |
| 2125 } else { |
| 2126 ProcessMouseEvent(mouse_event); |
| 2127 } |
| 2128 |
| 2108 // Ensure that we get keyboard focus on mouse down as a plugin window may | 2129 // Ensure that we get keyboard focus on mouse down as a plugin window may |
| 2109 // have grabbed keyboard focus. | 2130 // have grabbed keyboard focus. |
| 2110 if (event->type() == ui::ET_MOUSE_PRESSED) | 2131 if (event->type() == ui::ET_MOUSE_PRESSED) |
| 2111 SetKeyboardFocus(); | 2132 SetKeyboardFocus(); |
| 2112 } | 2133 } |
| 2113 } | 2134 } |
| 2114 | 2135 |
| 2115 switch (event->type()) { | 2136 switch (event->type()) { |
| 2116 case ui::ET_MOUSE_PRESSED: | 2137 case ui::ET_MOUSE_PRESSED: |
| 2117 window_->SetCapture(); | 2138 window_->SetCapture(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2136 window_->parent()->delegate()->OnMouseEvent(event); | 2157 window_->parent()->delegate()->OnMouseEvent(event); |
| 2137 } | 2158 } |
| 2138 | 2159 |
| 2139 if (!IsXButtonUpEvent(event)) | 2160 if (!IsXButtonUpEvent(event)) |
| 2140 event->SetHandled(); | 2161 event->SetHandled(); |
| 2141 } | 2162 } |
| 2142 | 2163 |
| 2143 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( | 2164 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( |
| 2144 const gfx::Point& point, | 2165 const gfx::Point& point, |
| 2145 gfx::Point* transformed_point) { | 2166 gfx::Point* transformed_point) { |
| 2146 return cc::SurfaceIdAllocator::NamespaceForId( | 2167 cc::SurfaceId id = |
| 2147 delegated_frame_host_->SurfaceIdAtPoint(point, transformed_point)); | 2168 delegated_frame_host_->SurfaceIdAtPoint(point, transformed_point); |
| 2169 // It is possible that the renderer has not yet produced a surface, in which |
| 2170 // case we return our current namespace. |
| 2171 if (id.is_null()) |
| 2172 return GetSurfaceIdNamespace(); |
| 2173 return cc::SurfaceIdAllocator::NamespaceForId(id); |
| 2174 } |
| 2175 |
| 2176 void RenderWidgetHostViewAura::ProcessMouseEvent( |
| 2177 const blink::WebMouseEvent& event) { |
| 2178 host_->ForwardMouseEvent(event); |
| 2179 } |
| 2180 |
| 2181 void RenderWidgetHostViewAura::ProcessMouseWheelEvent( |
| 2182 const blink::WebMouseWheelEvent& event) { |
| 2183 host_->ForwardWheelEvent(event); |
| 2148 } | 2184 } |
| 2149 | 2185 |
| 2150 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2186 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 2151 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2187 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
| 2152 | 2188 |
| 2153 if (event->type() == ui::ET_SCROLL) { | 2189 if (event->type() == ui::ET_SCROLL) { |
| 2154 #if !defined(OS_WIN) | 2190 #if !defined(OS_WIN) |
| 2155 // TODO(ananta) | 2191 // TODO(ananta) |
| 2156 // Investigate if this is true for Windows 8 Metro ASH as well. | 2192 // Investigate if this is true for Windows 8 Metro ASH as well. |
| 2157 if (event->finger_count() != 2) | 2193 if (event->finger_count() != 2) |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2372 | 2408 |
| 2373 UpdateScreenInfo(window_); | 2409 UpdateScreenInfo(window_); |
| 2374 } | 2410 } |
| 2375 | 2411 |
| 2376 //////////////////////////////////////////////////////////////////////////////// | 2412 //////////////////////////////////////////////////////////////////////////////// |
| 2377 // RenderWidgetHostViewAura, private: | 2413 // RenderWidgetHostViewAura, private: |
| 2378 | 2414 |
| 2379 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 2415 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
| 2380 selection_controller_.reset(); | 2416 selection_controller_.reset(); |
| 2381 selection_controller_client_.reset(); | 2417 selection_controller_client_.reset(); |
| 2418 |
| 2419 if (UseSurfacesEnabled() && host_->delegate() && |
| 2420 host_->delegate()->GetInputEventRouter()) { |
| 2421 host_->delegate()->GetInputEventRouter()->RemoveSurfaceIdNamespaceOwner( |
| 2422 GetSurfaceIdNamespace()); |
| 2423 } |
| 2382 delegated_frame_host_.reset(); | 2424 delegated_frame_host_.reset(); |
| 2383 window_observer_.reset(); | 2425 window_observer_.reset(); |
| 2384 if (window_->GetHost()) | 2426 if (window_->GetHost()) |
| 2385 window_->GetHost()->RemoveObserver(this); | 2427 window_->GetHost()->RemoveObserver(this); |
| 2386 UnlockMouse(); | 2428 UnlockMouse(); |
| 2387 if (popup_parent_host_view_) { | 2429 if (popup_parent_host_view_) { |
| 2388 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || | 2430 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || |
| 2389 popup_parent_host_view_->popup_child_host_view_ == this); | 2431 popup_parent_host_view_->popup_child_host_view_ == this); |
| 2390 popup_parent_host_view_->popup_child_host_view_ = NULL; | 2432 popup_parent_host_view_->popup_child_host_view_ = NULL; |
| 2391 } | 2433 } |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2837 | 2879 |
| 2838 //////////////////////////////////////////////////////////////////////////////// | 2880 //////////////////////////////////////////////////////////////////////////////// |
| 2839 // RenderWidgetHostViewBase, public: | 2881 // RenderWidgetHostViewBase, public: |
| 2840 | 2882 |
| 2841 // static | 2883 // static |
| 2842 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2884 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2843 GetScreenInfoForWindow(results, NULL); | 2885 GetScreenInfoForWindow(results, NULL); |
| 2844 } | 2886 } |
| 2845 | 2887 |
| 2846 } // namespace content | 2888 } // namespace content |
| OLD | NEW |