Commit cc5861b4 authored by Adina Shanholtz's avatar Adina Shanholtz Committed by Commit Bot

Virtual Views now firing native events

NVDA now reads table in HungRendererDialogView. AxVirtualView needed to
implement GetTargetForNativeAccessibilityEvent. As of now, this works
for the repro steps in http://crbug.com/998237.

Bug: 998237
Change-Id: Idadf5be2345e56dc6aa14107710adc7685d07584
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773569Reviewed-by: default avatarKevin Babbitt <kbabbitt@microsoft.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Adina Shanholtz <adinas@microsoft.com>
Cr-Commit-Position: refs/heads/master@{#694307}
parent f8ac17e8
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h" #include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_tree_data.h" #include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/platform/ax_platform_node.h" #include "ui/accessibility/platform/ax_platform_node.h"
...@@ -20,6 +21,10 @@ ...@@ -20,6 +21,10 @@
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#if OS_WIN
#include "ui/views/win/hwnd_util.h"
#endif
namespace views { namespace views {
// Tracks all virtual ax views. // Tracks all virtual ax views.
...@@ -311,6 +316,16 @@ const ui::AXUniqueId& AXVirtualView::GetUniqueId() const { ...@@ -311,6 +316,16 @@ const ui::AXUniqueId& AXVirtualView::GetUniqueId() const {
return unique_id_; return unique_id_;
} }
// Virtual views need to implement this function in order for A11Y events
// to be routed correctly.
gfx::AcceleratedWidget AXVirtualView::GetTargetForNativeAccessibilityEvent() {
#if defined(OS_WIN)
if (GetOwnerView())
return HWNDForView(GetOwnerView());
#endif
return gfx::kNullAcceleratedWidget;
}
bool AXVirtualView::HandleAccessibleAction( bool AXVirtualView::HandleAccessibleAction(
const ui::AXActionData& action_data) { const ui::AXActionData& action_data) {
return false; return false;
......
...@@ -139,6 +139,7 @@ class VIEWS_EXPORT AXVirtualView : public ui::AXPlatformNodeDelegateBase { ...@@ -139,6 +139,7 @@ class VIEWS_EXPORT AXVirtualView : public ui::AXPlatformNodeDelegateBase {
bool ShouldIgnoreHoveredStateForTesting() override; bool ShouldIgnoreHoveredStateForTesting() override;
bool IsOffscreen() const override; bool IsOffscreen() const override;
const ui::AXUniqueId& GetUniqueId() const override; const ui::AXUniqueId& GetUniqueId() const override;
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
// Gets the real View that owns our shallowest virtual ancestor,, if any. // Gets the real View that owns our shallowest virtual ancestor,, if any.
View* GetOwnerView() const; View* GetOwnerView() const;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ui/views/accessibility/ax_virtual_view.h" #include "ui/views/accessibility/ax_virtual_view.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h" #include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
...@@ -15,6 +16,10 @@ ...@@ -15,6 +16,10 @@
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#if defined(OS_WIN)
#include "ui/views/win/hwnd_util.h"
#endif
namespace views { namespace views {
namespace test { namespace test {
...@@ -385,5 +390,15 @@ TEST_F(AXVirtualViewTest, Navigation) { ...@@ -385,5 +390,15 @@ TEST_F(AXVirtualViewTest, Navigation) {
EXPECT_EQ(0, virtual_child_4->GetIndexInParent()); EXPECT_EQ(0, virtual_child_4->GetIndexInParent());
} }
// Test for GetTargetForNativeAccessibilityEvent().
#if defined(OS_WIN)
TEST_F(AXVirtualViewTest, GetTargetForEvents) {
EXPECT_EQ(button_, virtual_label_->GetOwnerView());
EXPECT_NE(nullptr, HWNDForView(virtual_label_->GetOwnerView()));
EXPECT_EQ(HWNDForView(button_),
virtual_label_->GetTargetForNativeAccessibilityEvent());
}
#endif
} // namespace test } // namespace test
} // namespace views } // namespace views
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