summaryrefslogtreecommitdiff
path: root/chromium/ui/views/accessibility
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/views/accessibility')
-rw-r--r--chromium/ui/views/accessibility/ax_tree_source_views_unittest.cc2
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view.cc14
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view.h5
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view_unittest.cc13
-rw-r--r--chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc9
-rw-r--r--chromium/ui/views/accessibility/ax_widget_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_window_obj_wrapper.cc28
-rw-r--r--chromium/ui/views/accessibility/ax_window_obj_wrapper.h10
-rw-r--r--chromium/ui/views/accessibility/view_accessibility.cc25
-rw-r--r--chromium/ui/views/accessibility/view_accessibility.h15
-rw-r--r--chromium/ui/views/accessibility/view_ax_platform_node_delegate.cc96
-rw-r--r--chromium/ui/views/accessibility/view_ax_platform_node_delegate.h13
-rw-r--r--chromium/ui/views/accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc42
-rw-r--r--chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc16
14 files changed, 201 insertions, 88 deletions
diff --git a/chromium/ui/views/accessibility/ax_tree_source_views_unittest.cc b/chromium/ui/views/accessibility/ax_tree_source_views_unittest.cc
index bb90519552e..4f0f799ec48 100644
--- a/chromium/ui/views/accessibility/ax_tree_source_views_unittest.cc
+++ b/chromium/ui/views/accessibility/ax_tree_source_views_unittest.cc
@@ -50,7 +50,7 @@ class AXTreeSourceViewsTest : public ViewsTestBase {
params.bounds = gfx::Rect(11, 22, 333, 444);
params.context = GetContext();
widget_->Init(std::move(params));
- widget_->SetContentsView(new View());
+ widget_->SetContentsView(std::make_unique<View>());
label1_ = new Label(base::ASCIIToUTF16("Label 1"));
label1_->SetBounds(1, 1, 111, 111);
diff --git a/chromium/ui/views/accessibility/ax_virtual_view.cc b/chromium/ui/views/accessibility/ax_virtual_view.cc
index a222443d37e..060d4a77c65 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view.cc
+++ b/chromium/ui/views/accessibility/ax_virtual_view.cc
@@ -395,7 +395,7 @@ bool AXVirtualView::AccessibilityPerformAction(const ui::AXActionData& data) {
if (custom_data_.HasAction(data.action))
result = HandleAccessibleAction(data);
if (!result && GetOwnerView())
- return GetOwnerView()->HandleAccessibleAction(data);
+ return HandleAccessibleActionInOwnerView(data);
return result;
}
@@ -449,7 +449,17 @@ bool AXVirtualView::HandleAccessibleAction(
break;
}
- return GetOwnerView()->HandleAccessibleAction(action_data);
+ return HandleAccessibleActionInOwnerView(action_data);
+}
+
+bool AXVirtualView::HandleAccessibleActionInOwnerView(
+ const ui::AXActionData& action_data) {
+ DCHECK(GetOwnerView());
+ // Save the node id so that the owner view can determine which virtual view
+ // is being targeted for action.
+ ui::AXActionData forwarded_action_data = action_data;
+ forwarded_action_data.target_node_id = GetData().id;
+ return GetOwnerView()->HandleAccessibleAction(forwarded_action_data);
}
View* AXVirtualView::GetOwnerView() const {
diff --git a/chromium/ui/views/accessibility/ax_virtual_view.h b/chromium/ui/views/accessibility/ax_virtual_view.h
index 105c961b102..6b1f9eeda4a 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view.h
+++ b/chromium/ui/views/accessibility/ax_virtual_view.h
@@ -171,6 +171,11 @@ class VIEWS_EXPORT AXVirtualView : public ui::AXPlatformNodeDelegateBase {
// via NotifyAccessibilityEvent().
virtual bool HandleAccessibleAction(const ui::AXActionData& action_data);
+ protected:
+ // Forwards a request from assistive technology to perform an action on this
+ // virtual view to the owner view's accessible action handler.
+ bool HandleAccessibleActionInOwnerView(const ui::AXActionData& action_data);
+
private:
// Internal class name.
static const char kViewClassName[];
diff --git a/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc b/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
index b48ada53153..23e1ba55ab2 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
+++ b/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
@@ -487,6 +487,13 @@ TEST_F(AXVirtualViewTest, OverrideFocus) {
ASSERT_NE(nullptr, virtual_label_->GetNativeObject());
ExpectReceivedAccessibilityEvents({});
+ button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+ button_->RequestFocus();
+ ExpectReceivedAccessibilityEvents(
+ {std::make_pair(GetButtonAccessibility(), ax::mojom::Event::kFocus),
+ std::make_pair(GetButtonAccessibility(),
+ ax::mojom::Event::kChildrenChanged)});
+
EXPECT_EQ(button_accessibility.GetNativeObject(),
button_accessibility.GetFocusedDescendant());
button_accessibility.OverrideFocus(virtual_label_);
@@ -536,6 +543,10 @@ TEST_F(AXVirtualViewTest, OverrideFocus) {
// Test that calling GetFocus() while the owner view is not focused will
// return nullptr.
+ button_->SetFocusBehavior(View::FocusBehavior::NEVER);
+ button_->RequestFocus();
+ ExpectReceivedAccessibilityEvents({std::make_pair(
+ GetButtonAccessibility(), ax::mojom::Event::kChildrenChanged)});
EXPECT_EQ(nullptr, virtual_label_->GetFocus());
EXPECT_EQ(nullptr, virtual_child_1->GetFocus());
EXPECT_EQ(nullptr, virtual_child_2->GetFocus());
@@ -544,7 +555,7 @@ TEST_F(AXVirtualViewTest, OverrideFocus) {
button_->SetFocusBehavior(View::FocusBehavior::ALWAYS);
button_->RequestFocus();
ExpectReceivedAccessibilityEvents(
- {std::make_pair(GetButtonAccessibility(), ax::mojom::Event::kFocus),
+ {std::make_pair(virtual_child_3, ax::mojom::Event::kFocus),
std::make_pair(GetButtonAccessibility(),
ax::mojom::Event::kChildrenChanged)});
diff --git a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
index 9aeeb45a0bc..c58811c8b67 100644
--- a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
@@ -70,6 +70,15 @@ void AXWidgetObjWrapper::OnWidgetDestroying(Widget* widget) {
aura_obj_cache_->Remove(widget);
}
+void AXWidgetObjWrapper::OnWidgetDestroyed(Widget* widget) {
+ // Normally this does not run because of OnWidgetDestroying should have
+ // removed |this| from cache. However, some code could trigger a destroying
+ // widget to be created after OnWidgetDestroying. This guards against such
+ // situation and ensures the destroyed widget is removed from cache.
+ // See https://crbug.com/1091545
+ aura_obj_cache_->Remove(widget);
+}
+
void AXWidgetObjWrapper::OnWidgetClosing(Widget* widget) {
aura_obj_cache_->Remove(widget);
}
diff --git a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
index 2f6cc93f1ef..9d768b80b85 100644
--- a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
@@ -40,6 +40,7 @@ class AXWidgetObjWrapper : public AXAuraObjWrapper,
// WidgetObserver overrides.
void OnWidgetDestroying(Widget* widget) override;
+ void OnWidgetDestroyed(Widget* widget) override;
void OnWidgetClosing(Widget* widget) override;
void OnWidgetVisibilityChanged(Widget*, bool) override;
diff --git a/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
index 5e79b94b22c..bc23c390e2f 100644
--- a/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/aura/aura_window_properties.h"
+#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_tree_id.h"
@@ -88,6 +89,15 @@ AXWindowObjWrapper::AXWindowObjWrapper(AXAuraObjCache* aura_obj_cache,
AXWindowObjWrapper::~AXWindowObjWrapper() = default;
+bool AXWindowObjWrapper::HandleAccessibleAction(
+ const ui::AXActionData& action) {
+ if (action.action == ax::mojom::Action::kFocus) {
+ window_->Focus();
+ return true;
+ }
+ return false;
+}
+
bool AXWindowObjWrapper::IsIgnored() {
return false;
}
@@ -160,6 +170,9 @@ void AXWindowObjWrapper::OnWindowDestroyed(aura::Window* window) {
}
void AXWindowObjWrapper::OnWindowDestroying(aura::Window* window) {
+ if (window == window_)
+ window_destroying_ = true;
+
Widget* widget = GetWidgetForWindow(window);
if (widget)
aura_obj_cache_->Remove(widget);
@@ -179,6 +192,9 @@ void AXWindowObjWrapper::OnWindowBoundsChanged(
const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds,
ui::PropertyChangeReason reason) {
+ if (window_destroying_)
+ return;
+
if (window == window_)
FireLocationChangesRecursively(window_, aura_obj_cache_);
}
@@ -186,22 +202,34 @@ void AXWindowObjWrapper::OnWindowBoundsChanged(
void AXWindowObjWrapper::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) {
+ if (window_destroying_)
+ return;
+
if (window == window_ && key == ui::kChildAXTreeID)
FireEvent(ax::mojom::Event::kChildrenChanged);
}
void AXWindowObjWrapper::OnWindowVisibilityChanged(aura::Window* window,
bool visible) {
+ if (window_destroying_)
+ return;
+
FireEvent(ax::mojom::Event::kStateChanged);
}
void AXWindowObjWrapper::OnWindowTransformed(aura::Window* window,
ui::PropertyChangeReason reason) {
+ if (window_destroying_)
+ return;
+
if (window == window_)
FireLocationChangesRecursively(window_, aura_obj_cache_);
}
void AXWindowObjWrapper::OnWindowTitleChanged(aura::Window* window) {
+ if (window_destroying_)
+ return;
+
FireEventOnWindowChildWidgetAndRootView(
window_, ax::mojom::Event::kTreeChanged, aura_obj_cache_);
}
diff --git a/chromium/ui/views/accessibility/ax_window_obj_wrapper.h b/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
index 841a3d03710..7c5514b3b5e 100644
--- a/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
@@ -30,6 +30,7 @@ class AXWindowObjWrapper : public AXAuraObjWrapper,
~AXWindowObjWrapper() override;
// AXAuraObjWrapper overrides.
+ bool HandleAccessibleAction(const ui::AXActionData& action) override;
bool IsIgnored() override;
AXAuraObjWrapper* GetParent() override;
void GetChildren(std::vector<AXAuraObjWrapper*>* out_children) override;
@@ -57,12 +58,17 @@ class AXWindowObjWrapper : public AXAuraObjWrapper,
// Fires an accessibility event.
void FireEvent(ax::mojom::Event event_type);
- aura::Window* window_;
+ aura::Window* const window_;
- bool is_root_window_;
+ const bool is_root_window_;
const ui::AXUniqueId unique_id_;
+ // Whether OnWindowDestroying has happened for |window_|. Used to suppress
+ // further events from |window| after OnWindowDestroying. Otherwise, dangling
+ // pointer could be left in |aura_obj_cache_|. See https://crbug.com/1091545
+ bool window_destroying_ = false;
+
ScopedObserver<aura::Window, aura::WindowObserver> observer_{this};
};
diff --git a/chromium/ui/views/accessibility/view_accessibility.cc b/chromium/ui/views/accessibility/view_accessibility.cc
index 4ff677b664e..5dfb136d2d1 100644
--- a/chromium/ui/views/accessibility/view_accessibility.cc
+++ b/chromium/ui/views/accessibility/view_accessibility.cc
@@ -121,6 +121,10 @@ const ui::AXUniqueId& ViewAccessibility::GetUniqueId() const {
return unique_id_;
}
+bool ViewAccessibility::IsLeaf() const {
+ return is_leaf_;
+}
+
void ViewAccessibility::GetAccessibleNodeData(ui::AXNodeData* data) const {
data->id = GetUniqueId().Get();
@@ -206,7 +210,7 @@ void ViewAccessibility::GetAccessibleNodeData(ui::AXNodeData* data) const {
return;
}
- if (view_->IsAccessibilityFocusable())
+ if (view_->IsAccessibilityFocusable() && !focused_virtual_child_)
data->AddState(ax::mojom::State::kFocusable);
if (!view_->GetEnabled())
@@ -224,13 +228,24 @@ void ViewAccessibility::OverrideFocus(AXVirtualView* virtual_view) {
<< "|virtual_view| must be nullptr or a descendant of this view.";
focused_virtual_child_ = virtual_view;
- if (focused_virtual_child_) {
- focused_virtual_child_->NotifyAccessibilityEvent(ax::mojom::Event::kFocus);
- } else {
- view_->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true);
+ if (view_->HasFocus()) {
+ if (focused_virtual_child_) {
+ focused_virtual_child_->NotifyAccessibilityEvent(
+ ax::mojom::Event::kFocus);
+ } else {
+ view_->NotifyAccessibilityEvent(ax::mojom::Event::kFocus, true);
+ }
}
}
+void ViewAccessibility::SetPopupFocusOverride() {}
+
+void ViewAccessibility::EndPopupFocusOverride() {}
+
+bool ViewAccessibility::IsFocusedForTesting() {
+ return view_->HasFocus() && !focused_virtual_child_;
+}
+
void ViewAccessibility::OverrideRole(const ax::mojom::Role role) {
DCHECK(IsValidRoleForViews(role)) << "Invalid role for Views.";
custom_data_.role = role;
diff --git a/chromium/ui/views/accessibility/view_accessibility.h b/chromium/ui/views/accessibility/view_accessibility.h
index 50fdcfef62b..69cb2423d88 100644
--- a/chromium/ui/views/accessibility/view_accessibility.h
+++ b/chromium/ui/views/accessibility/view_accessibility.h
@@ -108,7 +108,7 @@ class VIEWS_EXPORT ViewAccessibility {
View* view() const { return view_; }
AXVirtualView* FocusedVirtualChild() const { return focused_virtual_child_; }
- bool IsLeaf() const { return is_leaf_; }
+ virtual bool IsLeaf() const;
bool IsIgnored() const { return is_ignored_; }
//
@@ -144,6 +144,19 @@ class VIEWS_EXPORT ViewAccessibility {
// native accessibility object associated with this view.
gfx::NativeViewAccessible GetFocusedDescendant();
+ // Call when this is the active descendant of a popup view that temporarily
+ // takes over focus. It is only necessary to use this for menus like autofill,
+ // where the actual focus is in content.
+ // When the popup closes, call EndPopupFocusOverride().
+ virtual void SetPopupFocusOverride();
+
+ // Call when popup closes, if it used SetPopupFocusOverride().
+ virtual void EndPopupFocusOverride();
+
+ // Return true if this view is considered focused.
+ virtual bool IsFocusedForTesting();
+
+ // Call when a menu closes, to restore focus to where it was previously.
virtual void FireFocusAfterMenuClose();
// Used for testing. Allows a test to watch accessibility events.
diff --git a/chromium/ui/views/accessibility/view_ax_platform_node_delegate.cc b/chromium/ui/views/accessibility/view_ax_platform_node_delegate.cc
index 748c8569207..35dce74a77b 100644
--- a/chromium/ui/views/accessibility/view_ax_platform_node_delegate.cc
+++ b/chromium/ui/views/accessibility/view_ax_platform_node_delegate.cc
@@ -11,6 +11,7 @@
#include <vector>
#include "base/bind.h"
+#include "base/containers/adapters.h"
#include "base/lazy_instance.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/accessibility/ax_action_data.h"
@@ -121,9 +122,6 @@ struct ViewAXPlatformNodeDelegate::ChildWidgetsResult {
bool is_tab_modal_showing;
};
-// static
-int ViewAXPlatformNodeDelegate::menu_depth_ = 0;
-
ViewAXPlatformNodeDelegate::ViewAXPlatformNodeDelegate(View* view)
: ViewAccessibility(view) {
ax_platform_node_ = ui::AXPlatformNode::Create(this);
@@ -139,7 +137,7 @@ ViewAXPlatformNodeDelegate::ViewAXPlatformNodeDelegate(View* view)
ViewAXPlatformNodeDelegate::~ViewAXPlatformNodeDelegate() {
if (ui::AXPlatformNode::GetPopupFocusOverride() == GetNativeObject())
- ui::AXPlatformNode::SetPopupFocusOverride(nullptr);
+ EndPopupFocusOverride();
ax_platform_node_->Destroy();
}
@@ -148,6 +146,21 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::GetNativeObject() const {
return ax_platform_node_->GetNativeViewAccessible();
}
+void ViewAXPlatformNodeDelegate::SetPopupFocusOverride() {
+ ui::AXPlatformNode::SetPopupFocusOverride(GetNativeObject());
+}
+
+void ViewAXPlatformNodeDelegate::EndPopupFocusOverride() {
+ ui::AXPlatformNode::SetPopupFocusOverride(nullptr);
+}
+
+bool ViewAXPlatformNodeDelegate::IsFocusedForTesting() {
+ if (ui::AXPlatformNode::GetPopupFocusOverride())
+ return ui::AXPlatformNode::GetPopupFocusOverride() == GetNativeObject();
+
+ return ViewAccessibility::IsFocusedForTesting();
+}
+
void ViewAXPlatformNodeDelegate::NotifyAccessibilityEvent(
ax::mojom::Event event_type) {
DCHECK(ax_platform_node_);
@@ -160,16 +173,21 @@ void ViewAXPlatformNodeDelegate::NotifyAccessibilityEvent(
// Some events have special handling.
switch (event_type) {
- case ax::mojom::Event::kMenuStart:
- OnMenuStart();
+ case ax::mojom::Event::kFocusAfterMenuClose: {
+ DCHECK(!ui::AXPlatformNode::GetPopupFocusOverride())
+ << "Must call ViewAccessibility::EndPopupFocusOverride() as menu "
+ "closes.";
break;
- case ax::mojom::Event::kMenuEnd:
- OnMenuEnd();
- break;
- case ax::mojom::Event::kSelection: {
- ax::mojom::Role role = GetData().role;
- if (menu_depth_ && (ui::IsMenuItem(role) || ui::IsListItem(role)))
- OnMenuItemActive();
+ }
+ case ax::mojom::Event::kFocus: {
+ if (ui::AXPlatformNode::GetPopupFocusOverride()) {
+ DCHECK_EQ(ui::AXPlatformNode::GetPopupFocusOverride(),
+ GetNativeObject())
+ << "If the popup focus override is on, then the kFocus event must "
+ "match it. Most likely the popup has closed, but did not call "
+ "ViewAccessibility::EndPopupFocusOverride(), and focus has "
+ "now moved on.";
+ }
break;
}
case ax::mojom::Event::kFocusContext: {
@@ -201,27 +219,6 @@ void ViewAXPlatformNodeDelegate::AnnounceText(const base::string16& text) {
}
#endif
-void ViewAXPlatformNodeDelegate::OnMenuItemActive() {
- // When a native menu is shown and has an item selected, treat it and the
- // currently selected item as focused, even though the actual focus is in the
- // browser's currently focused textfield.
- ui::AXPlatformNode::SetPopupFocusOverride(
- ax_platform_node_->GetNativeViewAccessible());
-}
-
-void ViewAXPlatformNodeDelegate::OnMenuStart() {
- ++menu_depth_;
-}
-
-void ViewAXPlatformNodeDelegate::OnMenuEnd() {
- // When a native menu is hidden, restore accessibility focus to the current
- // focus in the document.
- if (menu_depth_ >= 1)
- --menu_depth_;
- if (menu_depth_ == 0)
- ui::AXPlatformNode::SetPopupFocusOverride(nullptr);
-}
-
void ViewAXPlatformNodeDelegate::FireFocusAfterMenuClose() {
ui::AXPlatformNodeBase* focused_node =
static_cast<ui::AXPlatformNodeBase*>(ax_platform_node_);
@@ -276,7 +273,7 @@ const ui::AXNodeData& ViewAXPlatformNodeDelegate::GetData() const {
}
int ViewAXPlatformNodeDelegate::GetChildCount() const {
- if (IsLeaf())
+ if (ViewAccessibility::IsLeaf())
return 0;
if (!virtual_children().empty()) {
@@ -371,6 +368,15 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::GetParent() {
return nullptr;
}
+bool ViewAXPlatformNodeDelegate::IsChildOfLeaf() const {
+ // Needed to prevent endless loops, see: http://crbug.com/1100047
+ return false;
+}
+
+bool ViewAXPlatformNodeDelegate::IsLeaf() const {
+ return ViewAccessibility::IsLeaf() || AXPlatformNodeDelegateBase::IsLeaf();
+}
+
gfx::Rect ViewAXPlatformNodeDelegate::GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
const ui::AXClippingBehavior clipping_behavior,
@@ -419,6 +425,22 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::HitTestSync(
if (!view()->HitTestPoint(point))
return nullptr;
+ // Check if the point is within any of the virtual children of this view.
+ // AXVirtualView's HitTestSync is a recursive function that will return the
+ // deepest child, since it does not support relative bounds.
+ if (!virtual_children().empty()) {
+ // Search the greater indices first, since they're on top in the z-order.
+ for (const std::unique_ptr<AXVirtualView>& child :
+ base::Reversed(virtual_children())) {
+ gfx::NativeViewAccessible result =
+ child->HitTestSync(screen_physical_pixel_x, screen_physical_pixel_y);
+ if (result)
+ return result;
+ }
+ // If it's not inside any of our virtual children, it's inside this view.
+ return GetNativeObject();
+ }
+
// Check if the point is within any of the immediate children of this
// view. We don't have to search further because AXPlatformNode will
// do a recursive hit test if we return anything other than |this| or NULL.
@@ -426,6 +448,10 @@ gfx::NativeViewAccessible ViewAXPlatformNodeDelegate::HitTestSync(
const auto is_point_in_child = [point, v](View* child) {
if (!child->GetVisible())
return false;
+ ui::AXNodeData child_data;
+ child->GetViewAccessibility().GetAccessibleNodeData(&child_data);
+ if (child_data.HasState(ax::mojom::State::kInvisible))
+ return false;
gfx::Point point_in_child_coords = point;
v->ConvertPointToTarget(v, child, &point_in_child_coords);
return child->HitTestPoint(point_in_child_coords);
diff --git a/chromium/ui/views/accessibility/view_ax_platform_node_delegate.h b/chromium/ui/views/accessibility/view_ax_platform_node_delegate.h
index 433ef8986f7..8d3ddca5571 100644
--- a/chromium/ui/views/accessibility/view_ax_platform_node_delegate.h
+++ b/chromium/ui/views/accessibility/view_ax_platform_node_delegate.h
@@ -61,6 +61,8 @@ class ViewAXPlatformNodeDelegate : public ViewAccessibility,
gfx::NativeViewAccessible GetNSWindow() override;
gfx::NativeViewAccessible GetNativeViewAccessible() override;
gfx::NativeViewAccessible GetParent() override;
+ bool IsChildOfLeaf() const override;
+ bool IsLeaf() const override;
gfx::Rect GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
const ui::AXClippingBehavior clipping_behavior,
@@ -86,6 +88,10 @@ class ViewAXPlatformNodeDelegate : public ViewAccessibility,
base::Optional<int> GetPosInSet() const override;
base::Optional<int> GetSetSize() const override;
+ void SetPopupFocusOverride() override;
+ void EndPopupFocusOverride() override;
+ bool IsFocusedForTesting() override;
+
protected:
explicit ViewAXPlatformNodeDelegate(View* view);
@@ -100,18 +106,11 @@ class ViewAXPlatformNodeDelegate : public ViewAccessibility,
ChildWidgetsResult GetChildWidgets() const;
- void OnMenuItemActive();
- void OnMenuStart();
- void OnMenuEnd();
-
// We own this, but it is reference-counted on some platforms so we can't use
// a unique_ptr. It is destroyed in the destructor.
ui::AXPlatformNode* ax_platform_node_;
mutable ui::AXNodeData data_;
-
- // Levels of menu are currently open, e.g. 0: none, 1: top, 2: submenu ...
- static int32_t menu_depth_;
};
} // namespace views
diff --git a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc
index f9c0de73d1b..3f8100365a7 100644
--- a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc
+++ b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc
@@ -5,6 +5,7 @@
#include "ui/views/accessibility/view_ax_platform_node_delegate.h"
#include <atk/atk.h>
+#include <memory>
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -29,12 +30,10 @@ TEST_F(ViewAXPlatformNodeDelegateAuraLinuxTest, TextfieldAccessibility) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* content = new View;
- widget.SetContentsView(content);
+ View* content = widget.SetContentsView(std::make_unique<View>());
Textfield* textfield = new Textfield;
textfield->SetAccessibleName(base::UTF8ToUTF16("Name"));
- textfield->SetText(base::UTF8ToUTF16("Value"));
content->AddChildView(textfield);
AtkText* atk_text = ATK_TEXT(textfield->GetNativeViewAccessible());
@@ -56,49 +55,44 @@ TEST_F(ViewAXPlatformNodeDelegateAuraLinuxTest, TextfieldAccessibility) {
g_signal_connect(atk_text, "text-insert", callback, &text_insert_events);
g_signal_connect(atk_text, "text-remove", callback, &text_remove_events);
- textfield->NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
+ textfield->SetText(base::UTF8ToUTF16("Value"));
ASSERT_EQ(text_remove_events.size(), 0ul);
ASSERT_EQ(text_insert_events.size(), 1ul);
- ASSERT_EQ(text_insert_events[0].position, 0);
- ASSERT_EQ(text_insert_events[0].length, 5);
- ASSERT_EQ(text_insert_events[0].text, "Value");
+ EXPECT_EQ(text_insert_events[0].position, 0);
+ EXPECT_EQ(text_insert_events[0].length, 5);
+ EXPECT_EQ(text_insert_events[0].text, "Value");
text_insert_events.clear();
textfield->SetText(base::UTF8ToUTF16("Value A"));
- textfield->NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
-
ASSERT_EQ(text_remove_events.size(), 0ul);
ASSERT_EQ(text_insert_events.size(), 1ul);
- ASSERT_EQ(text_insert_events[0].position, 5);
- ASSERT_EQ(text_insert_events[0].length, 2);
- ASSERT_EQ(text_insert_events[0].text, " A");
+ EXPECT_EQ(text_insert_events[0].position, 5);
+ EXPECT_EQ(text_insert_events[0].length, 2);
+ EXPECT_EQ(text_insert_events[0].text, " A");
text_insert_events.clear();
textfield->SetText(base::UTF8ToUTF16("Value"));
- textfield->NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
ASSERT_EQ(text_remove_events.size(), 1ul);
ASSERT_EQ(text_insert_events.size(), 0ul);
- ASSERT_EQ(text_remove_events[0].position, 5);
- ASSERT_EQ(text_remove_events[0].length, 2);
- ASSERT_EQ(text_remove_events[0].text, " A");
+ EXPECT_EQ(text_remove_events[0].position, 5);
+ EXPECT_EQ(text_remove_events[0].length, 2);
+ EXPECT_EQ(text_remove_events[0].text, " A");
text_remove_events.clear();
textfield->SetText(base::UTF8ToUTF16("Prefix Value"));
- textfield->NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
ASSERT_EQ(text_remove_events.size(), 0ul);
ASSERT_EQ(text_insert_events.size(), 1ul);
- ASSERT_EQ(text_insert_events[0].position, 0);
- ASSERT_EQ(text_insert_events[0].length, 7);
- ASSERT_EQ(text_insert_events[0].text, "Prefix ");
+ EXPECT_EQ(text_insert_events[0].position, 0);
+ EXPECT_EQ(text_insert_events[0].length, 7);
+ EXPECT_EQ(text_insert_events[0].text, "Prefix ");
text_insert_events.clear();
textfield->SetText(base::UTF8ToUTF16("Value"));
- textfield->NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
ASSERT_EQ(text_remove_events.size(), 1ul);
ASSERT_EQ(text_insert_events.size(), 0ul);
- ASSERT_EQ(text_remove_events[0].position, 0);
- ASSERT_EQ(text_remove_events[0].length, 7);
- ASSERT_EQ(text_remove_events[0].text, "Prefix ");
+ EXPECT_EQ(text_remove_events[0].position, 0);
+ EXPECT_EQ(text_remove_events[0].length, 7);
+ EXPECT_EQ(text_remove_events[0].text, "Prefix ");
text_insert_events.clear();
}
diff --git a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
index 797c0eb5482..00ffe077cd7 100644
--- a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
+++ b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
@@ -7,6 +7,7 @@
#include <oleacc.h>
#include <wrl/client.h>
+#include <memory>
#include <utility>
#include "base/win/scoped_bstr.h"
@@ -69,8 +70,7 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, TextfieldAccessibility) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* content = new View;
- widget.SetContentsView(content);
+ View* content = widget.SetContentsView(std::make_unique<View>());
Textfield* textfield = new Textfield;
textfield->SetAccessibleName(L"Name");
@@ -112,8 +112,7 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, TextfieldAssociatedLabel) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* content = new View;
- widget.SetContentsView(content);
+ View* content = widget.SetContentsView(std::make_unique<View>());
Label* label = new Label(L"Label");
content->AddChildView(label);
@@ -259,8 +258,7 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, DISABLED_RetrieveAllAlerts) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* content = new View;
- widget.SetContentsView(content);
+ View* content = widget.SetContentsView(std::make_unique<View>());
View* infobar = new View;
content->AddChildView(infobar);
@@ -358,8 +356,7 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, Overrides) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* contents_view = new View;
- widget.SetContentsView(contents_view);
+ View* contents_view = widget.SetContentsView(std::make_unique<View>());
View* alert_view = new ScrollView;
alert_view->GetViewAccessibility().OverrideRole(ax::mojom::Role::kAlert);
@@ -417,8 +414,7 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, GridRowColumnCount) {
init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget.Init(std::move(init_params));
- View* content = new View;
- widget.SetContentsView(content);
+ View* content = widget.SetContentsView(std::make_unique<View>());
TestListGridView* grid = new TestListGridView();
content->AddChildView(grid);