Commit 6c37e934 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Move sources to views_bridge_mac component

The views_bridge_mac directory contains the Cocoa front-end of the
macOS implementation of the views framework.

Start moving sources from ui/views/cocoa that have no dependencies
on ui/views over to this component.

Eventually the app shim process on macOS will only require this
component (and views will exist entirely in the browser process).

Bug: 821651
Change-Id: I215acfa0620154771cd039fe593d43fb068d51cb
Reviewed-on: https://chromium-review.googlesource.com/1241199
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593816}
parent c6e0f95b
......@@ -445,13 +445,9 @@ jumbo_component("views") {
"cocoa/bridged_content_view.h",
"cocoa/bridged_content_view.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/cocoa_mouse_capture.h",
"cocoa/cocoa_mouse_capture.mm",
"cocoa/cocoa_mouse_capture_delegate.h",
"cocoa/cocoa_window_move_loop.h",
"cocoa/cocoa_window_move_loop.mm",
"cocoa/drag_drop_client_mac.h",
......@@ -740,6 +736,7 @@ jumbo_component("views") {
"//components/crash/core/common",
"//ui/accelerated_widget_mac",
"//ui/events:dom_keycode_converter",
"//ui/views_bridge_mac",
]
public_deps += [ "//ui/views_bridge_mac:mojo" ]
libs = [
......@@ -1117,7 +1114,10 @@ source_set("views_unittests_sources") {
if (is_mac) {
# views_unittests not yet compiling on Mac. http://crbug.com/378134
sources -= [ "controls/native/native_view_host_unittest.cc" ]
public_deps += [ "//ui/accelerated_widget_mac" ]
public_deps += [
"//ui/accelerated_widget_mac",
"//ui/views_bridge_mac:views_bridge_mac",
]
}
}
......
......@@ -6,7 +6,7 @@
#include "base/no_destructor.h"
#include "ui/views/cocoa/bridged_native_widget.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
namespace views_bridge_mac {
......
......@@ -32,8 +32,8 @@
#import "ui/gfx/path_mac.h"
#include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
#import "ui/views/cocoa/bridged_native_widget.h"
#import "ui/views/cocoa/bridged_native_widget_host.h"
#import "ui/views/cocoa/drag_drop_client_mac.h"
#include "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
namespace {
......
......@@ -19,10 +19,10 @@
#include "ui/base/ime/text_input_client.h"
#include "ui/display/display_observer.h"
#import "ui/views/cocoa/bridged_native_widget_owner.h"
#import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
#import "ui/views/focus/focus_manager.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/widget.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture_delegate.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget.mojom.h"
@class BridgedContentView;
......@@ -31,9 +31,14 @@
@class ViewsNSWindowDelegate;
namespace views_bridge_mac {
namespace mojom {
class BridgedNativeWidgetHost;
} // namespace mojom
class CocoaMouseCapture;
class BridgedNativeWidgetHostHelper;
} // namespace views_bridge_mac
namespace views {
......@@ -41,13 +46,14 @@ namespace test {
class BridgedNativeWidgetTestApi;
}
class BridgedNativeWidgetHostHelper;
class CocoaMouseCapture;
class CocoaWindowMoveLoop;
class DragDropClientMac;
class View;
using views_bridge_mac::mojom::BridgedNativeWidgetHost;
using views_bridge_mac::BridgedNativeWidgetHostHelper;
using views_bridge_mac::CocoaMouseCapture;
using views_bridge_mac::CocoaMouseCaptureDelegate;
// A bridge to an NSWindow managed by an instance of NativeWidgetMac or
// DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
......
......@@ -28,13 +28,13 @@
#import "ui/gfx/mac/nswindow_frame_controls.h"
#import "ui/native_theme/native_theme_mac.h"
#import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/bridged_native_widget_host.h"
#import "ui/views/cocoa/cocoa_mouse_capture.h"
#import "ui/views/cocoa/cocoa_window_move_loop.h"
#import "ui/views/cocoa/drag_drop_client_mac.h"
#import "ui/views/cocoa/native_widget_mac_nswindow.h"
#import "ui/views/cocoa/views_nswindow_delegate.h"
#import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
#import "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
using views_bridge_mac::mojom::WindowVisibilityState;
......
......@@ -15,11 +15,11 @@
#include "ui/base/ime/input_method_delegate.h"
#include "ui/compositor/layer_owner.h"
#include "ui/views/cocoa/bridge_factory_host.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_observer.h"
#include "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget.mojom.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
......@@ -39,7 +39,7 @@ class NativeWidgetMac;
// communicates to the BridgedNativeWidgetImpl, which interacts with the Cocoa
// APIs, and which may live in an app shim process.
class VIEWS_EXPORT BridgedNativeWidgetHostImpl
: public BridgedNativeWidgetHostHelper,
: public views_bridge_mac::BridgedNativeWidgetHostHelper,
public BridgeFactoryHost::Observer,
public views_bridge_mac::mojom::BridgedNativeWidgetHost,
public DialogObserver,
......@@ -172,6 +172,9 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
bool IsWindowKey() const { return is_window_key_; }
bool IsMouseCaptureActive() const { return is_mouse_capture_active_; }
// Used by NativeWidgetPrivate::GetGlobalCapture.
static NSView* GetGlobalCaptureView();
private:
gfx::Vector2d GetBoundsOffsetForParent() const;
void UpdateCompositorProperties();
......
......@@ -24,6 +24,7 @@
#include "ui/views/window/dialog_client_view.h"
#include "ui/views/window/dialog_delegate.h"
#include "ui/views/word_lookup_client.h"
#include "ui/views_bridge_mac/cocoa_mouse_capture.h"
using views_bridge_mac::mojom::BridgedNativeWidgetInitParams;
using views_bridge_mac::mojom::WindowVisibilityState;
......@@ -419,8 +420,14 @@ void BridgedNativeWidgetHostImpl::RankNSViewsRecursive(
RankNSViewsRecursive(view->child_at(i), rank);
}
// static
NSView* BridgedNativeWidgetHostImpl::GetGlobalCaptureView() {
// TODO(ccameron): This will not work across process boundaries.
return [CocoaMouseCapture::GetGlobalCaptureWindow() contentView];
}
////////////////////////////////////////////////////////////////////////////////
// BridgedNativeWidgetHostImpl, views::BridgedNativeWidgetHostHelper:
// BridgedNativeWidgetHostImpl, views_bridge_mac::BridgedNativeWidgetHostHelper:
NSView* BridgedNativeWidgetHostImpl::GetNativeViewAccessible() {
return root_view_ ? root_view_->GetNativeViewAccessible() : nil;
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ui/views/cocoa/cocoa_mouse_capture.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture.h"
#import <Cocoa/Cocoa.h>
......@@ -10,7 +10,7 @@
#include "base/macros.h"
#import "ui/base/test/cocoa_helper.h"
#import "ui/events/test/cocoa_test_event_utils.h"
#import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture_delegate.h"
// Simple test view that counts calls to -[NSView mouseDown:].
@interface CocoaMouseCaptureTestView : NSView {
......@@ -30,7 +30,7 @@
@end
namespace views {
namespace views_bridge_mac {
namespace {
// Simple capture delegate that just counts events forwarded.
......@@ -128,4 +128,4 @@ TEST_F(CocoaMouseCaptureTest, CaptureEvents) {
EXPECT_EQ(2, [view mouseDownCount]);
}
} // namespace views
} // namespace views_bridge_mac
......@@ -9,10 +9,10 @@
#import "ui/base/cocoa/user_interface_item_command_handler.h"
#import "ui/base/cocoa/window_size_constants.h"
#import "ui/views/cocoa/bridged_native_widget.h"
#import "ui/views/cocoa/bridged_native_widget_host.h"
#import "ui/views/cocoa/views_nswindow_delegate.h"
#import "ui/views/cocoa/window_touch_bar_delegate.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
@interface NSWindow (Private)
......
......@@ -9,7 +9,7 @@
#include "base/threading/thread_task_runner_handle.h"
#import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/bridged_native_widget.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views_bridge_mac/bridged_native_widget_host_helper.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
@implementation ViewsNSWindowDelegate
......
......@@ -27,7 +27,6 @@
#import "ui/views/cocoa/bridged_content_view.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"
#import "ui/views/cocoa/drag_drop_client_mac.h"
#import "ui/views/cocoa/native_widget_mac_nswindow.h"
#import "ui/views/cocoa/views_nswindow_delegate.h"
......@@ -826,7 +825,7 @@ gfx::FontList NativeWidgetPrivate::GetWindowTitleFontList() {
// static
gfx::NativeView NativeWidgetPrivate::GetGlobalCapture(
gfx::NativeView native_view) {
return [CocoaMouseCapture::GetGlobalCaptureWindow() contentView];
return BridgedNativeWidgetHostImpl::GetGlobalCaptureView();
}
} // namespace internal
......
......@@ -4,6 +4,26 @@
import("//mojo/public/tools/bindings/mojom.gni")
component("views_bridge_mac") {
assert(is_mac)
sources = [
"bridged_native_widget_host_helper.h",
"cocoa_mouse_capture.h",
"cocoa_mouse_capture.mm",
"cocoa_mouse_capture_delegate.h",
"views_bridge_mac_export.h",
]
defines = [ "VIEWS_BRIDGE_MAC_IMPLEMENTATION" ]
deps = [
"//base",
"//ui/base",
"//ui/events",
"//ui/gfx",
]
libs = [ "Cocoa.framework" ]
}
mojom("mojo") {
assert(is_mac)
......
include_rules = [
"+ui/base",
"+ui/events",
"+ui/gfx",
]
......@@ -2,24 +2,24 @@
// 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_
#ifndef UI_VIEWS_BRIDGE_MAC_BRIDGED_NATIVE_WIDGET_HOST_HELPER_H_
#define UI_VIEWS_BRIDGE_MAC_BRIDGED_NATIVE_WIDGET_HOST_HELPER_H_
#include "ui/base/ui_base_types.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/decorated_text.h"
#include "ui/gfx/geometry/point.h"
#include "ui/views/views_export.h"
#include "ui/views_bridge_mac/views_bridge_mac_export.h"
@class NSView;
namespace views {
namespace views_bridge_mac {
// This is a helper class for the mojo interface BridgedNativeWidgetHost.
// This provides an easier-to-use interface than the mojo for selected
// functions. It also is temporarily exposing functionality that is not yet
// implemented over mojo.
class VIEWS_EXPORT BridgedNativeWidgetHostHelper {
class VIEWS_BRIDGE_MAC_EXPORT BridgedNativeWidgetHostHelper {
public:
virtual ~BridgedNativeWidgetHostHelper() = default;
......@@ -56,6 +56,6 @@ class VIEWS_EXPORT BridgedNativeWidgetHostHelper {
virtual double SheetPositionY() = 0;
};
} // namespace views
} // namespace views_bridge_mac
#endif // UI_VIEWS_COCOA_BRIDGED_NATIVE_WIDGET_HOST_H_
#endif // UI_VIEWS_BRIDGE_MAC_BRIDGED_NATIVE_WIDGET_HOST_HELPER_H_
......@@ -2,17 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
#define UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
#ifndef UI_VIEWS_BRIDGE_MAC_COCOA_MOUSE_CAPTURE_H_
#define UI_VIEWS_BRIDGE_MAC_COCOA_MOUSE_CAPTURE_H_
#include <memory>
#include "base/macros.h"
#include "ui/views/views_export.h"
#include "ui/views_bridge_mac/views_bridge_mac_export.h"
@class NSWindow;
namespace views {
namespace views_bridge_mac {
class CocoaMouseCaptureDelegate;
......@@ -21,7 +21,7 @@ class CocoaMouseCaptureDelegate;
// menu should dismiss the menu and "swallow" the mouse event. All events are
// forwarded, but only events to the same application are "swallowed", which is
// consistent with how native NSMenus behave.
class VIEWS_EXPORT CocoaMouseCapture {
class VIEWS_BRIDGE_MAC_EXPORT CocoaMouseCapture {
public:
explicit CocoaMouseCapture(CocoaMouseCaptureDelegate* delegate);
~CocoaMouseCapture();
......@@ -48,6 +48,6 @@ class VIEWS_EXPORT CocoaMouseCapture {
DISALLOW_COPY_AND_ASSIGN(CocoaMouseCapture);
};
} // namespace views
} // namespace views_bridge_mac
#endif // UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_H_
......@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ui/views/cocoa/cocoa_mouse_capture.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture.h"
#import <Cocoa/Cocoa.h>
#include "base/logging.h"
#include "base/macros.h"
#include "ui/base/cocoa/weak_ptr_nsobject.h"
#import "ui/views/cocoa/cocoa_mouse_capture_delegate.h"
#import "ui/views_bridge_mac/cocoa_mouse_capture_delegate.h"
namespace views {
namespace views_bridge_mac {
// The ActiveEventTap is a RAII handle on the resources being used to capture
// events. There is either 0 or 1 active instance of this class. If a second
......@@ -125,4 +125,4 @@ void CocoaMouseCapture::OnOtherClientGotCapture() {
active_handle_.reset();
}
} // namespace views
} // namespace views_bridge_mac
......@@ -2,13 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_DELEGATE_H_
#define UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_DELEGATE_H_
#ifndef UI_VIEWS_BRIDGE_MAC_COCOA_MOUSE_CAPTURE_DELEGATE_H_
#define UI_VIEWS_BRIDGE_MAC_COCOA_MOUSE_CAPTURE_DELEGATE_H_
@class NSEvent;
@class NSWindow;
namespace views {
namespace views_bridge_mac {
// Delegate for receiving captured events from a CocoaMouseCapture.
class CocoaMouseCaptureDelegate {
......@@ -26,6 +26,6 @@ class CocoaMouseCaptureDelegate {
virtual NSWindow* GetWindow() const = 0;
};
} // namespace views
} // namespace views_bridge_mac
#endif // UI_VIEWS_COCOA_COCOA_MOUSE_CAPTURE_DELEGATE_H_
#endif // UI_VIEWS_BRIDGE_MAC_COCOA_MOUSE_CAPTURE_DELEGATE_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_BRIDGE_MAC_VIEWS_BRIDGE_MAC_EXPORT_H_
#define UI_VIEWS_BRIDGE_MAC_VIEWS_BRIDGE_MAC_EXPORT_H_
// Defines VIEWS_BRIDGE_MAC_EXPORT so that functionality implemented by the
// RemoteMacViews module can be exported to consumers.
#if defined(COMPONENT_BUILD)
#if defined(WIN32)
#if defined(VIEWS_BRIDGE_MAC_IMPLEMENTATION)
#define VIEWS_BRIDGE_MAC_EXPORT __declspec(dllexport)
#else
#define VIEWS_BRIDGE_MAC_EXPORT __declspec(dllimport)
#endif // defined(VIEWS_BRIDGE_MAC_IMPLEMENTATION)
#else // defined(WIN32)
#if defined(VIEWS_BRIDGE_MAC_IMPLEMENTATION)
#define VIEWS_BRIDGE_MAC_EXPORT __attribute__((visibility("default")))
#else
#define VIEWS_BRIDGE_MAC_EXPORT
#endif
#endif
#else // defined(COMPONENT_BUILD)
#define VIEWS_BRIDGE_MAC_EXPORT
#endif
#endif // UI_VIEWS_BRIDGE_MAC_VIEWS_BRIDGE_MAC_EXPORT_H_
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