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

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

Issue 2317333002: Refactor EventHandler out of RenderWidgetHostViewAura (Closed)
Patch Set: Fix popups Created 4 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 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/browser/renderer_host/dip_util.h" 34 #include "content/browser/renderer_host/dip_util.h"
35 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 35 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
36 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h" 36 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
37 #include "content/browser/renderer_host/overscroll_controller.h" 37 #include "content/browser/renderer_host/overscroll_controller.h"
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/render_widget_host_view_event_handler.h"
44 #include "content/browser/renderer_host/ui_events_helper.h" 45 #include "content/browser/renderer_host/ui_events_helper.h"
45 #include "content/common/content_switches_internal.h" 46 #include "content/common/content_switches_internal.h"
46 #include "content/common/input_messages.h" 47 #include "content/common/input_messages.h"
47 #include "content/common/site_isolation_policy.h" 48 #include "content/common/site_isolation_policy.h"
48 #include "content/common/text_input_state.h" 49 #include "content/common/text_input_state.h"
49 #include "content/common/view_messages.h" 50 #include "content/common/view_messages.h"
50 #include "content/public/browser/content_browser_client.h" 51 #include "content/public/browser/content_browser_client.h"
51 #include "content/public/browser/overscroll_configuration.h" 52 #include "content/public/browser/overscroll_configuration.h"
52 #include "content/public/browser/render_view_host.h" 53 #include "content/public/browser/render_view_host.h"
53 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 using gfx::SkIRectToRect; 116 using gfx::SkIRectToRect;
116 117
117 using blink::WebInputEvent; 118 using blink::WebInputEvent;
118 using blink::WebGestureEvent; 119 using blink::WebGestureEvent;
119 using blink::WebTouchEvent; 120 using blink::WebTouchEvent;
120 121
121 namespace content { 122 namespace content {
122 123
123 namespace { 124 namespace {
124 125
125 // In mouse lock mode, we need to prevent the (invisible) cursor from hitting
126 // the border of the view, in order to get valid movement information. However,
127 // forcing the cursor back to the center of the view after each mouse move
128 // doesn't work well. It reduces the frequency of useful mouse move messages
129 // significantly. Therefore, we move the cursor to the center of the view only
130 // if it approaches the border. |kMouseLockBorderPercentage| specifies the width
131 // of the border area, in percentage of the corresponding dimension.
132 const int kMouseLockBorderPercentage = 15;
133
134 // When accelerated compositing is enabled and a widget resize is pending, 126 // When accelerated compositing is enabled and a widget resize is pending,
135 // we delay further resizes of the UI. The following constant is the maximum 127 // we delay further resizes of the UI. The following constant is the maximum
136 // length of time that we should delay further UI resizes while waiting for a 128 // length of time that we should delay further UI resizes while waiting for a
137 // resized frame from a renderer. 129 // resized frame from a renderer.
138 const int kResizeLockTimeoutMs = 67; 130 const int kResizeLockTimeoutMs = 67;
139 131
140 #if defined(OS_WIN) 132 #if defined(OS_WIN)
141 // A callback function for EnumThreadWindows to enumerate and dismiss
142 // any owned popup windows.
143 BOOL CALLBACK DismissOwnedPopups(HWND window, LPARAM arg) {
144 const HWND toplevel_hwnd = reinterpret_cast<HWND>(arg);
145 133
146 if (::IsWindowVisible(window)) {
147 const HWND owner = ::GetWindow(window, GW_OWNER);
148 if (toplevel_hwnd == owner) {
149 ::PostMessage(window, WM_CANCELMODE, 0, 0);
150 }
151 }
152
153 return TRUE;
154 }
155 #endif
156
157 // We don't mark these as handled so that they're sent back to the
158 // DefWindowProc so it can generate WM_APPCOMMAND as necessary.
159 bool IsXButtonUpEvent(const ui::MouseEvent* event) {
160 #if defined(OS_WIN)
161 switch (event->native_event().message) {
162 case WM_XBUTTONUP:
163 case WM_NCXBUTTONUP:
164 return true;
165 }
166 #endif
167 return false;
168 }
169
170 bool IsFractionalScaleFactor(float scale_factor) {
171 return (scale_factor - static_cast<int>(scale_factor)) > 0;
172 }
173
174 // Reset unchanged touch point to StateStationary for touchmove and
175 // touchcancel.
176 void MarkUnchangedTouchPointsAsStationary(
177 blink::WebTouchEvent* event,
178 int changed_touch_id) {
179 if (event->type == blink::WebInputEvent::TouchMove ||
180 event->type == blink::WebInputEvent::TouchCancel) {
181 for (size_t i = 0; i < event->touchesLength; ++i) {
182 if (event->touches[i].id != changed_touch_id)
183 event->touches[i].state = blink::WebTouchPoint::StateStationary;
184 }
185 }
186 }
187
188 gfx::Point GetScreenLocationFromEvent(const ui::LocatedEvent& event) {
189 aura::Window* root =
190 static_cast<aura::Window*>(event.target())->GetRootWindow();
191 aura::client::ScreenPositionClient* spc =
192 aura::client::GetScreenPositionClient(root);
193 if (!spc)
194 return event.root_location();
195
196 gfx::Point screen_location(event.root_location());
197 spc->ConvertPointToScreen(root, &screen_location);
198 return screen_location;
199 }
200
201 #if defined(OS_WIN)
202 // This class implements the ui::OnScreenKeyboardObserver interface 134 // This class implements the ui::OnScreenKeyboardObserver interface
203 // which provides notifications about the on screen keyboard on Windows getting 135 // which provides notifications about the on screen keyboard on Windows getting
204 // displayed or hidden in response to taps on editable fields. 136 // displayed or hidden in response to taps on editable fields.
205 // It provides functionality to request blink to scroll the input field if it 137 // It provides functionality to request blink to scroll the input field if it
206 // is obscured by the on screen keyboard. 138 // is obscured by the on screen keyboard.
207 class WinScreenKeyboardObserver : public ui::OnScreenKeyboardObserver { 139 class WinScreenKeyboardObserver : public ui::OnScreenKeyboardObserver {
208 public: 140 public:
209 WinScreenKeyboardObserver(RenderWidgetHostImpl* host, 141 WinScreenKeyboardObserver(RenderWidgetHostImpl* host,
210 const gfx::Point& location_in_screen, 142 const gfx::Point& location_in_screen,
211 float scale_factor, 143 float scale_factor,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // The location in DIPs where the touch occurred. 202 // The location in DIPs where the touch occurred.
271 gfx::Point location_in_screen_; 203 gfx::Point location_in_screen_;
272 // The current device scale factor. 204 // The current device scale factor.
273 float device_scale_factor_; 205 float device_scale_factor_;
274 206
275 // The content Window. 207 // The content Window.
276 aura::Window* window_; 208 aura::Window* window_;
277 209
278 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver); 210 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver);
279 }; 211 };
280 #endif 212 #endif // defined(OS_WIN)
281 213
282 } // namespace 214 } // namespace
283 215
284 // We need to watch for mouse events outside a Web Popup or its parent 216 // We need to watch for mouse events outside a Web Popup or its parent
285 // and dismiss the popup for certain events. 217 // and dismiss the popup for certain events.
286 class RenderWidgetHostViewAura::EventFilterForPopupExit 218 class RenderWidgetHostViewAura::EventFilterForPopupExit
287 : public ui::EventHandler { 219 : public ui::EventHandler {
288 public: 220 public:
289 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 221 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
290 : rwhva_(rwhva) { 222 : rwhva_(rwhva) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 aura::Window* target = static_cast<aura::Window*>(event->target()); 256 aura::Window* target = static_cast<aura::Window*>(event->target());
325 if (target != window_ && 257 if (target != window_ &&
326 (!popup_parent_host_view_ || 258 (!popup_parent_host_view_ ||
327 target != popup_parent_host_view_->window_)) { 259 target != popup_parent_host_view_->window_)) {
328 // If we enter this code path it means that we did not receive any focus 260 // If we enter this code path it means that we did not receive any focus
329 // lost notifications for the popup window. Ensure that blink is aware 261 // lost notifications for the popup window. Ensure that blink is aware
330 // of the fact that focus was lost for the host window by sending a Blur 262 // of the fact that focus was lost for the host window by sending a Blur
331 // notification. We also set a flag in the view indicating that we need 263 // notification. We also set a flag in the view indicating that we need
332 // to force a Focus notification on the next mouse down. 264 // to force a Focus notification on the next mouse down.
333 if (popup_parent_host_view_ && popup_parent_host_view_->host_) { 265 if (popup_parent_host_view_ && popup_parent_host_view_->host_) {
334 popup_parent_host_view_->set_focus_on_mouse_down_or_key_event_ = true; 266 popup_parent_host_view_->event_handler()
267 ->set_focus_on_mouse_down_or_key_event(true);
335 popup_parent_host_view_->host_->Blur(); 268 popup_parent_host_view_->host_->Blur();
336 } 269 }
337 // Note: popup_parent_host_view_ may be NULL when there are multiple 270 // Note: popup_parent_host_view_ may be NULL when there are multiple
338 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup(). 271 // popup children per view. See: RenderWidgetHostViewAura::InitAsPopup().
339 Shutdown(); 272 Shutdown();
340 } 273 }
341 } 274 }
342 275
343 // We have to implement the WindowObserver interface on a separate object 276 // We have to implement the WindowObserver interface on a separate object
344 // because clang doesn't like implementing multiple interfaces that have 277 // because clang doesn't like implementing multiple interfaces that have
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 : host_(RenderWidgetHostImpl::From(host)), 364 : host_(RenderWidgetHostImpl::From(host)),
432 window_(nullptr), 365 window_(nullptr),
433 delegated_frame_host_(new DelegatedFrameHost(this)), 366 delegated_frame_host_(new DelegatedFrameHost(this)),
434 in_shutdown_(false), 367 in_shutdown_(false),
435 in_bounds_changed_(false), 368 in_bounds_changed_(false),
436 is_fullscreen_(false), 369 is_fullscreen_(false),
437 popup_parent_host_view_(nullptr), 370 popup_parent_host_view_(nullptr),
438 popup_child_host_view_(nullptr), 371 popup_child_host_view_(nullptr),
439 is_loading_(false), 372 is_loading_(false),
440 has_composition_text_(false), 373 has_composition_text_(false),
441 accept_return_character_(false),
442 begin_frame_source_(nullptr), 374 begin_frame_source_(nullptr),
443 synthetic_move_sent_(false),
444 cursor_visibility_state_in_renderer_(UNKNOWN), 375 cursor_visibility_state_in_renderer_(UNKNOWN),
445 #if defined(OS_WIN) 376 #if defined(OS_WIN)
446 legacy_render_widget_host_HWND_(nullptr), 377 legacy_render_widget_host_HWND_(nullptr),
447 legacy_window_destroyed_(false), 378 legacy_window_destroyed_(false),
448 virtual_keyboard_requested_(false), 379 virtual_keyboard_requested_(false),
449 #endif 380 #endif
450 has_snapped_to_boundary_(false), 381 has_snapped_to_boundary_(false),
451 is_guest_view_hack_(is_guest_view_hack), 382 is_guest_view_hack_(is_guest_view_hack),
452 set_focus_on_mouse_down_or_key_event_(false),
453 device_scale_factor_(0.0f), 383 device_scale_factor_(0.0f),
454 disable_input_event_router_for_testing_(false),
455 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), 384 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID),
456 last_active_widget_routing_id_(MSG_ROUTING_NONE), 385 last_active_widget_routing_id_(MSG_ROUTING_NONE),
386 event_handler_(new RenderWidgetHostViewEventHandler(host_, this)),
457 weak_ptr_factory_(this) { 387 weak_ptr_factory_(this) {
458 if (!is_guest_view_hack_) 388 if (!is_guest_view_hack_)
459 host_->SetView(this); 389 host_->SetView(this);
460 390
461 // Let the page-level input event router know about our surface ID 391 // Let the page-level input event router know about our surface ID
462 // namespace for surface-based hit testing. 392 // namespace for surface-based hit testing.
463 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 393 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
464 host_->delegate()->GetInputEventRouter()->AddSurfaceClientIdOwner( 394 host_->delegate()->GetInputEventRouter()->AddSurfaceClientIdOwner(
465 GetSurfaceClientId(), this); 395 GetSurfaceClientId(), this);
466 } 396 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or 451 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or
522 // similar mechanism to ensure a second popup doesn't cause the first one 452 // similar mechanism to ensure a second popup doesn't cause the first one
523 // to never get a chance to filter events. See crbug.com/160589. 453 // to never get a chance to filter events. See crbug.com/160589.
524 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); 454 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_);
525 if (transient_window_client) { 455 if (transient_window_client) {
526 transient_window_client->RemoveTransientChild( 456 transient_window_client->RemoveTransientChild(
527 popup_parent_host_view_->window_, old_child->window_); 457 popup_parent_host_view_->window_, old_child->window_);
528 } 458 }
529 old_child->popup_parent_host_view_ = NULL; 459 old_child->popup_parent_host_view_ = NULL;
530 } 460 }
531 popup_parent_host_view_->popup_child_host_view_ = this; 461 popup_parent_host_view_->SetPopupChildHostView(this);
532 window_->SetType(ui::wm::WINDOW_TYPE_MENU); 462 window_->SetType(ui::wm::WINDOW_TYPE_MENU);
533 window_->Init(ui::LAYER_SOLID_COLOR); 463 window_->Init(ui::LAYER_SOLID_COLOR);
534 window_->SetName("RenderWidgetHostViewAura"); 464 window_->SetName("RenderWidgetHostViewAura");
535 window_->layer()->SetColor(background_color_); 465 window_->layer()->SetColor(background_color_);
536 466
537 // Setting the transient child allows for the popup to get mouse events when 467 // Setting the transient child allows for the popup to get mouse events when
538 // in a system modal dialog. Do this before calling ParentWindowWithContext 468 // in a system modal dialog. Do this before calling ParentWindowWithContext
539 // below so that the transient parent is visible to WindowTreeClient. 469 // below so that the transient parent is visible to WindowTreeClient.
540 // This fixes crbug.com/328593. 470 // This fixes crbug.com/328593.
541 if (transient_window_client) { 471 if (transient_window_client) {
(...skipping 24 matching lines...) Expand all
566 window_->Init(ui::LAYER_SOLID_COLOR); 496 window_->Init(ui::LAYER_SOLID_COLOR);
567 window_->SetName("RenderWidgetHostViewAura"); 497 window_->SetName("RenderWidgetHostViewAura");
568 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 498 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
569 window_->layer()->SetColor(background_color_); 499 window_->layer()->SetColor(background_color_);
570 500
571 aura::Window* parent = NULL; 501 aura::Window* parent = NULL;
572 gfx::Rect bounds; 502 gfx::Rect bounds;
573 if (reference_host_view) { 503 if (reference_host_view) {
574 aura::Window* reference_window = 504 aura::Window* reference_window =
575 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 505 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
576 if (reference_window) { 506 event_handler_->TrackHost(reference_window);
577 host_tracker_.reset(new aura::WindowTracker);
578 host_tracker_->Add(reference_window);
579 }
580 display::Display display = 507 display::Display display =
581 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); 508 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window);
582 parent = reference_window->GetRootWindow(); 509 parent = reference_window->GetRootWindow();
583 bounds = display.bounds(); 510 bounds = display.bounds();
584 } 511 }
585 aura::client::ParentWindowWithContext(window_, parent, bounds); 512 aura::client::ParentWindowWithContext(window_, parent, bounds);
586 Show(); 513 Show();
587 Focus(); 514 Focus();
588 515
589 const display::Display display = 516 const display::Display display =
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 656
730 const cc::BeginFrameArgs& RenderWidgetHostViewAura::LastUsedBeginFrameArgs() 657 const cc::BeginFrameArgs& RenderWidgetHostViewAura::LastUsedBeginFrameArgs()
731 const { 658 const {
732 return last_begin_frame_args_; 659 return last_begin_frame_args_;
733 } 660 }
734 661
735 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) { 662 void RenderWidgetHostViewAura::OnBeginFrameSourcePausedChanged(bool paused) {
736 // Only used on Android WebView. 663 // Only used on Android WebView.
737 } 664 }
738 665
739 void RenderWidgetHostViewAura::SetKeyboardFocus() {
740 #if defined(OS_WIN)
741 if (CanFocus()) {
742 aura::WindowTreeHost* host = window_->GetHost();
743 if (host) {
744 gfx::AcceleratedWidget hwnd = host->GetAcceleratedWidget();
745 if (!(::GetWindowLong(hwnd, GWL_EXSTYLE) & WS_EX_NOACTIVATE))
746 ::SetFocus(hwnd);
747 }
748 }
749 #endif
750 // TODO(wjmaclean): can host_ ever be null?
751 if (host_ && set_focus_on_mouse_down_or_key_event_) {
752 set_focus_on_mouse_down_or_key_event_ = false;
753 host_->Focus();
754 }
755 }
756
757 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() { 666 RenderFrameHostImpl* RenderWidgetHostViewAura::GetFocusedFrame() {
758 RenderViewHost* rvh = RenderViewHost::From(host_); 667 RenderViewHost* rvh = RenderViewHost::From(host_);
759 if (!rvh) 668 if (!rvh)
760 return nullptr; 669 return nullptr;
761 FrameTreeNode* focused_frame = 670 FrameTreeNode* focused_frame =
762 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame(); 671 rvh->GetDelegate()->GetFrameTree()->GetFocusedFrame();
763 if (!focused_frame) 672 if (!focused_frame)
764 return nullptr; 673 return nullptr;
765 674
766 return focused_frame->current_frame_host(); 675 return focused_frame->current_frame_host();
767 } 676 }
768 677
769 bool RenderWidgetHostViewAura::CanRendererHandleEvent(
770 const ui::MouseEvent* event,
771 bool mouse_locked,
772 bool selection_popup) const {
773 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED)
774 return false;
775
776 if (event->type() == ui::ET_MOUSE_EXITED) {
777 if (mouse_locked || selection_popup)
778 return false;
779 #if defined(OS_WIN)
780 // Don't forward the mouse leave message which is received when the context
781 // menu is displayed by the page. This confuses the page and causes state
782 // changes.
783 if (IsShowingContextMenu())
784 return false;
785 #endif
786 return true;
787 }
788
789 #if defined(OS_WIN)
790 // Renderer cannot handle WM_XBUTTON or NC events.
791 switch (event->native_event().message) {
792 case WM_XBUTTONDOWN:
793 case WM_XBUTTONUP:
794 case WM_XBUTTONDBLCLK:
795 case WM_NCMOUSELEAVE:
796 case WM_NCMOUSEMOVE:
797 case WM_NCLBUTTONDOWN:
798 case WM_NCLBUTTONUP:
799 case WM_NCLBUTTONDBLCLK:
800 case WM_NCRBUTTONDOWN:
801 case WM_NCRBUTTONUP:
802 case WM_NCRBUTTONDBLCLK:
803 case WM_NCMBUTTONDOWN:
804 case WM_NCMBUTTONUP:
805 case WM_NCMBUTTONDBLCLK:
806 case WM_NCXBUTTONDOWN:
807 case WM_NCXBUTTONUP:
808 case WM_NCXBUTTONDBLCLK:
809 return false;
810 default:
811 break;
812 }
813 #elif defined(USE_X11)
814 // Renderer only supports standard mouse buttons, so ignore programmable
815 // buttons.
816 switch (event->type()) {
817 case ui::ET_MOUSE_PRESSED:
818 case ui::ET_MOUSE_RELEASED: {
819 const int kAllowedButtons = ui::EF_LEFT_MOUSE_BUTTON |
820 ui::EF_MIDDLE_MOUSE_BUTTON |
821 ui::EF_RIGHT_MOUSE_BUTTON;
822 return (event->flags() & kAllowedButtons) != 0;
823 }
824 default:
825 break;
826 }
827 #endif
828 return true;
829 }
830
831 bool RenderWidgetHostViewAura::ShouldRouteEvent(const ui::Event* event) const {
832 // We should route an event in two cases:
833 // 1) Mouse events are routed only if cross-process frames are possible.
834 // 2) Touch events are always routed. In the absence of a BrowserPlugin
835 // we expect the routing to always send the event to this view. If
836 // one or more BrowserPlugins are present, then the event may be targeted
837 // to one of them, or this view. This allows GuestViews to have access to
838 // them while still forcing pinch-zoom to be handled by the top-level
839 // frame. TODO(wjmaclean): At present, this doesn't work for OOPIF, but
840 // it should be a simple extension to modify RenderWidgetHostViewChildFrame
841 // in a similar manner to RenderWidgetHostViewGuest.
842 bool result = host_->delegate() && host_->delegate()->GetInputEventRouter() &&
843 !disable_input_event_router_for_testing_;
844 // ScrollEvents get transformed into MouseWheel events, and so are treated
845 // the same as mouse events for routing purposes.
846 if (event->IsMouseEvent() || event->type() == ui::ET_SCROLL)
847 result = result && SiteIsolationPolicy::AreCrossProcessFramesPossible();
848 return result;
849 }
850
851 void RenderWidgetHostViewAura::HandleParentBoundsChanged() { 678 void RenderWidgetHostViewAura::HandleParentBoundsChanged() {
852 SnapToPhysicalPixelBoundary(); 679 SnapToPhysicalPixelBoundary();
853 #if defined(OS_WIN) 680 #if defined(OS_WIN)
854 if (legacy_render_widget_host_HWND_) { 681 if (legacy_render_widget_host_HWND_) {
855 legacy_render_widget_host_HWND_->SetBounds( 682 legacy_render_widget_host_HWND_->SetBounds(
856 window_->GetBoundsInRootWindow()); 683 window_->GetBoundsInRootWindow());
857 } 684 }
858 #endif 685 #endif
859 if (!in_shutdown_) { 686 if (!in_shutdown_) {
860 // Send screen rects through the delegate if there is one. Not every 687 // Send screen rects through the delegate if there is one. Not every
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 } 725 }
899 726
900 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) { 727 void RenderWidgetHostViewAura::SetBackgroundColor(SkColor color) {
901 RenderWidgetHostViewBase::SetBackgroundColor(color); 728 RenderWidgetHostViewBase::SetBackgroundColor(color);
902 bool opaque = GetBackgroundOpaque(); 729 bool opaque = GetBackgroundOpaque();
903 host_->SetBackgroundOpaque(opaque); 730 host_->SetBackgroundOpaque(opaque);
904 window_->layer()->SetFillsBoundsOpaquely(opaque); 731 window_->layer()->SetFillsBoundsOpaquely(opaque);
905 window_->layer()->SetColor(color); 732 window_->layer()->SetColor(color);
906 } 733 }
907 734
735 bool RenderWidgetHostViewAura::IsMouseLocked() {
736 return event_handler_->mouse_locked();
737 }
738
908 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const { 739 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() const {
909 gfx::Rect requested_rect(GetRequestedRendererSize()); 740 gfx::Rect requested_rect(GetRequestedRendererSize());
910 requested_rect.Inset(insets_); 741 requested_rect.Inset(insets_);
911 return requested_rect.size(); 742 return requested_rect.size();
912 } 743 }
913 744
914 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) { 745 void RenderWidgetHostViewAura::SetInsets(const gfx::Insets& insets) {
915 if (insets != insets_) { 746 if (insets != insets_) {
916 insets_ = insets; 747 insets_ = insets;
917 host_->WasResized(); 748 host_->WasResized();
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 gfx::NativeViewAccessible 1093 gfx::NativeViewAccessible
1263 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() { 1094 RenderWidgetHostViewAura::AccessibilityGetNativeViewAccessible() {
1264 #if defined(OS_WIN) 1095 #if defined(OS_WIN)
1265 if (legacy_render_widget_host_HWND_) 1096 if (legacy_render_widget_host_HWND_)
1266 return legacy_render_widget_host_HWND_->window_accessible(); 1097 return legacy_render_widget_host_HWND_->window_accessible();
1267 #endif 1098 #endif
1268 return NULL; 1099 return NULL;
1269 } 1100 }
1270 1101
1271 bool RenderWidgetHostViewAura::LockMouse() { 1102 bool RenderWidgetHostViewAura::LockMouse() {
1272 aura::Window* root_window = window_->GetRootWindow(); 1103 return event_handler_->LockMouse();
1273 if (!root_window)
1274 return false;
1275
1276 if (mouse_locked_)
1277 return true;
1278
1279 mouse_locked_ = true;
1280 #if !defined(OS_WIN)
1281 window_->SetCapture();
1282 #else
1283 UpdateMouseLockRegion();
1284 #endif
1285 aura::client::CursorClient* cursor_client =
1286 aura::client::GetCursorClient(root_window);
1287 if (cursor_client) {
1288 cursor_client->HideCursor();
1289 cursor_client->LockCursor();
1290 }
1291
1292 if (ShouldMoveToCenter()) {
1293 synthetic_move_sent_ = true;
1294 window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint());
1295 }
1296 tooltip_disabler_.reset(new aura::client::ScopedTooltipDisabler(root_window));
sadrul 2016/09/13 15:39:46 It might make sense to keep this tooltip disabler
jonross 2016/09/15 16:39:59 Moved the tooltip disabler back to RWHVA, and adde
1297 return true;
1298 } 1104 }
1299 1105
1300 void RenderWidgetHostViewAura::UnlockMouse() { 1106 void RenderWidgetHostViewAura::UnlockMouse() {
1301 tooltip_disabler_.reset(); 1107 event_handler_->UnlockMouse();
1302
1303 aura::Window* root_window = window_->GetRootWindow();
1304 if (!mouse_locked_ || !root_window)
1305 return;
1306
1307 mouse_locked_ = false;
1308
1309 if (window_->HasCapture())
1310 window_->ReleaseCapture();
1311
1312 #if defined(OS_WIN)
1313 ::ClipCursor(NULL);
1314 #endif
1315
1316 // Ensure that the global mouse position is updated here to its original
1317 // value. If we don't do this then the synthesized mouse move which is posted
1318 // after the cursor is moved ends up getting a large movement delta which is
1319 // not what sites expect. The delta is computed in the
1320 // ModifyEventMovementAndCoords function.
1321 global_mouse_position_ = unlocked_global_mouse_position_;
1322 window_->MoveCursorTo(unlocked_mouse_position_);
1323
1324 aura::client::CursorClient* cursor_client =
1325 aura::client::GetCursorClient(root_window);
1326 if (cursor_client) {
1327 cursor_client->UnlockCursor();
1328 cursor_client->ShowCursor();
1329 }
1330
1331 host_->LostMouseLock();
1332 } 1108 }
1333 1109
1334 //////////////////////////////////////////////////////////////////////////////// 1110 ////////////////////////////////////////////////////////////////////////////////
1335 // RenderWidgetHostViewAura, ui::TextInputClient implementation: 1111 // RenderWidgetHostViewAura, ui::TextInputClient implementation:
1336 void RenderWidgetHostViewAura::SetCompositionText( 1112 void RenderWidgetHostViewAura::SetCompositionText(
1337 const ui::CompositionText& composition) { 1113 const ui::CompositionText& composition) {
1338 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) 1114 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1339 return; 1115 return;
1340 1116
1341 // TODO(suzhe): convert both renderer_host and renderer to use 1117 // TODO(suzhe): convert both renderer_host and renderer to use
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 } 1165 }
1390 1166
1391 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1167 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1392 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1168 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1393 popup_child_host_view_->InsertChar(event); 1169 popup_child_host_view_->InsertChar(event);
1394 return; 1170 return;
1395 } 1171 }
1396 1172
1397 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 1173 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547
1398 // TODO(wjmaclean): can host_ ever be null? 1174 // TODO(wjmaclean): can host_ ever be null?
1399 if (host_ && 1175 if (host_ && (event_handler_->accept_return_character() ||
1400 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { 1176 event.GetCharacter() != ui::VKEY_RETURN)) {
1401 // Send a blink::WebInputEvent::Char event to |host_|. 1177 // Send a blink::WebInputEvent::Char event to |host_|.
1402 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); 1178 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter()));
1403 } 1179 }
1404 } 1180 }
1405 1181
1406 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { 1182 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const {
1407 if (text_input_manager_ && text_input_manager_->GetTextInputState()) 1183 if (text_input_manager_ && text_input_manager_->GetTextInputState())
1408 return text_input_manager_->GetTextInputState()->type; 1184 return text_input_manager_->GetTextInputState()->type;
1409 return ui::TEXT_INPUT_TYPE_NONE; 1185 return ui::TEXT_INPUT_TYPE_NONE;
1410 } 1186 }
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1759 return false; 1535 return false;
1760 } 1536 }
1761 1537
1762 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1538 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1763 } 1539 }
1764 1540
1765 //////////////////////////////////////////////////////////////////////////////// 1541 ////////////////////////////////////////////////////////////////////////////////
1766 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1542 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1767 1543
1768 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1544 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1769 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 1545 event_handler_->OnKeyEvent(event);
1770
1771 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1772 popup_child_host_view_->OnKeyEvent(event);
1773 if (event->handled())
1774 return;
1775 }
1776
1777 // We need to handle the Escape key for Pepper Flash.
1778 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1779 // Focus the window we were created from.
1780 if (host_tracker_.get() && !host_tracker_->windows().empty()) {
1781 aura::Window* host = *(host_tracker_->windows().begin());
1782 aura::client::FocusClient* client = aura::client::GetFocusClient(host);
1783 if (client) {
1784 // Calling host->Focus() may delete |this|. We create a local observer
1785 // for that. In that case we exit without further access to any members.
1786 aura::WindowTracker tracker;
1787 aura::Window* window = window_;
1788 tracker.Add(window);
1789 host->Focus();
1790 if (!tracker.Contains(window)) {
1791 event->SetHandled();
1792 return;
1793 }
1794 }
1795 }
1796 Shutdown();
1797 } else {
1798 if (event->key_code() == ui::VKEY_RETURN) {
1799 // Do not forward return key release events if no press event was handled.
1800 if (event->type() == ui::ET_KEY_RELEASED && !accept_return_character_)
1801 return;
1802 // Accept return key character events between press and release events.
1803 accept_return_character_ = event->type() == ui::ET_KEY_PRESSED;
1804 }
1805
1806 // Call SetKeyboardFocus() for not only ET_KEY_PRESSED but also
1807 // ET_KEY_RELEASED. If a user closed the hotdog menu with ESC key press,
1808 // we need to notify focus to Blink on ET_KEY_RELEASED for ESC key.
1809 SetKeyboardFocus();
1810 // We don't have to communicate with an input method here.
1811 NativeWebKeyboardEvent webkit_event(*event);
1812 ForwardKeyboardEvent(webkit_event);
1813 }
1814 event->SetHandled();
1815 } 1546 }
1816 1547
1817 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { 1548 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1818 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); 1549 event_handler_->OnMouseEvent(event);
1819
1820 ForwardMouseEventToParent(event);
1821 // TODO(mgiuca): Return if event->handled() returns true. This currently
1822 // breaks drop-down lists which means something is incorrectly setting
1823 // event->handled to true (http://crbug.com/577983).
1824
1825 if (mouse_locked_) {
1826 aura::client::CursorClient* cursor_client =
1827 aura::client::GetCursorClient(window_->GetRootWindow());
1828 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
1829
1830 if (event->type() == ui::ET_MOUSEWHEEL) {
1831 blink::WebMouseWheelEvent mouse_wheel_event =
1832 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event),
1833 base::Bind(&GetScreenLocationFromEvent));
1834 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
1835 host_->ForwardWheelEvent(mouse_wheel_event);
1836 return;
1837 }
1838
1839 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint());
1840
1841 // If we receive non client mouse messages while we are in the locked state
1842 // it probably means that the mouse left the borders of our window and
1843 // needs to be moved back to the center.
1844 if (event->flags() & ui::EF_IS_NON_CLIENT) {
1845 synthetic_move_sent_ = true;
1846 window_->MoveCursorTo(center);
1847 return;
1848 }
1849
1850 blink::WebMouseEvent mouse_event =
1851 ui::MakeWebMouseEvent(*event, base::Bind(&GetScreenLocationFromEvent));
1852
1853 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED ||
1854 event->type() == ui::ET_MOUSE_DRAGGED) &&
1855 mouse_event.x == center.x() && mouse_event.y == center.y();
1856
1857 // For fractional scale factors, the conversion from pixels to dip and
1858 // vice versa could result in off by 1 or 2 errors which hurts us because
1859 // we want to avoid sending the artificial move to center event to the
1860 // renderer. Sending the move to center to the renderer cause the cursor
1861 // to bounce around the center of the screen leading to the lock operation
1862 // not working correctly.
1863 // Workaround is to treat a mouse move or drag event off by at most 2 px
1864 // from the center as a move to center event.
1865 if (synthetic_move_sent_ &&
1866 IsFractionalScaleFactor(current_device_scale_factor_)) {
1867 if (event->type() == ui::ET_MOUSE_MOVED ||
1868 event->type() == ui::ET_MOUSE_DRAGGED) {
1869 if ((abs(mouse_event.x - center.x()) <= 2) &&
1870 (abs(mouse_event.y - center.y()) <= 2)) {
1871 is_move_to_center_event = true;
1872 }
1873 }
1874 }
1875
1876 ModifyEventMovementAndCoords(&mouse_event);
1877
1878 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_;
1879 if (should_not_forward) {
1880 synthetic_move_sent_ = false;
1881 } else {
1882 // Check if the mouse has reached the border and needs to be centered.
1883 if (ShouldMoveToCenter()) {
1884 synthetic_move_sent_ = true;
1885 window_->MoveCursorTo(center);
1886 }
1887 bool is_selection_popup = popup_child_host_view_ &&
1888 popup_child_host_view_->NeedsInputGrab();
1889 // Forward event to renderer.
1890 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
1891 !(event->flags() & ui::EF_FROM_TOUCH)) {
1892 host_->ForwardMouseEvent(mouse_event);
1893 // Ensure that we get keyboard focus on mouse down as a plugin window
1894 // may have grabbed keyboard focus.
1895 if (event->type() == ui::ET_MOUSE_PRESSED)
1896 SetKeyboardFocus();
1897 }
1898 }
1899 return;
1900 }
1901
1902 // As the overscroll is handled during scroll events from the trackpad, the
1903 // RWHVA window is transformed by the overscroll controller. This transform
1904 // triggers a synthetic mouse-move event to be generated (by the aura
1905 // RootWindow). But this event interferes with the overscroll gesture. So,
1906 // ignore such synthetic mouse-move events if an overscroll gesture is in
1907 // progress.
1908 if (overscroll_controller_ &&
1909 overscroll_controller_->overscroll_mode() != OVERSCROLL_NONE &&
1910 event->flags() & ui::EF_IS_SYNTHESIZED &&
1911 (event->type() == ui::ET_MOUSE_ENTERED ||
1912 event->type() == ui::ET_MOUSE_EXITED ||
1913 event->type() == ui::ET_MOUSE_MOVED)) {
1914 event->StopPropagation();
1915 return;
1916 }
1917
1918 if (event->type() == ui::ET_MOUSEWHEEL) {
1919 #if defined(OS_WIN)
1920 // We get mouse wheel/scroll messages even if we are not in the foreground.
1921 // So here we check if we have any owned popup windows in the foreground and
1922 // dismiss them.
1923 aura::WindowTreeHost* host = window_->GetHost();
1924 if (host) {
1925 HWND parent = host->GetAcceleratedWidget();
1926 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT);
1927 EnumThreadWindows(GetCurrentThreadId(),
1928 DismissOwnedPopups,
1929 reinterpret_cast<LPARAM>(toplevel_hwnd));
1930 }
1931 #endif
1932 blink::WebMouseWheelEvent mouse_wheel_event =
1933 ui::MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event),
1934 base::Bind(&GetScreenLocationFromEvent));
1935 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) {
1936 if (ShouldRouteEvent(event)) {
1937 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
1938 this, &mouse_wheel_event);
1939 } else {
1940 ProcessMouseWheelEvent(mouse_wheel_event, *event->latency());
1941 }
1942 }
1943 } else {
1944 bool is_selection_popup =
1945 popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab();
1946 if (CanRendererHandleEvent(event, mouse_locked_, is_selection_popup) &&
1947 !(event->flags() & ui::EF_FROM_TOUCH)) {
1948 // Confirm existing composition text on mouse press, to make sure
1949 // the input caret won't be moved with an ongoing composition text.
1950 if (event->type() == ui::ET_MOUSE_PRESSED)
1951 FinishImeCompositionSession();
1952
1953 blink::WebMouseEvent mouse_event = ui::MakeWebMouseEvent(
1954 *event, base::Bind(&GetScreenLocationFromEvent));
1955 ModifyEventMovementAndCoords(&mouse_event);
1956 if (ShouldRouteEvent(event)) {
1957 host_->delegate()->GetInputEventRouter()->RouteMouseEvent(this,
1958 &mouse_event);
1959 } else {
1960 ProcessMouseEvent(mouse_event, *event->latency());
1961 }
1962
1963 // Ensure that we get keyboard focus on mouse down as a plugin window may
1964 // have grabbed keyboard focus.
1965 if (event->type() == ui::ET_MOUSE_PRESSED)
1966 SetKeyboardFocus();
1967 }
1968 }
1969
1970 switch (event->type()) {
1971 case ui::ET_MOUSE_PRESSED:
1972 window_->SetCapture();
1973 break;
1974 case ui::ET_MOUSE_RELEASED:
1975 if (!NeedsMouseCapture())
1976 window_->ReleaseCapture();
1977 break;
1978 default:
1979 break;
1980 }
1981
1982 if (!IsXButtonUpEvent(event))
1983 event->SetHandled();
1984 } 1550 }
1985 1551
1986 uint32_t RenderWidgetHostViewAura::SurfaceClientIdAtPoint( 1552 uint32_t RenderWidgetHostViewAura::SurfaceClientIdAtPoint(
1987 cc::SurfaceHittestDelegate* delegate, 1553 cc::SurfaceHittestDelegate* delegate,
1988 const gfx::Point& point, 1554 const gfx::Point& point,
1989 gfx::Point* transformed_point) { 1555 gfx::Point* transformed_point) {
1990 DCHECK(device_scale_factor_ != 0.0f); 1556 DCHECK(device_scale_factor_ != 0.0f);
1991 1557
1992 // The surface hittest happens in device pixels, so we need to convert the 1558 // The surface hittest happens in device pixels, so we need to convert the
1993 // |point| from DIPs to pixels before hittesting. 1559 // |point| from DIPs to pixels before hittesting.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 if (rvh && rvh->GetDelegate()) 1627 if (rvh && rvh->GetDelegate())
2062 rvh->GetDelegate()->SetIsVirtualKeyboardRequested(false); 1628 rvh->GetDelegate()->SetIsVirtualKeyboardRequested(false);
2063 1629
2064 DCHECK(ui::OnScreenKeyboardDisplayManager::GetInstance()); 1630 DCHECK(ui::OnScreenKeyboardDisplayManager::GetInstance());
2065 ui::OnScreenKeyboardDisplayManager::GetInstance()->DismissVirtualKeyboard(); 1631 ui::OnScreenKeyboardDisplayManager::GetInstance()->DismissVirtualKeyboard();
2066 } 1632 }
2067 #endif 1633 #endif
2068 } 1634 }
2069 1635
2070 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 1636 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2071 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 1637 event_handler_->OnScrollEvent(event);
2072
2073 if (event->type() == ui::ET_SCROLL) {
2074 #if !defined(OS_WIN)
2075 // TODO(ananta)
2076 // Investigate if this is true for Windows 8 Metro ASH as well.
2077 if (event->finger_count() != 2)
2078 return;
2079 #endif
2080 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEventFlingCancel();
2081 // Coordinates need to be transferred to the fling cancel gesture only
2082 // for Surface-targeting to ensure that it is targeted to the correct
2083 // RenderWidgetHost.
2084 gesture_event.x = event->x();
2085 gesture_event.y = event->y();
2086 blink::WebMouseWheelEvent mouse_wheel_event = ui::MakeWebMouseWheelEvent(
2087 *event, base::Bind(&GetScreenLocationFromEvent));
2088 if (ShouldRouteEvent(event)) {
2089 host_->delegate()->GetInputEventRouter()->RouteGestureEvent(
2090 this, &gesture_event, ui::LatencyInfo());
2091 host_->delegate()->GetInputEventRouter()->RouteMouseWheelEvent(
2092 this, &mouse_wheel_event);
2093 } else {
2094 host_->ForwardGestureEvent(gesture_event);
2095 host_->ForwardWheelEventWithLatencyInfo(mouse_wheel_event,
2096 *event->latency());
2097 }
2098 RecordAction(base::UserMetricsAction("TrackpadScroll"));
2099 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
2100 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
2101 blink::WebGestureEvent gesture_event = ui::MakeWebGestureEvent(
2102 *event, base::Bind(&GetScreenLocationFromEvent));
2103 if (ShouldRouteEvent(event)) {
2104 host_->delegate()->GetInputEventRouter()->RouteGestureEvent(
2105 this, &gesture_event, ui::LatencyInfo());
2106 } else {
2107 host_->ForwardGestureEvent(gesture_event);
2108 }
2109 if (event->type() == ui::ET_SCROLL_FLING_START)
2110 RecordAction(base::UserMetricsAction("TrackpadScrollFling"));
2111 }
2112
2113 event->SetHandled();
2114 } 1638 }
2115 1639
2116 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 1640 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
2117 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 1641 event_handler_->OnTouchEvent(event);
2118
2119 bool had_no_pointer = !pointer_state_.GetPointerCount();
2120
2121 // Update the touch event first.
2122 if (!pointer_state_.OnTouch(*event)) {
2123 event->StopPropagation();
2124 return;
2125 }
2126
2127 blink::WebTouchEvent touch_event;
2128 bool handled = selection_controller_->WillHandleTouchEvent(pointer_state_);
2129 if (handled) {
2130 event->SetHandled();
2131 } else {
2132 touch_event = ui::CreateWebTouchEventFromMotionEvent(
2133 pointer_state_, event->may_cause_scrolling());
2134 }
2135 pointer_state_.CleanupRemovedTouchPoints(*event);
2136
2137 if (handled)
2138 return;
2139
2140 if (had_no_pointer)
2141 selection_controller_client_->OnTouchDown();
2142 if (!pointer_state_.GetPointerCount())
2143 selection_controller_client_->OnTouchUp();
2144
2145 // It is important to always mark events as being handled asynchronously when
2146 // they are forwarded. This ensures that the current event does not get
2147 // processed by the gesture recognizer before events currently awaiting
2148 // dispatch in the touch queue.
2149 event->DisableSynchronousHandling();
2150
2151 // Set unchanged touch point to StateStationary for touchmove and
2152 // touchcancel to make sure only send one ack per WebTouchEvent.
2153 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2154 if (ShouldRouteEvent(event)) {
2155 host_->delegate()->GetInputEventRouter()->RouteTouchEvent(
2156 this, &touch_event, *event->latency());
2157 } else {
2158 ProcessTouchEvent(touch_event, *event->latency());
2159 }
2160 } 1642 }
2161 1643
2162 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 1644 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2163 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 1645 event_handler_->OnGestureEvent(event);
2164
2165 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2166 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2167 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2168 event->SetHandled();
2169 return;
2170 }
2171
2172 HandleGestureForTouchSelection(event);
2173 if (event->handled())
2174 return;
2175
2176 // Confirm existing composition text on TAP gesture, to make sure the input
2177 // caret won't be moved with an ongoing composition text.
2178 if (event->type() == ui::ET_GESTURE_TAP)
2179 FinishImeCompositionSession();
2180
2181 blink::WebGestureEvent gesture =
2182 ui::MakeWebGestureEvent(*event, base::Bind(&GetScreenLocationFromEvent));
2183 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
2184 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an
2185 // event to stop any in-progress flings.
2186 blink::WebGestureEvent fling_cancel = gesture;
2187 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel;
2188 fling_cancel.sourceDevice = blink::WebGestureDeviceTouchscreen;
2189 if (ShouldRouteEvent(event)) {
2190 host_->delegate()->GetInputEventRouter()->RouteGestureEvent(
2191 this, &fling_cancel, ui::LatencyInfo());
2192 } else {
2193 host_->ForwardGestureEvent(fling_cancel);
2194 }
2195 }
2196
2197 if (gesture.type != blink::WebInputEvent::Undefined) {
2198 if (ShouldRouteEvent(event)) {
2199 host_->delegate()->GetInputEventRouter()->RouteGestureEvent(
2200 this, &gesture, *event->latency());
2201 } else {
2202 host_->ForwardGestureEventWithLatencyInfo(gesture, *event->latency());
2203 }
2204
2205 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN ||
2206 event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
2207 event->type() == ui::ET_GESTURE_SCROLL_END) {
2208 RecordAction(base::UserMetricsAction("TouchscreenScroll"));
2209 } else if (event->type() == ui::ET_SCROLL_FLING_START) {
2210 RecordAction(base::UserMetricsAction("TouchscreenScrollFling"));
2211 }
2212 }
2213
2214 // If a gesture is not processed by the webpage, then WebKit processes it
2215 // (e.g. generates synthetic mouse events).
2216 event->SetHandled();
2217 } 1646 }
2218 1647
2219 //////////////////////////////////////////////////////////////////////////////// 1648 ////////////////////////////////////////////////////////////////////////////////
2220 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: 1649 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation:
2221 1650
2222 bool RenderWidgetHostViewAura::ShouldActivate() const { 1651 bool RenderWidgetHostViewAura::ShouldActivate() const {
2223 aura::WindowTreeHost* host = window_->GetHost(); 1652 aura::WindowTreeHost* host = window_->GetHost();
2224 if (!host) 1653 if (!host)
2225 return true; 1654 return true;
2226 const ui::Event* event = host->dispatcher()->current_event(); 1655 const ui::Event* event = host->dispatcher()->current_event();
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 display::Screen::GetScreen()->RemoveObserver(this); 1777 display::Screen::GetScreen()->RemoveObserver(this);
2349 1778
2350 // This call is usually no-op since |this| object is already removed from 1779 // This call is usually no-op since |this| object is already removed from
2351 // the Aura root window and we don't have a way to get an input method 1780 // the Aura root window and we don't have a way to get an input method
2352 // object associated with the window, but just in case. 1781 // object associated with the window, but just in case.
2353 DetachFromInputMethod(); 1782 DetachFromInputMethod();
2354 } 1783 }
2355 if (popup_parent_host_view_) { 1784 if (popup_parent_host_view_) {
2356 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 1785 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2357 popup_parent_host_view_->popup_child_host_view_ == this); 1786 popup_parent_host_view_->popup_child_host_view_ == this);
2358 popup_parent_host_view_->popup_child_host_view_ = NULL; 1787 popup_parent_host_view_->SetPopupChildHostView(nullptr);
2359 } 1788 }
2360 if (popup_child_host_view_) { 1789 if (popup_child_host_view_) {
2361 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL || 1790 DCHECK(popup_child_host_view_->popup_parent_host_view_ == NULL ||
2362 popup_child_host_view_->popup_parent_host_view_ == this); 1791 popup_child_host_view_->popup_parent_host_view_ == this);
2363 popup_child_host_view_->popup_parent_host_view_ = NULL; 1792 popup_child_host_view_->popup_parent_host_view_ = NULL;
2364 } 1793 }
2365 event_filter_for_popup_exit_.reset(); 1794 event_filter_for_popup_exit_.reset();
2366 1795
2367 #if defined(OS_WIN) 1796 #if defined(OS_WIN)
2368 // The LegacyRenderWidgetHostHWND window should have been destroyed in 1797 // The LegacyRenderWidgetHostHWND window should have been destroyed in
(...skipping 10 matching lines...) Expand all
2379 1808
2380 #endif 1809 #endif
2381 1810
2382 if (text_input_manager_) 1811 if (text_input_manager_)
2383 text_input_manager_->RemoveObserver(this); 1812 text_input_manager_->RemoveObserver(this);
2384 } 1813 }
2385 1814
2386 void RenderWidgetHostViewAura::CreateAuraWindow() { 1815 void RenderWidgetHostViewAura::CreateAuraWindow() {
2387 DCHECK(!window_); 1816 DCHECK(!window_);
2388 window_ = new aura::Window(this); 1817 window_ = new aura::Window(this);
1818 event_handler_->set_window(window_);
2389 window_observer_.reset(new WindowObserver(this)); 1819 window_observer_.reset(new WindowObserver(this));
2390 1820
2391 aura::client::SetTooltipText(window_, &tooltip_); 1821 aura::client::SetTooltipText(window_, &tooltip_);
2392 aura::client::SetActivationDelegate(window_, this); 1822 aura::client::SetActivationDelegate(window_, this);
2393 aura::client::SetFocusChangeObserver(window_, this); 1823 aura::client::SetFocusChangeObserver(window_, this);
2394 window_->set_layer_owner_delegate(delegated_frame_host_.get()); 1824 window_->set_layer_owner_delegate(delegated_frame_host_.get());
2395 display::Screen::GetScreen()->AddObserver(this); 1825 display::Screen::GetScreen()->AddObserver(this);
2396 } 1826 }
2397 1827
2398 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 1828 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 return popup_type_ == blink::WebPopupTypePage; 1908 return popup_type_ == blink::WebPopupTypePage;
2479 } 1909 }
2480 1910
2481 bool RenderWidgetHostViewAura::NeedsMouseCapture() { 1911 bool RenderWidgetHostViewAura::NeedsMouseCapture() {
2482 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1912 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
2483 return NeedsInputGrab(); 1913 return NeedsInputGrab();
2484 #endif 1914 #endif
2485 return false; 1915 return false;
2486 } 1916 }
2487 1917
2488 void RenderWidgetHostViewAura::FinishImeCompositionSession() {
2489 if (!has_composition_text_)
2490 return;
2491
2492 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) {
2493 text_input_manager_->GetActiveWidget()->ImeConfirmComposition(
2494 base::string16(), gfx::Range::InvalidRange(), false);
2495 }
2496 ImeCancelComposition();
2497 }
2498
2499 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords(
2500 blink::WebMouseEvent* event) {
2501 // If the mouse has just entered, we must report zero movementX/Y. Hence we
2502 // reset any global_mouse_position set previously.
2503 if (event->type == blink::WebInputEvent::MouseEnter ||
2504 event->type == blink::WebInputEvent::MouseLeave)
2505 global_mouse_position_.SetPoint(event->globalX, event->globalY);
2506
2507 // Movement is computed by taking the difference of the new cursor position
2508 // and the previous. Under mouse lock the cursor will be warped back to the
2509 // center so that we are not limited by clipping boundaries.
2510 // We do not measure movement as the delta from cursor to center because
2511 // we may receive more mouse movement events before our warp has taken
2512 // effect.
2513 event->movementX = event->globalX - global_mouse_position_.x();
2514 event->movementY = event->globalY - global_mouse_position_.y();
2515
2516 global_mouse_position_.SetPoint(event->globalX, event->globalY);
2517
2518 // Under mouse lock, coordinates of mouse are locked to what they were when
2519 // mouse lock was entered.
2520 if (mouse_locked_) {
2521 event->x = unlocked_mouse_position_.x();
2522 event->y = unlocked_mouse_position_.y();
2523 event->windowX = unlocked_mouse_position_.x();
2524 event->windowY = unlocked_mouse_position_.y();
2525 event->globalX = unlocked_global_mouse_position_.x();
2526 event->globalY = unlocked_global_mouse_position_.y();
2527 } else {
2528 unlocked_mouse_position_.SetPoint(event->x, event->y);
2529 unlocked_global_mouse_position_.SetPoint(event->globalX, event->globalY);
2530 }
2531 }
2532
2533 void RenderWidgetHostViewAura::NotifyRendererOfCursorVisibilityState( 1918 void RenderWidgetHostViewAura::NotifyRendererOfCursorVisibilityState(
2534 bool is_visible) { 1919 bool is_visible) {
2535 if (host_->is_hidden() || 1920 if (host_->is_hidden() ||
2536 (cursor_visibility_state_in_renderer_ == VISIBLE && is_visible) || 1921 (cursor_visibility_state_in_renderer_ == VISIBLE && is_visible) ||
2537 (cursor_visibility_state_in_renderer_ == NOT_VISIBLE && !is_visible)) 1922 (cursor_visibility_state_in_renderer_ == NOT_VISIBLE && !is_visible))
2538 return; 1923 return;
2539 1924
2540 cursor_visibility_state_in_renderer_ = is_visible ? VISIBLE : NOT_VISIBLE; 1925 cursor_visibility_state_in_renderer_ = is_visible ? VISIBLE : NOT_VISIBLE;
2541 host_->SendCursorVisibilityState(is_visible); 1926 host_->SendCursorVisibilityState(is_visible);
2542 } 1927 }
(...skipping 19 matching lines...) Expand all
2562 1947
2563 if (snapped && snapped != window_) 1948 if (snapped && snapped != window_)
2564 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); 1949 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer());
2565 1950
2566 has_snapped_to_boundary_ = true; 1951 has_snapped_to_boundary_ = true;
2567 } 1952 }
2568 1953
2569 bool RenderWidgetHostViewAura::OnShowContextMenu( 1954 bool RenderWidgetHostViewAura::OnShowContextMenu(
2570 const ContextMenuParams& params) { 1955 const ContextMenuParams& params) {
2571 #if defined(OS_WIN) 1956 #if defined(OS_WIN)
2572 last_context_menu_params_.reset(); 1957 event_handler_->SetContextMenuParams(params);
2573 1958 return params.source_type != ui::MENU_SOURCE_LONG_PRESS;
2574 if (params.source_type == ui::MENU_SOURCE_LONG_PRESS) { 1959 #else
2575 last_context_menu_params_.reset(new ContextMenuParams);
2576 *last_context_menu_params_ = params;
2577 return false;
2578 }
2579 #endif
2580 return true; 1960 return true;
1961 #endif // defined(OS_WIN)
2581 } 1962 }
2582 1963
2583 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( 1964 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest(
2584 std::unique_ptr<TouchSelectionControllerClientAura> client) { 1965 std::unique_ptr<TouchSelectionControllerClientAura> client) {
2585 selection_controller_client_.swap(client); 1966 selection_controller_client_.swap(client);
2586 CreateSelectionController(); 1967 CreateSelectionController();
2587 disable_input_event_router_for_testing_ = true;
2588 } 1968 }
2589 1969
2590 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 1970 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2591 SnapToPhysicalPixelBoundary(); 1971 SnapToPhysicalPixelBoundary();
2592 // Don't recursively call SetBounds if this bounds update is the result of 1972 // Don't recursively call SetBounds if this bounds update is the result of
2593 // a Window::SetBoundsInternal call. 1973 // a Window::SetBoundsInternal call.
2594 if (!in_bounds_changed_) 1974 if (!in_bounds_changed_)
2595 window_->SetBounds(rect); 1975 window_->SetBounds(rect);
2596 host_->WasResized(); 1976 host_->WasResized();
2597 delegated_frame_host_->WasResized(); 1977 delegated_frame_host_->WasResized();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 const gfx::Rect& clip) { 2013 const gfx::Rect& clip) {
2634 if (!clip.IsEmpty()) { 2014 if (!clip.IsEmpty()) {
2635 gfx::Rect to_paint = gfx::SubtractRects(rect, clip); 2015 gfx::Rect to_paint = gfx::SubtractRects(rect, clip);
2636 if (!to_paint.IsEmpty()) 2016 if (!to_paint.IsEmpty())
2637 window_->SchedulePaintInRect(to_paint); 2017 window_->SchedulePaintInRect(to_paint);
2638 } else { 2018 } else {
2639 window_->SchedulePaintInRect(rect); 2019 window_->SchedulePaintInRect(rect);
2640 } 2020 }
2641 } 2021 }
2642 2022
2643 bool RenderWidgetHostViewAura::ShouldMoveToCenter() {
2644 gfx::Rect rect = window_->bounds();
2645 rect = ConvertRectToScreen(rect);
2646 int border_x = rect.width() * kMouseLockBorderPercentage / 100;
2647 int border_y = rect.height() * kMouseLockBorderPercentage / 100;
2648
2649 return global_mouse_position_.x() < rect.x() + border_x ||
2650 global_mouse_position_.x() > rect.right() - border_x ||
2651 global_mouse_position_.y() < rect.y() + border_y ||
2652 global_mouse_position_.y() > rect.bottom() - border_y;
2653 }
2654
2655 void RenderWidgetHostViewAura::AddedToRootWindow() { 2023 void RenderWidgetHostViewAura::AddedToRootWindow() {
2656 window_->GetHost()->AddObserver(this); 2024 window_->GetHost()->AddObserver(this);
2657 UpdateScreenInfo(window_); 2025 UpdateScreenInfo(window_);
2658 2026
2659 aura::client::CursorClient* cursor_client = 2027 aura::client::CursorClient* cursor_client =
2660 aura::client::GetCursorClient(window_->GetRootWindow()); 2028 aura::client::GetCursorClient(window_->GetRootWindow());
2661 if (cursor_client) { 2029 if (cursor_client) {
2662 cursor_client->AddObserver(this); 2030 cursor_client->AddObserver(this);
2663 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 2031 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
2664 } 2032 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 ui::TouchSelectionController::Config tsc_config; 2120 ui::TouchSelectionController::Config tsc_config;
2753 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds( 2121 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds(
2754 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms()); 2122 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms());
2755 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance() 2123 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
2756 ->max_touch_move_in_pixels_for_click(); 2124 ->max_touch_move_in_pixels_for_click();
2757 tsc_config.enable_longpress_drag_selection = false; 2125 tsc_config.enable_longpress_drag_selection = false;
2758 selection_controller_.reset(new ui::TouchSelectionController( 2126 selection_controller_.reset(new ui::TouchSelectionController(
2759 selection_controller_client_.get(), tsc_config)); 2127 selection_controller_client_.get(), tsc_config));
2760 } 2128 }
2761 2129
2762 void RenderWidgetHostViewAura::HandleGestureForTouchSelection(
2763 ui::GestureEvent* event) {
2764 switch (event->type()) {
2765 case ui::ET_GESTURE_LONG_PRESS:
2766 if (selection_controller_->WillHandleLongPressEvent(
2767 event->time_stamp(), event->location_f())) {
2768 event->SetHandled();
2769 }
2770 break;
2771 case ui::ET_GESTURE_TAP:
2772 if (selection_controller_->WillHandleTapEvent(
2773 event->location_f(), event->details().tap_count())) {
2774 event->SetHandled();
2775 }
2776 break;
2777 case ui::ET_GESTURE_SCROLL_BEGIN:
2778 selection_controller_client_->OnScrollStarted();
2779 break;
2780 case ui::ET_GESTURE_SCROLL_END:
2781 selection_controller_client_->OnScrollCompleted();
2782 break;
2783 #if defined(OS_WIN)
2784 case ui::ET_GESTURE_LONG_TAP: {
2785 if (!last_context_menu_params_)
2786 break;
2787
2788 std::unique_ptr<ContextMenuParams> context_menu_params =
2789 std::move(last_context_menu_params_);
2790
2791 // On Windows we want to display the context menu when the long press
2792 // gesture is released. To achieve that, we switch the saved context
2793 // menu params source type to MENU_SOURCE_TOUCH. This is to ensure that
2794 // the RenderWidgetHostViewAura::OnShowContextMenu function which is
2795 // called from the ShowContextMenu call below, does not treat it as
2796 // a context menu request coming in from the long press gesture.
2797 DCHECK(context_menu_params->source_type == ui::MENU_SOURCE_LONG_PRESS);
2798 context_menu_params->source_type = ui::MENU_SOURCE_TOUCH;
2799
2800 RenderViewHostDelegateView* delegate_view =
2801 GetRenderViewHostDelegateView();
2802 if (delegate_view)
2803 delegate_view->ShowContextMenu(GetFocusedFrame(),
2804 *context_menu_params);
2805
2806 event->SetHandled();
2807 // WARNING: we may have been deleted during the call to ShowContextMenu().
2808 break;
2809 }
2810 #endif
2811 default:
2812 break;
2813 }
2814 }
2815
2816 void RenderWidgetHostViewAura::ForwardMouseEventToParent(
2817 ui::MouseEvent* event) {
2818 // Needed to propagate mouse event to |window_->parent()->delegate()|, but
2819 // note that it might be something other than a WebContentsViewAura instance.
2820 // TODO(pkotwicz): Find a better way of doing this.
2821 // In fullscreen mode which is typically used by flash, don't forward
2822 // the mouse events to the parent. The renderer and the plugin process
2823 // handle these events.
2824 if (is_fullscreen_)
2825 return;
2826
2827 if (event->flags() & ui::EF_FROM_TOUCH)
2828 return;
2829
2830 if (!window_->parent() || !window_->parent()->delegate())
2831 return;
2832
2833 // Take a copy of |event|, to avoid ConvertLocationToTarget mutating the
2834 // event.
2835 std::unique_ptr<ui::Event> event_copy = ui::Event::Clone(*event);
2836 ui::MouseEvent* mouse_event = static_cast<ui::MouseEvent*>(event_copy.get());
2837 mouse_event->ConvertLocationToTarget(window_, window_->parent());
2838 window_->parent()->delegate()->OnMouseEvent(mouse_event);
2839 if (mouse_event->handled())
2840 event->SetHandled();
2841 }
2842
2843 RenderViewHostDelegateView*
2844 RenderWidgetHostViewAura::GetRenderViewHostDelegateView() {
2845 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will
2846 // actually show the disambiguation popup.
2847 RenderViewHost* rvh = RenderViewHost::From(host_);
2848 if (!rvh)
2849 return nullptr;
2850
2851 RenderViewHostDelegate* delegate = rvh->GetDelegate();
2852 if (!delegate)
2853 return nullptr;
2854
2855 return delegate->GetDelegateView();
2856 }
2857
2858 //////////////////////////////////////////////////////////////////////////////// 2130 ////////////////////////////////////////////////////////////////////////////////
2859 // DelegatedFrameHost, public: 2131 // DelegatedFrameHost, public:
2860 2132
2861 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { 2133 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const {
2862 return window_->layer(); 2134 return window_->layer();
2863 } 2135 }
2864 2136
2865 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { 2137 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const {
2866 return !host_->is_hidden(); 2138 return !host_->is_hidden();
2867 } 2139 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 if (GetTextInputManager() 2309 if (GetTextInputManager()
3038 ->GetTextSelection(focused_view) 2310 ->GetTextSelection(focused_view)
3039 ->GetSelectedText(&selected_text)) { 2311 ->GetSelectedText(&selected_text)) {
3040 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 2312 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3041 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 2313 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3042 clipboard_writer.WriteText(selected_text); 2314 clipboard_writer.WriteText(selected_text);
3043 } 2315 }
3044 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 2316 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3045 } 2317 }
3046 2318
2319 void RenderWidgetHostViewAura::SetPopupChildHostView(
2320 RenderWidgetHostViewAura* popup_child_host_view) {
2321 popup_child_host_view_ = popup_child_host_view;
2322 event_handler_->SetPopupChildHostView(popup_child_host_view);
2323 }
2324
3047 } // namespace content 2325 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698