Commit 5ff407e1 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Mojo-ify BridgedNativeWidgetHost

Take the existing BridgedNativeWidgetHost and break it into two parts
- a mojo interface views_bridge_mac::mojo::BridgedNativeWidgetHost
- a helper and "stuff we haven't mojo-ified-yet" interface
  BridgedNativeWidgetHostHelper
  - this is not named BridgedNativeWidgetHost to avoid conflicts
  - this will be moved to //ui/views_bridge_mac soon (build is tangled)

Add mojo support for ui::DialogButton, because it's used by this
interface.

For keyboard event handling, use the BridgedNativeWidgetHostHelper
interface because a mojo-compatible interface would be hard for the
callers to use.

Bug: 859152
Change-Id: If6802ab4d6e518184cd3fa57eef5d8a510b80e59
Reviewed-on: https://chromium-review.googlesource.com/1198014Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: ccameron <ccameron@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588144}
parent f8c5470d
......@@ -4,6 +4,13 @@
module ui.mojom;
// Dialog button identifiers used to specify which buttons to show the user.
enum DialogButton {
NONE,
OK,
CANCEL,
};
// Specifies the type of modality applied to a window. Different modal
// treatments may be handled differently by the window manager.
enum ModalType {
......
......@@ -9,4 +9,7 @@ public_deps = [
"//ui/base",
]
traits_headers = [ "//ui/base/mojo/ui_base_types_struct_traits.h" ]
type_mappings = [ "ui.mojom.ModalType=ui::ModalType" ]
type_mappings = [
"ui.mojom.DialogButton=ui::DialogButton",
"ui.mojom.ModalType=ui::ModalType",
]
......@@ -11,6 +11,41 @@
namespace mojo {
template <>
struct EnumTraits<ui::mojom::DialogButton, ui::DialogButton> {
static ui::mojom::DialogButton ToMojom(ui::DialogButton modal_type) {
switch (modal_type) {
case ui::DIALOG_BUTTON_NONE:
return ui::mojom::DialogButton::NONE;
case ui::DIALOG_BUTTON_OK:
return ui::mojom::DialogButton::OK;
case ui::DIALOG_BUTTON_CANCEL:
return ui::mojom::DialogButton::CANCEL;
default:
NOTREACHED();
return ui::mojom::DialogButton::NONE;
}
}
static bool FromMojom(ui::mojom::DialogButton modal_type,
ui::DialogButton* out) {
switch (modal_type) {
case ui::mojom::DialogButton::NONE:
*out = ui::DIALOG_BUTTON_NONE;
return true;
case ui::mojom::DialogButton::OK:
*out = ui::DIALOG_BUTTON_OK;
return true;
case ui::mojom::DialogButton::CANCEL:
*out = ui::DIALOG_BUTTON_CANCEL;
return true;
default:
NOTREACHED();
return false;
}
}
};
template <>
struct EnumTraits<ui::mojom::ModalType, ui::ModalType> {
static ui::mojom::ModalType ToMojom(ui::ModalType modal_type) {
......
......@@ -37,6 +37,7 @@
#include "ui/views/view.h"
#include "ui/views/widget/native_widget_mac.h"
#include "ui/views/widget/widget.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
namespace {
......@@ -423,13 +424,13 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
[self updateTooltipIfRequiredAt:event_location];
if (isScrollEvent) {
ui::ScrollEvent event(theEvent);
event.set_location(event_location);
bridge_->host()->OnScrollEvent(event);
auto event = std::make_unique<ui::ScrollEvent>(theEvent);
event->set_location(event_location);
bridge_->host()->OnScrollEvent(std::move(event));
} else {
ui::MouseEvent event(theEvent);
event.set_location(event_location);
bridge_->host()->OnMouseEvent(event);
auto event = std::make_unique<ui::MouseEvent>(theEvent);
event->set_location(event_location);
bridge_->host()->OnMouseEvent(std::move(event));
}
}
......@@ -453,11 +454,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
// BridgedContentView private implementation.
- (void)dispatchKeyEvent:(ui::KeyEvent*)event {
bool eventHandled = false;
if (bridge_)
bridge_->host()->DispatchKeyEvent(*event, &eventHandled);
if (eventHandled)
event->SetHandled();
bridge_->host_helper()->DispatchKeyEvent(event);
}
- (BOOL)hasActiveMenuController {
......@@ -468,15 +466,9 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
}
- (BOOL)dispatchKeyEventToMenuController:(ui::KeyEvent*)event {
bool eventSwallowed = false;
bool eventHandled = false;
if (bridge_) {
bridge_->host()->DispatchKeyEventToMenuController(*event, &eventSwallowed,
&eventHandled);
}
if (eventHandled)
event->SetHandled();
return eventSwallowed;
if (bridge_)
return bridge_->host_helper()->DispatchKeyEventToMenuController(event);
return false;
}
- (void)handleKeyEvent:(ui::KeyEvent*)event {
......@@ -691,13 +683,13 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
return;
DCHECK([theEvent type] != NSScrollWheel);
ui::MouseEvent event(theEvent);
[self adjustUiEventLocation:&event fromNativeEvent:theEvent];
auto event = std::make_unique<ui::MouseEvent>(theEvent);
[self adjustUiEventLocation:event.get() fromNativeEvent:theEvent];
// Aura updates tooltips with the help of aura::Window::AddPreTargetHandler().
// Mac hooks in here.
[self updateTooltipIfRequiredAt:event.location()];
bridge_->host()->OnMouseEvent(event);
[self updateTooltipIfRequiredAt:event->location()];
bridge_->host()->OnMouseEvent(std::move(event));
}
- (void)forceTouchEvent:(NSEvent*)theEvent {
......@@ -860,13 +852,13 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
if (!bridge_)
return;
ui::ScrollEvent event(theEvent);
[self adjustUiEventLocation:&event fromNativeEvent:theEvent];
auto event = std::make_unique<ui::ScrollEvent>(theEvent);
[self adjustUiEventLocation:event.get() fromNativeEvent:theEvent];
// Aura updates tooltips with the help of aura::Window::AddPreTargetHandler().
// Mac hooks in here.
[self updateTooltipIfRequiredAt:event.location()];
bridge_->host()->OnScrollEvent(event);
[self updateTooltipIfRequiredAt:event->location()];
bridge_->host()->OnScrollEvent(std::move(event));
}
// Called when we get a three-finger swipe, and they're enabled in System
......@@ -890,10 +882,10 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
// Note this uses the default unique_touch_event_id of 0 (Swipe events do not
// support -[NSEvent eventNumber]). This doesn't seem like a real omission
// because the three-finger swipes are instant and can't be tracked anyway.
ui::GestureEvent gestureEvent(location.x(), location.y(),
ui::EventFlagsFromNative(event),
ui::EventTimeFromNative(event), swipeDetails);
bridge_->host()->OnGestureEvent(gestureEvent);
auto gestureEvent = std::make_unique<ui::GestureEvent>(
location.x(), location.y(), ui::EventFlagsFromNative(event),
ui::EventTimeFromNative(event), swipeDetails);
bridge_->host()->OnGestureEvent(std::move(gestureEvent));
}
- (void)quickLookWithEvent:(NSEvent*)theEvent {
......@@ -906,8 +898,8 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
bool foundWord = false;
gfx::DecoratedText decoratedWord;
gfx::Point baselinePoint;
bridge_->host()->GetWordAt(locationInContent, &foundWord, &decoratedWord,
&baselinePoint);
bridge_->host_helper()->GetWordAt(locationInContent, &foundWord,
&decoratedWord, &baselinePoint);
if (!foundWord)
return;
......@@ -1536,21 +1528,21 @@ ui::TextEditCommand GetTextEditCommandForMenuAction(SEL action) {
- (id)accessibilityAttributeValue:(NSString*)attribute {
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
return @[ bridge_->host()->GetNativeViewAccessible() ];
return @[ bridge_->host_helper()->GetNativeViewAccessible() ];
}
return [super accessibilityAttributeValue:attribute];
}
- (id)accessibilityHitTest:(NSPoint)point {
return
[bridge_->host()->GetNativeViewAccessible() accessibilityHitTest:point];
return [bridge_->host_helper()->GetNativeViewAccessible()
accessibilityHitTest:point];
}
- (id)accessibilityFocusedUIElement {
if (!bridge_)
return nil;
return [bridge_->host()->GetNativeViewAccessible()
return [bridge_->host_helper()->GetNativeViewAccessible()
accessibilityFocusedUIElement];
}
......
......@@ -9,7 +9,7 @@
#import "ui/base/cocoa/touch_bar_forward_declarations.h"
#import "ui/views/cocoa/bridged_content_view.h"
#import "ui/views/cocoa/bridged_native_widget.h"
#import "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
namespace {
......
......@@ -29,18 +29,26 @@
@class NativeWidgetMacNSWindow;
@class ViewsNSWindowDelegate;
namespace views_bridge_mac {
namespace mojom {
class BridgedNativeWidgetHost;
} // namespace mojom
} // namespace views_bridge_mac
namespace views {
namespace test {
class BridgedNativeWidgetTestApi;
}
class BridgedNativeWidgetHost;
class BridgedNativeWidgetHostHelper;
class CocoaMouseCapture;
class CocoaWindowMoveLoop;
class DragDropClientMac;
class NativeWidgetMac;
class View;
using views_bridge_mac::mojom::BridgedNativeWidgetHost;
// A bridge to an NSWindow managed by an instance of NativeWidgetMac or
// DesktopNativeWidgetMac. Serves as a helper class to bridge requests from the
// NativeWidgetMac to the Cocoa window. Behaves a bit like an aura::Window.
......@@ -60,7 +68,9 @@ class VIEWS_EXPORT BridgedNativeWidget
const gfx::Size& size);
// Creates one side of the bridge. |host| and |parent| must not be NULL.
BridgedNativeWidget(BridgedNativeWidgetHost* host, NativeWidgetMac* parent);
BridgedNativeWidget(BridgedNativeWidgetHost* host,
BridgedNativeWidgetHostHelper* host_helper,
NativeWidgetMac* parent);
~BridgedNativeWidget() override;
// Initialize the NSWindow by taking ownership of the specified object.
......@@ -151,6 +161,7 @@ class VIEWS_EXPORT BridgedNativeWidget
NativeWidgetMac* native_widget_mac() { return native_widget_mac_; }
BridgedContentView* ns_view() { return bridged_view_; }
BridgedNativeWidgetHost* host() { return host_; }
BridgedNativeWidgetHostHelper* host_helper() { return host_helper_; }
NSWindow* ns_window();
TooltipManager* tooltip_manager() { return tooltip_manager_.get(); }
......@@ -280,7 +291,8 @@ class VIEWS_EXPORT BridgedNativeWidget
bool IsVisibleParent() const override;
void RemoveChildWindow(BridgedNativeWidget* child) override;
BridgedNativeWidgetHost* const host_; // Weak. Owns this.
BridgedNativeWidgetHost* const host_; // Weak. Owns this.
BridgedNativeWidgetHostHelper* const host_helper_; // Weak, owned by |host_|.
NativeWidgetMac* const native_widget_mac_; // Weak. Owns |host_|.
base::scoped_nsobject<NativeWidgetMacNSWindow> window_;
base::scoped_nsobject<ViewsNSWindowDelegate> window_delegate_;
......
......@@ -35,6 +35,7 @@
#import "ui/views/cocoa/widget_owner_nswindow_adapter.h"
#include "ui/views/widget/native_widget_mac.h"
#include "ui/views/widget/widget.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
using views_bridge_mac::mojom::WindowVisibilityState;
......@@ -236,9 +237,11 @@ gfx::Size BridgedNativeWidget::GetWindowSizeForClientSize(
return gfx::Size(NSWidth(frame_rect), NSHeight(frame_rect));
}
BridgedNativeWidget::BridgedNativeWidget(BridgedNativeWidgetHost* host,
NativeWidgetMac* parent)
: host_(host), native_widget_mac_(parent) {
BridgedNativeWidget::BridgedNativeWidget(
BridgedNativeWidgetHost* host,
BridgedNativeWidgetHostHelper* host_helper,
NativeWidgetMac* parent)
: host_(host), host_helper_(host_helper), native_widget_mac_(parent) {
DCHECK(parent);
window_delegate_.reset(
[[ViewsNSWindowDelegate alloc] initWithBridgedNativeWidget:this]);
......
......@@ -9,18 +9,19 @@
#include "ui/events/event_utils.h"
#include "ui/gfx/decorated_text.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/views_export.h"
@class NSView;
namespace views {
// The interface through which the app shim (BridgedNativeWidgetImpl)
// communicates with the browser process (BridgedNativeWidgetHostImpl).
class VIEWS_EXPORT BridgedNativeWidgetHost {
// 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 {
public:
virtual ~BridgedNativeWidgetHost() = default;
virtual ~BridgedNativeWidgetHostHelper() = default;
// Retrieve the NSView for accessibility for this widget.
// TODO(ccameron): This interface cannot be implemented over IPC. A scheme
......@@ -28,123 +29,25 @@ class VIEWS_EXPORT BridgedNativeWidgetHost {
// implemented.
virtual NSView* GetNativeViewAccessible() = 0;
// Update the views::Widget, ui::Compositor and ui::Layer's visibility.
virtual void OnVisibilityChanged(bool visible) = 0;
// Synchronously dispatch a key event. Note that this function will modify
// |event| based on whether or not it was handled.
virtual void DispatchKeyEvent(ui::KeyEvent* event) = 0;
// Resize the underlying views::View to |new_size|. Note that this will not
// necessarily match the content bounds from OnWindowGeometryChanged.
virtual void SetViewSize(const gfx::Size& new_size) = 0;
// Indicate if full keyboard accessibility is needed and updates focus if
// needed.
virtual void SetKeyboardAccessible(bool enabled) = 0;
// Indicate if the NSView is the first responder.
virtual void SetIsFirstResponder(bool is_first_responder) = 0;
// Indicate if mouse capture is active.
virtual void OnMouseCaptureActiveChanged(bool capture_is_active) = 0;
// Handle events. Note that whether or not the event is actually handled is
// not returned.
virtual void OnScrollEvent(const ui::ScrollEvent& const_event) = 0;
virtual void OnMouseEvent(const ui::MouseEvent& const_event) = 0;
virtual void OnGestureEvent(const ui::GestureEvent& const_event) = 0;
// Synchronously dispatch a key event and return in |event_handled| whether
// or not the event was handled.
virtual void DispatchKeyEvent(const ui::KeyEvent& const_event,
bool* event_handled) = 0;
// Synchronously dispatch a key event to the current menu controller (if any)
// exists. Return in |event_swallowed| whether or not the event was swallowed
// (that is, if the menu's dispatch returned POST_DISPATCH_NONE). Return in
// in |event_handled| whether or not the event was handled (that is, if the
// event in the caller's frame should be marked as handled).
virtual void DispatchKeyEventToMenuController(const ui::KeyEvent& const_event,
bool* event_swallowed,
bool* event_handled) = 0;
// Synchronously return in |has_menu_controller| whether or not a menu
// controller exists for this widget.
virtual void GetHasMenuController(bool* has_menu_controller) = 0;
// Synchronously query if |location_in_content| is a draggable background.
virtual void GetIsDraggableBackgroundAt(const gfx::Point& location_in_content,
bool* is_draggable_background) = 0;
// Synchronously query the tooltip text for |location_in_content|.
virtual void GetTooltipTextAt(const gfx::Point& location_in_content,
base::string16* new_tooltip_text) = 0;
// Synchronously dispatch a key event to the current menu controller (if one
// exists and it is owned by the widget for this). Return true if the event
// was swallowed (that is, if the menu's dispatch returned
// POST_DISPATCH_NONE). Note that this function will modify |event| based on
// whether or not it was handled.
virtual bool DispatchKeyEventToMenuController(ui::KeyEvent* event) = 0;
// Synchronously query the quicklook text at |location_in_content|. Return in
// |found_word| whether or not a word was found.
// TODO(ccameron): This needs gfx::DecoratedText to be mojo-ified before it
// can be done over mojo.
virtual void GetWordAt(const gfx::Point& location_in_content,
bool* found_word,
gfx::DecoratedText* decorated_word,
gfx::Point* baseline_point) = 0;
// Synchronously query the value of IsModal for this widget and store it in
// |*widget_is_modal|.
virtual void GetWidgetIsModal(bool* widget_is_modal) = 0;
// Synchronously return in |is_textual| whether or not the focused view
// contains text that can be selected and copied.
virtual void GetIsFocusedViewTextual(bool* is_textual) = 0;
// Called whenever the NSWindow's size or position changes.
virtual void OnWindowGeometryChanged(
const gfx::Rect& window_bounds_in_screen_dips,
const gfx::Rect& content_bounds_in_screen_dips) = 0;
// Called when the window begins transitioning to or from being fullscreen.
virtual void OnWindowFullscreenTransitionStart(
bool target_fullscreen_state) = 0;
// Called when the window has completed its transition to or from being
// fullscreen. Note that if there are multiple consecutive transitions
// (because a new transition was initiated before the previous one completed)
// then this will only be called when all transitions have competed.
virtual void OnWindowFullscreenTransitionComplete(bool is_fullscreen) = 0;
// Called when the window is miniaturized or deminiaturized.
virtual void OnWindowMiniaturizedChanged(bool miniaturized) = 0;
// Called when the current display or the properties of the current display
// change.
virtual void OnWindowDisplayChanged(const display::Display& display) = 0;
// Called before the NSWindow is closed and destroyed.
virtual void OnWindowWillClose() = 0;
// Called after the NSWindow has been closed and destroyed.
virtual void OnWindowHasClosed() = 0;
// Called when the NSWindow becomes key or resigns from being key. Additional
// state required for the transition include whether or not the content NSView
// is the first responder for the NSWindow in |is_content_first_responder| and
// whether or not the NSApp's full keyboard access is enabled in
// |full_keyboard_access_enabled|.
virtual void OnWindowKeyStatusChanged(bool is_key,
bool is_content_first_responder,
bool full_keyboard_access_enabled) = 0;
// Accept or cancel the current dialog window (depending on the value of
// |button|), if a current dialog exists.
virtual void DoDialogButtonAction(ui::DialogButton button) = 0;
// Synchronously determine if the specified button exists in the current
// dialog (if any), along with its label, whether or not it is enabled, and
// whether or not it is the default button..
virtual void GetDialogButtonInfo(ui::DialogButton button,
bool* button_exists,
base::string16* title,
bool* is_button_enabled,
bool* is_button_default) = 0;
// Synchronously return in |buttons_exist| whether or not any buttons exist
// for the current dialog.
virtual void GetDoDialogButtonsExist(bool* buttons_exist) = 0;
};
} // namespace views
......
......@@ -16,6 +16,7 @@
#include "ui/views/views_export.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_observer.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
namespace views_bridge_mac {
namespace mojom {
......@@ -36,7 +37,8 @@ class NativeWidgetMac;
// 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 BridgedNativeWidgetHostHelper,
public views_bridge_mac::mojom::BridgedNativeWidgetHost,
public DialogObserver,
public FocusChangeListener,
public ui::internal::InputMethodDelegate,
......@@ -120,32 +122,36 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
void UpdateCompositorProperties();
void DestroyCompositor();
// views::BridgedNativeWidgetHost:
// BridgedNativeWidgetHostHelper:
NSView* GetNativeViewAccessible() override;
void DispatchKeyEvent(ui::KeyEvent* event) override;
bool DispatchKeyEventToMenuController(ui::KeyEvent* event) override;
void GetWordAt(const gfx::Point& location_in_content,
bool* found_word,
gfx::DecoratedText* decorated_word,
gfx::Point* baseline_point) override;
// views_bridge_mac::mojom::BridgedNativeWidgetHost:
void OnVisibilityChanged(bool visible) override;
void SetViewSize(const gfx::Size& new_size) override;
void SetKeyboardAccessible(bool enabled) override;
void SetIsFirstResponder(bool is_first_responder) override;
void OnMouseCaptureActiveChanged(bool capture_is_active) override;
void OnScrollEvent(const ui::ScrollEvent& const_event) override;
void OnMouseEvent(const ui::MouseEvent& const_event) override;
void OnGestureEvent(const ui::GestureEvent& const_event) override;
void DispatchKeyEvent(const ui::KeyEvent& const_event,
bool* event_handled) override;
void DispatchKeyEventToMenuController(const ui::KeyEvent& const_event,
bool* event_swallowed,
bool* event_handled) override;
void GetHasMenuController(bool* has_menu_controller) override;
void GetIsDraggableBackgroundAt(const gfx::Point& location_in_content,
void OnScrollEvent(std::unique_ptr<ui::Event> event) override;
void OnMouseEvent(std::unique_ptr<ui::Event> event) override;
void OnGestureEvent(std::unique_ptr<ui::Event> event) override;
bool DispatchKeyEventRemote(std::unique_ptr<ui::Event> event,
bool* event_handled) override;
bool DispatchKeyEventToMenuControllerRemote(std::unique_ptr<ui::Event> event,
bool* event_swallowed,
bool* event_handled) override;
bool GetHasMenuController(bool* has_menu_controller) override;
bool GetIsDraggableBackgroundAt(const gfx::Point& location_in_content,
bool* is_draggable_background) override;
void GetTooltipTextAt(const gfx::Point& location_in_content,
bool GetTooltipTextAt(const gfx::Point& location_in_content,
base::string16* new_tooltip_text) override;
void GetWordAt(const gfx::Point& location_in_content,
bool* found_word,
gfx::DecoratedText* decorated_word,
gfx::Point* baseline_point) override;
void GetWidgetIsModal(bool* widget_is_modal) override;
void GetIsFocusedViewTextual(bool* is_textual) override;
bool GetWidgetIsModal(bool* widget_is_modal) override;
bool GetIsFocusedViewTextual(bool* is_textual) override;
void OnWindowGeometryChanged(
const gfx::Rect& window_bounds_in_screen_dips,
const gfx::Rect& content_bounds_in_screen_dips) override;
......@@ -160,12 +166,32 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
bool is_content_first_responder,
bool full_keyboard_access_enabled) override;
void DoDialogButtonAction(ui::DialogButton button) override;
void GetDialogButtonInfo(ui::DialogButton type,
bool GetDialogButtonInfo(ui::DialogButton type,
bool* button_exists,
base::string16* button_label,
bool* is_button_enabled,
bool* is_button_default) override;
void GetDoDialogButtonsExist(bool* buttons_exist) override;
bool GetDoDialogButtonsExist(bool* buttons_exist) override;
// views_bridge_mac::mojom::BridgedNativeWidgetHost, synchronous callbacks:
void DispatchKeyEventRemote(std::unique_ptr<ui::Event> event,
DispatchKeyEventRemoteCallback callback) override;
void DispatchKeyEventToMenuControllerRemote(
std::unique_ptr<ui::Event> event,
DispatchKeyEventToMenuControllerRemoteCallback callback) override;
void GetHasMenuController(GetHasMenuControllerCallback callback) override;
void GetIsDraggableBackgroundAt(
const gfx::Point& location_in_content,
GetIsDraggableBackgroundAtCallback callback) override;
void GetTooltipTextAt(const gfx::Point& location_in_content,
GetTooltipTextAtCallback callback) override;
void GetWidgetIsModal(GetWidgetIsModalCallback callback) override;
void GetIsFocusedViewTextual(
GetIsFocusedViewTextualCallback callback) override;
void GetDialogButtonInfo(ui::DialogButton button,
GetDialogButtonInfoCallback callback) override;
void GetDoDialogButtonsExist(
GetDoDialogButtonsExistCallback callback) override;
// DialogObserver:
void OnDialogModelChanged() override;
......
......@@ -11,6 +11,7 @@
#import "ui/views/cocoa/bridged_native_widget.h"
#include "ui/views/cocoa/bridged_native_widget_host.h"
#include "ui/views/widget/native_widget_mac.h"
#include "ui/views_bridge_mac/mojo/bridged_native_widget_host.mojom.h"
@implementation ViewsNSWindowDelegate
......
......@@ -9,11 +9,14 @@ mojom("mojo") {
sources = [
"mojo/bridged_native_widget.mojom",
"mojo/bridged_native_widget_host.mojom",
]
public_deps = [
"//mojo/public/mojom/base",
"//ui/base/mojo",
"//ui/display/mojo:interfaces",
"//ui/events/mojo:interfaces",
"//ui/gfx/geometry/mojo",
"//ui/gfx/mojo",
]
......
// 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.
module views_bridge_mac.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "ui/base/mojo/ui_base_types.mojom";
import "ui/display/mojo/display.mojom";
import "ui/events/mojo/event.mojom";
import "ui/gfx/geometry/mojo/geometry.mojom";
import "ui/gfx/mojo/ca_layer_params.mojom";
// The interface through which a NativeWidgetMac may interact with an NSWindow
// in another process.
interface BridgedNativeWidgetHost {
// Update the views::Widget, ui::Compositor and ui::Layer's visibility.
OnVisibilityChanged(bool visible);
// Resize the underlying views::View to |new_size|. Note that this will not
// necessarily match the content bounds from OnWindowGeometryChanged.
SetViewSize(gfx.mojom.Size new_size);
// Indicate if full keyboard accessibility is needed and update focus if
// needed.
SetKeyboardAccessible(bool enabled);
// Indicate if the NSView for this widget is the first responder for the
// NSWindow for this widget.
SetIsFirstResponder(bool is_first_responder);
// Indicate if mouse capture is active.
OnMouseCaptureActiveChanged(bool capture_is_active);
// Handle events. Note that whether or not the event is actually handled is
// not returned.
OnScrollEvent(ui.mojom.Event event);
OnMouseEvent(ui.mojom.Event event);
OnGestureEvent(ui.mojom.Event event);
// Synchronously dispatch a key event and return in |event_handled| whether
// or not the event was handled. This method is to be used only via the
// BridgedNativeWidgetHostHelper interface.
[Sync]
DispatchKeyEventRemote(ui.mojom.Event event) => (bool event_handled);
// Synchronously dispatch a key event to the current menu controller (if one
// exists and is owned by the widget for this). Return in |event_swallowed|
// whether or not the event was swallowed (that is, if the menu's dispatch
// returned POST_DISPATCH_NONE). Return in |event_handled| whether or not the
// event was handled (that is, if the event in the caller's scope should be
// marked as handled). This method is to be used only via the
// BridgedNativeWidgetHostHelper interface.
[Sync]
DispatchKeyEventToMenuControllerRemote(ui.mojom.Event event) =>
(bool event_swallowed, bool event_handled);
// Synchronously return in |has_menu_controller| whether or not a menu
// controller exists for this widget.
[Sync]
GetHasMenuController() => (bool has_menu_controller);
// Synchronously query if |location_in_content| is a draggable background.
[Sync]
GetIsDraggableBackgroundAt(gfx.mojom.Point location_in_content) =>
(bool is_draggable_background);
// Synchronously query the tooltip text for |location_in_content|.
[Sync]
GetTooltipTextAt(gfx.mojom.Point location_in_content) =>
(mojo_base.mojom.String16 new_tooltip_text);
// Synchronously query the value of IsModal for this widget and store it in
// |widget_is_modal|.
[Sync]
GetWidgetIsModal() => (bool widget_is_modal);
// Synchronously return in |is_textual| whether or not the focused view
// contains text that can be selected and copied.
[Sync]
GetIsFocusedViewTextual() => (bool is_textual);
// Called whenever the NSWindow's size or position changes.
OnWindowGeometryChanged(
gfx.mojom.Rect window_bounds_in_screen_dips,
gfx.mojom.Rect content_bounds_in_screen_dips);
// Called when the window begins transitioning to or from being fullscreen.
OnWindowFullscreenTransitionStart(
bool target_fullscreen_state);
// Called when the window has completed its transition to or from being
// fullscreen. Note that if there are multiple consecutive transitions
// (because a new transition was initiated before the previous one completed)
// then this will only be called when all transitions have competed.
OnWindowFullscreenTransitionComplete(bool is_fullscreen);
// Called when the window is miniaturized or deminiaturized.
OnWindowMiniaturizedChanged(bool miniaturized);
// Called when the current display or the properties of the current display
// change.
OnWindowDisplayChanged(display.mojom.Display display);
// Called before the NSWindow is closed and destroyed.
OnWindowWillClose();
// Called after the NSWindow has been closed and destroyed.
OnWindowHasClosed();
// Called when the NSWindow becomes key or resigns from being key. Additional
// state required for the transition include whether or not the content NSView
// is the first responder for the NSWindow in |is_content_first_responder| and
// whether or not the NSApp's full keyboard access is enabled in
// |full_keyboard_access_enabled|.
OnWindowKeyStatusChanged(bool is_key,
bool is_content_first_responder,
bool full_keyboard_access_enabled);
// Accept or cancel the current dialog window (depending on the value of
// |button|), if a current dialog exists.
DoDialogButtonAction(ui.mojom.DialogButton button);
// Synchronously determine if the specified button exists in the current
// dialog (if any), along with its label, whether or not it is enabled, and
// whether or not it is the default button..
[Sync]
GetDialogButtonInfo(ui.mojom.DialogButton button) => (bool button_exists,
mojo_base.mojom.String16 title,
bool is_button_enabled,
bool is_button_default);
// Synchronously return in |buttons_exist| whether or not any buttons exist
// for the current dialog.
[Sync]
GetDoDialogButtonsExist() => (bool buttons_exist);
};
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