OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "cc/resources/texture_mailbox.h" | 23 #include "cc/resources/texture_mailbox.h" |
24 #include "cc/trees/layer_tree_settings.h" | 24 #include "cc/trees/layer_tree_settings.h" |
25 #include "components/display_compositor/gl_helper.h" | 25 #include "components/display_compositor/gl_helper.h" |
26 #include "content/browser/accessibility/browser_accessibility_manager.h" | 26 #include "content/browser/accessibility/browser_accessibility_manager.h" |
27 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 27 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
28 #include "content/browser/bad_message.h" | 28 #include "content/browser/bad_message.h" |
29 #include "content/browser/frame_host/frame_tree.h" | 29 #include "content/browser/frame_host/frame_tree.h" |
30 #include "content/browser/frame_host/frame_tree_node.h" | 30 #include "content/browser/frame_host/frame_tree_node.h" |
31 #include "content/browser/frame_host/render_frame_host_impl.h" | 31 #include "content/browser/frame_host/render_frame_host_impl.h" |
32 #include "content/browser/gpu/compositor_util.h" | 32 #include "content/browser/gpu/compositor_util.h" |
33 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" | 33 #include "content/browser/renderer_host/delegated_frame_host_client_aura.h" |
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/render_widget_host_view_event_handler.h" |
45 #include "content/browser/renderer_host/ui_events_helper.h" | 45 #include "content/browser/renderer_host/ui_events_helper.h" |
46 #include "content/common/content_switches_internal.h" | 46 #include "content/common/content_switches_internal.h" |
47 #include "content/common/input_messages.h" | 47 #include "content/common/input_messages.h" |
| 48 #include "content/common/render_widget_window_tree_client_factory.mojom.h" |
48 #include "content/common/site_isolation_policy.h" | 49 #include "content/common/site_isolation_policy.h" |
49 #include "content/common/text_input_state.h" | 50 #include "content/common/text_input_state.h" |
50 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
51 #include "content/public/browser/content_browser_client.h" | 52 #include "content/public/browser/content_browser_client.h" |
52 #include "content/public/browser/overscroll_configuration.h" | 53 #include "content/public/browser/overscroll_configuration.h" |
53 #include "content/public/browser/render_view_host.h" | 54 #include "content/public/browser/render_view_host.h" |
54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" | 55 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
55 #include "content/public/browser/user_metrics.h" | 56 #include "content/public/browser/user_metrics.h" |
56 #include "content/public/common/child_process_host.h" | 57 #include "content/public/common/child_process_host.h" |
57 #include "content/public/common/content_switches.h" | 58 #include "content/public/common/content_switches.h" |
58 #include "gpu/ipc/common/gpu_messages.h" | 59 #include "gpu/ipc/common/gpu_messages.h" |
| 60 #include "services/service_manager/public/cpp/interface_provider.h" |
| 61 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" |
59 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 62 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
60 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 63 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
61 #include "ui/aura/client/aura_constants.h" | 64 #include "ui/aura/client/aura_constants.h" |
62 #include "ui/aura/client/cursor_client.h" | 65 #include "ui/aura/client/cursor_client.h" |
63 #include "ui/aura/client/cursor_client_observer.h" | 66 #include "ui/aura/client/cursor_client_observer.h" |
64 #include "ui/aura/client/focus_client.h" | 67 #include "ui/aura/client/focus_client.h" |
65 #include "ui/aura/client/screen_position_client.h" | 68 #include "ui/aura/client/screen_position_client.h" |
66 #include "ui/aura/client/transient_window_client.h" | 69 #include "ui/aura/client/transient_window_client.h" |
67 #include "ui/aura/client/window_parenting_client.h" | 70 #include "ui/aura/client/window_parenting_client.h" |
68 #include "ui/aura/env.h" | 71 #include "ui/aura/env.h" |
| 72 #include "ui/aura/mus/window_port_mus.h" |
69 #include "ui/aura/window.h" | 73 #include "ui/aura/window.h" |
70 #include "ui/aura/window_event_dispatcher.h" | 74 #include "ui/aura/window_event_dispatcher.h" |
71 #include "ui/aura/window_observer.h" | 75 #include "ui/aura/window_observer.h" |
72 #include "ui/aura/window_tree_host.h" | 76 #include "ui/aura/window_tree_host.h" |
73 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 77 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
74 #include "ui/base/hit_test.h" | 78 #include "ui/base/hit_test.h" |
75 #include "ui/base/ime/input_method.h" | 79 #include "ui/base/ime/input_method.h" |
76 #include "ui/base/ui_base_types.h" | 80 #include "ui/base/ui_base_types.h" |
77 #include "ui/compositor/compositor_vsync_manager.h" | 81 #include "ui/compositor/compositor_vsync_manager.h" |
78 #include "ui/compositor/dip_util.h" | 82 #include "ui/compositor/dip_util.h" |
79 #include "ui/display/display.h" | 83 #include "ui/display/display.h" |
80 #include "ui/display/screen.h" | 84 #include "ui/display/screen.h" |
81 #include "ui/events/blink/blink_event_util.h" | 85 #include "ui/events/blink/blink_event_util.h" |
82 #include "ui/events/blink/web_input_event.h" | 86 #include "ui/events/blink/web_input_event.h" |
83 #include "ui/events/event.h" | 87 #include "ui/events/event.h" |
84 #include "ui/events/event_utils.h" | 88 #include "ui/events/event_utils.h" |
85 #include "ui/events/gesture_detection/gesture_configuration.h" | 89 #include "ui/events/gesture_detection/gesture_configuration.h" |
86 #include "ui/events/gestures/gesture_recognizer.h" | 90 #include "ui/events/gestures/gesture_recognizer.h" |
87 #include "ui/gfx/canvas.h" | 91 #include "ui/gfx/canvas.h" |
88 #include "ui/gfx/geometry/dip_util.h" | 92 #include "ui/gfx/geometry/dip_util.h" |
89 #include "ui/gfx/geometry/rect_conversions.h" | 93 #include "ui/gfx/geometry/rect_conversions.h" |
90 #include "ui/gfx/geometry/size_conversions.h" | 94 #include "ui/gfx/geometry/size_conversions.h" |
91 #include "ui/gfx/skia_util.h" | 95 #include "ui/gfx/skia_util.h" |
92 #include "ui/touch_selection/touch_selection_controller.h" | 96 #include "ui/touch_selection/touch_selection_controller.h" |
93 #include "ui/wm/public/activation_client.h" | 97 #include "ui/wm/public/activation_client.h" |
94 #include "ui/wm/public/scoped_tooltip_disabler.h" | 98 #include "ui/wm/public/scoped_tooltip_disabler.h" |
95 #include "ui/wm/public/tooltip_client.h" | 99 #include "ui/wm/public/tooltip_client.h" |
96 #include "ui/wm/public/window_types.h" | |
97 | 100 |
98 #if defined(OS_WIN) | 101 #if defined(OS_WIN) |
99 #include "base/time/time.h" | 102 #include "base/time/time.h" |
100 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 103 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
101 #include "content/browser/accessibility/browser_accessibility_win.h" | 104 #include "content/browser/accessibility/browser_accessibility_win.h" |
102 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" | 105 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
103 #include "ui/base/win/hidden_window.h" | 106 #include "ui/base/win/hidden_window.h" |
104 #include "ui/base/win/osk_display_manager.h" | 107 #include "ui/base/win/osk_display_manager.h" |
105 #include "ui/base/win/osk_display_observer.h" | 108 #include "ui/base/win/osk_display_observer.h" |
106 #include "ui/display/win/screen_win.h" | 109 #include "ui/display/win/screen_win.h" |
107 #include "ui/gfx/gdi_util.h" | 110 #include "ui/gfx/gdi_util.h" |
108 #endif | 111 #endif |
109 | 112 |
110 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 113 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
111 #include "ui/base/ime/linux/text_edit_command_auralinux.h" | 114 #include "ui/base/ime/linux/text_edit_command_auralinux.h" |
112 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" | 115 #include "ui/base/ime/linux/text_edit_key_bindings_delegate_auralinux.h" |
113 #endif | 116 #endif |
114 | 117 |
115 using gfx::RectToSkIRect; | 118 using gfx::RectToSkIRect; |
116 using gfx::SkIRectToRect; | 119 using gfx::SkIRectToRect; |
117 | 120 |
118 using blink::WebInputEvent; | 121 using blink::WebInputEvent; |
119 using blink::WebGestureEvent; | 122 using blink::WebGestureEvent; |
120 using blink::WebTouchEvent; | 123 using blink::WebTouchEvent; |
121 | 124 |
122 namespace content { | 125 namespace content { |
123 | 126 |
124 namespace { | 127 namespace { |
125 | 128 |
126 // When accelerated compositing is enabled and a widget resize is pending, | |
127 // we delay further resizes of the UI. The following constant is the maximum | |
128 // length of time that we should delay further UI resizes while waiting for a | |
129 // resized frame from a renderer. | |
130 const int kResizeLockTimeoutMs = 67; | |
131 | |
132 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
133 | 130 |
134 // This class implements the ui::OnScreenKeyboardObserver interface | 131 // This class implements the ui::OnScreenKeyboardObserver interface |
135 // which provides notifications about the on screen keyboard on Windows getting | 132 // which provides notifications about the on screen keyboard on Windows getting |
136 // displayed or hidden in response to taps on editable fields. | 133 // displayed or hidden in response to taps on editable fields. |
137 // It provides functionality to request blink to scroll the input field if it | 134 // It provides functionality to request blink to scroll the input field if it |
138 // is obscured by the on screen keyboard. | 135 // is obscured by the on screen keyboard. |
139 class WinScreenKeyboardObserver : public ui::OnScreenKeyboardObserver { | 136 class WinScreenKeyboardObserver : public ui::OnScreenKeyboardObserver { |
140 public: | 137 public: |
141 WinScreenKeyboardObserver(RenderWidgetHostImpl* host, | 138 WinScreenKeyboardObserver(RenderWidgetHostImpl* host, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // The current device scale factor. | 201 // The current device scale factor. |
205 float device_scale_factor_; | 202 float device_scale_factor_; |
206 | 203 |
207 // The content Window. | 204 // The content Window. |
208 aura::Window* window_; | 205 aura::Window* window_; |
209 | 206 |
210 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver); | 207 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver); |
211 }; | 208 }; |
212 #endif // defined(OS_WIN) | 209 #endif // defined(OS_WIN) |
213 | 210 |
| 211 // Callback from embedding the renderer. |
| 212 void EmbedCallback(bool result) { |
| 213 if (!result) |
| 214 DVLOG(1) << "embed failed"; |
| 215 } |
| 216 |
214 } // namespace | 217 } // namespace |
215 | 218 |
216 // We need to watch for mouse events outside a Web Popup or its parent | 219 // We need to watch for mouse events outside a Web Popup or its parent |
217 // and dismiss the popup for certain events. | 220 // and dismiss the popup for certain events. |
218 class RenderWidgetHostViewAura::EventFilterForPopupExit | 221 class RenderWidgetHostViewAura::EventFilterForPopupExit |
219 : public ui::EventHandler { | 222 : public ui::EventHandler { |
220 public: | 223 public: |
221 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 224 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
222 : rwhva_(rwhva) { | 225 : rwhva_(rwhva) { |
223 DCHECK(rwhva_); | 226 DCHECK(rwhva_); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 ancestor->RemoveObserver(this); | 352 ancestor->RemoveObserver(this); |
350 ancestors_.clear(); | 353 ancestors_.clear(); |
351 } | 354 } |
352 | 355 |
353 RenderWidgetHostViewAura* view_; | 356 RenderWidgetHostViewAura* view_; |
354 std::set<aura::Window*> ancestors_; | 357 std::set<aura::Window*> ancestors_; |
355 | 358 |
356 DISALLOW_COPY_AND_ASSIGN(WindowAncestorObserver); | 359 DISALLOW_COPY_AND_ASSIGN(WindowAncestorObserver); |
357 }; | 360 }; |
358 | 361 |
| 362 bool IsMus() { |
| 363 return aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS && |
| 364 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 365 switches::kUseMusInRenderer); |
| 366 } |
| 367 |
359 //////////////////////////////////////////////////////////////////////////////// | 368 //////////////////////////////////////////////////////////////////////////////// |
360 // RenderWidgetHostViewAura, public: | 369 // RenderWidgetHostViewAura, public: |
361 | 370 |
362 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, | 371 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, |
363 bool is_guest_view_hack) | 372 bool is_guest_view_hack) |
364 : host_(RenderWidgetHostImpl::From(host)), | 373 : host_(RenderWidgetHostImpl::From(host)), |
365 window_(nullptr), | 374 window_(nullptr), |
366 in_shutdown_(false), | 375 in_shutdown_(false), |
367 in_bounds_changed_(false), | 376 in_bounds_changed_(false), |
368 popup_parent_host_view_(nullptr), | 377 popup_parent_host_view_(nullptr), |
(...skipping 10 matching lines...) Expand all Loading... |
379 legacy_window_destroyed_(false), | 388 legacy_window_destroyed_(false), |
380 virtual_keyboard_requested_(false), | 389 virtual_keyboard_requested_(false), |
381 #endif | 390 #endif |
382 has_snapped_to_boundary_(false), | 391 has_snapped_to_boundary_(false), |
383 is_guest_view_hack_(is_guest_view_hack), | 392 is_guest_view_hack_(is_guest_view_hack), |
384 device_scale_factor_(0.0f), | 393 device_scale_factor_(0.0f), |
385 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), | 394 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), |
386 last_active_widget_routing_id_(MSG_ROUTING_NONE), | 395 last_active_widget_routing_id_(MSG_ROUTING_NONE), |
387 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), | 396 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), |
388 weak_ptr_factory_(this) { | 397 weak_ptr_factory_(this) { |
389 // GuestViews have two RenderWidgetHostViews and so we need to make sure | |
390 // we don't have FrameSinkId collisions. | |
391 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | |
392 cc::FrameSinkId frame_sink_id = | |
393 is_guest_view_hack_ | |
394 ? factory->GetContextFactoryPrivate()->AllocateFrameSinkId() | |
395 : cc::FrameSinkId( | |
396 base::checked_cast<uint32_t>(host_->GetProcess()->GetID()), | |
397 base::checked_cast<uint32_t>(host_->GetRoutingID())); | |
398 delegated_frame_host_ = | |
399 base::MakeUnique<DelegatedFrameHost>(frame_sink_id, this); | |
400 | |
401 if (!is_guest_view_hack_) | 398 if (!is_guest_view_hack_) |
402 host_->SetView(this); | 399 host_->SetView(this); |
403 | 400 |
404 // Let the page-level input event router know about our surface ID | |
405 // namespace for surface-based hit testing. | |
406 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { | |
407 host_->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner( | |
408 GetFrameSinkId(), this); | |
409 } | |
410 | |
411 // We should start observing the TextInputManager for IME-related events as | 401 // We should start observing the TextInputManager for IME-related events as |
412 // well as monitoring its lifetime. | 402 // well as monitoring its lifetime. |
413 if (GetTextInputManager()) | 403 if (GetTextInputManager()) |
414 GetTextInputManager()->AddObserver(this); | 404 GetTextInputManager()->AddObserver(this); |
415 | 405 |
416 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> | 406 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> |
417 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; | 407 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; |
418 SetOverscrollControllerEnabled(overscroll_enabled); | 408 SetOverscrollControllerEnabled(overscroll_enabled); |
419 | 409 |
420 selection_controller_client_.reset( | 410 selection_controller_client_.reset( |
421 new TouchSelectionControllerClientAura(this)); | 411 new TouchSelectionControllerClientAura(this)); |
422 CreateSelectionController(); | 412 CreateSelectionController(); |
423 | 413 |
424 RenderViewHost* rvh = RenderViewHost::From(host_); | 414 RenderViewHost* rvh = RenderViewHost::From(host_); |
425 if (rvh) { | 415 if (rvh) { |
426 // TODO(mostynb): actually use prefs. Landing this as a separate CL | 416 // TODO(mostynb): actually use prefs. Landing this as a separate CL |
427 // first to rebaseline some unreliable layout tests. | 417 // first to rebaseline some unreliable layout tests. |
428 ignore_result(rvh->GetWebkitPreferences()); | 418 ignore_result(rvh->GetWebkitPreferences()); |
429 } | 419 } |
430 } | 420 } |
431 | 421 |
432 //////////////////////////////////////////////////////////////////////////////// | 422 //////////////////////////////////////////////////////////////////////////////// |
433 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 423 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
434 | 424 |
435 void RenderWidgetHostViewAura::InitAsChild( | 425 void RenderWidgetHostViewAura::InitAsChild( |
436 gfx::NativeView parent_view) { | 426 gfx::NativeView parent_view) { |
437 CreateAuraWindow(); | 427 CreateDelegatedFrameHostClient(); |
438 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL); | 428 |
439 window_->Init(ui::LAYER_SOLID_COLOR); | 429 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL); |
440 window_->SetName("RenderWidgetHostViewAura"); | |
441 window_->layer()->SetColor(background_color_); | |
442 | 430 |
443 if (parent_view) | 431 if (parent_view) |
444 parent_view->AddChild(GetNativeView()); | 432 parent_view->AddChild(GetNativeView()); |
445 | 433 |
446 const display::Display display = | 434 const display::Display display = |
447 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 435 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
448 device_scale_factor_ = display.device_scale_factor(); | 436 device_scale_factor_ = display.device_scale_factor(); |
449 } | 437 } |
450 | 438 |
451 void RenderWidgetHostViewAura::InitAsPopup( | 439 void RenderWidgetHostViewAura::InitAsPopup( |
452 RenderWidgetHostView* parent_host_view, | 440 RenderWidgetHostView* parent_host_view, |
453 const gfx::Rect& bounds_in_screen) { | 441 const gfx::Rect& bounds_in_screen) { |
454 CreateAuraWindow(); | 442 CreateDelegatedFrameHostClient(); |
| 443 |
455 popup_parent_host_view_ = | 444 popup_parent_host_view_ = |
456 static_cast<RenderWidgetHostViewAura*>(parent_host_view); | 445 static_cast<RenderWidgetHostViewAura*>(parent_host_view); |
457 | 446 |
458 // TransientWindowClient may be NULL during tests. | 447 // TransientWindowClient may be NULL during tests. |
459 aura::client::TransientWindowClient* transient_window_client = | 448 aura::client::TransientWindowClient* transient_window_client = |
460 aura::client::GetTransientWindowClient(); | 449 aura::client::GetTransientWindowClient(); |
461 RenderWidgetHostViewAura* old_child = | 450 RenderWidgetHostViewAura* old_child = |
462 popup_parent_host_view_->popup_child_host_view_; | 451 popup_parent_host_view_->popup_child_host_view_; |
463 if (old_child) { | 452 if (old_child) { |
464 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or | 453 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or |
465 // similar mechanism to ensure a second popup doesn't cause the first one | 454 // similar mechanism to ensure a second popup doesn't cause the first one |
466 // to never get a chance to filter events. See crbug.com/160589. | 455 // to never get a chance to filter events. See crbug.com/160589. |
467 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); | 456 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); |
468 if (transient_window_client) { | 457 if (transient_window_client) { |
469 transient_window_client->RemoveTransientChild( | 458 transient_window_client->RemoveTransientChild( |
470 popup_parent_host_view_->window_, old_child->window_); | 459 popup_parent_host_view_->window_, old_child->window_); |
471 } | 460 } |
472 old_child->popup_parent_host_view_ = NULL; | 461 old_child->popup_parent_host_view_ = NULL; |
473 } | 462 } |
474 popup_parent_host_view_->SetPopupChild(this); | 463 popup_parent_host_view_->SetPopupChild(this); |
475 window_->SetType(ui::wm::WINDOW_TYPE_MENU); | 464 CreateAuraWindow(ui::wm::WINDOW_TYPE_MENU); |
476 window_->Init(ui::LAYER_SOLID_COLOR); | |
477 window_->SetName("RenderWidgetHostViewAura"); | |
478 window_->layer()->SetColor(background_color_); | |
479 | 465 |
480 // Setting the transient child allows for the popup to get mouse events when | 466 // Setting the transient child allows for the popup to get mouse events when |
481 // in a system modal dialog. Do this before calling ParentWindowWithContext | 467 // in a system modal dialog. Do this before calling ParentWindowWithContext |
482 // below so that the transient parent is visible to WindowTreeClient. | 468 // below so that the transient parent is visible to WindowTreeClient. |
483 // This fixes crbug.com/328593. | 469 // This fixes crbug.com/328593. |
484 if (transient_window_client) { | 470 if (transient_window_client) { |
485 transient_window_client->AddTransientChild( | 471 transient_window_client->AddTransientChild( |
486 popup_parent_host_view_->window_, window_); | 472 popup_parent_host_view_->window_, window_); |
487 } | 473 } |
488 | 474 |
489 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); | 475 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); |
490 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); | 476 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); |
491 | 477 |
492 SetBounds(bounds_in_screen); | 478 SetBounds(bounds_in_screen); |
493 Show(); | 479 Show(); |
494 if (NeedsMouseCapture()) | 480 if (NeedsMouseCapture()) |
495 window_->SetCapture(); | 481 window_->SetCapture(); |
496 | 482 |
497 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 483 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
498 | 484 |
499 const display::Display display = | 485 const display::Display display = |
500 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); | 486 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); |
501 device_scale_factor_ = display.device_scale_factor(); | 487 device_scale_factor_ = display.device_scale_factor(); |
502 } | 488 } |
503 | 489 |
504 void RenderWidgetHostViewAura::InitAsFullscreen( | 490 void RenderWidgetHostViewAura::InitAsFullscreen( |
505 RenderWidgetHostView* reference_host_view) { | 491 RenderWidgetHostView* reference_host_view) { |
506 CreateAuraWindow(); | |
507 is_fullscreen_ = true; | 492 is_fullscreen_ = true; |
508 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 493 CreateDelegatedFrameHostClient(); |
509 window_->Init(ui::LAYER_SOLID_COLOR); | 494 CreateAuraWindow(ui::wm::WINDOW_TYPE_NORMAL); |
510 window_->SetName("RenderWidgetHostViewAura"); | |
511 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 495 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
512 window_->layer()->SetColor(background_color_); | |
513 | 496 |
514 aura::Window* parent = NULL; | 497 aura::Window* parent = NULL; |
515 gfx::Rect bounds; | 498 gfx::Rect bounds; |
516 if (reference_host_view) { | 499 if (reference_host_view) { |
517 aura::Window* reference_window = | 500 aura::Window* reference_window = |
518 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; | 501 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; |
519 event_handler_->TrackHost(reference_window); | 502 event_handler_->TrackHost(reference_window); |
520 display::Display display = | 503 display::Display display = |
521 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); | 504 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); |
522 parent = reference_window->GetRootWindow(); | 505 parent = reference_window->GetRootWindow(); |
(...skipping 11 matching lines...) Expand all Loading... |
534 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { | 517 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { |
535 return host_; | 518 return host_; |
536 } | 519 } |
537 | 520 |
538 void RenderWidgetHostViewAura::Show() { | 521 void RenderWidgetHostViewAura::Show() { |
539 window_->Show(); | 522 window_->Show(); |
540 | 523 |
541 if (!host_->is_hidden()) | 524 if (!host_->is_hidden()) |
542 return; | 525 return; |
543 | 526 |
544 bool has_saved_frame = delegated_frame_host_->HasSavedFrame(); | 527 bool has_saved_frame = |
| 528 delegated_frame_host_ ? delegated_frame_host_->HasSavedFrame() : false; |
545 ui::LatencyInfo renderer_latency_info, browser_latency_info; | 529 ui::LatencyInfo renderer_latency_info, browser_latency_info; |
546 if (has_saved_frame) { | 530 if (has_saved_frame) { |
547 browser_latency_info.AddLatencyNumber( | 531 browser_latency_info.AddLatencyNumber( |
548 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); | 532 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); |
549 } else { | 533 } else { |
550 renderer_latency_info.AddLatencyNumber( | 534 renderer_latency_info.AddLatencyNumber( |
551 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); | 535 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); |
552 } | 536 } |
553 host_->WasShown(renderer_latency_info); | 537 host_->WasShown(renderer_latency_info); |
554 | 538 |
555 aura::Window* root = window_->GetRootWindow(); | 539 aura::Window* root = window_->GetRootWindow(); |
556 if (root) { | 540 if (root) { |
557 aura::client::CursorClient* cursor_client = | 541 aura::client::CursorClient* cursor_client = |
558 aura::client::GetCursorClient(root); | 542 aura::client::GetCursorClient(root); |
559 if (cursor_client) | 543 if (cursor_client) |
560 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 544 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
561 } | 545 } |
562 | 546 |
563 delegated_frame_host_->WasShown(browser_latency_info); | 547 if (delegated_frame_host_) |
| 548 delegated_frame_host_->WasShown(browser_latency_info); |
564 | 549 |
565 #if defined(OS_WIN) | 550 #if defined(OS_WIN) |
566 UpdateLegacyWin(); | 551 UpdateLegacyWin(); |
567 #endif | 552 #endif |
568 } | 553 } |
569 | 554 |
570 void RenderWidgetHostViewAura::Hide() { | 555 void RenderWidgetHostViewAura::Hide() { |
571 window_->Hide(); | 556 window_->Hide(); |
572 | 557 |
573 // TODO(wjmaclean): can host_ ever be null? | 558 // TODO(wjmaclean): can host_ ever be null? |
574 if (host_ && !host_->is_hidden()) { | 559 if (host_ && !host_->is_hidden()) { |
575 host_->WasHidden(); | 560 host_->WasHidden(); |
576 delegated_frame_host_->WasHidden(); | 561 if (delegated_frame_host_) |
| 562 delegated_frame_host_->WasHidden(); |
577 | 563 |
578 #if defined(OS_WIN) | 564 #if defined(OS_WIN) |
579 aura::WindowTreeHost* host = window_->GetHost(); | 565 aura::WindowTreeHost* host = window_->GetHost(); |
580 if (host) { | 566 if (host) { |
581 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global | 567 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global |
582 // hidden window on the same lines as Windowed plugin windows. | 568 // hidden window on the same lines as Windowed plugin windows. |
583 if (legacy_render_widget_host_HWND_) | 569 if (legacy_render_widget_host_HWND_) |
584 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); | 570 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); |
585 } | 571 } |
586 #endif | 572 #endif |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); | 723 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); |
738 if (client) | 724 if (client) |
739 window_->Focus(); | 725 window_->Focus(); |
740 } | 726 } |
741 | 727 |
742 bool RenderWidgetHostViewAura::HasFocus() const { | 728 bool RenderWidgetHostViewAura::HasFocus() const { |
743 return window_->HasFocus(); | 729 return window_->HasFocus(); |
744 } | 730 } |
745 | 731 |
746 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { | 732 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { |
747 return delegated_frame_host_->CanCopyToBitmap(); | 733 return delegated_frame_host_ ? delegated_frame_host_->CanCopyToBitmap() |
| 734 : false; |
748 } | 735 } |
749 | 736 |
750 bool RenderWidgetHostViewAura::IsShowing() { | 737 bool RenderWidgetHostViewAura::IsShowing() { |
751 return window_->IsVisible(); | 738 return window_->IsVisible(); |
752 } | 739 } |
753 | 740 |
754 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { | 741 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { |
755 return window_->GetBoundsInScreen(); | 742 return window_->GetBoundsInScreen(); |
756 } | 743 } |
757 | 744 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 aura::client::TooltipClient* tooltip_client = | 831 aura::client::TooltipClient* tooltip_client = |
845 aura::client::GetTooltipClient(root_window); | 832 aura::client::GetTooltipClient(root_window); |
846 if (tooltip_client) { | 833 if (tooltip_client) { |
847 tooltip_client->UpdateTooltip(window_); | 834 tooltip_client->UpdateTooltip(window_); |
848 // Content tooltips should be visible indefinitely. | 835 // Content tooltips should be visible indefinitely. |
849 tooltip_client->SetTooltipShownTimeout(window_, 0); | 836 tooltip_client->SetTooltipShownTimeout(window_, 0); |
850 } | 837 } |
851 } | 838 } |
852 | 839 |
853 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { | 840 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { |
854 return delegated_frame_host_->GetRequestedRendererSize(); | 841 return delegated_frame_host_ |
| 842 ? delegated_frame_host_->GetRequestedRendererSize() |
| 843 : RenderWidgetHostViewBase::GetRequestedRendererSize(); |
855 } | 844 } |
856 | 845 |
857 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 846 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
858 const gfx::Rect& src_subrect, | 847 const gfx::Rect& src_subrect, |
859 const gfx::Size& dst_size, | 848 const gfx::Size& dst_size, |
860 const ReadbackRequestCallback& callback, | 849 const ReadbackRequestCallback& callback, |
861 const SkColorType preferred_color_type) { | 850 const SkColorType preferred_color_type) { |
| 851 if (!delegated_frame_host_) |
| 852 return; |
862 delegated_frame_host_->CopyFromCompositingSurface( | 853 delegated_frame_host_->CopyFromCompositingSurface( |
863 src_subrect, dst_size, callback, preferred_color_type); | 854 src_subrect, dst_size, callback, preferred_color_type); |
864 } | 855 } |
865 | 856 |
866 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( | 857 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( |
867 const gfx::Rect& src_subrect, | 858 const gfx::Rect& src_subrect, |
868 const scoped_refptr<media::VideoFrame>& target, | 859 const scoped_refptr<media::VideoFrame>& target, |
869 const base::Callback<void(const gfx::Rect&, bool)>& callback) { | 860 const base::Callback<void(const gfx::Rect&, bool)>& callback) { |
| 861 if (!delegated_frame_host_) |
| 862 return; |
870 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame( | 863 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame( |
871 src_subrect, target, callback); | 864 src_subrect, target, callback); |
872 } | 865 } |
873 | 866 |
874 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { | 867 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { |
875 return delegated_frame_host_->CanCopyToVideoFrame(); | 868 return delegated_frame_host_ ? delegated_frame_host_->CanCopyToVideoFrame() |
| 869 : false; |
876 } | 870 } |
877 | 871 |
878 void RenderWidgetHostViewAura::BeginFrameSubscription( | 872 void RenderWidgetHostViewAura::BeginFrameSubscription( |
879 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { | 873 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { |
880 delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); | 874 if (delegated_frame_host_) |
| 875 delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); |
881 } | 876 } |
882 | 877 |
883 void RenderWidgetHostViewAura::EndFrameSubscription() { | 878 void RenderWidgetHostViewAura::EndFrameSubscription() { |
884 delegated_frame_host_->EndFrameSubscription(); | 879 if (delegated_frame_host_) |
| 880 delegated_frame_host_->EndFrameSubscription(); |
885 } | 881 } |
886 | 882 |
887 #if defined(OS_WIN) | 883 #if defined(OS_WIN) |
888 bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const { | 884 bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const { |
889 return (legacy_render_widget_host_HWND_ != NULL); | 885 return (legacy_render_widget_host_HWND_ != NULL); |
890 } | 886 } |
891 | 887 |
892 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { | 888 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { |
893 RECT window_rect = | 889 RECT window_rect = |
894 display::Screen::GetScreen() | 890 display::Screen::GetScreen() |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 | 924 |
929 start_edge_top.Scale(viewportToDIPScale); | 925 start_edge_top.Scale(viewportToDIPScale); |
930 start_edge_bottom.Scale(viewportToDIPScale); | 926 start_edge_bottom.Scale(viewportToDIPScale); |
931 end_edge_top.Scale(viewportToDIPScale); | 927 end_edge_top.Scale(viewportToDIPScale); |
932 end_edge_bottom.Scale(viewportToDIPScale); | 928 end_edge_bottom.Scale(viewportToDIPScale); |
933 | 929 |
934 selection.start.SetEdge(start_edge_top, start_edge_bottom); | 930 selection.start.SetEdge(start_edge_top, start_edge_bottom); |
935 selection.end.SetEdge(end_edge_top, end_edge_bottom); | 931 selection.end.SetEdge(end_edge_top, end_edge_bottom); |
936 } | 932 } |
937 | 933 |
938 delegated_frame_host_->SwapDelegatedFrame(compositor_frame_sink_id, | 934 if (delegated_frame_host_) { |
939 std::move(frame)); | 935 delegated_frame_host_->SwapDelegatedFrame(compositor_frame_sink_id, |
| 936 std::move(frame)); |
| 937 } |
940 SelectionUpdated(selection.is_editable, selection.is_empty_text_form_control, | 938 SelectionUpdated(selection.is_editable, selection.is_empty_text_form_control, |
941 selection.start, selection.end); | 939 selection.start, selection.end); |
942 } | 940 } |
943 | 941 |
944 void RenderWidgetHostViewAura::ClearCompositorFrame() { | 942 void RenderWidgetHostViewAura::ClearCompositorFrame() { |
945 delegated_frame_host_->ClearDelegatedFrame(); | 943 if (delegated_frame_host_) |
| 944 delegated_frame_host_->ClearDelegatedFrame(); |
946 } | 945 } |
947 | 946 |
948 void RenderWidgetHostViewAura::DidStopFlinging() { | 947 void RenderWidgetHostViewAura::DidStopFlinging() { |
949 selection_controller_client_->OnScrollCompleted(); | 948 selection_controller_client_->OnScrollCompleted(); |
950 } | 949 } |
951 | 950 |
952 bool RenderWidgetHostViewAura::HasAcceleratedSurface( | 951 bool RenderWidgetHostViewAura::HasAcceleratedSurface( |
953 const gfx::Size& desired_size) { | 952 const gfx::Size& desired_size) { |
954 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't | 953 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't |
955 // matter what is returned here as GetBackingStore is the only caller of this | 954 // matter what is returned here as GetBackingStore is the only caller of this |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 cc::FrameSinkId RenderWidgetHostViewAura::FrameSinkIdAtPoint( | 1593 cc::FrameSinkId RenderWidgetHostViewAura::FrameSinkIdAtPoint( |
1595 cc::SurfaceHittestDelegate* delegate, | 1594 cc::SurfaceHittestDelegate* delegate, |
1596 const gfx::Point& point, | 1595 const gfx::Point& point, |
1597 gfx::Point* transformed_point) { | 1596 gfx::Point* transformed_point) { |
1598 DCHECK(device_scale_factor_ != 0.0f); | 1597 DCHECK(device_scale_factor_ != 0.0f); |
1599 | 1598 |
1600 // The surface hittest happens in device pixels, so we need to convert the | 1599 // The surface hittest happens in device pixels, so we need to convert the |
1601 // |point| from DIPs to pixels before hittesting. | 1600 // |point| from DIPs to pixels before hittesting. |
1602 gfx::Point point_in_pixels = | 1601 gfx::Point point_in_pixels = |
1603 gfx::ConvertPointToPixel(device_scale_factor_, point); | 1602 gfx::ConvertPointToPixel(device_scale_factor_, point); |
1604 cc::SurfaceId id = delegated_frame_host_->SurfaceIdAtPoint( | 1603 // TODO: this shouldn't be used with aura-mus, so that the null check so |
1605 delegate, point_in_pixels, transformed_point); | 1604 // go away and become a DCHECK. |
| 1605 cc::SurfaceId id = delegated_frame_host_ |
| 1606 ? delegated_frame_host_->SurfaceIdAtPoint( |
| 1607 delegate, point_in_pixels, transformed_point) |
| 1608 : cc::SurfaceId(); |
1606 *transformed_point = | 1609 *transformed_point = |
1607 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); | 1610 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); |
1608 | 1611 |
1609 // It is possible that the renderer has not yet produced a surface, in which | 1612 // It is possible that the renderer has not yet produced a surface, in which |
1610 // case we return our current namespace. | 1613 // case we return our current namespace. |
1611 if (!id.is_valid()) | 1614 if (!id.is_valid()) |
1612 return GetFrameSinkId(); | 1615 return GetFrameSinkId(); |
1613 return id.frame_sink_id(); | 1616 return id.frame_sink_id(); |
1614 } | 1617 } |
1615 | 1618 |
(...skipping 22 matching lines...) Expand all Loading... |
1638 } | 1641 } |
1639 | 1642 |
1640 bool RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( | 1643 bool RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( |
1641 const gfx::Point& point, | 1644 const gfx::Point& point, |
1642 const cc::SurfaceId& original_surface, | 1645 const cc::SurfaceId& original_surface, |
1643 gfx::Point* transformed_point) { | 1646 gfx::Point* transformed_point) { |
1644 // Transformations use physical pixels rather than DIP, so conversion | 1647 // Transformations use physical pixels rather than DIP, so conversion |
1645 // is necessary. | 1648 // is necessary. |
1646 gfx::Point point_in_pixels = | 1649 gfx::Point point_in_pixels = |
1647 gfx::ConvertPointToPixel(device_scale_factor_, point); | 1650 gfx::ConvertPointToPixel(device_scale_factor_, point); |
1648 if (!delegated_frame_host_->TransformPointToLocalCoordSpace( | 1651 // TODO: this shouldn't be used with aura-mus, so that the null check so |
| 1652 // go away and become a DCHECK. |
| 1653 if (delegated_frame_host_ && |
| 1654 !delegated_frame_host_->TransformPointToLocalCoordSpace( |
1649 point_in_pixels, original_surface, transformed_point)) | 1655 point_in_pixels, original_surface, transformed_point)) |
1650 return false; | 1656 return false; |
1651 *transformed_point = | 1657 *transformed_point = |
1652 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); | 1658 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); |
1653 return true; | 1659 return true; |
1654 } | 1660 } |
1655 | 1661 |
1656 bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView( | 1662 bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView( |
1657 const gfx::Point& point, | 1663 const gfx::Point& point, |
1658 RenderWidgetHostViewBase* target_view, | 1664 RenderWidgetHostViewBase* target_view, |
1659 gfx::Point* transformed_point) { | 1665 gfx::Point* transformed_point) { |
1660 if (target_view == this) { | 1666 if (target_view == this || !delegated_frame_host_) { |
1661 *transformed_point = point; | 1667 *transformed_point = point; |
1662 return true; | 1668 return true; |
1663 } | 1669 } |
1664 | 1670 |
1665 // In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion, | 1671 // In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion, |
1666 // but it is not necessary here because the final target view is responsible | 1672 // but it is not necessary here because the final target view is responsible |
1667 // for converting before computing the final transform. | 1673 // for converting before computing the final transform. |
1668 return delegated_frame_host_->TransformPointToCoordSpaceForView( | 1674 return delegated_frame_host_->TransformPointToCoordSpaceForView( |
1669 point, target_view, transformed_point); | 1675 point, target_view, transformed_point); |
1670 } | 1676 } |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1858 DCHECK(osk_display_manager); | 1864 DCHECK(osk_display_manager); |
1859 osk_display_manager->RemoveObserver(keyboard_observer_.get()); | 1865 osk_display_manager->RemoveObserver(keyboard_observer_.get()); |
1860 } | 1866 } |
1861 | 1867 |
1862 #endif | 1868 #endif |
1863 | 1869 |
1864 if (text_input_manager_) | 1870 if (text_input_manager_) |
1865 text_input_manager_->RemoveObserver(this); | 1871 text_input_manager_->RemoveObserver(this); |
1866 } | 1872 } |
1867 | 1873 |
1868 void RenderWidgetHostViewAura::CreateAuraWindow() { | 1874 void RenderWidgetHostViewAura::CreateAuraWindow(ui::wm::WindowType type) { |
1869 DCHECK(!window_); | 1875 DCHECK(!window_); |
1870 window_ = new aura::Window(this); | 1876 window_ = new aura::Window(this); |
| 1877 window_->SetName("RenderWidgetHostViewAura"); |
1871 event_handler_->set_window(window_); | 1878 event_handler_->set_window(window_); |
1872 window_observer_.reset(new WindowObserver(this)); | 1879 window_observer_.reset(new WindowObserver(this)); |
1873 | 1880 |
1874 aura::client::SetTooltipText(window_, &tooltip_); | 1881 aura::client::SetTooltipText(window_, &tooltip_); |
1875 aura::client::SetActivationDelegate(window_, this); | 1882 aura::client::SetActivationDelegate(window_, this); |
1876 aura::client::SetFocusChangeObserver(window_, this); | 1883 aura::client::SetFocusChangeObserver(window_, this); |
1877 display::Screen::GetScreen()->AddObserver(this); | 1884 display::Screen::GetScreen()->AddObserver(this); |
| 1885 |
| 1886 window_->SetType(type); |
| 1887 window_->Init(ui::LAYER_SOLID_COLOR); |
| 1888 window_->layer()->SetColor(background_color_); |
| 1889 |
| 1890 if (!IsMus()) |
| 1891 return; |
| 1892 |
| 1893 // Connect to the renderer, pass it a WindowTreeClient interface request |
| 1894 // and embed that client inside our mus window. |
| 1895 mojom::RenderWidgetWindowTreeClientFactoryPtr factory; |
| 1896 host_->GetProcess()->GetRemoteInterfaces()->GetInterface(&factory); |
| 1897 |
| 1898 ui::mojom::WindowTreeClientPtr window_tree_client; |
| 1899 factory->CreateWindowTreeClientForRenderWidget( |
| 1900 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client)); |
| 1901 aura::WindowPortMus::Get(window_)->Embed( |
| 1902 std::move(window_tree_client), |
| 1903 ui::mojom::kEmbedFlagEmbedderInterceptsEvents, |
| 1904 base::Bind(&EmbedCallback)); |
| 1905 } |
| 1906 |
| 1907 void RenderWidgetHostViewAura::CreateDelegatedFrameHostClient() { |
| 1908 if (IsMus()) |
| 1909 return; |
| 1910 |
| 1911 // GuestViews have two RenderWidgetHostViews and so we need to make sure |
| 1912 // we don't have FrameSinkId collisions. |
| 1913 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
| 1914 cc::FrameSinkId frame_sink_id = |
| 1915 is_guest_view_hack_ |
| 1916 ? factory->GetContextFactoryPrivate()->AllocateFrameSinkId() |
| 1917 : cc::FrameSinkId( |
| 1918 base::checked_cast<uint32_t>(host_->GetProcess()->GetID()), |
| 1919 base::checked_cast<uint32_t>(host_->GetRoutingID())); |
| 1920 // Tests may set |delegated_frame_host_client_|. |
| 1921 if (!delegated_frame_host_client_) { |
| 1922 delegated_frame_host_client_ = |
| 1923 base::MakeUnique<DelegatedFrameHostClientAura>(this); |
| 1924 } |
| 1925 delegated_frame_host_ = base::MakeUnique<DelegatedFrameHost>( |
| 1926 frame_sink_id, delegated_frame_host_client_.get()); |
| 1927 |
| 1928 // Let the page-level input event router know about our surface ID |
| 1929 // namespace for surface-based hit testing. |
| 1930 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { |
| 1931 host_->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner( |
| 1932 GetFrameSinkId(), this); |
| 1933 } |
1878 } | 1934 } |
1879 | 1935 |
1880 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { | 1936 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { |
1881 if (host_->GetProcess()->FastShutdownStarted()) | 1937 if (host_->GetProcess()->FastShutdownStarted()) |
1882 return; | 1938 return; |
1883 | 1939 |
1884 aura::Window* root_window = window_->GetRootWindow(); | 1940 aura::Window* root_window = window_->GetRootWindow(); |
1885 if (!root_window) | 1941 if (!root_window) |
1886 return; | 1942 return; |
1887 | 1943 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 CreateSelectionController(); | 2102 CreateSelectionController(); |
2047 } | 2103 } |
2048 | 2104 |
2049 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2105 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
2050 SnapToPhysicalPixelBoundary(); | 2106 SnapToPhysicalPixelBoundary(); |
2051 // Don't recursively call SetBounds if this bounds update is the result of | 2107 // Don't recursively call SetBounds if this bounds update is the result of |
2052 // a Window::SetBoundsInternal call. | 2108 // a Window::SetBoundsInternal call. |
2053 if (!in_bounds_changed_) | 2109 if (!in_bounds_changed_) |
2054 window_->SetBounds(rect); | 2110 window_->SetBounds(rect); |
2055 host_->WasResized(); | 2111 host_->WasResized(); |
2056 delegated_frame_host_->WasResized(); | 2112 if (delegated_frame_host_) |
| 2113 delegated_frame_host_->WasResized(); |
2057 #if defined(OS_WIN) | 2114 #if defined(OS_WIN) |
2058 UpdateLegacyWin(); | 2115 UpdateLegacyWin(); |
2059 | 2116 |
2060 if (mouse_locked_) | 2117 if (mouse_locked_) |
2061 UpdateMouseLockRegion(); | 2118 UpdateMouseLockRegion(); |
2062 #endif | 2119 #endif |
2063 } | 2120 } |
2064 | 2121 |
2065 #if defined(OS_WIN) | 2122 #if defined(OS_WIN) |
2066 void RenderWidgetHostViewAura::UpdateLegacyWin() { | 2123 void RenderWidgetHostViewAura::UpdateLegacyWin() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 if (HasFocus()) { | 2169 if (HasFocus()) { |
2113 ui::InputMethod* input_method = GetInputMethod(); | 2170 ui::InputMethod* input_method = GetInputMethod(); |
2114 if (input_method) | 2171 if (input_method) |
2115 input_method->SetFocusedTextInputClient(this); | 2172 input_method->SetFocusedTextInputClient(this); |
2116 } | 2173 } |
2117 | 2174 |
2118 #if defined(OS_WIN) | 2175 #if defined(OS_WIN) |
2119 UpdateLegacyWin(); | 2176 UpdateLegacyWin(); |
2120 #endif | 2177 #endif |
2121 | 2178 |
2122 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); | 2179 if (delegated_frame_host_) |
| 2180 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); |
2123 } | 2181 } |
2124 | 2182 |
2125 void RenderWidgetHostViewAura::RemovingFromRootWindow() { | 2183 void RenderWidgetHostViewAura::RemovingFromRootWindow() { |
2126 aura::client::CursorClient* cursor_client = | 2184 aura::client::CursorClient* cursor_client = |
2127 aura::client::GetCursorClient(window_->GetRootWindow()); | 2185 aura::client::GetCursorClient(window_->GetRootWindow()); |
2128 if (cursor_client) | 2186 if (cursor_client) |
2129 cursor_client->RemoveObserver(this); | 2187 cursor_client->RemoveObserver(this); |
2130 | 2188 |
2131 DetachFromInputMethod(); | 2189 DetachFromInputMethod(); |
2132 | 2190 |
2133 window_->GetHost()->RemoveObserver(this); | 2191 window_->GetHost()->RemoveObserver(this); |
2134 delegated_frame_host_->ResetCompositor(); | 2192 if (delegated_frame_host_) |
| 2193 delegated_frame_host_->ResetCompositor(); |
2135 | 2194 |
2136 #if defined(OS_WIN) | 2195 #if defined(OS_WIN) |
2137 // Update the legacy window's parent temporarily to the hidden window. It | 2196 // Update the legacy window's parent temporarily to the hidden window. It |
2138 // will eventually get reparented to the right root. | 2197 // will eventually get reparented to the right root. |
2139 if (legacy_render_widget_host_HWND_) | 2198 if (legacy_render_widget_host_HWND_) |
2140 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); | 2199 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); |
2141 #endif | 2200 #endif |
2142 } | 2201 } |
2143 | 2202 |
2144 void RenderWidgetHostViewAura::DetachFromInputMethod() { | 2203 void RenderWidgetHostViewAura::DetachFromInputMethod() { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 ui::TouchSelectionController::Config tsc_config; | 2257 ui::TouchSelectionController::Config tsc_config; |
2199 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds( | 2258 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds( |
2200 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms()); | 2259 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms()); |
2201 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance() | 2260 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance() |
2202 ->max_touch_move_in_pixels_for_click(); | 2261 ->max_touch_move_in_pixels_for_click(); |
2203 tsc_config.enable_longpress_drag_selection = false; | 2262 tsc_config.enable_longpress_drag_selection = false; |
2204 selection_controller_.reset(new ui::TouchSelectionController( | 2263 selection_controller_.reset(new ui::TouchSelectionController( |
2205 selection_controller_client_.get(), tsc_config)); | 2264 selection_controller_client_.get(), tsc_config)); |
2206 } | 2265 } |
2207 | 2266 |
2208 //////////////////////////////////////////////////////////////////////////////// | |
2209 // DelegatedFrameHost, public: | |
2210 | |
2211 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { | |
2212 return window_->layer(); | |
2213 } | |
2214 | |
2215 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { | |
2216 return !host_->is_hidden(); | |
2217 } | |
2218 | |
2219 SkColor RenderWidgetHostViewAura::DelegatedFrameHostGetGutterColor( | |
2220 SkColor color) const { | |
2221 // When making an element on the page fullscreen the element's background | |
2222 // may not match the page's, so use black as the gutter color to avoid | |
2223 // flashes of brighter colors during the transition. | |
2224 if (host_->delegate() && host_->delegate()->IsFullscreenForCurrentTab()) | |
2225 return SK_ColorBLACK; | |
2226 return color; | |
2227 } | |
2228 | |
2229 gfx::Size RenderWidgetHostViewAura::DelegatedFrameHostDesiredSizeInDIP() const { | |
2230 return window_->bounds().size(); | |
2231 } | |
2232 | |
2233 bool RenderWidgetHostViewAura::DelegatedFrameCanCreateResizeLock() const { | |
2234 #if !defined(OS_CHROMEOS) | |
2235 // On Windows and Linux, holding pointer moves will not help throttling | |
2236 // resizes. | |
2237 // TODO(piman): on Windows we need to block (nested message loop?) the | |
2238 // WM_SIZE event. On Linux we need to throttle at the WM level using | |
2239 // _NET_WM_SYNC_REQUEST. | |
2240 return false; | |
2241 #else | |
2242 if (host_->auto_resize_enabled()) | |
2243 return false; | |
2244 return true; | |
2245 #endif | |
2246 } | |
2247 | |
2248 std::unique_ptr<ResizeLock> | |
2249 RenderWidgetHostViewAura::DelegatedFrameHostCreateResizeLock( | |
2250 bool defer_compositor_lock) { | |
2251 gfx::Size desired_size = window_->bounds().size(); | |
2252 return std::unique_ptr<ResizeLock>(new CompositorResizeLock( | |
2253 window_->GetHost(), desired_size, defer_compositor_lock, | |
2254 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs))); | |
2255 } | |
2256 | |
2257 void RenderWidgetHostViewAura::DelegatedFrameHostResizeLockWasReleased() { | |
2258 host_->WasResized(); | |
2259 } | |
2260 | |
2261 void RenderWidgetHostViewAura::DelegatedFrameHostSendReclaimCompositorResources( | |
2262 int compositor_frame_sink_id, | |
2263 bool is_swap_ack, | |
2264 const cc::ReturnedResourceArray& resources) { | |
2265 host_->Send(new ViewMsg_ReclaimCompositorResources( | |
2266 host_->GetRoutingID(), compositor_frame_sink_id, is_swap_ack, resources)); | |
2267 } | |
2268 | |
2269 void RenderWidgetHostViewAura::SetBeginFrameSource( | |
2270 cc::BeginFrameSource* source) { | |
2271 if (begin_frame_source_ && added_frame_observer_) { | |
2272 begin_frame_source_->RemoveObserver(this); | |
2273 added_frame_observer_ = false; | |
2274 } | |
2275 begin_frame_source_ = source; | |
2276 UpdateNeedsBeginFramesInternal(); | |
2277 } | |
2278 | |
2279 bool RenderWidgetHostViewAura::IsAutoResizeEnabled() const { | |
2280 return host_->auto_resize_enabled(); | |
2281 } | |
2282 | |
2283 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { | 2267 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() { |
2284 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); | 2268 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); |
2285 } | 2269 } |
2286 | 2270 |
2287 void RenderWidgetHostViewAura::LockCompositingSurface() { | 2271 void RenderWidgetHostViewAura::LockCompositingSurface() { |
2288 NOTIMPLEMENTED(); | 2272 NOTIMPLEMENTED(); |
2289 } | 2273 } |
2290 | 2274 |
2291 void RenderWidgetHostViewAura::UnlockCompositingSurface() { | 2275 void RenderWidgetHostViewAura::UnlockCompositingSurface() { |
2292 NOTIMPLEMENTED(); | 2276 NOTIMPLEMENTED(); |
2293 } | 2277 } |
2294 | 2278 |
2295 cc::FrameSinkId RenderWidgetHostViewAura::GetFrameSinkId() { | 2279 cc::FrameSinkId RenderWidgetHostViewAura::GetFrameSinkId() { |
2296 return delegated_frame_host_->GetFrameSinkId(); | 2280 return delegated_frame_host_ ? delegated_frame_host_->GetFrameSinkId() |
| 2281 : cc::FrameSinkId(); |
2297 } | 2282 } |
2298 | 2283 |
2299 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { | 2284 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { |
2300 return delegated_frame_host_->SurfaceIdForTesting(); | 2285 return delegated_frame_host_ ? delegated_frame_host_->SurfaceIdForTesting() |
| 2286 : cc::SurfaceId(); |
2301 } | 2287 } |
2302 | 2288 |
2303 void RenderWidgetHostViewAura::OnUpdateTextInputStateCalled( | 2289 void RenderWidgetHostViewAura::OnUpdateTextInputStateCalled( |
2304 TextInputManager* text_input_manager, | 2290 TextInputManager* text_input_manager, |
2305 RenderWidgetHostViewBase* updated_view, | 2291 RenderWidgetHostViewBase* updated_view, |
2306 bool did_update_state) { | 2292 bool did_update_state) { |
2307 DCHECK_EQ(text_input_manager_, text_input_manager); | 2293 DCHECK_EQ(text_input_manager_, text_input_manager); |
2308 | 2294 |
2309 if (!GetInputMethod()) | 2295 if (!GetInputMethod()) |
2310 return; | 2296 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2394 | 2380 |
2395 void RenderWidgetHostViewAura::SetPopupChild( | 2381 void RenderWidgetHostViewAura::SetPopupChild( |
2396 RenderWidgetHostViewAura* popup_child_host_view) { | 2382 RenderWidgetHostViewAura* popup_child_host_view) { |
2397 popup_child_host_view_ = popup_child_host_view; | 2383 popup_child_host_view_ = popup_child_host_view; |
2398 event_handler_->SetPopupChild( | 2384 event_handler_->SetPopupChild( |
2399 popup_child_host_view, | 2385 popup_child_host_view, |
2400 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); | 2386 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); |
2401 } | 2387 } |
2402 | 2388 |
2403 } // namespace content | 2389 } // namespace content |
OLD | NEW |