Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1306)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1255483004: Implement surface-based browser process hit testing for Mac and Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing test file Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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()->GetInputEventRouter()) {
493 host_->delegate()->GetInputEventRouter()->AddSurfaceIdNamespaceOwner(
494 GetSurfaceIdNamespace(), this);
495 }
496
488 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 497 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
489 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 498 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
490 SetOverscrollControllerEnabled(overscroll_enabled); 499 SetOverscrollControllerEnabled(overscroll_enabled);
491 500
492 selection_controller_client_.reset( 501 selection_controller_client_.reset(
493 new TouchSelectionControllerClientAura(this)); 502 new TouchSelectionControllerClientAura(this));
494 CreateSelectionController(); 503 CreateSelectionController();
495 } 504 }
496 505
497 //////////////////////////////////////////////////////////////////////////////// 506 ////////////////////////////////////////////////////////////////////////////////
(...skipping 1586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2084 DismissOwnedPopups, 2093 DismissOwnedPopups,
2085 reinterpret_cast<LPARAM>(toplevel_hwnd)); 2094 reinterpret_cast<LPARAM>(toplevel_hwnd));
2086 } 2095 }
2087 #endif 2096 #endif
2088 // 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
2089 // manually dismiss it. 2098 // manually dismiss it.
2090 HideDisambiguationPopup(); 2099 HideDisambiguationPopup();
2091 2100
2092 blink::WebMouseWheelEvent mouse_wheel_event = 2101 blink::WebMouseWheelEvent mouse_wheel_event =
2093 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 2102 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
2094 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 2103 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
2095 host_->ForwardWheelEvent(mouse_wheel_event); 2104 if (host_->delegate()->GetInputEventRouter()) {
2105 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
2106 this, &mouse_wheel_event);
2107 } else {
2108 ProcessMouseWheelEvent(mouse_wheel_event);
2109 }
2110 }
2096 } else { 2111 } else {
2097 bool is_selection_popup = popup_child_host_view_ && 2112 bool is_selection_popup =
2098 popup_child_host_view_->NeedsInputGrab(); 2113 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
2099 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) && 2114 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
2100 !(event->flags() & ui::EF_FROM_TOUCH)) { 2115 !(event->flags() & ui::EF_FROM_TOUCH)) {
2101 // Confirm existing composition text on mouse press, to make sure 2116 // Confirm existing composition text on mouse press, to make sure
2102 // 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.
2103 if (event->type() == ui::ET_MOUSE_PRESSED) 2118 if (event->type() == ui::ET_MOUSE_PRESSED)
2104 FinishImeCompositionSession(); 2119 FinishImeCompositionSession();
2105 2120
2106 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); 2121 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event);
2107 ModifyEventMovementAndCoords(&mouse_event); 2122 if (host_->delegate()->GetInputEventRouter()) {
2108 host_->ForwardMouseEvent(mouse_event); 2123 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
2124 &mouse_event);
2125 } else {
2126 ProcessMouseEvent(mouse_event);
2127 }
2128
2109 // 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
2110 // have grabbed keyboard focus. 2130 // have grabbed keyboard focus.
2111 if (event->type() == ui::ET_MOUSE_PRESSED) 2131 if (event->type() == ui::ET_MOUSE_PRESSED)
2112 SetKeyboardFocus(); 2132 SetKeyboardFocus();
2113 } 2133 }
2114 } 2134 }
2115 2135
2116 switch (event->type()) { 2136 switch (event->type()) {
2117 case ui::ET_MOUSE_PRESSED: 2137 case ui::ET_MOUSE_PRESSED:
2118 window_->SetCapture(); 2138 window_->SetCapture();
(...skipping 18 matching lines...) Expand all
2137 window_->parent()->delegate()->OnMouseEvent(event); 2157 window_->parent()->delegate()->OnMouseEvent(event);
2138 } 2158 }
2139 2159
2140 if (!IsXButtonUpEvent(event)) 2160 if (!IsXButtonUpEvent(event))
2141 event->SetHandled(); 2161 event->SetHandled();
2142 } 2162 }
2143 2163
2144 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( 2164 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint(
2145 const gfx::Point& point, 2165 const gfx::Point& point,
2146 gfx::Point* transformed_point) { 2166 gfx::Point* transformed_point) {
2147 return cc::SurfaceIdAllocator::NamespaceForId( 2167 cc::SurfaceId id =
2148 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);
2149 } 2184 }
2150 2185
2151 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2186 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2152 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2187 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2153 2188
2154 if (event->type() == ui::ET_SCROLL) { 2189 if (event->type() == ui::ET_SCROLL) {
2155 #if !defined(OS_WIN) 2190 #if !defined(OS_WIN)
2156 // TODO(ananta) 2191 // TODO(ananta)
2157 // 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.
2158 if (event->finger_count() != 2) 2193 if (event->finger_count() != 2)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 2408
2374 UpdateScreenInfo(window_); 2409 UpdateScreenInfo(window_);
2375 } 2410 }
2376 2411
2377 //////////////////////////////////////////////////////////////////////////////// 2412 ////////////////////////////////////////////////////////////////////////////////
2378 // RenderWidgetHostViewAura, private: 2413 // RenderWidgetHostViewAura, private:
2379 2414
2380 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 2415 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
2381 selection_controller_.reset(); 2416 selection_controller_.reset();
2382 selection_controller_client_.reset(); 2417 selection_controller_client_.reset();
2418
2419 if (UseSurfacesEnabled() && host_->delegate()->GetInputEventRouter()) {
2420 host_->delegate()->GetInputEventRouter()->RemoveSurfaceIdNamespaceOwner(
2421 GetSurfaceIdNamespace());
2422 }
2383 delegated_frame_host_.reset(); 2423 delegated_frame_host_.reset();
2384 window_observer_.reset(); 2424 window_observer_.reset();
2385 if (window_->GetHost()) 2425 if (window_->GetHost())
2386 window_->GetHost()->RemoveObserver(this); 2426 window_->GetHost()->RemoveObserver(this);
2387 UnlockMouse(); 2427 UnlockMouse();
2388 if (popup_parent_host_view_) { 2428 if (popup_parent_host_view_) {
2389 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 2429 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2390 popup_parent_host_view_->popup_child_host_view_ == this); 2430 popup_parent_host_view_->popup_child_host_view_ == this);
2391 popup_parent_host_view_->popup_child_host_view_ = NULL; 2431 popup_parent_host_view_->popup_child_host_view_ = NULL;
2392 } 2432 }
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 2875
2836 //////////////////////////////////////////////////////////////////////////////// 2876 ////////////////////////////////////////////////////////////////////////////////
2837 // RenderWidgetHostViewBase, public: 2877 // RenderWidgetHostViewBase, public:
2838 2878
2839 // static 2879 // static
2840 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2880 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2841 GetScreenInfoForWindow(results, NULL); 2881 GetScreenInfoForWindow(results, NULL);
2842 } 2882 }
2843 2883
2844 } // namespace content 2884 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698