Commit 83e3b96c authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Add BridgedNativeWidgetHost[Impl]

Add an empty BridgedNativeWidgetHost interface and a largely-empty
BridgedNativeWidgetHostImpl implementation. These will be the browser
process part of BridgedNativeWidget.

Update NativeWidgetMac to have a BridgedNativeWidgetHost instead of a
BridgedNativeWidget, but still allow calls through the old interface.

The next steps will be a long process of shuffling members and methods
to these interfaces.

Bug: 859152
Change-Id: Id8be908302a32e52dc0ae1bf54fe19a285adccef
Reviewed-on: https://chromium-review.googlesource.com/1162875Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#581146}
parent 5c568461
...@@ -434,6 +434,9 @@ jumbo_component("views") { ...@@ -434,6 +434,9 @@ jumbo_component("views") {
"cocoa/bridged_content_view.h", "cocoa/bridged_content_view.h",
"cocoa/bridged_content_view.mm", "cocoa/bridged_content_view.mm",
"cocoa/bridged_content_view_touch_bar.mm", "cocoa/bridged_content_view_touch_bar.mm",
"cocoa/bridged_native_widget_host.h",
"cocoa/bridged_native_widget_host_impl.h",
"cocoa/bridged_native_widget_host_impl.mm",
"cocoa/bridged_native_widget_owner.h", "cocoa/bridged_native_widget_owner.h",
"cocoa/cocoa_mouse_capture.h", "cocoa/cocoa_mouse_capture.h",
"cocoa/cocoa_mouse_capture.mm", "cocoa/cocoa_mouse_capture.mm",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
#define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
#include "ui/views/views_export.h"
namespace views {
// The interface through which the app shim (BridgedNativeWidgetImpl)
// communicates with the browser process (BridgedNativeWidgetHostImpl).
class VIEWS_EXPORT BridgedNativeWidgetHost {
public:
virtual ~BridgedNativeWidgetHost() = default;
};
} // namespace views
#endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
#define UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
#include <memory>
#include "base/macros.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views/views_export.h"
namespace views {
class BridgedNativeWidget;
class NativeWidgetMac;
// The portion of NativeWidgetMac that lives in the browser process. This
// communicates to the BridgedNativeWidget, which interacts with the Cocoa
// APIs, and which may live in an app shim process.
class VIEWS_EXPORT BridgedNativeWidgetHostImpl
: public BridgedNativeWidgetHost {
public:
// Creates one side of the bridge. |parent| must not be NULL.
explicit BridgedNativeWidgetHostImpl(NativeWidgetMac* parent);
~BridgedNativeWidgetHostImpl() override;
// Provide direct access to the BridgedNativeWidget that this is hosting.
// TODO(ccameron): Remove all accesses to this member, and replace them
// with methods that may be sent across processes.
BridgedNativeWidget* bridge() const { return bridge_.get(); }
private:
// TODO(ccameron): Rather than instantiate a BridgedNativeWidget here,
// we will instantiate a mojo BridgedNativeWidget interface to a Cocoa
// instance that may be in another process.
std::unique_ptr<BridgedNativeWidget> bridge_;
DISALLOW_COPY_AND_ASSIGN(BridgedNativeWidgetHostImpl);
};
} // namespace views
#endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_IMPL_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/cocoa/bridged_native_widget.h"
namespace views {
BridgedNativeWidgetHostImpl::BridgedNativeWidgetHostImpl(
NativeWidgetMac* parent)
: bridge_(new BridgedNativeWidget(parent)) {}
BridgedNativeWidgetHostImpl::~BridgedNativeWidgetHostImpl() {}
} // namespace views
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "ui/base/test/ui_controls.h" #include "ui/base/test/ui_controls.h"
#import "ui/base/test/windowed_nsnotification_observer.h" #import "ui/base/test/windowed_nsnotification_observer.h"
#import "ui/events/test/cocoa_test_event_utils.h" #import "ui/events/test/cocoa_test_event_utils.h"
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/test/views_interactive_ui_test_base.h" #include "ui/views/test/views_interactive_ui_test_base.h"
#include "ui/views/test/widget_test.h" #include "ui/views/test/widget_test.h"
#include "ui/views/widget/native_widget_mac.h" #include "ui/views/widget/native_widget_mac.h"
...@@ -256,7 +257,7 @@ class HitTestNativeWidgetMac : public NativeWidgetMac { ...@@ -256,7 +257,7 @@ class HitTestNativeWidgetMac : public NativeWidgetMac {
HitTestNativeWidgetMac(internal::NativeWidgetDelegate* delegate, HitTestNativeWidgetMac(internal::NativeWidgetDelegate* delegate,
NativeFrameView* native_frame_view) NativeFrameView* native_frame_view)
: NativeWidgetMac(delegate), native_frame_view_(native_frame_view) { : NativeWidgetMac(delegate), native_frame_view_(native_frame_view) {
NativeWidgetMac::bridge_.reset(new BridgedNativeWidget(this)); bridge_host_ = std::make_unique<BridgedNativeWidgetHostImpl>(this);
} }
// internal::NativeWidgetPrivate: // internal::NativeWidgetPrivate:
......
...@@ -288,9 +288,7 @@ class MockNativeWidgetMac : public NativeWidgetMac { ...@@ -288,9 +288,7 @@ class MockNativeWidgetMac : public NativeWidgetMac {
public: public:
explicit MockNativeWidgetMac(internal::NativeWidgetDelegate* delegate) explicit MockNativeWidgetMac(internal::NativeWidgetDelegate* delegate)
: NativeWidgetMac(delegate) {} : NativeWidgetMac(delegate) {}
using NativeWidgetMac::bridge;
// Expose a reference, so that it can be reset() independently.
std::unique_ptr<BridgedNativeWidget>& bridge() { return bridge_; }
// internal::NativeWidgetPrivate: // internal::NativeWidgetPrivate:
void InitNativeWidget(const Widget::InitParams& params) override { void InitNativeWidget(const Widget::InitParams& params) override {
...@@ -301,7 +299,7 @@ class MockNativeWidgetMac : public NativeWidgetMac { ...@@ -301,7 +299,7 @@ class MockNativeWidgetMac : public NativeWidgetMac {
delegate()->OnNativeWidgetCreated(true); delegate()->OnNativeWidgetCreated(true);
// To allow events to dispatch to a view, it needs a way to get focus. // To allow events to dispatch to a view, it needs a way to get focus.
bridge_->SetFocusManager(GetWidget()->GetFocusManager()); bridge()->SetFocusManager(GetWidget()->GetFocusManager());
} }
void ReorderNativeViews() override { void ReorderNativeViews() override {
...@@ -324,9 +322,7 @@ class BridgedNativeWidgetTestBase : public ui::CocoaTest { ...@@ -324,9 +322,7 @@ class BridgedNativeWidgetTestBase : public ui::CocoaTest {
explicit BridgedNativeWidgetTestBase(SkipInitialization tag) explicit BridgedNativeWidgetTestBase(SkipInitialization tag)
: native_widget_mac_(nullptr) {} : native_widget_mac_(nullptr) {}
std::unique_ptr<BridgedNativeWidget>& bridge() { BridgedNativeWidget* bridge() { return native_widget_mac_->bridge(); }
return native_widget_mac_->bridge();
}
// Overridden from testing::Test: // Overridden from testing::Test:
void SetUp() override { void SetUp() override {
......
...@@ -22,6 +22,7 @@ class MockNativeWidgetMac; ...@@ -22,6 +22,7 @@ class MockNativeWidgetMac;
} }
class BridgedNativeWidget; class BridgedNativeWidget;
class BridgedNativeWidgetHostImpl;
class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
public: public:
...@@ -152,13 +153,14 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate { ...@@ -152,13 +153,14 @@ class VIEWS_EXPORT NativeWidgetMac : public internal::NativeWidgetPrivate {
virtual void OnWindowDestroying(NSWindow* window) {} virtual void OnWindowDestroying(NSWindow* window) {}
internal::NativeWidgetDelegate* delegate() { return delegate_; } internal::NativeWidgetDelegate* delegate() { return delegate_; }
BridgedNativeWidget* bridge() const;
private: private:
friend class test::MockNativeWidgetMac; friend class test::MockNativeWidgetMac;
friend class test::HitTestNativeWidgetMac; friend class test::HitTestNativeWidgetMac;
internal::NativeWidgetDelegate* delegate_; internal::NativeWidgetDelegate* delegate_;
std::unique_ptr<BridgedNativeWidget> bridge_; std::unique_ptr<BridgedNativeWidgetHostImpl> bridge_host_;
Widget::InitParams::Ownership ownership_; Widget::InitParams::Ownership ownership_;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ui/native_theme/native_theme_mac.h" #include "ui/native_theme/native_theme_mac.h"
#import "ui/views/cocoa/bridged_content_view.h" #import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/bridged_native_widget.h" #import "ui/views/cocoa/bridged_native_widget.h"
#import "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/cocoa/cocoa_mouse_capture.h" #include "ui/views/cocoa/cocoa_mouse_capture.h"
#import "ui/views/cocoa/drag_drop_client_mac.h" #import "ui/views/cocoa/drag_drop_client_mac.h"
#import "ui/views/cocoa/native_widget_mac_nswindow.h" #import "ui/views/cocoa/native_widget_mac_nswindow.h"
...@@ -75,9 +76,8 @@ NSInteger StyleMaskForParams(const Widget::InitParams& params) { ...@@ -75,9 +76,8 @@ NSInteger StyleMaskForParams(const Widget::InitParams& params) {
NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate) NativeWidgetMac::NativeWidgetMac(internal::NativeWidgetDelegate* delegate)
: delegate_(delegate), : delegate_(delegate),
bridge_(new BridgedNativeWidget(this)), bridge_host_(new BridgedNativeWidgetHostImpl(this)),
ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) { ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) {}
}
NativeWidgetMac::~NativeWidgetMac() { NativeWidgetMac::~NativeWidgetMac() {
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
...@@ -93,13 +93,13 @@ BridgedNativeWidget* NativeWidgetMac::GetBridgeForNativeWindow( ...@@ -93,13 +93,13 @@ BridgedNativeWidget* NativeWidgetMac::GetBridgeForNativeWindow(
if ([window_delegate respondsToSelector:@selector(nativeWidgetMac)]) { if ([window_delegate respondsToSelector:@selector(nativeWidgetMac)]) {
ViewsNSWindowDelegate* delegate = ViewsNSWindowDelegate* delegate =
base::mac::ObjCCastStrict<ViewsNSWindowDelegate>(window_delegate); base::mac::ObjCCastStrict<ViewsNSWindowDelegate>(window_delegate);
return [delegate nativeWidgetMac]->bridge_.get(); return [delegate nativeWidgetMac]->bridge();
} }
return nullptr; // Not created by NativeWidgetMac. return nullptr; // Not created by NativeWidgetMac.
} }
bool NativeWidgetMac::IsWindowModalSheet() const { bool NativeWidgetMac::IsWindowModalSheet() const {
return bridge_ && bridge_->parent() && return bridge() && bridge()->parent() &&
GetWidget()->widget_delegate()->GetModalType() == GetWidget()->widget_delegate()->GetModalType() ==
ui::MODAL_TYPE_WINDOW; ui::MODAL_TYPE_WINDOW;
} }
...@@ -110,8 +110,8 @@ void NativeWidgetMac::WindowDestroying() { ...@@ -110,8 +110,8 @@ void NativeWidgetMac::WindowDestroying() {
} }
void NativeWidgetMac::WindowDestroyed() { void NativeWidgetMac::WindowDestroyed() {
DCHECK(bridge_); DCHECK(bridge());
bridge_.reset(); bridge_host_.reset();
delegate_->OnNativeWidgetDestroyed(); delegate_->OnNativeWidgetDestroyed();
if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
delete this; delete this;
...@@ -131,7 +131,7 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { ...@@ -131,7 +131,7 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
name_ = params.name; name_ = params.name;
base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]); base::scoped_nsobject<NSWindow> window([CreateNSWindow(params) retain]);
[window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject. [window setReleasedWhenClosed:NO]; // Owned by scoped_nsobject.
bridge_->Init(window, params); bridge()->Init(window, params);
// Only set always-on-top here if it is true since setting it may affect how // Only set always-on-top here if it is true since setting it may affect how
// the window is treated by Expose. // the window is treated by Expose.
...@@ -141,21 +141,21 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) { ...@@ -141,21 +141,21 @@ void NativeWidgetMac::InitNativeWidget(const Widget::InitParams& params) {
delegate_->OnNativeWidgetCreated(true); delegate_->OnNativeWidgetCreated(true);
DCHECK(GetWidget()->GetRootView()); DCHECK(GetWidget()->GetRootView());
bridge_->SetRootView(GetWidget()->GetRootView()); bridge()->SetRootView(GetWidget()->GetRootView());
if (auto* focus_manager = GetWidget()->GetFocusManager()) { if (auto* focus_manager = GetWidget()->GetFocusManager()) {
[window makeFirstResponder:bridge_->ns_view()]; [window makeFirstResponder:bridge()->ns_view()];
bridge_->SetFocusManager(focus_manager); bridge()->SetFocusManager(focus_manager);
} }
// "Infer" must be handled by ViewsDelegate::OnBeforeWidgetInit(). // "Infer" must be handled by ViewsDelegate::OnBeforeWidgetInit().
DCHECK_NE(Widget::InitParams::INFER_OPACITY, params.opacity); DCHECK_NE(Widget::InitParams::INFER_OPACITY, params.opacity);
bool translucent = params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW; bool translucent = params.opacity == Widget::InitParams::TRANSLUCENT_WINDOW;
bridge_->CreateLayer(params.layer_type, translucent); bridge()->CreateLayer(params.layer_type, translucent);
} }
void NativeWidgetMac::OnWidgetInitDone() { void NativeWidgetMac::OnWidgetInitDone() {
OnSizeConstraintsChanged(); OnSizeConstraintsChanged();
bridge_->OnWidgetInitDone(); bridge()->OnWidgetInitDone();
} }
NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() { NonClientFrameView* NativeWidgetMac::CreateNonClientFrameView() {
...@@ -193,7 +193,7 @@ gfx::NativeView NativeWidgetMac::GetNativeView() const { ...@@ -193,7 +193,7 @@ gfx::NativeView NativeWidgetMac::GetNativeView() const {
} }
gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const { gfx::NativeWindow NativeWidgetMac::GetNativeWindow() const {
return bridge_ ? bridge_->ns_window() : nil; return bridge() ? bridge()->ns_window() : nil;
} }
Widget* NativeWidgetMac::GetTopLevelWidget() { Widget* NativeWidgetMac::GetTopLevelWidget() {
...@@ -202,60 +202,60 @@ Widget* NativeWidgetMac::GetTopLevelWidget() { ...@@ -202,60 +202,60 @@ Widget* NativeWidgetMac::GetTopLevelWidget() {
} }
const ui::Compositor* NativeWidgetMac::GetCompositor() const { const ui::Compositor* NativeWidgetMac::GetCompositor() const {
return bridge_ && bridge_->layer() ? bridge_->layer()->GetCompositor() return bridge() && bridge()->layer() ? bridge()->layer()->GetCompositor()
: nullptr; : nullptr;
} }
const ui::Layer* NativeWidgetMac::GetLayer() const { const ui::Layer* NativeWidgetMac::GetLayer() const {
return bridge_ ? bridge_->layer() : nullptr; return bridge() ? bridge()->layer() : nullptr;
} }
void NativeWidgetMac::ReorderNativeViews() { void NativeWidgetMac::ReorderNativeViews() {
if (bridge_) if (bridge())
bridge_->ReorderChildViews(); bridge()->ReorderChildViews();
} }
void NativeWidgetMac::ViewRemoved(View* view) { void NativeWidgetMac::ViewRemoved(View* view) {
DragDropClientMac* client = bridge_ ? bridge_->drag_drop_client() : nullptr; DragDropClientMac* client = bridge() ? bridge()->drag_drop_client() : nullptr;
if (client) if (client)
client->drop_helper()->ResetTargetViewIfEquals(view); client->drop_helper()->ResetTargetViewIfEquals(view);
} }
void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) { void NativeWidgetMac::SetNativeWindowProperty(const char* name, void* value) {
if (bridge_) if (bridge())
bridge_->SetNativeWindowProperty(name, value); bridge()->SetNativeWindowProperty(name, value);
} }
void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const { void* NativeWidgetMac::GetNativeWindowProperty(const char* name) const {
if (bridge_) if (bridge())
return bridge_->GetNativeWindowProperty(name); return bridge()->GetNativeWindowProperty(name);
return nullptr; return nullptr;
} }
TooltipManager* NativeWidgetMac::GetTooltipManager() const { TooltipManager* NativeWidgetMac::GetTooltipManager() const {
if (bridge_) if (bridge())
return bridge_->tooltip_manager(); return bridge()->tooltip_manager();
return nullptr; return nullptr;
} }
void NativeWidgetMac::SetCapture() { void NativeWidgetMac::SetCapture() {
if (bridge_ && !bridge_->HasCapture()) if (bridge() && !bridge()->HasCapture())
bridge_->AcquireCapture(); bridge()->AcquireCapture();
} }
void NativeWidgetMac::ReleaseCapture() { void NativeWidgetMac::ReleaseCapture() {
if (bridge_) if (bridge())
bridge_->ReleaseCapture(); bridge()->ReleaseCapture();
} }
bool NativeWidgetMac::HasCapture() const { bool NativeWidgetMac::HasCapture() const {
return bridge_ && bridge_->HasCapture(); return bridge() && bridge()->HasCapture();
} }
ui::InputMethod* NativeWidgetMac::GetInputMethod() { ui::InputMethod* NativeWidgetMac::GetInputMethod() {
return bridge_ ? bridge_->GetInputMethod() : nullptr; return bridge() ? bridge()->GetInputMethod() : nullptr;
} }
void NativeWidgetMac::CenterWindow(const gfx::Size& size) { void NativeWidgetMac::CenterWindow(const gfx::Size& size) {
...@@ -307,7 +307,7 @@ void NativeWidgetMac::InitModalType(ui::ModalType modal_type) { ...@@ -307,7 +307,7 @@ void NativeWidgetMac::InitModalType(ui::ModalType modal_type) {
// A peculiarity of the constrained window framework is that it permits a // A peculiarity of the constrained window framework is that it permits a
// dialog of MODAL_TYPE_WINDOW to have a null parent window; falling back to // dialog of MODAL_TYPE_WINDOW to have a null parent window; falling back to
// a non-modal window in this case. // a non-modal window in this case.
DCHECK(bridge_->parent() || modal_type == ui::MODAL_TYPE_WINDOW); DCHECK(bridge()->parent() || modal_type == ui::MODAL_TYPE_WINDOW);
// Everything happens upon show. // Everything happens upon show.
} }
...@@ -323,7 +323,7 @@ gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const { ...@@ -323,7 +323,7 @@ gfx::Rect NativeWidgetMac::GetClientAreaBoundsInScreen() const {
} }
gfx::Rect NativeWidgetMac::GetRestoredBounds() const { gfx::Rect NativeWidgetMac::GetRestoredBounds() const {
return bridge_ ? bridge_->GetRestoredBounds() : gfx::Rect(); return bridge() ? bridge()->GetRestoredBounds() : gfx::Rect();
} }
std::string NativeWidgetMac::GetWorkspace() const { std::string NativeWidgetMac::GetWorkspace() const {
...@@ -331,18 +331,18 @@ std::string NativeWidgetMac::GetWorkspace() const { ...@@ -331,18 +331,18 @@ std::string NativeWidgetMac::GetWorkspace() const {
} }
void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) { void NativeWidgetMac::SetBounds(const gfx::Rect& bounds) {
if (bridge_) if (bridge())
bridge_->SetBounds(bounds); bridge()->SetBounds(bounds);
} }
void NativeWidgetMac::SetBoundsConstrained(const gfx::Rect& bounds) { void NativeWidgetMac::SetBoundsConstrained(const gfx::Rect& bounds) {
if (!bridge_) if (!bridge())
return; return;
gfx::Rect new_bounds(bounds); gfx::Rect new_bounds(bounds);
NativeWidgetPrivate* ancestor = NativeWidgetPrivate* ancestor =
bridge_ && bridge_->parent() bridge() && bridge()->parent()
? GetNativeWidgetForNativeWindow(bridge_->parent()->GetNSWindow()) ? GetNativeWidgetForNativeWindow(bridge()->parent()->GetNSWindow())
: nullptr; : nullptr;
if (!ancestor) { if (!ancestor) {
new_bounds = ConstrainBoundsToDisplayWorkArea(new_bounds); new_bounds = ConstrainBoundsToDisplayWorkArea(new_bounds);
...@@ -373,7 +373,7 @@ void NativeWidgetMac::SetShape(std::unique_ptr<Widget::ShapeRects> shape) { ...@@ -373,7 +373,7 @@ void NativeWidgetMac::SetShape(std::unique_ptr<Widget::ShapeRects> shape) {
} }
void NativeWidgetMac::Close() { void NativeWidgetMac::Close() {
if (!bridge_) if (!bridge())
return; return;
// Keep |window| on the stack so that the ObjectiveC block below can capture // Keep |window| on the stack so that the ObjectiveC block below can capture
...@@ -395,13 +395,13 @@ void NativeWidgetMac::Close() { ...@@ -395,13 +395,13 @@ void NativeWidgetMac::Close() {
} }
// For other modal types, animate the close. // For other modal types, animate the close.
if (bridge_->ShouldRunCustomAnimationFor(Widget::ANIMATE_HIDE)) { if (bridge()->ShouldRunCustomAnimationFor(Widget::ANIMATE_HIDE)) {
[ViewsNSWindowCloseAnimator closeWindowWithAnimation:window]; [ViewsNSWindowCloseAnimator closeWindowWithAnimation:window];
return; return;
} }
// Clear the view early to suppress repaints. // Clear the view early to suppress repaints.
bridge_->SetRootView(nullptr); bridge()->SetRootView(nullptr);
// Widget::Close() ensures [Non]ClientView::CanClose() returns true, so there // Widget::Close() ensures [Non]ClientView::CanClose() returns true, so there
// is no need to call the NSWindow or its delegate's -windowShouldClose: // is no need to call the NSWindow or its delegate's -windowShouldClose:
...@@ -420,7 +420,7 @@ void NativeWidgetMac::Close() { ...@@ -420,7 +420,7 @@ void NativeWidgetMac::Close() {
} }
void NativeWidgetMac::CloseNow() { void NativeWidgetMac::CloseNow() {
if (!bridge_) if (!bridge())
return; return;
// NSWindows must be retained until -[NSWindow close] returns. // NSWindows must be retained until -[NSWindow close] returns.
...@@ -438,10 +438,10 @@ void NativeWidgetMac::Show() { ...@@ -438,10 +438,10 @@ void NativeWidgetMac::Show() {
} }
void NativeWidgetMac::Hide() { void NativeWidgetMac::Hide() {
if (!bridge_) if (!bridge())
return; return;
bridge_->SetVisibilityState(BridgedNativeWidget::HIDE_WINDOW); bridge()->SetVisibilityState(BridgedNativeWidget::HIDE_WINDOW);
} }
void NativeWidgetMac::ShowMaximizedWithBounds( void NativeWidgetMac::ShowMaximizedWithBounds(
...@@ -450,7 +450,7 @@ void NativeWidgetMac::ShowMaximizedWithBounds( ...@@ -450,7 +450,7 @@ void NativeWidgetMac::ShowMaximizedWithBounds(
} }
void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) {
if (!bridge_) if (!bridge())
return; return;
switch (state) { switch (state) {
...@@ -467,7 +467,8 @@ void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { ...@@ -467,7 +467,8 @@ void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) {
NOTREACHED(); NOTREACHED();
break; break;
} }
bridge_->SetVisibilityState(state == ui::SHOW_STATE_INACTIVE bridge()->SetVisibilityState(
state == ui::SHOW_STATE_INACTIVE
? BridgedNativeWidget::SHOW_INACTIVE ? BridgedNativeWidget::SHOW_INACTIVE
: BridgedNativeWidget::SHOW_AND_ACTIVATE_WINDOW); : BridgedNativeWidget::SHOW_AND_ACTIVATE_WINDOW);
...@@ -477,14 +478,14 @@ void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) { ...@@ -477,14 +478,14 @@ void NativeWidgetMac::ShowWithWindowState(ui::WindowShowState state) {
} }
bool NativeWidgetMac::IsVisible() const { bool NativeWidgetMac::IsVisible() const {
return bridge_ && bridge_->window_visible(); return bridge() && bridge()->window_visible();
} }
void NativeWidgetMac::Activate() { void NativeWidgetMac::Activate() {
if (!bridge_) if (!bridge())
return; return;
bridge_->SetVisibilityState(BridgedNativeWidget::SHOW_AND_ACTIVATE_WINDOW); bridge()->SetVisibilityState(BridgedNativeWidget::SHOW_AND_ACTIVATE_WINDOW);
} }
void NativeWidgetMac::Deactivate() { void NativeWidgetMac::Deactivate() {
...@@ -541,14 +542,14 @@ void NativeWidgetMac::Restore() { ...@@ -541,14 +542,14 @@ void NativeWidgetMac::Restore() {
} }
void NativeWidgetMac::SetFullscreen(bool fullscreen) { void NativeWidgetMac::SetFullscreen(bool fullscreen) {
if (!bridge_ || fullscreen == IsFullscreen()) if (!bridge() || fullscreen == IsFullscreen())
return; return;
bridge_->ToggleDesiredFullscreenState(); bridge()->ToggleDesiredFullscreenState();
} }
bool NativeWidgetMac::IsFullscreen() const { bool NativeWidgetMac::IsFullscreen() const {
return bridge_ && bridge_->target_fullscreen_state(); return bridge() && bridge()->target_fullscreen_state();
} }
void NativeWidgetMac::SetOpacity(float opacity) { void NativeWidgetMac::SetOpacity(float opacity) {
...@@ -569,7 +570,7 @@ void NativeWidgetMac::RunShellDrag(View* view, ...@@ -569,7 +570,7 @@ void NativeWidgetMac::RunShellDrag(View* view,
const gfx::Point& location, const gfx::Point& location,
int operation, int operation,
ui::DragDropTypes::DragEventSource source) { ui::DragDropTypes::DragEventSource source) {
bridge_->drag_drop_client()->StartDragAndDrop(view, data, operation, source); bridge()->drag_drop_client()->StartDragAndDrop(view, data, operation, source);
} }
void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) {
...@@ -582,13 +583,13 @@ void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) { ...@@ -582,13 +583,13 @@ void NativeWidgetMac::SchedulePaintInRect(const gfx::Rect& rect) {
target_rect.origin.y = target_rect.origin.y =
NSHeight(client_rect) - target_rect.origin.y - NSHeight(target_rect); NSHeight(client_rect) - target_rect.origin.y - NSHeight(target_rect);
[GetNativeView() setNeedsDisplayInRect:target_rect]; [GetNativeView() setNeedsDisplayInRect:target_rect];
if (bridge_ && bridge_->layer()) if (bridge() && bridge()->layer())
bridge_->layer()->SchedulePaint(rect); bridge()->layer()->SchedulePaint(rect);
} }
void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) { void NativeWidgetMac::SetCursor(gfx::NativeCursor cursor) {
if (bridge_) if (bridge())
bridge_->SetCursor(cursor); bridge()->SetCursor(cursor);
} }
bool NativeWidgetMac::IsMouseEventsEnabled() const { bool NativeWidgetMac::IsMouseEventsEnabled() const {
...@@ -613,20 +614,20 @@ Widget::MoveLoopResult NativeWidgetMac::RunMoveLoop( ...@@ -613,20 +614,20 @@ Widget::MoveLoopResult NativeWidgetMac::RunMoveLoop(
const gfx::Vector2d& drag_offset, const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source, Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) { Widget::MoveLoopEscapeBehavior escape_behavior) {
if (!bridge_) if (!bridge())
return Widget::MOVE_LOOP_CANCELED; return Widget::MOVE_LOOP_CANCELED;
return bridge_->RunMoveLoop(drag_offset); return bridge()->RunMoveLoop(drag_offset);
} }
void NativeWidgetMac::EndMoveLoop() { void NativeWidgetMac::EndMoveLoop() {
if (bridge_) if (bridge())
bridge_->EndMoveLoop(); bridge()->EndMoveLoop();
} }
void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) { void NativeWidgetMac::SetVisibilityChangedAnimationsEnabled(bool value) {
if (bridge_) if (bridge())
bridge_->SetAnimationEnabled(value); bridge()->SetAnimationEnabled(value);
} }
void NativeWidgetMac::SetVisibilityAnimationDuration( void NativeWidgetMac::SetVisibilityAnimationDuration(
...@@ -636,8 +637,8 @@ void NativeWidgetMac::SetVisibilityAnimationDuration( ...@@ -636,8 +637,8 @@ void NativeWidgetMac::SetVisibilityAnimationDuration(
void NativeWidgetMac::SetVisibilityAnimationTransition( void NativeWidgetMac::SetVisibilityAnimationTransition(
Widget::VisibilityTransition transition) { Widget::VisibilityTransition transition) {
if (bridge_) if (bridge())
bridge_->set_transitions_to_animate(transition); bridge()->set_transitions_to_animate(transition);
} }
bool NativeWidgetMac::IsTranslucentWindowOpacitySupported() const { bool NativeWidgetMac::IsTranslucentWindowOpacitySupported() const {
...@@ -645,7 +646,7 @@ bool NativeWidgetMac::IsTranslucentWindowOpacitySupported() const { ...@@ -645,7 +646,7 @@ bool NativeWidgetMac::IsTranslucentWindowOpacitySupported() const {
} }
void NativeWidgetMac::OnSizeConstraintsChanged() { void NativeWidgetMac::OnSizeConstraintsChanged() {
bridge_->OnSizeConstraintsChanged(); bridge()->OnSizeConstraintsChanged();
} }
void NativeWidgetMac::RepostNativeEvent(gfx::NativeEvent native_event) { void NativeWidgetMac::RepostNativeEvent(gfx::NativeEvent native_event) {
...@@ -668,6 +669,10 @@ NativeWidgetMacNSWindow* NativeWidgetMac::CreateNSWindow( ...@@ -668,6 +669,10 @@ NativeWidgetMacNSWindow* NativeWidgetMac::CreateNSWindow(
defer:NO] autorelease]; defer:NO] autorelease];
} }
BridgedNativeWidget* NativeWidgetMac::bridge() const {
return bridge_host_ ? bridge_host_->bridge() : nullptr;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Widget, public: // Widget, public:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment