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

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

Issue 2577023003: Removes WebContentsViewMus/RenderWidgetHostViewMus (Closed)
Patch Set: cleanup Created 4 years 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 13 matching lines...) Expand all
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/compositor_resize_lock_aura.h"
34 #include "content/browser/renderer_host/delegated_frame_host.h"
34 #include "content/browser/renderer_host/dip_util.h" 35 #include "content/browser/renderer_host/dip_util.h"
35 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 36 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
36 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h" 37 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
37 #include "content/browser/renderer_host/overscroll_controller.h" 38 #include "content/browser/renderer_host/overscroll_controller.h"
38 #include "content/browser/renderer_host/render_view_host_delegate.h" 39 #include "content/browser/renderer_host/render_view_host_delegate.h"
39 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 40 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
40 #include "content/browser/renderer_host/render_view_host_impl.h" 41 #include "content/browser/renderer_host/render_view_host_impl.h"
41 #include "content/browser/renderer_host/render_widget_host_delegate.h" 42 #include "content/browser/renderer_host/render_widget_host_delegate.h"
42 #include "content/browser/renderer_host/render_widget_host_impl.h" 43 #include "content/browser/renderer_host/render_widget_host_impl.h"
43 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 44 #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" 45 #include "content/browser/renderer_host/render_widget_host_view_event_handler.h"
45 #include "content/browser/renderer_host/ui_events_helper.h" 46 #include "content/browser/renderer_host/ui_events_helper.h"
46 #include "content/common/content_switches_internal.h" 47 #include "content/common/content_switches_internal.h"
47 #include "content/common/input_messages.h" 48 #include "content/common/input_messages.h"
49 #include "content/common/render_widget_window_tree_client_factory.mojom.h"
48 #include "content/common/site_isolation_policy.h" 50 #include "content/common/site_isolation_policy.h"
49 #include "content/common/text_input_state.h" 51 #include "content/common/text_input_state.h"
50 #include "content/common/view_messages.h" 52 #include "content/common/view_messages.h"
51 #include "content/public/browser/content_browser_client.h" 53 #include "content/public/browser/content_browser_client.h"
52 #include "content/public/browser/overscroll_configuration.h" 54 #include "content/public/browser/overscroll_configuration.h"
53 #include "content/public/browser/render_view_host.h" 55 #include "content/public/browser/render_view_host.h"
54 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 56 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
55 #include "content/public/browser/user_metrics.h" 57 #include "content/public/browser/user_metrics.h"
56 #include "content/public/common/child_process_host.h" 58 #include "content/public/common/child_process_host.h"
57 #include "content/public/common/content_switches.h" 59 #include "content/public/common/content_switches.h"
58 #include "gpu/ipc/common/gpu_messages.h" 60 #include "gpu/ipc/common/gpu_messages.h"
61 #include "services/service_manager/public/cpp/interface_provider.h"
62 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
59 #include "third_party/WebKit/public/platform/WebInputEvent.h" 63 #include "third_party/WebKit/public/platform/WebInputEvent.h"
60 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 64 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
61 #include "ui/aura/client/aura_constants.h" 65 #include "ui/aura/client/aura_constants.h"
62 #include "ui/aura/client/cursor_client.h" 66 #include "ui/aura/client/cursor_client.h"
63 #include "ui/aura/client/cursor_client_observer.h" 67 #include "ui/aura/client/cursor_client_observer.h"
64 #include "ui/aura/client/focus_client.h" 68 #include "ui/aura/client/focus_client.h"
65 #include "ui/aura/client/screen_position_client.h" 69 #include "ui/aura/client/screen_position_client.h"
66 #include "ui/aura/client/transient_window_client.h" 70 #include "ui/aura/client/transient_window_client.h"
67 #include "ui/aura/client/window_parenting_client.h" 71 #include "ui/aura/client/window_parenting_client.h"
68 #include "ui/aura/env.h" 72 #include "ui/aura/env.h"
73 #include "ui/aura/mus/window_port_mus.h"
69 #include "ui/aura/window.h" 74 #include "ui/aura/window.h"
70 #include "ui/aura/window_event_dispatcher.h" 75 #include "ui/aura/window_event_dispatcher.h"
71 #include "ui/aura/window_observer.h" 76 #include "ui/aura/window_observer.h"
72 #include "ui/aura/window_tree_host.h" 77 #include "ui/aura/window_tree_host.h"
73 #include "ui/base/clipboard/scoped_clipboard_writer.h" 78 #include "ui/base/clipboard/scoped_clipboard_writer.h"
74 #include "ui/base/hit_test.h" 79 #include "ui/base/hit_test.h"
75 #include "ui/base/ime/input_method.h" 80 #include "ui/base/ime/input_method.h"
76 #include "ui/base/ui_base_types.h" 81 #include "ui/base/ui_base_types.h"
77 #include "ui/compositor/compositor_vsync_manager.h" 82 #include "ui/compositor/compositor_vsync_manager.h"
78 #include "ui/compositor/dip_util.h" 83 #include "ui/compositor/dip_util.h"
79 #include "ui/display/display.h" 84 #include "ui/display/display.h"
80 #include "ui/display/screen.h" 85 #include "ui/display/screen.h"
81 #include "ui/events/blink/blink_event_util.h" 86 #include "ui/events/blink/blink_event_util.h"
82 #include "ui/events/blink/web_input_event.h" 87 #include "ui/events/blink/web_input_event.h"
83 #include "ui/events/event.h" 88 #include "ui/events/event.h"
84 #include "ui/events/event_utils.h" 89 #include "ui/events/event_utils.h"
85 #include "ui/events/gesture_detection/gesture_configuration.h" 90 #include "ui/events/gesture_detection/gesture_configuration.h"
86 #include "ui/events/gestures/gesture_recognizer.h" 91 #include "ui/events/gestures/gesture_recognizer.h"
87 #include "ui/gfx/canvas.h" 92 #include "ui/gfx/canvas.h"
88 #include "ui/gfx/geometry/dip_util.h" 93 #include "ui/gfx/geometry/dip_util.h"
89 #include "ui/gfx/geometry/rect_conversions.h" 94 #include "ui/gfx/geometry/rect_conversions.h"
90 #include "ui/gfx/geometry/size_conversions.h" 95 #include "ui/gfx/geometry/size_conversions.h"
91 #include "ui/gfx/skia_util.h" 96 #include "ui/gfx/skia_util.h"
92 #include "ui/touch_selection/touch_selection_controller.h" 97 #include "ui/touch_selection/touch_selection_controller.h"
93 #include "ui/wm/public/activation_client.h" 98 #include "ui/wm/public/activation_client.h"
94 #include "ui/wm/public/scoped_tooltip_disabler.h" 99 #include "ui/wm/public/scoped_tooltip_disabler.h"
95 #include "ui/wm/public/tooltip_client.h" 100 #include "ui/wm/public/tooltip_client.h"
96 #include "ui/wm/public/window_types.h"
97 101
98 #if defined(OS_WIN) 102 #if defined(OS_WIN)
99 #include "base/time/time.h" 103 #include "base/time/time.h"
100 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 104 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
101 #include "content/browser/accessibility/browser_accessibility_win.h" 105 #include "content/browser/accessibility/browser_accessibility_win.h"
102 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 106 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
103 #include "ui/base/win/hidden_window.h" 107 #include "ui/base/win/hidden_window.h"
104 #include "ui/base/win/osk_display_manager.h" 108 #include "ui/base/win/osk_display_manager.h"
105 #include "ui/base/win/osk_display_observer.h" 109 #include "ui/base/win/osk_display_observer.h"
106 #include "ui/display/win/screen_win.h" 110 #include "ui/display/win/screen_win.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // The current device scale factor. 208 // The current device scale factor.
205 float device_scale_factor_; 209 float device_scale_factor_;
206 210
207 // The content Window. 211 // The content Window.
208 aura::Window* window_; 212 aura::Window* window_;
209 213
210 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver); 214 DISALLOW_COPY_AND_ASSIGN(WinScreenKeyboardObserver);
211 }; 215 };
212 #endif // defined(OS_WIN) 216 #endif // defined(OS_WIN)
213 217
218 // Callback from embedding the renderer.
219 void EmbedCallback(bool result) {
220 if (!result)
221 DVLOG(1) << "embed failed";
222 }
223
214 } // namespace 224 } // namespace
215 225
216 // We need to watch for mouse events outside a Web Popup or its parent 226 // We need to watch for mouse events outside a Web Popup or its parent
217 // and dismiss the popup for certain events. 227 // and dismiss the popup for certain events.
218 class RenderWidgetHostViewAura::EventFilterForPopupExit 228 class RenderWidgetHostViewAura::EventFilterForPopupExit
219 : public ui::EventHandler { 229 : public ui::EventHandler {
220 public: 230 public:
221 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 231 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
222 : rwhva_(rwhva) { 232 : rwhva_(rwhva) {
223 DCHECK(rwhva_); 233 DCHECK(rwhva_);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 ancestor->RemoveObserver(this); 359 ancestor->RemoveObserver(this);
350 ancestors_.clear(); 360 ancestors_.clear();
351 } 361 }
352 362
353 RenderWidgetHostViewAura* view_; 363 RenderWidgetHostViewAura* view_;
354 std::set<aura::Window*> ancestors_; 364 std::set<aura::Window*> ancestors_;
355 365
356 DISALLOW_COPY_AND_ASSIGN(WindowAncestorObserver); 366 DISALLOW_COPY_AND_ASSIGN(WindowAncestorObserver);
357 }; 367 };
358 368
369 // DelegatedFrameHostClient implementation, not used in mus.
370 class RenderWidgetHostViewAura::DelegatedFrameHostClientImpl
371 : public DelegatedFrameHostClient {
372 public:
373 DelegatedFrameHostClientImpl(
sadrul 2016/12/16 01:56:20 explicit
sky 2016/12/16 22:30:52 Done.
374 RenderWidgetHostViewAura* render_widget_host_view)
375 : render_widget_host_view_(render_widget_host_view) {}
376 ~DelegatedFrameHostClientImpl() {}
377
378 private:
379 // DelegatedFrameHostClient implementation.
380 ui::Layer* DelegatedFrameHostGetLayer() const override {
381 return render_widget_host_view_->window_->layer();
382 }
383 bool DelegatedFrameHostIsVisible() const override {
384 return !render_widget_host_view_->host_->is_hidden();
385 }
386 SkColor DelegatedFrameHostGetGutterColor(SkColor color) const override {
387 // When making an element on the page fullscreen the element's background
388 // may not match the page's, so use black as the gutter color to avoid
389 // flashes of brighter colors during the transition.
390 if (render_widget_host_view_->host_->delegate() &&
391 render_widget_host_view_->host_->delegate()
392 ->IsFullscreenForCurrentTab()) {
393 return SK_ColorBLACK;
394 }
395 return color;
396 }
397 gfx::Size DelegatedFrameHostDesiredSizeInDIP() const override {
398 return render_widget_host_view_->window_->bounds().size();
399 }
400 bool DelegatedFrameCanCreateResizeLock() const override {
401 #if !defined(OS_CHROMEOS)
402 // On Windows and Linux, holding pointer moves will not help throttling
403 // resizes.
404 // TODO(piman): on Windows we need to block (nested message loop?) the
405 // WM_SIZE event. On Linux we need to throttle at the WM level using
406 // _NET_WM_SYNC_REQUEST.
407 return false;
408 #else
409 if (render_widget_host_view_->host_->auto_resize_enabled())
410 return false;
411 return true;
412 #endif
413 }
414 std::unique_ptr<ResizeLock> DelegatedFrameHostCreateResizeLock(
415 bool defer_compositor_lock) override {
416 gfx::Size desired_size = render_widget_host_view_->window_->bounds().size();
417 return std::unique_ptr<ResizeLock>(new CompositorResizeLock(
418 render_widget_host_view_->window_->GetHost(), desired_size,
419 defer_compositor_lock,
420 base::TimeDelta::FromMilliseconds(kResizeLockTimeoutMs)));
421 }
422 void DelegatedFrameHostResizeLockWasReleased() override {
423 render_widget_host_view_->host_->WasResized();
424 }
425 void DelegatedFrameHostSendReclaimCompositorResources(
426 int compositor_frame_sink_id,
427 bool is_swap_ack,
428 const cc::ReturnedResourceArray& resources) override {
429 render_widget_host_view_->host_->Send(
430 new ViewMsg_ReclaimCompositorResources(
431 render_widget_host_view_->host_->GetRoutingID(),
432 compositor_frame_sink_id, is_swap_ack, resources));
433 }
434 void SetBeginFrameSource(cc::BeginFrameSource* source) override {
435 if (render_widget_host_view_->begin_frame_source_ &&
436 render_widget_host_view_->added_frame_observer_) {
437 render_widget_host_view_->begin_frame_source_->RemoveObserver(
438 render_widget_host_view_);
439 render_widget_host_view_->added_frame_observer_ = false;
440 }
441 render_widget_host_view_->begin_frame_source_ = source;
442 render_widget_host_view_->UpdateNeedsBeginFramesInternal();
443 }
444 bool IsAutoResizeEnabled() const override {
445 return render_widget_host_view_->host_->auto_resize_enabled();
446 }
447
448 RenderWidgetHostViewAura* render_widget_host_view_;
449
450 DISALLOW_COPY_AND_ASSIGN(DelegatedFrameHostClientImpl);
451 };
452
453 bool IsMus() {
454 return aura::Env::GetInstance()->mode() == aura::Env::Mode::MUS &&
455 base::CommandLine::ForCurrentProcess()->HasSwitch(
456 switches::kUseMusInRenderer);
457 }
458
359 //////////////////////////////////////////////////////////////////////////////// 459 ////////////////////////////////////////////////////////////////////////////////
360 // RenderWidgetHostViewAura, public: 460 // RenderWidgetHostViewAura, public:
361 461
362 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host, 462 RenderWidgetHostViewAura::RenderWidgetHostViewAura(RenderWidgetHost* host,
363 bool is_guest_view_hack) 463 bool is_guest_view_hack)
364 : host_(RenderWidgetHostImpl::From(host)), 464 : host_(RenderWidgetHostImpl::From(host)),
365 window_(nullptr), 465 window_(nullptr),
366 in_shutdown_(false), 466 in_shutdown_(false),
367 in_bounds_changed_(false), 467 in_bounds_changed_(false),
368 popup_parent_host_view_(nullptr), 468 popup_parent_host_view_(nullptr),
(...skipping 10 matching lines...) Expand all
379 legacy_window_destroyed_(false), 479 legacy_window_destroyed_(false),
380 virtual_keyboard_requested_(false), 480 virtual_keyboard_requested_(false),
381 #endif 481 #endif
382 has_snapped_to_boundary_(false), 482 has_snapped_to_boundary_(false),
383 is_guest_view_hack_(is_guest_view_hack), 483 is_guest_view_hack_(is_guest_view_hack),
384 device_scale_factor_(0.0f), 484 device_scale_factor_(0.0f),
385 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID), 485 last_active_widget_process_id_(ChildProcessHost::kInvalidUniqueID),
386 last_active_widget_routing_id_(MSG_ROUTING_NONE), 486 last_active_widget_routing_id_(MSG_ROUTING_NONE),
387 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)), 487 event_handler_(new RenderWidgetHostViewEventHandler(host_, this, this)),
388 weak_ptr_factory_(this) { 488 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_) 489 if (!is_guest_view_hack_)
402 host_->SetView(this); 490 host_->SetView(this);
403 491
404 // Let the page-level input event router know about our surface ID 492 if (!IsMus()) {
405 // namespace for surface-based hit testing. 493 // GuestViews have two RenderWidgetHostViews and so we need to make sure
406 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) { 494 // we don't have FrameSinkId collisions.
407 host_->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner( 495 ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
408 GetFrameSinkId(), this); 496 cc::FrameSinkId frame_sink_id =
497 is_guest_view_hack_
498 ? factory->GetContextFactoryPrivate()->AllocateFrameSinkId()
499 : cc::FrameSinkId(
500 base::checked_cast<uint32_t>(host_->GetProcess()->GetID()),
501 base::checked_cast<uint32_t>(host_->GetRoutingID()));
502 delegated_frame_host_client_ =
503 base::MakeUnique<DelegatedFrameHostClientImpl>(this);
504 delegated_frame_host_ = base::MakeUnique<DelegatedFrameHost>(
505 frame_sink_id, delegated_frame_host_client_.get());
506
507 // Let the page-level input event router know about our surface ID
508 // namespace for surface-based hit testing.
509 if (host_->delegate() && host_->delegate()->GetInputEventRouter()) {
510 host_->delegate()->GetInputEventRouter()->AddFrameSinkIdOwner(
511 GetFrameSinkId(), this);
512 }
409 } 513 }
410 514
411 // We should start observing the TextInputManager for IME-related events as 515 // We should start observing the TextInputManager for IME-related events as
412 // well as monitoring its lifetime. 516 // well as monitoring its lifetime.
413 if (GetTextInputManager()) 517 if (GetTextInputManager())
414 GetTextInputManager()->AddObserver(this); 518 GetTextInputManager()->AddObserver(this);
415 519
416 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 520 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
417 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 521 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
418 SetOverscrollControllerEnabled(overscroll_enabled); 522 SetOverscrollControllerEnabled(overscroll_enabled);
419 523
420 selection_controller_client_.reset( 524 selection_controller_client_.reset(
421 new TouchSelectionControllerClientAura(this)); 525 new TouchSelectionControllerClientAura(this));
422 CreateSelectionController(); 526 CreateSelectionController();
423 527
424 RenderViewHost* rvh = RenderViewHost::From(host_); 528 RenderViewHost* rvh = RenderViewHost::From(host_);
425 if (rvh) { 529 if (rvh) {
426 // TODO(mostynb): actually use prefs. Landing this as a separate CL 530 // TODO(mostynb): actually use prefs. Landing this as a separate CL
427 // first to rebaseline some unreliable layout tests. 531 // first to rebaseline some unreliable layout tests.
428 ignore_result(rvh->GetWebkitPreferences()); 532 ignore_result(rvh->GetWebkitPreferences());
429 } 533 }
430 } 534 }
431 535
432 //////////////////////////////////////////////////////////////////////////////// 536 ////////////////////////////////////////////////////////////////////////////////
433 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 537 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
434 538
435 void RenderWidgetHostViewAura::InitAsChild( 539 void RenderWidgetHostViewAura::InitAsChild(
436 gfx::NativeView parent_view) { 540 gfx::NativeView parent_view) {
437 CreateAuraWindow(); 541 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL);
438 window_->SetType(ui::wm::WINDOW_TYPE_CONTROL);
439 window_->Init(ui::LAYER_SOLID_COLOR);
440 window_->SetName("RenderWidgetHostViewAura");
441 window_->layer()->SetColor(background_color_);
442 542
443 if (parent_view) 543 if (parent_view)
444 parent_view->AddChild(GetNativeView()); 544 parent_view->AddChild(GetNativeView());
445 545
446 const display::Display display = 546 const display::Display display =
447 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); 547 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
448 device_scale_factor_ = display.device_scale_factor(); 548 device_scale_factor_ = display.device_scale_factor();
449 } 549 }
450 550
451 void RenderWidgetHostViewAura::InitAsPopup( 551 void RenderWidgetHostViewAura::InitAsPopup(
452 RenderWidgetHostView* parent_host_view, 552 RenderWidgetHostView* parent_host_view,
453 const gfx::Rect& bounds_in_screen) { 553 const gfx::Rect& bounds_in_screen) {
454 CreateAuraWindow();
455 popup_parent_host_view_ = 554 popup_parent_host_view_ =
456 static_cast<RenderWidgetHostViewAura*>(parent_host_view); 555 static_cast<RenderWidgetHostViewAura*>(parent_host_view);
457 556
458 // TransientWindowClient may be NULL during tests. 557 // TransientWindowClient may be NULL during tests.
459 aura::client::TransientWindowClient* transient_window_client = 558 aura::client::TransientWindowClient* transient_window_client =
460 aura::client::GetTransientWindowClient(); 559 aura::client::GetTransientWindowClient();
461 RenderWidgetHostViewAura* old_child = 560 RenderWidgetHostViewAura* old_child =
462 popup_parent_host_view_->popup_child_host_view_; 561 popup_parent_host_view_->popup_child_host_view_;
463 if (old_child) { 562 if (old_child) {
464 // TODO(jhorwich): Allow multiple popup_child_host_view_ per view, or 563 // 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 564 // 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. 565 // to never get a chance to filter events. See crbug.com/160589.
467 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_); 566 DCHECK(old_child->popup_parent_host_view_ == popup_parent_host_view_);
468 if (transient_window_client) { 567 if (transient_window_client) {
469 transient_window_client->RemoveTransientChild( 568 transient_window_client->RemoveTransientChild(
470 popup_parent_host_view_->window_, old_child->window_); 569 popup_parent_host_view_->window_, old_child->window_);
471 } 570 }
472 old_child->popup_parent_host_view_ = NULL; 571 old_child->popup_parent_host_view_ = NULL;
473 } 572 }
474 popup_parent_host_view_->SetPopupChild(this); 573 popup_parent_host_view_->SetPopupChild(this);
475 window_->SetType(ui::wm::WINDOW_TYPE_MENU); 574 CreateAuraWindow(ui::wm::WINDOW_TYPE_MENU);
476 window_->Init(ui::LAYER_SOLID_COLOR);
477 window_->SetName("RenderWidgetHostViewAura");
478 window_->layer()->SetColor(background_color_);
479 575
480 // Setting the transient child allows for the popup to get mouse events when 576 // Setting the transient child allows for the popup to get mouse events when
481 // in a system modal dialog. Do this before calling ParentWindowWithContext 577 // in a system modal dialog. Do this before calling ParentWindowWithContext
482 // below so that the transient parent is visible to WindowTreeClient. 578 // below so that the transient parent is visible to WindowTreeClient.
483 // This fixes crbug.com/328593. 579 // This fixes crbug.com/328593.
484 if (transient_window_client) { 580 if (transient_window_client) {
485 transient_window_client->AddTransientChild( 581 transient_window_client->AddTransientChild(
486 popup_parent_host_view_->window_, window_); 582 popup_parent_host_view_->window_, window_);
487 } 583 }
488 584
489 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); 585 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow();
490 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); 586 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen);
491 587
492 SetBounds(bounds_in_screen); 588 SetBounds(bounds_in_screen);
493 Show(); 589 Show();
494 if (NeedsMouseCapture()) 590 if (NeedsMouseCapture())
495 window_->SetCapture(); 591 window_->SetCapture();
496 592
497 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 593 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
498 594
499 const display::Display display = 595 const display::Display display =
500 display::Screen::GetScreen()->GetDisplayNearestWindow(window_); 596 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
501 device_scale_factor_ = display.device_scale_factor(); 597 device_scale_factor_ = display.device_scale_factor();
502 } 598 }
503 599
504 void RenderWidgetHostViewAura::InitAsFullscreen( 600 void RenderWidgetHostViewAura::InitAsFullscreen(
505 RenderWidgetHostView* reference_host_view) { 601 RenderWidgetHostView* reference_host_view) {
506 CreateAuraWindow();
507 is_fullscreen_ = true; 602 is_fullscreen_ = true;
508 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); 603 CreateAuraWindow(ui::wm::WINDOW_TYPE_NORMAL);
509 window_->Init(ui::LAYER_SOLID_COLOR);
510 window_->SetName("RenderWidgetHostViewAura");
511 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 604 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
512 window_->layer()->SetColor(background_color_);
513 605
514 aura::Window* parent = NULL; 606 aura::Window* parent = NULL;
515 gfx::Rect bounds; 607 gfx::Rect bounds;
516 if (reference_host_view) { 608 if (reference_host_view) {
517 aura::Window* reference_window = 609 aura::Window* reference_window =
518 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 610 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
519 event_handler_->TrackHost(reference_window); 611 event_handler_->TrackHost(reference_window);
520 display::Display display = 612 display::Display display =
521 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); 613 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window);
522 parent = reference_window->GetRootWindow(); 614 parent = reference_window->GetRootWindow();
(...skipping 11 matching lines...) Expand all
534 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 626 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
535 return host_; 627 return host_;
536 } 628 }
537 629
538 void RenderWidgetHostViewAura::Show() { 630 void RenderWidgetHostViewAura::Show() {
539 window_->Show(); 631 window_->Show();
540 632
541 if (!host_->is_hidden()) 633 if (!host_->is_hidden())
542 return; 634 return;
543 635
544 bool has_saved_frame = delegated_frame_host_->HasSavedFrame(); 636 bool has_saved_frame =
637 delegated_frame_host_ ? delegated_frame_host_->HasSavedFrame() : false;
545 ui::LatencyInfo renderer_latency_info, browser_latency_info; 638 ui::LatencyInfo renderer_latency_info, browser_latency_info;
546 if (has_saved_frame) { 639 if (has_saved_frame) {
547 browser_latency_info.AddLatencyNumber( 640 browser_latency_info.AddLatencyNumber(
548 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); 641 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0);
549 } else { 642 } else {
550 renderer_latency_info.AddLatencyNumber( 643 renderer_latency_info.AddLatencyNumber(
551 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0); 644 ui::TAB_SHOW_COMPONENT, host_->GetLatencyComponentId(), 0);
552 } 645 }
553 host_->WasShown(renderer_latency_info); 646 host_->WasShown(renderer_latency_info);
554 647
555 aura::Window* root = window_->GetRootWindow(); 648 aura::Window* root = window_->GetRootWindow();
556 if (root) { 649 if (root) {
557 aura::client::CursorClient* cursor_client = 650 aura::client::CursorClient* cursor_client =
558 aura::client::GetCursorClient(root); 651 aura::client::GetCursorClient(root);
559 if (cursor_client) 652 if (cursor_client)
560 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); 653 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible());
561 } 654 }
562 655
563 delegated_frame_host_->WasShown(browser_latency_info); 656 if (delegated_frame_host_)
657 delegated_frame_host_->WasShown(browser_latency_info);
564 658
565 #if defined(OS_WIN) 659 #if defined(OS_WIN)
566 UpdateLegacyWin(); 660 UpdateLegacyWin();
567 #endif 661 #endif
568 } 662 }
569 663
570 void RenderWidgetHostViewAura::Hide() { 664 void RenderWidgetHostViewAura::Hide() {
571 window_->Hide(); 665 window_->Hide();
572 666
573 // TODO(wjmaclean): can host_ ever be null? 667 // TODO(wjmaclean): can host_ ever be null?
574 if (host_ && !host_->is_hidden()) { 668 if (host_ && !host_->is_hidden()) {
575 host_->WasHidden(); 669 host_->WasHidden();
576 delegated_frame_host_->WasHidden(); 670 if (delegated_frame_host_)
671 delegated_frame_host_->WasHidden();
577 672
578 #if defined(OS_WIN) 673 #if defined(OS_WIN)
579 aura::WindowTreeHost* host = window_->GetHost(); 674 aura::WindowTreeHost* host = window_->GetHost();
580 if (host) { 675 if (host) {
581 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global 676 // We reparent the legacy Chrome_RenderWidgetHostHWND window to the global
582 // hidden window on the same lines as Windowed plugin windows. 677 // hidden window on the same lines as Windowed plugin windows.
583 if (legacy_render_widget_host_HWND_) 678 if (legacy_render_widget_host_HWND_)
584 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); 679 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
585 } 680 }
586 #endif 681 #endif
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); 832 aura::client::FocusClient* client = aura::client::GetFocusClient(window_);
738 if (client) 833 if (client)
739 window_->Focus(); 834 window_->Focus();
740 } 835 }
741 836
742 bool RenderWidgetHostViewAura::HasFocus() const { 837 bool RenderWidgetHostViewAura::HasFocus() const {
743 return window_->HasFocus(); 838 return window_->HasFocus();
744 } 839 }
745 840
746 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 841 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
747 return delegated_frame_host_->CanCopyToBitmap(); 842 return delegated_frame_host_ ? delegated_frame_host_->CanCopyToBitmap()
843 : false;
748 } 844 }
749 845
750 bool RenderWidgetHostViewAura::IsShowing() { 846 bool RenderWidgetHostViewAura::IsShowing() {
751 return window_->IsVisible(); 847 return window_->IsVisible();
752 } 848 }
753 849
754 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const { 850 gfx::Rect RenderWidgetHostViewAura::GetViewBounds() const {
755 return window_->GetBoundsInScreen(); 851 return window_->GetBoundsInScreen();
756 } 852 }
757 853
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 aura::client::TooltipClient* tooltip_client = 940 aura::client::TooltipClient* tooltip_client =
845 aura::client::GetTooltipClient(root_window); 941 aura::client::GetTooltipClient(root_window);
846 if (tooltip_client) { 942 if (tooltip_client) {
847 tooltip_client->UpdateTooltip(window_); 943 tooltip_client->UpdateTooltip(window_);
848 // Content tooltips should be visible indefinitely. 944 // Content tooltips should be visible indefinitely.
849 tooltip_client->SetTooltipShownTimeout(window_, 0); 945 tooltip_client->SetTooltipShownTimeout(window_, 0);
850 } 946 }
851 } 947 }
852 948
853 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 949 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
854 return delegated_frame_host_->GetRequestedRendererSize(); 950 return delegated_frame_host_
951 ? delegated_frame_host_->GetRequestedRendererSize()
952 : RenderWidgetHostViewBase::GetRequestedRendererSize();
855 } 953 }
856 954
857 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 955 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
858 const gfx::Rect& src_subrect, 956 const gfx::Rect& src_subrect,
859 const gfx::Size& dst_size, 957 const gfx::Size& dst_size,
860 const ReadbackRequestCallback& callback, 958 const ReadbackRequestCallback& callback,
861 const SkColorType preferred_color_type) { 959 const SkColorType preferred_color_type) {
960 if (!delegated_frame_host_)
961 return;
862 delegated_frame_host_->CopyFromCompositingSurface( 962 delegated_frame_host_->CopyFromCompositingSurface(
863 src_subrect, dst_size, callback, preferred_color_type); 963 src_subrect, dst_size, callback, preferred_color_type);
864 } 964 }
865 965
866 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame( 966 void RenderWidgetHostViewAura::CopyFromCompositingSurfaceToVideoFrame(
867 const gfx::Rect& src_subrect, 967 const gfx::Rect& src_subrect,
868 const scoped_refptr<media::VideoFrame>& target, 968 const scoped_refptr<media::VideoFrame>& target,
869 const base::Callback<void(const gfx::Rect&, bool)>& callback) { 969 const base::Callback<void(const gfx::Rect&, bool)>& callback) {
970 if (!delegated_frame_host_)
971 return;
870 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame( 972 delegated_frame_host_->CopyFromCompositingSurfaceToVideoFrame(
871 src_subrect, target, callback); 973 src_subrect, target, callback);
872 } 974 }
873 975
874 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const { 976 bool RenderWidgetHostViewAura::CanCopyToVideoFrame() const {
875 return delegated_frame_host_->CanCopyToVideoFrame(); 977 return delegated_frame_host_ ? delegated_frame_host_->CanCopyToVideoFrame()
978 : false;
876 } 979 }
877 980
878 void RenderWidgetHostViewAura::BeginFrameSubscription( 981 void RenderWidgetHostViewAura::BeginFrameSubscription(
879 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) { 982 std::unique_ptr<RenderWidgetHostViewFrameSubscriber> subscriber) {
880 delegated_frame_host_->BeginFrameSubscription(std::move(subscriber)); 983 if (delegated_frame_host_)
984 delegated_frame_host_->BeginFrameSubscription(std::move(subscriber));
881 } 985 }
882 986
883 void RenderWidgetHostViewAura::EndFrameSubscription() { 987 void RenderWidgetHostViewAura::EndFrameSubscription() {
884 delegated_frame_host_->EndFrameSubscription(); 988 if (delegated_frame_host_)
989 delegated_frame_host_->EndFrameSubscription();
885 } 990 }
886 991
887 #if defined(OS_WIN) 992 #if defined(OS_WIN)
888 bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const { 993 bool RenderWidgetHostViewAura::UsesNativeWindowFrame() const {
889 return (legacy_render_widget_host_HWND_ != NULL); 994 return (legacy_render_widget_host_HWND_ != NULL);
890 } 995 }
891 996
892 void RenderWidgetHostViewAura::UpdateMouseLockRegion() { 997 void RenderWidgetHostViewAura::UpdateMouseLockRegion() {
893 RECT window_rect = 998 RECT window_rect =
894 display::Screen::GetScreen() 999 display::Screen::GetScreen()
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 1033
929 start_edge_top.Scale(viewportToDIPScale); 1034 start_edge_top.Scale(viewportToDIPScale);
930 start_edge_bottom.Scale(viewportToDIPScale); 1035 start_edge_bottom.Scale(viewportToDIPScale);
931 end_edge_top.Scale(viewportToDIPScale); 1036 end_edge_top.Scale(viewportToDIPScale);
932 end_edge_bottom.Scale(viewportToDIPScale); 1037 end_edge_bottom.Scale(viewportToDIPScale);
933 1038
934 selection.start.SetEdge(start_edge_top, start_edge_bottom); 1039 selection.start.SetEdge(start_edge_top, start_edge_bottom);
935 selection.end.SetEdge(end_edge_top, end_edge_bottom); 1040 selection.end.SetEdge(end_edge_top, end_edge_bottom);
936 } 1041 }
937 1042
938 delegated_frame_host_->SwapDelegatedFrame(compositor_frame_sink_id, 1043 if (delegated_frame_host_) {
939 std::move(frame)); 1044 delegated_frame_host_->SwapDelegatedFrame(compositor_frame_sink_id,
1045 std::move(frame));
1046 }
940 SelectionUpdated(selection.is_editable, selection.is_empty_text_form_control, 1047 SelectionUpdated(selection.is_editable, selection.is_empty_text_form_control,
941 selection.start, selection.end); 1048 selection.start, selection.end);
942 } 1049 }
943 1050
944 void RenderWidgetHostViewAura::ClearCompositorFrame() { 1051 void RenderWidgetHostViewAura::ClearCompositorFrame() {
945 delegated_frame_host_->ClearDelegatedFrame(); 1052 if (delegated_frame_host_)
1053 delegated_frame_host_->ClearDelegatedFrame();
946 } 1054 }
947 1055
948 void RenderWidgetHostViewAura::DidStopFlinging() { 1056 void RenderWidgetHostViewAura::DidStopFlinging() {
949 selection_controller_client_->OnScrollCompleted(); 1057 selection_controller_client_->OnScrollCompleted();
950 } 1058 }
951 1059
952 bool RenderWidgetHostViewAura::HasAcceleratedSurface( 1060 bool RenderWidgetHostViewAura::HasAcceleratedSurface(
953 const gfx::Size& desired_size) { 1061 const gfx::Size& desired_size) {
954 // Aura doesn't use GetBackingStore for accelerated pages, so it doesn't 1062 // 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 1063 // 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
1594 cc::FrameSinkId RenderWidgetHostViewAura::FrameSinkIdAtPoint( 1702 cc::FrameSinkId RenderWidgetHostViewAura::FrameSinkIdAtPoint(
1595 cc::SurfaceHittestDelegate* delegate, 1703 cc::SurfaceHittestDelegate* delegate,
1596 const gfx::Point& point, 1704 const gfx::Point& point,
1597 gfx::Point* transformed_point) { 1705 gfx::Point* transformed_point) {
1598 DCHECK(device_scale_factor_ != 0.0f); 1706 DCHECK(device_scale_factor_ != 0.0f);
1599 1707
1600 // The surface hittest happens in device pixels, so we need to convert the 1708 // The surface hittest happens in device pixels, so we need to convert the
1601 // |point| from DIPs to pixels before hittesting. 1709 // |point| from DIPs to pixels before hittesting.
1602 gfx::Point point_in_pixels = 1710 gfx::Point point_in_pixels =
1603 gfx::ConvertPointToPixel(device_scale_factor_, point); 1711 gfx::ConvertPointToPixel(device_scale_factor_, point);
1604 cc::SurfaceId id = delegated_frame_host_->SurfaceIdAtPoint( 1712 cc::SurfaceId id = delegated_frame_host_
1605 delegate, point_in_pixels, transformed_point); 1713 ? delegated_frame_host_->SurfaceIdAtPoint(
1714 delegate, point_in_pixels, transformed_point)
1715 : cc::SurfaceId();
1606 *transformed_point = 1716 *transformed_point =
sadrul 2016/12/16 01:56:20 We should ideally not even reach here in mus (sinc
sky 2016/12/16 22:30:52 I added a TODO.
1607 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); 1717 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point);
1608 1718
1609 // It is possible that the renderer has not yet produced a surface, in which 1719 // It is possible that the renderer has not yet produced a surface, in which
1610 // case we return our current namespace. 1720 // case we return our current namespace.
1611 if (!id.is_valid()) 1721 if (!id.is_valid())
1612 return GetFrameSinkId(); 1722 return GetFrameSinkId();
1613 return id.frame_sink_id(); 1723 return id.frame_sink_id();
1614 } 1724 }
1615 1725
1616 void RenderWidgetHostViewAura::ProcessMouseEvent( 1726 void RenderWidgetHostViewAura::ProcessMouseEvent(
(...skipping 21 matching lines...) Expand all
1638 } 1748 }
1639 1749
1640 bool RenderWidgetHostViewAura::TransformPointToLocalCoordSpace( 1750 bool RenderWidgetHostViewAura::TransformPointToLocalCoordSpace(
1641 const gfx::Point& point, 1751 const gfx::Point& point,
1642 const cc::SurfaceId& original_surface, 1752 const cc::SurfaceId& original_surface,
1643 gfx::Point* transformed_point) { 1753 gfx::Point* transformed_point) {
1644 // Transformations use physical pixels rather than DIP, so conversion 1754 // Transformations use physical pixels rather than DIP, so conversion
1645 // is necessary. 1755 // is necessary.
1646 gfx::Point point_in_pixels = 1756 gfx::Point point_in_pixels =
1647 gfx::ConvertPointToPixel(device_scale_factor_, point); 1757 gfx::ConvertPointToPixel(device_scale_factor_, point);
1648 if (!delegated_frame_host_->TransformPointToLocalCoordSpace( 1758 if (delegated_frame_host_ &&
sadrul 2016/12/16 01:56:20 ditto
sky 2016/12/16 22:30:52 TODO here too.
1759 !delegated_frame_host_->TransformPointToLocalCoordSpace(
1649 point_in_pixels, original_surface, transformed_point)) 1760 point_in_pixels, original_surface, transformed_point))
1650 return false; 1761 return false;
1651 *transformed_point = 1762 *transformed_point =
1652 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point); 1763 gfx::ConvertPointToDIP(device_scale_factor_, *transformed_point);
1653 return true; 1764 return true;
1654 } 1765 }
1655 1766
1656 bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView( 1767 bool RenderWidgetHostViewAura::TransformPointToCoordSpaceForView(
1657 const gfx::Point& point, 1768 const gfx::Point& point,
1658 RenderWidgetHostViewBase* target_view, 1769 RenderWidgetHostViewBase* target_view,
1659 gfx::Point* transformed_point) { 1770 gfx::Point* transformed_point) {
1660 if (target_view == this) { 1771 if (target_view == this || !delegated_frame_host_) {
1661 *transformed_point = point; 1772 *transformed_point = point;
1662 return true; 1773 return true;
1663 } 1774 }
1664 1775
1665 // In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion, 1776 // In TransformPointToLocalCoordSpace() there is a Point-to-Pixel conversion,
1666 // but it is not necessary here because the final target view is responsible 1777 // but it is not necessary here because the final target view is responsible
1667 // for converting before computing the final transform. 1778 // for converting before computing the final transform.
1668 return delegated_frame_host_->TransformPointToCoordSpaceForView( 1779 return delegated_frame_host_->TransformPointToCoordSpaceForView(
1669 point, target_view, transformed_point); 1780 point, target_view, transformed_point);
1670 } 1781 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 DCHECK(osk_display_manager); 1969 DCHECK(osk_display_manager);
1859 osk_display_manager->RemoveObserver(keyboard_observer_.get()); 1970 osk_display_manager->RemoveObserver(keyboard_observer_.get());
1860 } 1971 }
1861 1972
1862 #endif 1973 #endif
1863 1974
1864 if (text_input_manager_) 1975 if (text_input_manager_)
1865 text_input_manager_->RemoveObserver(this); 1976 text_input_manager_->RemoveObserver(this);
1866 } 1977 }
1867 1978
1868 void RenderWidgetHostViewAura::CreateAuraWindow() { 1979 void RenderWidgetHostViewAura::CreateAuraWindow(ui::wm::WindowType type) {
1869 DCHECK(!window_); 1980 DCHECK(!window_);
1870 window_ = new aura::Window(this); 1981 window_ = new aura::Window(this);
1982 window_->SetName("RenderWidgetHostViewAura");
1871 event_handler_->set_window(window_); 1983 event_handler_->set_window(window_);
1872 window_observer_.reset(new WindowObserver(this)); 1984 window_observer_.reset(new WindowObserver(this));
1873 1985
1874 aura::client::SetTooltipText(window_, &tooltip_); 1986 aura::client::SetTooltipText(window_, &tooltip_);
1875 aura::client::SetActivationDelegate(window_, this); 1987 aura::client::SetActivationDelegate(window_, this);
1876 aura::client::SetFocusChangeObserver(window_, this); 1988 aura::client::SetFocusChangeObserver(window_, this);
1877 display::Screen::GetScreen()->AddObserver(this); 1989 display::Screen::GetScreen()->AddObserver(this);
1990
1991 window_->SetType(type);
1992 window_->Init(ui::LAYER_SOLID_COLOR);
1993 window_->layer()->SetColor(background_color_);
1994
1995 if (!IsMus())
1996 return;
1997
1998 // Connect to the renderer, pass it a WindowTreeClient interface request
1999 // and embed that client inside our mus window.
2000 mojom::RenderWidgetWindowTreeClientFactoryPtr factory;
2001 host_->GetProcess()->GetRemoteInterfaces()->GetInterface(&factory);
2002
2003 ui::mojom::WindowTreeClientPtr window_tree_client;
2004 factory->CreateWindowTreeClientForRenderWidget(
2005 host_->GetRoutingID(), mojo::GetProxy(&window_tree_client));
2006 aura::WindowPortMus::Get(window_)->Embed(
2007 std::move(window_tree_client),
2008 ui::mojom::kEmbedFlagEmbedderInterceptsEvents,
2009 base::Bind(&EmbedCallback));
1878 } 2010 }
1879 2011
1880 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() { 2012 void RenderWidgetHostViewAura::UpdateCursorIfOverSelf() {
1881 if (host_->GetProcess()->FastShutdownStarted()) 2013 if (host_->GetProcess()->FastShutdownStarted())
1882 return; 2014 return;
1883 2015
1884 aura::Window* root_window = window_->GetRootWindow(); 2016 aura::Window* root_window = window_->GetRootWindow();
1885 if (!root_window) 2017 if (!root_window)
1886 return; 2018 return;
1887 2019
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 CreateSelectionController(); 2178 CreateSelectionController();
2047 } 2179 }
2048 2180
2049 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2181 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2050 SnapToPhysicalPixelBoundary(); 2182 SnapToPhysicalPixelBoundary();
2051 // Don't recursively call SetBounds if this bounds update is the result of 2183 // Don't recursively call SetBounds if this bounds update is the result of
2052 // a Window::SetBoundsInternal call. 2184 // a Window::SetBoundsInternal call.
2053 if (!in_bounds_changed_) 2185 if (!in_bounds_changed_)
2054 window_->SetBounds(rect); 2186 window_->SetBounds(rect);
2055 host_->WasResized(); 2187 host_->WasResized();
2056 delegated_frame_host_->WasResized(); 2188 if (delegated_frame_host_)
2189 delegated_frame_host_->WasResized();
2057 #if defined(OS_WIN) 2190 #if defined(OS_WIN)
2058 UpdateLegacyWin(); 2191 UpdateLegacyWin();
2059 2192
2060 if (mouse_locked_) 2193 if (mouse_locked_)
2061 UpdateMouseLockRegion(); 2194 UpdateMouseLockRegion();
2062 #endif 2195 #endif
2063 } 2196 }
2064 2197
2065 #if defined(OS_WIN) 2198 #if defined(OS_WIN)
2066 void RenderWidgetHostViewAura::UpdateLegacyWin() { 2199 void RenderWidgetHostViewAura::UpdateLegacyWin() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 if (HasFocus()) { 2245 if (HasFocus()) {
2113 ui::InputMethod* input_method = GetInputMethod(); 2246 ui::InputMethod* input_method = GetInputMethod();
2114 if (input_method) 2247 if (input_method)
2115 input_method->SetFocusedTextInputClient(this); 2248 input_method->SetFocusedTextInputClient(this);
2116 } 2249 }
2117 2250
2118 #if defined(OS_WIN) 2251 #if defined(OS_WIN)
2119 UpdateLegacyWin(); 2252 UpdateLegacyWin();
2120 #endif 2253 #endif
2121 2254
2122 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor()); 2255 if (delegated_frame_host_)
2256 delegated_frame_host_->SetCompositor(window_->GetHost()->compositor());
2123 } 2257 }
2124 2258
2125 void RenderWidgetHostViewAura::RemovingFromRootWindow() { 2259 void RenderWidgetHostViewAura::RemovingFromRootWindow() {
2126 aura::client::CursorClient* cursor_client = 2260 aura::client::CursorClient* cursor_client =
2127 aura::client::GetCursorClient(window_->GetRootWindow()); 2261 aura::client::GetCursorClient(window_->GetRootWindow());
2128 if (cursor_client) 2262 if (cursor_client)
2129 cursor_client->RemoveObserver(this); 2263 cursor_client->RemoveObserver(this);
2130 2264
2131 DetachFromInputMethod(); 2265 DetachFromInputMethod();
2132 2266
2133 window_->GetHost()->RemoveObserver(this); 2267 window_->GetHost()->RemoveObserver(this);
2134 delegated_frame_host_->ResetCompositor(); 2268 if (delegated_frame_host_)
2269 delegated_frame_host_->ResetCompositor();
2135 2270
2136 #if defined(OS_WIN) 2271 #if defined(OS_WIN)
2137 // Update the legacy window's parent temporarily to the hidden window. It 2272 // Update the legacy window's parent temporarily to the hidden window. It
2138 // will eventually get reparented to the right root. 2273 // will eventually get reparented to the right root.
2139 if (legacy_render_widget_host_HWND_) 2274 if (legacy_render_widget_host_HWND_)
2140 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow()); 2275 legacy_render_widget_host_HWND_->UpdateParent(ui::GetHiddenWindow());
2141 #endif 2276 #endif
2142 } 2277 }
2143 2278
2144 void RenderWidgetHostViewAura::DetachFromInputMethod() { 2279 void RenderWidgetHostViewAura::DetachFromInputMethod() {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
2198 ui::TouchSelectionController::Config tsc_config; 2333 ui::TouchSelectionController::Config tsc_config;
2199 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds( 2334 tsc_config.max_tap_duration = base::TimeDelta::FromMilliseconds(
2200 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms()); 2335 ui::GestureConfiguration::GetInstance()->long_press_time_in_ms());
2201 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance() 2336 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
2202 ->max_touch_move_in_pixels_for_click(); 2337 ->max_touch_move_in_pixels_for_click();
2203 tsc_config.enable_longpress_drag_selection = false; 2338 tsc_config.enable_longpress_drag_selection = false;
2204 selection_controller_.reset(new ui::TouchSelectionController( 2339 selection_controller_.reset(new ui::TouchSelectionController(
2205 selection_controller_client_.get(), tsc_config)); 2340 selection_controller_client_.get(), tsc_config));
2206 } 2341 }
2207 2342
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() { 2343 void RenderWidgetHostViewAura::OnDidNavigateMainFrameToNewPage() {
2284 ui::GestureRecognizer::Get()->CancelActiveTouches(window_); 2344 ui::GestureRecognizer::Get()->CancelActiveTouches(window_);
2285 } 2345 }
2286 2346
2287 void RenderWidgetHostViewAura::LockCompositingSurface() { 2347 void RenderWidgetHostViewAura::LockCompositingSurface() {
2288 NOTIMPLEMENTED(); 2348 NOTIMPLEMENTED();
2289 } 2349 }
2290 2350
2291 void RenderWidgetHostViewAura::UnlockCompositingSurface() { 2351 void RenderWidgetHostViewAura::UnlockCompositingSurface() {
2292 NOTIMPLEMENTED(); 2352 NOTIMPLEMENTED();
2293 } 2353 }
2294 2354
2295 cc::FrameSinkId RenderWidgetHostViewAura::GetFrameSinkId() { 2355 cc::FrameSinkId RenderWidgetHostViewAura::GetFrameSinkId() {
2296 return delegated_frame_host_->GetFrameSinkId(); 2356 return delegated_frame_host_ ? delegated_frame_host_->GetFrameSinkId()
2357 : cc::FrameSinkId();
2297 } 2358 }
2298 2359
2299 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const { 2360 cc::SurfaceId RenderWidgetHostViewAura::SurfaceIdForTesting() const {
2300 return delegated_frame_host_->SurfaceIdForTesting(); 2361 return delegated_frame_host_ ? delegated_frame_host_->SurfaceIdForTesting()
2362 : cc::SurfaceId();
2301 } 2363 }
2302 2364
2303 void RenderWidgetHostViewAura::OnUpdateTextInputStateCalled( 2365 void RenderWidgetHostViewAura::OnUpdateTextInputStateCalled(
2304 TextInputManager* text_input_manager, 2366 TextInputManager* text_input_manager,
2305 RenderWidgetHostViewBase* updated_view, 2367 RenderWidgetHostViewBase* updated_view,
2306 bool did_update_state) { 2368 bool did_update_state) {
2307 DCHECK_EQ(text_input_manager_, text_input_manager); 2369 DCHECK_EQ(text_input_manager_, text_input_manager);
2308 2370
2309 if (!GetInputMethod()) 2371 if (!GetInputMethod())
2310 return; 2372 return;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 2456
2395 void RenderWidgetHostViewAura::SetPopupChild( 2457 void RenderWidgetHostViewAura::SetPopupChild(
2396 RenderWidgetHostViewAura* popup_child_host_view) { 2458 RenderWidgetHostViewAura* popup_child_host_view) {
2397 popup_child_host_view_ = popup_child_host_view; 2459 popup_child_host_view_ = popup_child_host_view;
2398 event_handler_->SetPopupChild( 2460 event_handler_->SetPopupChild(
2399 popup_child_host_view, 2461 popup_child_host_view,
2400 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2462 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2401 } 2463 }
2402 2464
2403 } // namespace content 2465 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698