Add AXPlatformNodeWin and AXFragmentRootWin (flutter/engine#25121)

* Remove IAccessible and IChromeAccessible from AXPlatformNodeWin

* Fixes to make AXPlatformNodeWin, AXFragmentRootWin and associated unit
tests work and pass in Flutter/Windows
This commit is contained in:
George Wright
2021-03-22 16:59:38 -07:00
committed by GitHub
parent 78e6f91a60
commit 0317a21159
13 changed files with 548 additions and 6042 deletions

View File

@@ -155,6 +155,7 @@ source_set("flutter_windows_source") {
"//flutter/shell/platform/common/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:embedder_as_internal_library",
"//flutter/shell/platform/windows/client_wrapper:client_wrapper_windows",
"//flutter/third_party/accessibility",
"//third_party/angle:libEGL_static", # the order of libEGL_static and
# libGLESv2_static is important.. if
# reversed, will cause a linker error

View File

@@ -47,9 +47,7 @@ if (enable_unittests) {
public_configs = [ ":accessibility_config" ]
# TODO(cbracken): make this block unconditional once Windows node support
# is landed.
if (is_mac) {
if (is_mac || is_win) {
sources = [
"ax/ax_enum_util_unittest.cc",
"ax/ax_event_generator_unittest.cc",
@@ -74,31 +72,21 @@ if (enable_unittests) {
"ax/platform/test_ax_node_wrapper.h",
]
deps = [
":accessibility",
":accessibility_fixtures",
"//flutter/testing",
"//flutter/testing:dart",
]
} else if (is_win) {
sources = [
"base/win/dispatch_stub.cc",
"base/win/dispatch_stub.h",
"base/win/scoped_bstr_unittest.cc",
"base/win/scoped_safearray_unittest.cc",
"base/win/scoped_variant_unittest.cc",
]
if (is_win) {
sources += [
"ax/platform/ax_fragment_root_win_unittest.cc",
"ax/platform/ax_platform_node_win_unittest.cc",
"base/win/dispatch_stub.cc",
"base/win/dispatch_stub.h",
"base/win/scoped_bstr_unittest.cc",
"base/win/scoped_safearray_unittest.cc",
"base/win/scoped_variant_unittest.cc",
]
}
deps = [
":accessibility_fixtures",
"//flutter/testing",
"//flutter/testing:dart",
"//flutter/third_party/accessibility/base",
]
}
if (is_mac || is_win) {
sources += [
"base/logging_unittests.cc",
"base/string_utils_unittest.cc",
"gfx/geometry/insets_unittest.cc",
"gfx/geometry/point_unittest.cc",
"gfx/geometry/rect_unittest.cc",
@@ -109,7 +97,12 @@ if (enable_unittests) {
"gfx/test/gfx_util.h",
]
deps += [ "//flutter/third_party/accessibility/gfx" ]
deps = [
":accessibility",
":accessibility_fixtures",
"//flutter/testing",
"//flutter/testing:dart",
]
}
}
}

View File

@@ -86,10 +86,20 @@ source_set("ax") {
]
} else if (is_win) {
sources += [
"platform/ax_fragment_root_delegate_win.h",
"platform/ax_fragment_root_win.cc",
"platform/ax_fragment_root_win.h",
"platform/ax_platform_node_delegate_utils_win.cc",
"platform/ax_platform_node_delegate_utils_win.h",
"platform/ax_platform_node_win.cc",
"platform/ax_platform_node_win.h",
"platform/uia_registrar_win.cc",
"platform/uia_registrar_win.h",
]
libs = [ "uiautomationcore.lib" ]
libs = [
"oleacc.lib",
"uiautomationcore.lib",
]
}
public_deps = [

View File

@@ -5,7 +5,7 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_FRAGMENT_ROOT_DELEGATE_WIN_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_FRAGMENT_ROOT_DELEGATE_WIN_H_
#include "ui/gfx/native_widget_types.h"
#include "flutter/third_party/accessibility/gfx/native_widget_types.h"
namespace ui {

View File

@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/accessibility/platform/ax_fragment_root_win.h"
#include "ax_fragment_root_win.h"
#include <unordered_map>
#include "base/no_destructor.h"
#include "base/strings/string_number_conversions.h"
#include "ui/accessibility/platform/ax_fragment_root_delegate_win.h"
#include "ui/accessibility/platform/ax_platform_node_win.h"
#include "ui/accessibility/platform/uia_registrar_win.h"
#include "ui/base/win/atl_module.h"
#include "ax_fragment_root_delegate_win.h"
#include "ax_platform_node_win.h"
#include "base/win/atl_module.h"
#include "uia_registrar_win.h"
namespace ui {
@@ -35,7 +33,7 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
CComObject<AXFragmentRootPlatformNodeWin>* instance = nullptr;
HRESULT hr =
CComObject<AXFragmentRootPlatformNodeWin>::CreateInstance(&instance);
DCHECK(SUCCEEDED(hr));
BASE_DCHECK(SUCCEEDED(hr));
instance->Init(delegate);
instance->AddRef();
return instance;
@@ -49,7 +47,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
PROPERTYID property_id,
VARIANT value,
IRawElementProviderSimple** result) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ITEMCONTAINER_FINDITEMBYPROPERTY);
UIA_VALIDATE_CALL_1_ARG(result);
*result = nullptr;
@@ -58,8 +55,10 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
UiaRegistrarWin::GetInstance().GetUiaUniqueIdPropertyId() &&
value.vt == VT_BSTR) {
int32_t ax_unique_id;
if (!base::StringToInt(value.bstrVal, &ax_unique_id))
return S_OK;
// TODO(gw280): https://github.com/flutter/flutter/issues/78802
// detect and handle errors
ax_unique_id = std::stoi(value.bstrVal);
// In the Windows accessibility platform implementation, id 0 represents
// self; a positive id represents the immediate descendants; and a
@@ -91,7 +90,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
IFACEMETHODIMP get_HostRawElementProvider(
IRawElementProviderSimple** host_element_provider) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER);
UIA_VALIDATE_CALL_1_ARG(host_element_provider);
HWND hwnd = GetDelegate()->GetTargetForNativeAccessibilityEvent();
@@ -100,7 +98,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
IFACEMETHODIMP GetPatternProvider(PATTERNID pattern_id,
IUnknown** result) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PATTERN_PROVIDER);
UIA_VALIDATE_CALL_1_ARG(result);
*result = nullptr;
@@ -115,7 +112,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
IFACEMETHODIMP GetPropertyValue(PROPERTYID property_id,
VARIANT* result) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_PROPERTY_VALUE);
UIA_VALIDATE_CALL_1_ARG(result);
switch (property_id) {
@@ -149,7 +145,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
IFACEMETHODIMP get_FragmentRoot(
IRawElementProviderFragmentRoot** fragment_root) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FRAGMENTROOT);
UIA_VALIDATE_CALL_1_ARG(fragment_root);
QueryInterface(IID_PPV_ARGS(fragment_root));
@@ -163,8 +158,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
double screen_physical_pixel_x,
double screen_physical_pixel_y,
IRawElementProviderFragment** element_provider) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ELEMENT_PROVIDER_FROM_POINT);
WIN_ACCESSIBILITY_API_PERF_HISTOGRAM(UMA_API_ELEMENT_PROVIDER_FROM_POINT);
UIA_VALIDATE_CALL_1_ARG(element_provider);
*element_provider = nullptr;
@@ -192,7 +185,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
}
IFACEMETHODIMP GetFocus(IRawElementProviderFragment** focus) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_FOCUS);
UIA_VALIDATE_CALL_1_ARG(focus);
*focus = nullptr;
@@ -226,7 +218,6 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
//
IFACEMETHODIMP AdviseEventAdded(EVENTID event_id,
SAFEARRAY* property_ids) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADVISE_EVENT_ADDED);
if (event_id == UIA_LiveRegionChangedEventId) {
live_region_change_listeners_++;
@@ -249,9 +240,8 @@ class AXFragmentRootPlatformNodeWin : public AXPlatformNodeWin,
IFACEMETHODIMP AdviseEventRemoved(EVENTID event_id,
SAFEARRAY* property_ids) override {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ADVISE_EVENT_REMOVED);
if (event_id == UIA_LiveRegionChangedEventId) {
DCHECK(live_region_change_listeners_ > 0);
BASE_DCHECK(live_region_change_listeners_ > 0);
live_region_change_listeners_--;
}
return S_OK;
@@ -323,12 +313,6 @@ AXFragmentRootWin* AXFragmentRootWin::GetFragmentRootParentOf(
}
gfx::NativeViewAccessible AXFragmentRootWin::GetNativeViewAccessible() {
// The fragment root is the entry point from the operating system for UI
// Automation. Signal observers when we're asked for a platform object on it.
for (WinAccessibilityAPIUsageObserver& observer :
GetWinAccessibilityAPIUsageObserverList()) {
observer.OnUIAutomationUsed();
}
return platform_node_.Get();
}

View File

@@ -5,7 +5,7 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_FRAGMENT_ROOT_WIN_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_FRAGMENT_ROOT_WIN_H_
#include "ui/accessibility/platform/ax_platform_node_delegate_base.h"
#include "ax_platform_node_delegate_base.h"
#include <wrl/client.h>

View File

@@ -2,11 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/accessibility/platform/ax_fragment_root_win.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/accessibility/platform/ax_platform_node_win.h"
#include "ui/accessibility/platform/ax_platform_node_win_unittest.h"
#include "ui/accessibility/platform/test_ax_node_wrapper.h"
#include "ax_fragment_root_win.h"
#include "ax_platform_node_win.h"
#include "ax_platform_node_win_unittest.h"
#include "test_ax_node_wrapper.h"
#include <UIAutomationClient.h>
#include <UIAutomationCoreApi.h>
@@ -14,8 +13,8 @@
#include "base/auto_reset.h"
#include "base/win/scoped_safearray.h"
#include "base/win/scoped_variant.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/platform/uia_registrar_win.h"
#include "gtest/gtest.h"
#include "uia_registrar_win.h"
using base::win::ScopedVariant;
using Microsoft::WRL::ComPtr;
@@ -93,8 +92,8 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
// the item.
{
unique_id = AXPlatformNodeFromNode(GetRootAsAXNode())->GetUniqueId();
unique_id_variant.Set(
SysAllocString(base::NumberToString16(-unique_id).c_str()));
unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
base::NumberToString16(-unique_id).c_str())));
ComPtr<IRawElementProviderSimple> invalid_element_provider_simple;
EXPECT_HRESULT_SUCCEEDED(
@@ -113,8 +112,8 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
// corresponding IRawElementProviderSimple through FindItemByProperty().
{
unique_id = AXPlatformNodeFromNode(GetRootAsAXNode())->GetUniqueId();
unique_id_variant.Set(
SysAllocString(base::NumberToString16(-unique_id).c_str()));
unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
base::NumberToString16(-unique_id).c_str())));
// When |start_after_element| of FindItemByProperty() is nullptr, we should
// be able to find "text1".
@@ -151,8 +150,8 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
// corresponding IRawElementProviderSimple through FindItemByProperty().
{
unique_id = AXPlatformNodeFromNode(text1_node)->GetUniqueId();
unique_id_variant.Set(
SysAllocString(base::NumberToString16(-unique_id).c_str()));
unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
base::NumberToString16(-unique_id).c_str())));
// When |start_after_element| of FindItemByProperty() is nullptr, we should
// be able to find "text1".
@@ -188,8 +187,8 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
// corresponding IRawElementProviderSimple through FindItemByProperty().
{
unique_id = AXPlatformNodeFromNode(button_node)->GetUniqueId();
unique_id_variant.Set(
SysAllocString(base::NumberToString16(-unique_id).c_str()));
unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
base::NumberToString16(-unique_id).c_str())));
// When |start_after_element| of FindItemByProperty() is nullptr, we should
// be able to find "button".
@@ -225,8 +224,8 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
{
unique_id =
AXPlatformNodeFromNode(button_node->children()[0])->GetUniqueId();
unique_id_variant.Set(
SysAllocString(base::NumberToString16(-unique_id).c_str()));
unique_id_variant.Set(SysAllocString(reinterpret_cast<const wchar_t*>(
base::NumberToString16(-unique_id).c_str())));
// When |start_after_element| of FindItemByProperty() is nullptr, we should
// be able to find "text2".
@@ -263,6 +262,7 @@ TEST_F(AXFragmentRootTest, UIAFindItemByPropertyUniqueId) {
TEST_F(AXFragmentRootTest, TestUIAGetFragmentRoot) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -371,6 +371,7 @@ TEST_F(AXFragmentRootTest, TestUIAGetFocus) {
TEST_F(AXFragmentRootTest, TestUIAErrorHandling) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -410,6 +411,7 @@ TEST_F(AXFragmentRootTest, TestUIAErrorHandling) {
TEST_F(AXFragmentRootTest, TestGetChildCount) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -422,6 +424,7 @@ TEST_F(AXFragmentRootTest, TestGetChildCount) {
TEST_F(AXFragmentRootTest, TestChildAtIndex) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -437,6 +440,7 @@ TEST_F(AXFragmentRootTest, TestChildAtIndex) {
TEST_F(AXFragmentRootTest, TestGetParent) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -451,6 +455,7 @@ TEST_F(AXFragmentRootTest, TestGetParent) {
TEST_F(AXFragmentRootTest, TestGetPropertyValue) {
AXNodeData root;
root.id = 1;
Init(root);
InitFragmentRoot();
@@ -666,6 +671,7 @@ TEST_F(AXFragmentRootTest, TestUIAMultipleFragmentRoots) {
TEST_F(AXFragmentRootTest, TestFragmentRootMap) {
AXNodeData root;
root.id = 1;
Init(root);
// There should be nothing in the map before we create a fragment root.

View File

@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/accessibility/platform/ax_platform_node_delegate_utils_win.h"
#include "ax_platform_node_delegate_utils_win.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_role_properties.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#include "ax/ax_node_data.h"
#include "ax/ax_role_properties.h"
#include "ax/platform/ax_platform_node.h"
#include "ax/platform/ax_platform_node_delegate.h"
namespace ui {

View File

@@ -5,7 +5,7 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_UTILS_WIN_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_DELEGATE_UTILS_WIN_H_
#include "ui/accessibility/ax_export.h"
#include "ax/ax_export.h"
namespace ui {

View File

@@ -6,6 +6,8 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_H_
#include <atlbase.h>
#include <atlcom.h>
#include <objbase.h>
#include <oleacc.h>
#include <oleauto.h>
@@ -17,287 +19,10 @@
#include <string>
#include <vector>
#include "ax/ax_export.h"
#include "ax/platform/ax_platform_node_base.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/win/atl.h"
#include "third_party/iaccessible2/ia2_api_all.h"
#include "ui/accessibility/ax_enums.mojom-forward.h"
#include "ui/accessibility/ax_export.h"
#include "ui/accessibility/ax_text_utils.h"
#include "ui/accessibility/platform/ax_platform_node_base.h"
#include "ui/accessibility/platform/ax_platform_text_boundary.h"
#include "ui/accessibility/platform/ichromeaccessible.h"
#include "ui/gfx/range/range.h"
// IMPORTANT!
// These values are written to logs. Do not renumber or delete
// existing items; add new entries to the end of the list.
enum {
UMA_API_ACC_DO_DEFAULT_ACTION = 0,
UMA_API_ACC_HIT_TEST = 1,
UMA_API_ACC_LOCATION = 2,
UMA_API_ACC_NAVIGATE = 3,
UMA_API_ACC_SELECT = 4,
UMA_API_ADD_SELECTION = 5,
UMA_API_CONVERT_RETURNED_ELEMENT = 6,
UMA_API_DO_ACTION = 7,
UMA_API_GET_ACCESSIBLE_AT = 8,
UMA_API_GET_ACC_CHILD = 9,
UMA_API_GET_ACC_CHILD_COUNT = 10,
UMA_API_GET_ACC_DEFAULT_ACTION = 11,
UMA_API_GET_ACC_DESCRIPTION = 12,
UMA_API_GET_ACC_FOCUS = 13,
UMA_API_GET_ACC_HELP = 14,
UMA_API_GET_ACC_HELP_TOPIC = 15,
UMA_API_GET_ACC_KEYBOARD_SHORTCUT = 16,
UMA_API_GET_ACC_NAME = 17,
UMA_API_GET_ACC_PARENT = 18,
UMA_API_GET_ACC_ROLE = 19,
UMA_API_GET_ACC_SELECTION = 20,
UMA_API_GET_ACC_STATE = 21,
UMA_API_GET_ACC_VALUE = 22,
UMA_API_GET_ANCHOR = 23,
UMA_API_GET_ANCHOR_TARGET = 24,
UMA_API_GET_APP_NAME = 25,
UMA_API_GET_APP_VERSION = 26,
UMA_API_GET_ATTRIBUTES_FOR_NAMES = 27,
UMA_API_GET_CAPTION = 28,
UMA_API_GET_CARET_OFFSET = 29,
UMA_API_GET_CELL_AT = 30,
UMA_API_GET_CHARACTER_EXTENTS = 31,
UMA_API_GET_CHILD_AT = 32,
UMA_API_GET_CHILD_INDEX = 33,
UMA_API_GET_CLIPPED_SUBSTRING_BOUNDS = 34,
UMA_API_GET_COLUMN_DESCRIPTION = 35,
UMA_API_GET_COLUMN_EXTENT = 36,
UMA_API_GET_COLUMN_EXTENT_AT = 37,
UMA_API_GET_COLUMN_HEADER = 38,
UMA_API_GET_COLUMN_HEADER_CELLS = 39,
UMA_API_GET_COLUMN_INDEX = 40,
UMA_API_GET_COMPUTED_STYLE = 41,
UMA_API_GET_COMPUTED_STYLE_FOR_PROPERTIES = 42,
UMA_API_GET_CURRENT_VALUE = 43,
UMA_API_GET_DESCRIPTION = 44,
UMA_API_GET_DOC_TYPE = 45,
UMA_API_GET_DOM_TEXT = 46,
UMA_API_GET_END_INDEX = 47,
UMA_API_GET_EXTENDED_ROLE = 48,
UMA_API_GET_EXTENDED_STATES = 49,
UMA_API_GET_FIRST_CHILD = 50,
UMA_API_GET_FONT_FAMILY = 51,
UMA_API_GET_GROUP_POSITION = 52,
UMA_API_GET_HOST_RAW_ELEMENT_PROVIDER = 53,
UMA_API_GET_HYPERLINK = 54,
UMA_API_GET_HYPERLINK_INDEX = 55,
UMA_API_GET_IACCESSIBLE_PAIR = 56,
UMA_API_GET_IMAGE_POSITION = 57,
UMA_API_GET_IMAGE_SIZE = 58,
UMA_API_GET_INDEX_IN_PARENT = 59,
UMA_API_GET_INNER_HTML = 60,
UMA_API_GET_IS_COLUMN_SELECTED = 61,
UMA_API_GET_IS_ROW_SELECTED = 62,
UMA_API_GET_IS_SELECTED = 63,
UMA_API_GET_KEY_BINDING = 64,
UMA_API_GET_LANGUAGE = 65,
UMA_API_GET_LAST_CHILD = 66,
UMA_API_GET_LOCALE = 67,
UMA_API_GET_LOCALIZED_EXTENDED_ROLE = 68,
UMA_API_GET_LOCALIZED_EXTENDED_STATES = 69,
UMA_API_GET_LOCALIZED_NAME = 70,
UMA_API_GET_LOCAL_INTERFACE = 71,
UMA_API_GET_MAXIMUM_VALUE = 72,
UMA_API_GET_MIME_TYPE = 73,
UMA_API_GET_MINIMUM_VALUE = 74,
UMA_API_GET_NAME = 75,
UMA_API_GET_NAMESPACE_URI_FOR_ID = 76,
UMA_API_GET_NEW_TEXT = 77,
UMA_API_GET_NEXT_SIBLING = 78,
UMA_API_GET_NODE_INFO = 79,
UMA_API_GET_N_CHARACTERS = 80,
UMA_API_GET_N_COLUMNS = 81,
UMA_API_GET_N_EXTENDED_STATES = 82,
UMA_API_GET_N_HYPERLINKS = 83,
UMA_API_GET_N_RELATIONS = 84,
UMA_API_GET_N_ROWS = 85,
UMA_API_GET_N_SELECTED_CELLS = 86,
UMA_API_GET_N_SELECTED_CHILDREN = 87,
UMA_API_GET_N_SELECTED_COLUMNS = 88,
UMA_API_GET_N_SELECTED_ROWS = 89,
UMA_API_GET_N_SELECTIONS = 90,
UMA_API_GET_OBJECT_FOR_CHILD = 91,
UMA_API_GET_OFFSET_AT_POINT = 92,
UMA_API_GET_OLD_TEXT = 93,
UMA_API_GET_PARENT_NODE = 94,
UMA_API_GET_PATTERN_PROVIDER = 95,
UMA_API_GET_PREVIOUS_SIBLING = 96,
UMA_API_GET_PROPERTY_VALUE = 97,
UMA_API_GET_PROVIDER_OPTIONS = 98,
UMA_API_GET_RELATION = 99,
UMA_API_GET_RELATIONS = 100,
UMA_API_GET_ROW_COLUMN_EXTENTS = 101,
UMA_API_GET_ROW_COLUMN_EXTENTS_AT_INDEX = 102,
UMA_API_GET_ROW_DESCRIPTION = 103,
UMA_API_GET_ROW_EXTENT = 104,
UMA_API_GET_ROW_EXTENT_AT = 105,
UMA_API_GET_ROW_HEADER = 106,
UMA_API_GET_ROW_HEADER_CELLS = 107,
UMA_API_GET_ROW_INDEX = 108,
UMA_API_GET_RUNTIME_ID = 109,
UMA_API_GET_SELECTED_CELLS = 110,
UMA_API_GET_SELECTED_CHILDREN = 111,
UMA_API_GET_SELECTED_COLUMNS = 112,
UMA_API_GET_SELECTED_ROWS = 113,
UMA_API_GET_SELECTION = 114,
UMA_API_GET_START_INDEX = 115,
UMA_API_GET_STATES = 116,
UMA_API_GET_SUMMARY = 117,
UMA_API_GET_TABLE = 118,
UMA_API_GET_TEXT = 119,
UMA_API_GET_TEXT_AFTER_OFFSET = 120,
UMA_API_GET_TEXT_AT_OFFSET = 121,
UMA_API_GET_TEXT_BEFORE_OFFSET = 122,
UMA_API_GET_TITLE = 123,
UMA_API_GET_TOOLKIT_NAME = 124,
UMA_API_GET_TOOLKIT_VERSION = 125,
UMA_API_GET_UNCLIPPED_SUBSTRING_BOUNDS = 126,
UMA_API_GET_UNIQUE_ID = 127,
UMA_API_GET_URL = 128,
UMA_API_GET_VALID = 129,
UMA_API_GET_WINDOW_HANDLE = 130,
UMA_API_IA2_GET_ATTRIBUTES = 131,
UMA_API_IA2_SCROLL_TO = 132,
UMA_API_IAACTION_GET_DESCRIPTION = 133,
UMA_API_IATEXT_GET_ATTRIBUTES = 134,
UMA_API_ISIMPLEDOMNODE_GET_ATTRIBUTES = 135,
UMA_API_ISIMPLEDOMNODE_SCROLL_TO = 136,
UMA_API_N_ACTIONS = 137,
UMA_API_PUT_ALTERNATE_VIEW_MEDIA_TYPES = 138,
UMA_API_QUERY_SERVICE = 139,
UMA_API_REMOVE_SELECTION = 140,
UMA_API_ROLE = 141,
UMA_API_SCROLL_SUBSTRING_TO = 142,
UMA_API_SCROLL_SUBSTRING_TO_POINT = 143,
UMA_API_SCROLL_TO_POINT = 144,
UMA_API_SCROLL_TO_SUBSTRING = 145,
UMA_API_SELECT_COLUMN = 146,
UMA_API_SELECT_ROW = 147,
UMA_API_SET_CARET_OFFSET = 148,
UMA_API_SET_CURRENT_VALUE = 149,
UMA_API_SET_SELECTION = 150,
UMA_API_TABLE2_GET_SELECTED_COLUMNS = 151,
UMA_API_TABLE2_GET_SELECTED_ROWS = 152,
UMA_API_TABLECELL_GET_COLUMN_INDEX = 153,
UMA_API_TABLECELL_GET_IS_SELECTED = 154,
UMA_API_TABLECELL_GET_ROW_INDEX = 155,
UMA_API_UNSELECT_COLUMN = 156,
UMA_API_UNSELECT_ROW = 157,
UMA_API_GET_BOUNDINGRECTANGLE = 158,
UMA_API_GET_FRAGMENTROOT = 159,
UMA_API_GETEMBEDDEDFRAGMENTROOTS = 160,
UMA_API_NAVIGATE = 161,
UMA_API_SETFOCUS = 162,
UMA_API_SHOWCONTEXTMENU = 163,
UMA_API_EXPANDCOLLAPSE_COLLAPSE = 164,
UMA_API_EXPANDCOLLAPSE_EXPAND = 165,
UMA_API_EXPANDCOLLAPSE_GET_EXPANDCOLLAPSESTATE = 166,
UMA_API_GRIDITEM_GET_COLUMN = 167,
UMA_API_GRIDITEM_GET_COLUMNSPAN = 168,
UMA_API_GRIDITEM_GET_CONTAININGGRID = 169,
UMA_API_GRIDITEM_GET_ROW = 170,
UMA_API_GRIDITEM_GET_ROWSPAN = 171,
UMA_API_GRID_GETITEM = 172,
UMA_API_GRID_GET_ROWCOUNT = 173,
UMA_API_GRID_GET_COLUMNCOUNT = 174,
UMA_API_INVOKE_INVOKE = 175,
UMA_API_RANGEVALUE_SETVALUE = 176,
UMA_API_RANGEVALUE_GET_LARGECHANGE = 177,
UMA_API_RANGEVALUE_GET_MAXIMUM = 178,
UMA_API_RANGEVALUE_GET_MINIMUM = 179,
UMA_API_RANGEVALUE_GET_SMALLCHANGE = 180,
UMA_API_RANGEVALUE_GET_VALUE = 181,
UMA_API_SCROLLITEM_SCROLLINTOVIEW = 182,
UMA_API_SCROLL_SCROLL = 183,
UMA_API_SCROLL_SETSCROLLPERCENT = 184,
UMA_API_SCROLL_GET_HORIZONTALLYSCROLLABLE = 185,
UMA_API_SCROLL_GET_HORIZONTALSCROLLPERCENT = 186,
UMA_API_SCROLL_GET_HORIZONTALVIEWSIZE = 187,
UMA_API_SCROLL_GET_VERTICALLYSCROLLABLE = 188,
UMA_API_SCROLL_GET_VERTICALSCROLLPERCENT = 189,
UMA_API_SCROLL_GET_VERTICALVIEWSIZE = 190,
UMA_API_SELECTIONITEM_ADDTOSELECTION = 191,
UMA_API_SELECTIONITEM_REMOVEFROMSELECTION = 192,
UMA_API_SELECTIONITEM_SELECT = 193,
UMA_API_SELECTIONITEM_GET_ISSELECTED = 194,
UMA_API_SELECTIONITEM_GET_SELECTIONCONTAINER = 195,
UMA_API_SELECTION_GETSELECTION = 196,
UMA_API_SELECTION_GET_CANSELECTMULTIPLE = 197,
UMA_API_SELECTION_GET_ISSELECTIONREQUIRED = 198,
UMA_API_TABLEITEM_GETCOLUMNHEADERITEMS = 199,
UMA_API_TABLEITEM_GETROWHEADERITEMS = 200,
UMA_API_TABLE_GETCOLUMNHEADERS = 201,
UMA_API_TABLE_GETROWHEADERS = 202,
UMA_API_TABLE_GET_ROWORCOLUMNMAJOR = 203,
UMA_API_TEXT_GETSELECTION = 204,
UMA_API_TEXT_GETVISIBLERANGES = 205,
UMA_API_TEXT_RANGEFROMCHILD = 206,
UMA_API_TEXT_RANGEFROMPOINT = 207,
UMA_API_TEXT_GET_DOCUMENTRANGE = 208,
UMA_API_TEXT_GET_SUPPORTEDTEXTSELECTION = 209,
UMA_API_TEXTCHILD_GET_TEXTCONTAINER = 210,
UMA_API_TEXTCHILD_GET_TEXTRANGE = 211,
UMA_API_TEXTEDIT_GETACTIVECOMPOSITION = 212,
UMA_API_TEXTEDIT_GETCONVERSIONTARGET = 213,
UMA_API_TEXTRANGE_CLONE = 214,
UMA_API_TEXTRANGE_COMPARE = 215,
UMA_API_TEXTRANGE_COMPAREENDPOINTS = 216,
UMA_API_TEXTRANGE_EXPANDTOENCLOSINGUNIT = 217,
UMA_API_TEXTRANGE_FINDATTRIBUTE = 218,
UMA_API_TEXTRANGE_FINDTEXT = 219,
UMA_API_TEXTRANGE_GETATTRIBUTEVALUE = 220,
UMA_API_TEXTRANGE_GETBOUNDINGRECTANGLES = 221,
UMA_API_TEXTRANGE_GETENCLOSINGELEMENT = 222,
UMA_API_TEXTRANGE_GETTEXT = 223,
UMA_API_TEXTRANGE_MOVE = 224,
UMA_API_TEXTRANGE_MOVEENDPOINTBYUNIT = 225,
UMA_API_TEXTRANGE_MOVEENPOINTBYRANGE = 226,
UMA_API_TEXTRANGE_SELECT = 227,
UMA_API_TEXTRANGE_ADDTOSELECTION = 228,
UMA_API_TEXTRANGE_REMOVEFROMSELECTION = 229,
UMA_API_TEXTRANGE_SCROLLINTOVIEW = 230,
UMA_API_TEXTRANGE_GETCHILDREN = 231,
UMA_API_TOGGLE_TOGGLE = 232,
UMA_API_TOGGLE_GET_TOGGLESTATE = 233,
UMA_API_VALUE_SETVALUE = 234,
UMA_API_VALUE_GET_ISREADONLY = 235,
UMA_API_VALUE_GET_VALUE = 236,
UMA_API_WINDOW_SETVISUALSTATE = 237,
UMA_API_WINDOW_CLOSE = 238,
UMA_API_WINDOW_WAITFORINPUTIDLE = 239,
UMA_API_WINDOW_GET_CANMAXIMIZE = 240,
UMA_API_WINDOW_GET_CANMINIMIZE = 241,
UMA_API_WINDOW_GET_ISMODAL = 242,
UMA_API_WINDOW_GET_WINDOWVISUALSTATE = 243,
UMA_API_WINDOW_GET_WINDOWINTERACTIONSTATE = 244,
UMA_API_WINDOW_GET_ISTOPMOST = 245,
UMA_API_ELEMENT_PROVIDER_FROM_POINT = 246,
UMA_API_GET_FOCUS = 247,
UMA_API_ADVISE_EVENT_ADDED = 248,
UMA_API_ADVISE_EVENT_REMOVED = 249,
UMA_API_ITEMCONTAINER_FINDITEMBYPROPERTY = 250,
// This must always be the last enum. It's okay for its value to
// increase, but none of the other enum values may change.
UMA_API_MAX
};
#define WIN_ACCESSIBILITY_API_HISTOGRAM(enum_value) \
UMA_HISTOGRAM_ENUMERATION("Accessibility.WinAPIs", enum_value, UMA_API_MAX)
#define WIN_ACCESSIBILITY_API_PERF_HISTOGRAM(enum_value) \
SCOPED_UMA_HISTOGRAM_SHORT_TIMER( \
"Accessibility.Performance.WinAPIs." #enum_value)
#include "gfx/range/range.h"
//
// Macros to use at the top of any AXPlatformNodeWin (or derived class) method
@@ -324,39 +49,10 @@ class VariantVector;
namespace ui {
class AXPlatformNodeWin;
class AXPlatformRelationWin;
// A simple interface for a class that wants to be notified when Windows
// accessibility APIs are used by a client, a strong indication that full
// accessibility support should be enabled.
class AX_EXPORT WinAccessibilityAPIUsageObserver {
public:
WinAccessibilityAPIUsageObserver();
virtual ~WinAccessibilityAPIUsageObserver();
virtual void OnIAccessible2Used() = 0;
virtual void OnScreenReaderHoneyPotQueried() = 0;
virtual void OnAccNameCalled() = 0;
virtual void OnUIAutomationUsed() = 0;
};
// Get an observer list that allows modules across the codebase to
// listen to when usage of Windows accessibility APIs is detected.
extern AX_EXPORT
base::ObserverList<WinAccessibilityAPIUsageObserver>::Unchecked&
GetWinAccessibilityAPIUsageObserverList();
// TODO(nektar): Remove multithread superclass since we don't support it.
class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
AXPlatformNodeWin : public CComObjectRootEx<CComMultiThreadModel>,
public IDispatchImpl<IAccessible2_4,
&IID_IAccessible2_4,
&LIBID_IAccessible2Lib>,
public IAccessibleEx,
public IAccessibleHypertext,
public IAccessibleTable,
public IAccessibleTable2,
public IAccessibleTableCell,
public IAccessibleValue,
public IDispatchImpl<IAccessible>,
public IExpandCollapseProvider,
public IGridItemProvider,
public IGridProvider,
@@ -374,31 +70,16 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
public IToggleProvider,
public IValueProvider,
public IWindowProvider,
public IChromeAccessible,
public AXPlatformNodeBase {
using IDispatchImpl::Invoke;
public:
BEGIN_COM_MAP(AXPlatformNodeWin)
// TODO(nektar): Change the following to COM_INTERFACE_ENTRY(IDispatch).
COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2)
COM_INTERFACE_ENTRY2(IUnknown, IDispatchImpl)
// TODO(nektar): Find a way to remove the following entry because it's not
// an interface.
COM_INTERFACE_ENTRY(AXPlatformNodeWin)
COM_INTERFACE_ENTRY(IAccessible)
COM_INTERFACE_ENTRY(IAccessible2)
COM_INTERFACE_ENTRY(IAccessible2_2)
COM_INTERFACE_ENTRY(IAccessible2_3)
COM_INTERFACE_ENTRY(IAccessible2_4)
COM_INTERFACE_ENTRY(IAccessibleEx)
COM_INTERFACE_ENTRY(IAccessibleText)
COM_INTERFACE_ENTRY(IAccessibleHypertext)
COM_INTERFACE_ENTRY(IAccessibleTable)
COM_INTERFACE_ENTRY(IAccessibleTable2)
COM_INTERFACE_ENTRY(IAccessibleTableCell)
COM_INTERFACE_ENTRY(IAccessibleValue)
COM_INTERFACE_ENTRY(IChromeAccessible)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IExpandCollapseProvider)
COM_INTERFACE_ENTRY(IGridItemProvider)
COM_INTERFACE_ENTRY(IGridProvider)
@@ -423,16 +104,13 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
void Init(AXPlatformNodeDelegate* delegate) override;
// Clear any AXPlatformRelationWin nodes owned by this node.
void ClearOwnRelations();
// AXPlatformNode overrides.
gfx::NativeViewAccessible GetNativeViewAccessible() override;
void NotifyAccessibilityEvent(ax::mojom::Event event_type) override;
// AXPlatformNodeBase overrides.
void Destroy() override;
base::string16 GetValue() const override;
std::u16string GetValue() const override;
bool IsPlatformCheckable() const override;
//
@@ -509,81 +187,6 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
LONG* topic_id) override;
IFACEMETHODIMP put_accName(VARIANT var_id, BSTR put_name) override;
//
// IAccessible2 methods.
//
IFACEMETHODIMP role(LONG* role) override;
IFACEMETHODIMP get_states(AccessibleStates* states) override;
IFACEMETHODIMP get_uniqueID(LONG* unique_id) override;
IFACEMETHODIMP get_windowHandle(HWND* window_handle) override;
IFACEMETHODIMP get_relationTargetsOfType(BSTR type,
LONG max_targets,
IUnknown*** targets,
LONG* n_targets) override;
IFACEMETHODIMP get_attributes(BSTR* attributes) override;
IFACEMETHODIMP get_indexInParent(LONG* index_in_parent) override;
IFACEMETHODIMP get_nRelations(LONG* n_relations) override;
IFACEMETHODIMP get_relation(LONG relation_index,
IAccessibleRelation** relation) override;
IFACEMETHODIMP get_relations(LONG max_relations,
IAccessibleRelation** relations,
LONG* n_relations) override;
IFACEMETHODIMP get_attribute(BSTR name, VARIANT* attribute) override;
IFACEMETHODIMP get_extendedRole(BSTR* extended_role) override;
IFACEMETHODIMP scrollTo(enum IA2ScrollType scroll_type) override;
IFACEMETHODIMP scrollToPoint(enum IA2CoordinateType coordinate_type,
LONG x,
LONG y) override;
IFACEMETHODIMP get_groupPosition(LONG* group_level,
LONG* similar_items_in_group,
LONG* position_in_group) override;
IFACEMETHODIMP get_localizedExtendedRole(
BSTR* localized_extended_role) override;
IFACEMETHODIMP get_nExtendedStates(LONG* n_extended_states) override;
IFACEMETHODIMP get_extendedStates(LONG max_extended_states,
BSTR** extended_states,
LONG* n_extended_states) override;
IFACEMETHODIMP get_localizedExtendedStates(
LONG max_localized_extended_states,
BSTR** localized_extended_states,
LONG* n_localized_extended_states) override;
IFACEMETHODIMP get_locale(IA2Locale* locale) override;
IFACEMETHODIMP get_accessibleWithCaret(IUnknown** accessible,
LONG* caret_offset) override;
//
// IAccessible2_3 methods.
//
IFACEMETHODIMP get_selectionRanges(IA2Range** ranges, LONG* nRanges) override;
//
// IAccessible2_4 methods.
//
IFACEMETHODIMP setSelectionRanges(LONG nRanges, IA2Range* ranges) override;
//
// IAccessibleEx methods.
//
IFACEMETHODIMP GetObjectForChild(LONG child_id,
IAccessibleEx** result) override;
IFACEMETHODIMP GetIAccessiblePair(IAccessible** accessible,
LONG* child_id) override;
//
// IExpandCollapseProvider methods.
//
@@ -759,248 +362,6 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
IFACEMETHODIMP get_Value(double* result) override;
// IAccessibleEx methods not implemented.
IFACEMETHODIMP
ConvertReturnedElement(IRawElementProviderSimple* element,
IAccessibleEx** acc) override;
//
// IAccessibleText methods.
//
IFACEMETHODIMP get_nCharacters(LONG* n_characters) override;
IFACEMETHODIMP get_caretOffset(LONG* offset) override;
IFACEMETHODIMP get_nSelections(LONG* n_selections) override;
IFACEMETHODIMP get_selection(LONG selection_index,
LONG* start_offset,
LONG* end_offset) override;
IFACEMETHODIMP get_text(LONG start_offset,
LONG end_offset,
BSTR* text) override;
IFACEMETHODIMP get_textAtOffset(LONG offset,
enum IA2TextBoundaryType boundary_type,
LONG* start_offset,
LONG* end_offset,
BSTR* text) override;
IFACEMETHODIMP get_textBeforeOffset(LONG offset,
enum IA2TextBoundaryType boundary_type,
LONG* start_offset,
LONG* end_offset,
BSTR* text) override;
IFACEMETHODIMP get_textAfterOffset(LONG offset,
enum IA2TextBoundaryType boundary_type,
LONG* start_offset,
LONG* end_offset,
BSTR* text) override;
IFACEMETHODIMP get_offsetAtPoint(LONG x,
LONG y,
enum IA2CoordinateType coord_type,
LONG* offset) override;
//
// IAccessibleTable methods.
//
// get_description - also used by IAccessibleImage
IFACEMETHODIMP get_accessibleAt(LONG row,
LONG column,
IUnknown** accessible) override;
IFACEMETHODIMP get_caption(IUnknown** accessible) override;
IFACEMETHODIMP get_childIndex(LONG row_index,
LONG column_index,
LONG* cell_index) override;
IFACEMETHODIMP get_columnDescription(LONG column, BSTR* description) override;
IFACEMETHODIMP
get_columnExtentAt(LONG row, LONG column, LONG* n_columns_spanned) override;
IFACEMETHODIMP
get_columnHeader(IAccessibleTable** accessible_table,
LONG* starting_row_index) override;
IFACEMETHODIMP get_columnIndex(LONG cell_index, LONG* column_index) override;
IFACEMETHODIMP get_nColumns(LONG* column_count) override;
IFACEMETHODIMP get_nRows(LONG* row_count) override;
IFACEMETHODIMP get_nSelectedChildren(LONG* cell_count) override;
IFACEMETHODIMP get_nSelectedColumns(LONG* column_count) override;
IFACEMETHODIMP get_nSelectedRows(LONG* row_count) override;
IFACEMETHODIMP get_rowDescription(LONG row, BSTR* description) override;
IFACEMETHODIMP get_rowExtentAt(LONG row,
LONG column,
LONG* n_rows_spanned) override;
IFACEMETHODIMP
get_rowHeader(IAccessibleTable** accessible_table,
LONG* starting_column_index) override;
IFACEMETHODIMP get_rowIndex(LONG cell_index, LONG* row_index) override;
IFACEMETHODIMP get_selectedChildren(LONG max_children,
LONG** children,
LONG* n_children) override;
IFACEMETHODIMP get_selectedColumns(LONG max_columns,
LONG** columns,
LONG* n_columns) override;
IFACEMETHODIMP get_selectedRows(LONG max_rows,
LONG** rows,
LONG* n_rows) override;
IFACEMETHODIMP get_summary(IUnknown** accessible) override;
IFACEMETHODIMP
get_isColumnSelected(LONG column, boolean* is_selected) override;
IFACEMETHODIMP get_isRowSelected(LONG row, boolean* is_selected) override;
IFACEMETHODIMP get_isSelected(LONG row,
LONG column,
boolean* is_selected) override;
IFACEMETHODIMP
get_rowColumnExtentsAtIndex(LONG index,
LONG* row,
LONG* column,
LONG* row_extents,
LONG* column_extents,
boolean* is_selected) override;
IFACEMETHODIMP selectRow(LONG row) override;
IFACEMETHODIMP selectColumn(LONG column) override;
IFACEMETHODIMP unselectRow(LONG row) override;
IFACEMETHODIMP unselectColumn(LONG column) override;
IFACEMETHODIMP
get_modelChange(IA2TableModelChange* model_change) override;
//
// IAccessibleTable2 methods.
//
// (Most of these are duplicates of IAccessibleTable methods, only the
// unique ones are included here.)
//
IFACEMETHODIMP get_cellAt(LONG row, LONG column, IUnknown** cell) override;
IFACEMETHODIMP get_nSelectedCells(LONG* cell_count) override;
IFACEMETHODIMP
get_selectedCells(IUnknown*** cells, LONG* n_selected_cells) override;
IFACEMETHODIMP get_selectedColumns(LONG** columns, LONG* n_columns) override;
IFACEMETHODIMP get_selectedRows(LONG** rows, LONG* n_rows) override;
//
// IAccessibleTableCell methods.
//
IFACEMETHODIMP
get_columnExtent(LONG* n_columns_spanned) override;
IFACEMETHODIMP
get_columnHeaderCells(IUnknown*** cell_accessibles,
LONG* n_column_header_cells) override;
IFACEMETHODIMP get_columnIndex(LONG* column_index) override;
IFACEMETHODIMP get_rowExtent(LONG* n_rows_spanned) override;
IFACEMETHODIMP
get_rowHeaderCells(IUnknown*** cell_accessibles,
LONG* n_row_header_cells) override;
IFACEMETHODIMP get_rowIndex(LONG* row_index) override;
IFACEMETHODIMP get_isSelected(boolean* is_selected) override;
IFACEMETHODIMP
get_rowColumnExtents(LONG* row,
LONG* column,
LONG* row_extents,
LONG* column_extents,
boolean* is_selected) override;
IFACEMETHODIMP get_table(IUnknown** table) override;
//
// IAccessibleHypertext methods not implemented.
//
IFACEMETHODIMP get_nHyperlinks(LONG* hyperlink_count) override;
IFACEMETHODIMP
get_hyperlink(LONG index, IAccessibleHyperlink** hyperlink) override;
IFACEMETHODIMP
get_hyperlinkIndex(LONG char_index, LONG* hyperlink_index) override;
//
// IAccessibleText methods not implemented.
//
IFACEMETHODIMP get_newText(IA2TextSegment* new_text) override;
IFACEMETHODIMP get_oldText(IA2TextSegment* old_text) override;
IFACEMETHODIMP addSelection(LONG start_offset, LONG end_offset) override;
IFACEMETHODIMP get_attributes(LONG offset,
LONG* start_offset,
LONG* end_offset,
BSTR* text_attributes) override;
IFACEMETHODIMP get_characterExtents(LONG offset,
enum IA2CoordinateType coord_type,
LONG* x,
LONG* y,
LONG* width,
LONG* height) override;
IFACEMETHODIMP removeSelection(LONG selection_index) override;
IFACEMETHODIMP setCaretOffset(LONG offset) override;
IFACEMETHODIMP setSelection(LONG selection_index,
LONG start_offset,
LONG end_offset) override;
IFACEMETHODIMP scrollSubstringTo(LONG start_index,
LONG end_index,
enum IA2ScrollType scroll_type) override;
IFACEMETHODIMP scrollSubstringToPoint(LONG start_index,
LONG end_index,
enum IA2CoordinateType coordinate_type,
LONG x,
LONG y) override;
//
// IAccessibleValue methods.
//
IFACEMETHODIMP get_currentValue(VARIANT* value) override;
IFACEMETHODIMP get_minimumValue(VARIANT* value) override;
IFACEMETHODIMP get_maximumValue(VARIANT* value) override;
IFACEMETHODIMP setCurrentValue(VARIANT new_value) override;
//
// IRawElementProviderFragment methods.
//
@@ -1039,19 +400,6 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
IFACEMETHODIMP ShowContextMenu() override;
//
// IChromeAccessible methods.
//
IFACEMETHODIMP get_bulkFetch(BSTR input_json,
LONG request_id,
IChromeAccessibleDelegate* delegate) override;
IFACEMETHODIMP get_hitTest(LONG screen_physical_pixel_x,
LONG screen_physical_pixel_y,
LONG request_id,
IChromeAccessibleDelegate* delegate) override;
//
// IServiceProvider methods.
//
@@ -1074,8 +422,8 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// If either |start_offset| or |end_offset| are not provided then the
// endpoint is treated as the start or end of the node respectively.
HRESULT GetTextAttributeValue(TEXTATTRIBUTEID attribute_id,
const base::Optional<int>& start_offset,
const base::Optional<int>& end_offset,
const std::optional<int>& start_offset,
const std::optional<int>& end_offset,
base::win::VariantVector* result);
// IRawElementProviderSimple support method.
@@ -1098,7 +446,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Updates the active composition range and fires UIA text edit event about
// composition (active or committed)
void OnActiveComposition(const gfx::Range& range,
const base::string16& active_composition_text,
const std::u16string& active_composition_text,
bool is_composition_committed);
// Returns true if there is an active composition
bool HasActiveComposition() const;
@@ -1116,20 +464,20 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
AXPlatformNodeWin* GetFirstTextOnlyDescendant();
// Convert a mojo event to an MSAA event. Exposed for testing.
static base::Optional<DWORD> MojoEventToMSAAEvent(ax::mojom::Event event);
static std::optional<DWORD> MojoEventToMSAAEvent(ax::mojom::Event event);
// Convert a mojo event to a UIA event. Exposed for testing.
static base::Optional<EVENTID> MojoEventToUIAEvent(ax::mojom::Event event);
static std::optional<EVENTID> MojoEventToUIAEvent(ax::mojom::Event event);
// Convert a mojo event to a UIA property id. Exposed for testing.
static base::Optional<PROPERTYID> MojoEventToUIAProperty(
static std::optional<PROPERTYID> MojoEventToUIAProperty(
ax::mojom::Event event);
protected:
// This is hard-coded; all products based on the Chromium engine will have the
// same framework name, so that assistive technology can detect any
// Chromium-based product.
static constexpr const base::char16* FRAMEWORK_ID = L"Chrome";
static constexpr const wchar_t* FRAMEWORK_ID = L"Chrome";
AXPlatformNodeWin();
@@ -1137,15 +485,9 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
int MSAARole();
int32_t ComputeIA2State();
std::u16string UIAAriaRole();
int32_t ComputeIA2Role();
std::vector<base::string16> ComputeIA2Attributes();
base::string16 UIAAriaRole();
base::string16 ComputeUIAProperties();
std::u16string ComputeUIAProperties();
LONG ComputeUIAControlType();
@@ -1157,7 +499,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
bool IsUIAControl() const;
base::Optional<LONG> ComputeUIALandmarkType() const;
std::optional<LONG> ComputeUIALandmarkType() const;
bool IsInaccessibleDueToAncestor() const;
@@ -1168,46 +510,17 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// AXPlatformNodeBase overrides.
void Dispose() override;
// Relationships between this node and other nodes.
std::vector<Microsoft::WRL::ComPtr<AXPlatformRelationWin>> relations_;
AXHypertext old_hypertext_;
// These protected methods are still used by BrowserAccessibilityComWin. At
// some point post conversion, we can probably move these to be private
// methods.
//
// Helper methods for IA2 hyperlinks.
//
// Hyperlink is an IA2 misnomer. It refers to objects embedded within other
// objects, such as a numbered list within a contenteditable div.
// Also, in IA2, text that includes embedded objects is called hypertext.
// Returns true if the current object is an IA2 hyperlink.
bool IsHyperlink();
void ComputeHypertextRemovedAndInserted(size_t* start,
size_t* old_len,
size_t* new_len);
// If offset is a member of IA2TextSpecialOffsets this function updates the
// value of offset and returns, otherwise offset remains unchanged.
void HandleSpecialTextOffset(LONG* offset);
// A helper to add the given string value to |attributes|.
void AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) override;
// Escape special characters as specified by the IA2 spec.
void SanitizeTextAttributeValue(const std::string& input,
std::string* output) const override;
// Escapes characters in string attributes as required by the IA2 Spec.
// It's okay for input to be the same as output.
static void SanitizeStringAttributeForIA2(const std::string& input,
std::string* output);
FRIEND_TEST_ALL_PREFIXES(AXPlatformNodeWinTest,
SanitizeStringAttributeForIA2);
private:
bool IsWebAreaForPresentationalIframe();
bool ShouldNodeHaveFocusableState(const AXNodeData& data) const;
@@ -1221,49 +534,46 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
HRESULT GetNameAsBstr(BSTR* value_bstr) const;
// Sets the selection given a start and end offset in IA2 Hypertext.
void SetIA2HypertextSelection(LONG start_offset, LONG end_offset);
// Escapes characters in string attributes as required by the UIA Aria
// Property Spec. It's okay for input to be the same as output.
static void SanitizeStringAttributeForUIAAriaProperty(
const base::string16& input,
base::string16* output);
const std::u16string& input,
std::u16string* output);
// If the string attribute |attribute| is present, add its value as a
// UIA AriaProperties Property with the name |uia_aria_property|.
void StringAttributeToUIAAriaProperty(std::vector<base::string16>& properties,
void StringAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
ax::mojom::StringAttribute attribute,
const char* uia_aria_property);
// If the bool attribute |attribute| is present, add its value as a
// UIA AriaProperties Property with the name |uia_aria_property|.
void BoolAttributeToUIAAriaProperty(std::vector<base::string16>& properties,
void BoolAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
ax::mojom::BoolAttribute attribute,
const char* uia_aria_property);
// If the int attribute |attribute| is present, add its value as a
// UIA AriaProperties Property with the name |uia_aria_property|.
void IntAttributeToUIAAriaProperty(std::vector<base::string16>& properties,
void IntAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
ax::mojom::IntAttribute attribute,
const char* uia_aria_property);
// If the float attribute |attribute| is present, add its value as a
// UIA AriaProperties Property with the name |uia_aria_property|.
void FloatAttributeToUIAAriaProperty(std::vector<base::string16>& properties,
void FloatAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
ax::mojom::FloatAttribute attribute,
const char* uia_aria_property);
// If the state |state| exists, set the
// UIA AriaProperties Property with the name |uia_aria_property| to "true".
// Otherwise set the AriaProperties Property to "false".
void StateToUIAAriaProperty(std::vector<base::string16>& properties,
void StateToUIAAriaProperty(std::vector<std::u16string>& properties,
ax::mojom::State state,
const char* uia_aria_property);
// If the Html attribute |html_attribute_name| is present, add its value as a
// UIA AriaProperties Property with the name |uia_aria_property|.
void HtmlAttributeToUIAAriaProperty(std::vector<base::string16>& properties,
void HtmlAttributeToUIAAriaProperty(std::vector<std::u16string>& properties,
const char* html_attribute_name,
const char* uia_aria_property);
@@ -1316,21 +626,6 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// At, Before, or After a specified offset.
enum class TextOffsetType { kAtOffset, kBeforeOffset, kAfterOffset };
// Helper for implementing IAccessibleText::get_text{At|Before|After}Offset.
HRESULT IAccessibleTextGetTextForOffsetType(
TextOffsetType text_offset_type,
LONG offset,
enum IA2TextBoundaryType boundary_type,
LONG* start_offset,
LONG* end_offset,
BSTR* text);
// Search forwards or backwards from the given offset until the given IA2
// text boundary is found, and return the offset of that boundary.
LONG FindBoundary(IA2TextBoundaryType ia2_boundary,
LONG start_offset,
ax::mojom::MoveDirection direction);
// Many MSAA methods take a var_id parameter indicating that the operation
// should be performed on a particular child ID, rather than this object.
// This method tries to figure out the target object from |var_id| and
@@ -1359,12 +654,12 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
//
// Computes the AnnotationTypes Attribute for the current node.
HRESULT GetAnnotationTypesAttribute(const base::Optional<int>& start_offset,
const base::Optional<int>& end_offset,
HRESULT GetAnnotationTypesAttribute(const std::optional<int>& start_offset,
const std::optional<int>& end_offset,
base::win::VariantVector* result);
// Lookup the LCID for the language this node is using.
// Returns base::nullopt if there was an error.
base::Optional<LCID> GetCultureAttributeAsLCID() const;
std::optional<LCID> GetCultureAttributeAsLCID() const;
// Converts an int attribute to a COLORREF
COLORREF GetIntAttributeAsCOLORREF(ax::mojom::IntAttribute attribute) const;
// Converts the ListStyle to UIA BulletStyle
@@ -1372,7 +667,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Helper to get the UIA StyleId enumeration for this node
LONG ComputeUIAStyleId() const;
// Convert mojom TextAlign to UIA HorizontalTextAlignment enumeration
static base::Optional<HorizontalTextAlignment>
static std::optional<HorizontalTextAlignment>
AXTextAlignToUIAHorizontalTextAlignment(ax::mojom::TextAlign text_align);
// Converts IntAttribute::kHierarchicalLevel to UIA StyleId enumeration
static LONG AXHierarchicalLevelToUIAStyleId(int32_t hierarchical_level);
@@ -1402,8 +697,8 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Determine if a text range overlaps a |marker_type|, and whether
// the overlap is a partial or or complete match.
MarkerTypeRangeResult GetMarkerTypeFromRange(
const base::Optional<int>& start_offset,
const base::Optional<int>& end_offset,
const std::optional<int>& start_offset,
const std::optional<int>& end_offset,
ax::mojom::MarkerType marker_type);
bool IsAncestorComboBox();
@@ -1436,7 +731,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Fires UIA text edit event about composition (active or committed)
void FireUiaTextEditTextChangedEvent(
const gfx::Range& range,
const base::string16& active_composition_text,
const std::u16string& active_composition_text,
bool is_composition_committed);
// Return true if the given element is valid enough to be returned as a value

View File

@@ -5,18 +5,21 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_WIN_UNITTEST_H_
#include "ui/accessibility/platform/ax_platform_node_unittest.h"
#include "ax_platform_node_unittest.h"
// clang-format off
#include "third_party/accessibility/base/win/atl.h" // Must be before UIAutomationCore.h
// clang-format on
#include <UIAutomationCore.h>
#include <wrl.h>
#include <memory>
#include <string>
#include <unordered_set>
#include "base/test/scoped_feature_list.h"
#include "ui/accessibility/platform/ax_fragment_root_delegate_win.h"
#include "ui/base/win/accessibility_misc_utils.h"
#include "third_party/accessibility/ax/platform/ax_fragment_root_delegate_win.h"
struct IAccessible;
struct IAccessible2;
struct IAccessible2_2;
struct IAccessibleTableCell;
struct IRawElementProviderFragment;
struct IRawElementProviderFragmentRoot;
@@ -86,7 +89,7 @@ class AXPlatformNodeWinTest : public AXPlatformNodeTest {
void TearDown() override;
protected:
static const base::string16 kEmbeddedCharacterAsString;
static const std::u16string kEmbeddedCharacterAsString;
AXPlatformNode* AXPlatformNodeFromNode(AXNode* node);
template <typename T>
@@ -106,12 +109,6 @@ class AXPlatformNodeWinTest : public AXPlatformNodeTest {
IRawElementProviderFragmentFromNode(AXNode* node);
Microsoft::WRL::ComPtr<IAccessible> IAccessibleFromNode(AXNode* node);
Microsoft::WRL::ComPtr<IAccessible> GetRootIAccessible();
Microsoft::WRL::ComPtr<IAccessible2> ToIAccessible2(
Microsoft::WRL::ComPtr<IUnknown> unknown);
Microsoft::WRL::ComPtr<IAccessible2> ToIAccessible2(
Microsoft::WRL::ComPtr<IAccessible> accessible);
Microsoft::WRL::ComPtr<IAccessible2_2> ToIAccessible2_2(
Microsoft::WRL::ComPtr<IAccessible> accessible);
void CheckVariantHasName(const base::win::ScopedVariant& variant,
const wchar_t* expected_name);
void CheckIUnknownHasName(Microsoft::WRL::ComPtr<IUnknown> unknown,
@@ -129,8 +126,6 @@ class AXPlatformNodeWinTest : public AXPlatformNodeTest {
std::unique_ptr<AXFragmentRootWin> ax_fragment_root_;
std::unique_ptr<TestFragmentRootDelegate> test_fragment_root_delegate_;
base::test::ScopedFeatureList scoped_feature_list_;
};
} // namespace ui