Commit ca224255 authored by Christopher Cameron's avatar Christopher Cameron Committed by Commit Bot

RemoteMacViews: Return NSAccessibilityRemoteUIElement where appropriate

When using RemoteMacViews, for a given widget, the widget's NSWindow
and content NSView exist in the app shim process, while the tree of
AXPlatformNodeCocoas exists in the browser process.

In the browser process, the widget's NSWindow and content NSView are
represented by NSAccessibilityRemoteUIElements in
views::BridgedNativeWidgetHostImpl.

Update AXPlatformNodeDelegateMac::GetParent and GetNSWindow to retrieve
these values from views::BridgedNativeWidgetHostImpl.

In AXPlatformNodeDelegate, replace the method GetTopLevelWidget with
the method GetNSWindow and call this method in -[AXPlatformNodeCocoa
AXWindow]. Replace all subclass implementations except for
AXPlatformNodeDelegateMac with NOTREACHED.

Bug: 900846
Change-Id: Ia0d26c4d118391ce66cc1e080ca3b62fb228aa8c
Reviewed-on: https://chromium-review.googlesource.com/c/1338722
Commit-Queue: ccameron <ccameron@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609959}
parent 858f8a1e
......@@ -952,7 +952,7 @@ const ui::AXTreeData& BrowserAccessibility::GetTreeData() const {
return *empty_data;
}
gfx::NativeWindow BrowserAccessibility::GetTopLevelWidget() {
gfx::NativeViewAccessible BrowserAccessibility::GetNSWindow() {
NOTREACHED();
return nullptr;
}
......
......@@ -334,7 +334,7 @@ class CONTENT_EXPORT BrowserAccessibility : public ui::AXPlatformNodeDelegate {
// AXPlatformNodeDelegate.
const ui::AXNodeData& GetData() const override;
const ui::AXTreeData& GetTreeData() const override;
gfx::NativeWindow GetTopLevelWidget() override;
gfx::NativeViewAccessible GetNSWindow() override;
gfx::NativeViewAccessible GetParent() override;
int GetChildCount() override;
gfx::NativeViewAccessible ChildAtIndex(int index) override;
......
......@@ -50,8 +50,9 @@ class AX_EXPORT AXPlatformNodeDelegate {
// Get the accessibility tree data for this node.
virtual const AXTreeData& GetTreeData() const = 0;
// Get the window the node is contained in.
virtual gfx::NativeWindow GetTopLevelWidget() = 0;
// Get the accessibility node for the NSWindow the node is contained in. This
// method is only meaningful on macOS.
virtual gfx::NativeViewAccessible GetNSWindow() = 0;
// Get the parent of the node, which may be an AXPlatformNode or it may
// be a native accessible object implemented by another class.
......
......@@ -24,7 +24,7 @@ const AXTreeData& AXPlatformNodeDelegateBase::GetTreeData() const {
return *empty_data;
}
gfx::NativeWindow AXPlatformNodeDelegateBase::GetTopLevelWidget() {
gfx::NativeViewAccessible AXPlatformNodeDelegateBase::GetNSWindow() {
return nullptr;
}
......
......@@ -27,8 +27,8 @@ class AX_EXPORT AXPlatformNodeDelegateBase : public AXPlatformNodeDelegate {
// Get the accessibility tree data for this node.
const AXTreeData& GetTreeData() const override;
// Get the window the node is contained in.
gfx::NativeWindow GetTopLevelWidget() override;
// See comments in AXPlatformNodeDelegate.
gfx::NativeViewAccessible GetNSWindow() override;
// Get the parent of the node, which may be an AXPlatformNode or it may
// be a native accessible object implemented by another class.
......
......@@ -805,10 +805,7 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
}
- (id)AXWindow {
// TODO(ccameron): This should return the NSAccessibilityRemoteUIElement for
// the NSWindow in the viewer process. This requires that Widget have a method
// to retrieve this object, which does not exist yet.
return node_->GetDelegate()->GetTopLevelWidget().GetNativeNSWindow();
return node_->GetDelegate()->GetNSWindow();
}
- (id)AXTopLevelUIElement {
......
......@@ -191,9 +191,8 @@ gfx::NativeViewAccessible AXVirtualView::ChildAtIndex(int index) {
return nullptr;
}
gfx::NativeWindow AXVirtualView::GetTopLevelWidget() {
if (GetOwnerView() && GetOwnerView()->GetWidget())
return GetOwnerView()->GetWidget()->GetTopLevelWidget()->GetNativeWindow();
gfx::NativeViewAccessible AXVirtualView::GetNSWindow() {
NOTREACHED();
return nullptr;
}
......
......@@ -108,7 +108,7 @@ class VIEWS_EXPORT AXVirtualView : public ui::AXPlatformNodeDelegateBase {
const ui::AXNodeData& GetData() const override;
int GetChildCount() override;
gfx::NativeViewAccessible ChildAtIndex(int index) override;
gfx::NativeWindow GetTopLevelWidget() override;
gfx::NativeViewAccessible GetNSWindow() override;
gfx::NativeViewAccessible GetParent() override;
gfx::Rect GetClippedScreenBoundsRect() const override;
gfx::Rect GetUnclippedScreenBoundsRect() const override;
......
......@@ -285,9 +285,8 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::ChildAtIndex(int index) {
return nullptr;
}
gfx::NativeWindow ViewAXPlatformNodeDelegate::GetTopLevelWidget() {
if (view()->GetWidget())
return view()->GetWidget()->GetTopLevelWidget()->GetNativeWindow();
gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::GetNSWindow() {
NOTREACHED();
return nullptr;
}
......
......@@ -50,7 +50,7 @@ class ViewAXPlatformNodeDelegate : public ViewAccessibility,
const ui::AXNodeData& GetData() const override;
int GetChildCount() override;
gfx::NativeViewAccessible ChildAtIndex(int index) override;
gfx::NativeWindow GetTopLevelWidget() override;
gfx::NativeViewAccessible GetNSWindow() override;
gfx::NativeViewAccessible GetParent() override;
gfx::Rect GetClippedScreenBoundsRect() const override;
gfx::Rect GetUnclippedScreenBoundsRect() const override;
......
......@@ -17,6 +17,7 @@ class ViewAXPlatformNodeDelegateMac : public ViewAXPlatformNodeDelegate {
~ViewAXPlatformNodeDelegateMac() override;
// |ViewAXPlatformNodeDelegate| overrides:
gfx::NativeViewAccessible GetNSWindow() override;
gfx::NativeViewAccessible GetParent() override;
private:
......
......@@ -6,6 +6,7 @@
#include <memory>
#include "ui/views/cocoa/bridged_native_widget_host_impl.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
......@@ -21,18 +22,37 @@ ViewAXPlatformNodeDelegateMac::ViewAXPlatformNodeDelegateMac(View* view)
ViewAXPlatformNodeDelegateMac::~ViewAXPlatformNodeDelegateMac() = default;
gfx::NativeViewAccessible ViewAXPlatformNodeDelegateMac::GetNSWindow() {
auto* widget = view()->GetWidget();
if (!widget)
return nil;
auto* top_level_widget = widget->GetTopLevelWidget();
if (!top_level_widget)
return nil;
auto* bridge_host = BridgedNativeWidgetHostImpl::GetFromNativeWindow(
top_level_widget->GetNativeWindow());
if (!bridge_host)
return nil;
return bridge_host->GetNativeViewAccessibleForNSWindow();
}
gfx::NativeViewAccessible ViewAXPlatformNodeDelegateMac::GetParent() {
if (view()->parent())
return view()->parent()->GetNativeViewAccessible();
// TODO(ccameron): This should return the NSAccessibilityRemoteUIElement for
// the NSView in the viewer process. This requires that Widget have a
// method to retrieve this object, which will not necessarily coincide with
// GetNativeView.
if (view()->GetWidget())
return view()->GetWidget()->GetNativeView().GetNativeNSView();
auto* widget = view()->GetWidget();
if (!widget)
return nil;
auto* bridge_host = BridgedNativeWidgetHostImpl::GetFromNativeWindow(
view()->GetWidget()->GetNativeWindow());
if (!bridge_host)
return nil;
return nullptr;
return bridge_host->GetNativeViewAccessibleForNSView();
}
} // namespace views
......@@ -90,12 +90,11 @@ class VIEWS_EXPORT BridgedNativeWidgetHostImpl
// NSWindow. Otherwise, it mirrors the id and bounds of the child window.
NativeWidgetMacNSWindow* GetLocalNSWindow() const;
// Return the accessibility object for the parent NSView of the widget's root
// views::View.
gfx::NativeViewAccessible GetParentViewAccessible() const;
// Return the accessibility object for the content NSView.
gfx::NativeViewAccessible GetNativeViewAccessibleForNSView() const;
// Return the accessibility object for this widget's window.
gfx::NativeViewAccessible GetWindowAccessible() const;
// Return the accessibility object for the NSWindow.
gfx::NativeViewAccessible GetNativeViewAccessibleForNSWindow() const;
// The mojo interface through which to communicate with the underlying
// NSWindow and NSView.
......
......@@ -127,15 +127,15 @@ NativeWidgetMacNSWindow* BridgedNativeWidgetHostImpl::GetLocalNSWindow() const {
return local_window_.get();
}
gfx::NativeViewAccessible BridgedNativeWidgetHostImpl::GetParentViewAccessible()
const {
gfx::NativeViewAccessible
BridgedNativeWidgetHostImpl::GetNativeViewAccessibleForNSView() const {
if (bridge_impl_)
return bridge_impl_->ns_view();
return remote_view_accessible_.get();
}
gfx::NativeViewAccessible BridgedNativeWidgetHostImpl::GetWindowAccessible()
const {
gfx::NativeViewAccessible
BridgedNativeWidgetHostImpl::GetNativeViewAccessibleForNSWindow() const {
if (bridge_impl_)
return bridge_impl_->ns_window();
return remote_window_accessible_.get();
......
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