summaryrefslogtreecommitdiff
path: root/chromium/ui/accessibility/platform
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-20 10:33:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2017-11-22 11:45:12 +0000
commitbe59a35641616a4cf23c4a13fa0632624b021c1b (patch)
tree9da183258bdf9cc413f7562079d25ace6955467f /chromium/ui/accessibility/platform
parentd702e4b6a64574e97fc7df8fe3238cde70242080 (diff)
downloadqtwebengine-chromium-be59a35641616a4cf23c4a13fa0632624b021c1b.tar.gz
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/ui/accessibility/platform')
-rw-r--r--chromium/ui/accessibility/platform/atk_util_auralinux.cc75
-rw-r--r--chromium/ui/accessibility/platform/atk_util_auralinux.h15
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node.cc38
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node.h21
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc10
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_auralinux.h10
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_base.cc130
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_base.h42
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_delegate.h8
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_mac.h4
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_mac.mm42
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win.cc1510
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win.h191
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc855
-rw-r--r--chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.cc216
-rw-r--r--chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.h2
-rw-r--r--chromium/ui/accessibility/platform/ax_system_caret_win.cc7
-rw-r--r--chromium/ui/accessibility/platform/ax_system_caret_win.h6
-rw-r--r--chromium/ui/accessibility/platform/test_ax_node_wrapper.cc9
-rw-r--r--chromium/ui/accessibility/platform/test_ax_node_wrapper.h6
20 files changed, 2081 insertions, 1116 deletions
diff --git a/chromium/ui/accessibility/platform/atk_util_auralinux.cc b/chromium/ui/accessibility/platform/atk_util_auralinux.cc
index 0b25fcb10fe..207260ef57d 100644
--- a/chromium/ui/accessibility/platform/atk_util_auralinux.cc
+++ b/chromium/ui/accessibility/platform/atk_util_auralinux.cc
@@ -13,23 +13,26 @@
#include "base/memory/singleton.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
-#include "base/task_runner.h"
+#include "base/task_scheduler/post_task.h"
+#include "base/threading/thread_restrictions.h"
#include "ui/accessibility/platform/atk_util_auralinux.h"
#include "ui/accessibility/platform/ax_platform_node_auralinux.h"
namespace {
-typedef void (*gnome_accessibility_module_init)();
+typedef void (*GnomeAccessibilityModuleInitFunc)();
const char kAccessibilityEnabled[] = "ACCESSIBILITY_ENABLED";
-const char kAtkBridgeModule[] = "gail:atk-bridge";
+const char kAtkBridgeModule[] = "atk-bridge";
const char kAtkBridgePath[] = "gtk-2.0/modules/libatk-bridge.so";
const char kAtkBridgeSymbolName[] = "gnome_accessibility_module_init";
const char kGtkModules[] = "GTK_MODULES";
-gnome_accessibility_module_init g_accessibility_module_init = nullptr;
+// Returns a function pointer to be invoked on the main thread to init
+// the gnome accessibility module if it's enabled (nullptr otherwise).
+GnomeAccessibilityModuleInitFunc GetAccessibilityModuleInitFunc() {
+ base::ThreadRestrictions::AssertIOAllowed();
-bool AccessibilityModuleInitOnFileThread() {
// Try to load libatk-bridge.so.
base::FilePath atk_bridge_path(ATK_LIB_DIR);
atk_bridge_path = atk_bridge_path.Append(kAtkBridgePath);
@@ -37,18 +40,28 @@ bool AccessibilityModuleInitOnFileThread() {
static_cast<GModuleFlags>(0));
if (!bridge) {
VLOG(1) << "Unable to open module " << atk_bridge_path.value();
- return false;
+ return nullptr;
}
- if (!g_module_symbol(bridge, kAtkBridgeSymbolName,
- (gpointer *)&g_accessibility_module_init)) {
+ GnomeAccessibilityModuleInitFunc init_func = nullptr;
+
+ if (!g_module_symbol(bridge, kAtkBridgeSymbolName, (gpointer*)&init_func)) {
VLOG(1) << "Unable to get symbol pointer from " << atk_bridge_path.value();
- // Just to make sure it's null;
- g_accessibility_module_init = nullptr;
- return false;
+ return nullptr;
}
- return true;
+ DCHECK(init_func);
+ return init_func;
+}
+
+void FinishAccessibilityInitOnMainThread(
+ GnomeAccessibilityModuleInitFunc init_func) {
+ if (!init_func) {
+ VLOG(1) << "Will not enable ATK accessibility support.";
+ return;
+ }
+
+ init_func();
}
bool PlatformShouldEnableAccessibility() {
@@ -58,8 +71,8 @@ bool PlatformShouldEnableAccessibility() {
return false;
for (const std::string& module :
- base::SplitString(gtk_modules, base::kWhitespaceASCII,
- base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY)) {
+ base::SplitString(gtk_modules, ":", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY)) {
if (module == kAtkBridgeModule)
return true;
}
@@ -161,42 +174,18 @@ AtkUtilAuraLinux* AtkUtilAuraLinux::GetInstance() {
return base::Singleton<AtkUtilAuraLinux>::get();
}
-AtkUtilAuraLinux::AtkUtilAuraLinux() : is_enabled_(false) {}
-
-void AtkUtilAuraLinux::Initialize(
- scoped_refptr<base::TaskRunner> init_task_runner) {
-
+void AtkUtilAuraLinux::InitializeAsync() {
// Register our util class.
g_type_class_unref(g_type_class_ref(ATK_UTIL_AURALINUX_TYPE));
if (!ShouldEnableAccessibility())
return;
- init_task_runner->PostTaskAndReply(
+ base::PostTaskWithTraitsAndReplyWithResult(
FROM_HERE,
- base::Bind(
- &AtkUtilAuraLinux::CheckIfAccessibilityIsEnabledOnFileThread,
- base::Unretained(this)),
- base::Bind(
- &AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread,
- base::Unretained(this)));
-}
-
-AtkUtilAuraLinux::~AtkUtilAuraLinux() {
-}
-
-void AtkUtilAuraLinux::CheckIfAccessibilityIsEnabledOnFileThread() {
- is_enabled_ = AccessibilityModuleInitOnFileThread();
-}
-
-void AtkUtilAuraLinux::FinishAccessibilityInitOnUIThread() {
- if (!is_enabled_) {
- VLOG(1) << "Will not enable ATK accessibility support.";
- return;
- }
-
- DCHECK(g_accessibility_module_init);
- g_accessibility_module_init();
+ {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN},
+ base::Bind(&GetAccessibilityModuleInitFunc),
+ base::Bind(&FinishAccessibilityInitOnMainThread));
}
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/atk_util_auralinux.h b/chromium/ui/accessibility/platform/atk_util_auralinux.h
index 06cd8881bed..8119fb781c1 100644
--- a/chromium/ui/accessibility/platform/atk_util_auralinux.h
+++ b/chromium/ui/accessibility/platform/atk_util_auralinux.h
@@ -5,13 +5,10 @@
#ifndef UI_ACCESSIBILITY_AX_UTIL_AURALINUX_H_
#define UI_ACCESSIBILITY_AX_UTIL_AURALINUX_H_
+#include "base/macros.h"
#include "base/memory/singleton.h"
#include "ui/accessibility/ax_export.h"
-namespace base {
-class TaskRunner;
-}
-
namespace ui {
// This singleton class initializes ATK (accessibility toolkit) and
@@ -22,18 +19,14 @@ class AtkUtilAuraLinux {
// Get the single instance of this class.
static AtkUtilAuraLinux* GetInstance();
- AtkUtilAuraLinux();
- virtual ~AtkUtilAuraLinux();
+ AtkUtilAuraLinux() = default;
- void Initialize(scoped_refptr<base::TaskRunner> init_task_runner);
+ void InitializeAsync();
private:
friend struct base::DefaultSingletonTraits<AtkUtilAuraLinux>;
- void CheckIfAccessibilityIsEnabledOnFileThread();
- void FinishAccessibilityInitOnUIThread();
-
- bool is_enabled_;
+ DISALLOW_COPY_AND_ASSIGN(AtkUtilAuraLinux);
};
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node.cc b/chromium/ui/accessibility/platform/ax_platform_node.cc
index 93a374abbac..d7f68012f77 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node.cc
@@ -9,39 +9,35 @@
#include "build/build_config.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
-#include "ui/accessibility/platform/ax_platform_unique_id.h"
namespace ui {
-namespace {
+// static
+base::LazyInstance<base::ObserverList<AXModeObserver>>::Leaky
+ AXPlatformNode::ax_mode_observers_ = LAZY_INSTANCE_INITIALIZER;
-using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>;
-// Map from each AXPlatformNode's unique id to its instance.
-base::LazyInstance<UniqueIdMap>::DestructorAtExit g_unique_id_map =
- LAZY_INSTANCE_INITIALIZER;
-}
-
-AXPlatformNode::AXPlatformNode() : unique_id_(GetNextAXPlatformNodeUniqueId()) {
- g_unique_id_map.Get()[unique_id_] = this;
-}
+AXPlatformNode::AXPlatformNode() {}
AXPlatformNode::~AXPlatformNode() {
- if (unique_id_)
- g_unique_id_map.Get().erase(unique_id_);
}
void AXPlatformNode::Destroy() {
- g_unique_id_map.Get().erase(unique_id_);
- unique_id_ = 0;
}
-AXPlatformNode* AXPlatformNode::GetFromUniqueId(int32_t unique_id) {
- UniqueIdMap* unique_ids = g_unique_id_map.Pointer();
- auto iter = unique_ids->find(unique_id);
- if (iter != unique_ids->end())
- return iter->second;
+// static
+void AXPlatformNode::AddAXModeObserver(AXModeObserver* observer) {
+ ax_mode_observers_.Get().AddObserver(observer);
+}
+
+// static
+void AXPlatformNode::RemoveAXModeObserver(AXModeObserver* observer) {
+ ax_mode_observers_.Get().RemoveObserver(observer);
+}
- return nullptr;
+// static
+void AXPlatformNode::NotifyAddAXModeFlags(AXMode mode_flags) {
+ for (auto& observer : ax_mode_observers_.Get())
+ observer.OnAXModeAdded(mode_flags);
}
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node.h b/chromium/ui/accessibility/platform/ax_platform_node.h
index 7204c23aa88..8aa38ad0a82 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node.h
@@ -5,9 +5,12 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_H_
+#include "base/lazy_instance.h"
+#include "base/observer_list.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_export.h"
+#include "ui/accessibility/ax_mode_observer.h"
#include "ui/gfx/native_widget_types.h"
namespace ui {
@@ -30,6 +33,15 @@ class AX_EXPORT AXPlatformNode {
static AXPlatformNode* FromNativeViewAccessible(
gfx::NativeViewAccessible accessible);
+ // Register and unregister to receive notifications about AXMode changes
+ // for this node.
+ static void AddAXModeObserver(AXModeObserver* observer);
+ static void RemoveAXModeObserver(AXModeObserver* observer);
+
+ // Helper static function to notify all global observers about
+ // the addition of an AXMode flag.
+ static void NotifyAddAXModeFlags(AXMode mode_flags);
+
// Call Destroy rather than deleting this, because the subclass may
// use reference counting.
virtual void Destroy();
@@ -41,7 +53,7 @@ class AX_EXPORT AXPlatformNode {
// Fire a platform-specific notification that an event has occurred on
// this object.
- virtual void NotifyAccessibilityEvent(ui::AXEvent event_type) = 0;
+ virtual void NotifyAccessibilityEvent(AXEvent event_type) = 0;
// Return this object's delegate.
virtual AXPlatformNodeDelegate* GetDelegate() const = 0;
@@ -50,9 +62,10 @@ class AX_EXPORT AXPlatformNode {
AXPlatformNode();
virtual ~AXPlatformNode();
- virtual AXPlatformNode* GetFromUniqueId(int32_t unique_id);
-
- int32_t unique_id_;
+ private:
+ // Global ObserverList for AXMode changes.
+ static base::LazyInstance<base::ObserverList<AXModeObserver>>::Leaky
+ ax_mode_observers_;
};
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
index c73d7a93abf..1350607a562 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
@@ -8,7 +8,6 @@
#include "base/command_line.h"
#include "base/strings/sys_string_conversions.h"
-#include "base/task_runner.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/atk_util_auralinux.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
@@ -392,9 +391,8 @@ void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) {
}
// static
-void AXPlatformNodeAuraLinux::StaticInitialize(
- scoped_refptr<base::TaskRunner> init_task_runner) {
- AtkUtilAuraLinux::GetInstance()->Initialize(init_task_runner);
+void AXPlatformNodeAuraLinux::StaticInitialize() {
+ AtkUtilAuraLinux::GetInstance()->InitializeAsync();
}
AtkRole AXPlatformNodeAuraLinux::GetAtkRole() {
@@ -474,8 +472,12 @@ void AXPlatformNodeAuraLinux::GetAtkState(AtkStateSet* atk_state_set) {
atk_state_set_add_state(atk_state_set, ATK_STATE_EXPANDED);
if (data.HasState(ui::AX_STATE_FOCUSABLE))
atk_state_set_add_state(atk_state_set, ATK_STATE_FOCUSABLE);
+#if defined(ATK_CHECK_VERSION)
+#if ATK_CHECK_VERSION(2, 11, 2)
if (data.HasState(ui::AX_STATE_HASPOPUP))
atk_state_set_add_state(atk_state_set, ATK_STATE_HAS_POPUP);
+#endif
+#endif
if (data.HasState(ui::AX_STATE_SELECTED))
atk_state_set_add_state(atk_state_set, ATK_STATE_SELECTED);
if (data.HasState(ui::AX_STATE_SELECTABLE))
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
index 00581d93646..1504bfbf67b 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
@@ -8,14 +8,9 @@
#include <atk/atk.h>
#include "base/macros.h"
-#include "base/memory/ref_counted.h"
#include "ui/accessibility/ax_export.h"
#include "ui/accessibility/platform/ax_platform_node_base.h"
-namespace base {
-class TaskRunner;
-}
-
namespace ui {
// Implements accessibility on Aura Linux using ATK.
@@ -28,9 +23,8 @@ class AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
AX_EXPORT static void SetApplication(AXPlatformNode* application);
static AXPlatformNode* application() { return application_; }
- // Do static initialization using the given task runner for file operations.
- AX_EXPORT static void StaticInitialize(
- scoped_refptr<base::TaskRunner> init_task_runner);
+ // Do asynchronous static initialization.
+ AX_EXPORT static void StaticInitialize();
AtkRole GetAtkRole();
void GetAtkState(AtkStateSet* state_set);
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_base.cc b/chromium/ui/accessibility/platform/ax_platform_node_base.cc
index e16ba20c084..abdf04bba2b 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_base.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_base.cc
@@ -19,7 +19,7 @@ void AXPlatformNodeBase::Init(AXPlatformNodeDelegate* delegate) {
}
const AXNodeData& AXPlatformNodeBase::GetData() const {
- CR_DEFINE_STATIC_LOCAL(ui::AXNodeData, empty_data, ());
+ CR_DEFINE_STATIC_LOCAL(AXNodeData, empty_data, ());
if (delegate_)
return delegate_->GetData();
return empty_data;
@@ -115,115 +115,107 @@ bool AXPlatformNodeBase::IsDescendant(AXPlatformNodeBase* node) {
return IsDescendant(parent);
}
-bool AXPlatformNodeBase::HasBoolAttribute(
- ui::AXBoolAttribute attribute) const {
+bool AXPlatformNodeBase::HasBoolAttribute(AXBoolAttribute attribute) const {
if (!delegate_)
return false;
return GetData().HasBoolAttribute(attribute);
}
-bool AXPlatformNodeBase::GetBoolAttribute(
- ui::AXBoolAttribute attribute) const {
+bool AXPlatformNodeBase::GetBoolAttribute(AXBoolAttribute attribute) const {
if (!delegate_)
return false;
return GetData().GetBoolAttribute(attribute);
}
-bool AXPlatformNodeBase::GetBoolAttribute(
- ui::AXBoolAttribute attribute, bool* value) const {
+bool AXPlatformNodeBase::GetBoolAttribute(AXBoolAttribute attribute,
+ bool* value) const {
if (!delegate_)
return false;
return GetData().GetBoolAttribute(attribute, value);
}
-bool AXPlatformNodeBase::HasFloatAttribute(
- ui::AXFloatAttribute attribute) const {
+bool AXPlatformNodeBase::HasFloatAttribute(AXFloatAttribute attribute) const {
if (!delegate_)
return false;
return GetData().HasFloatAttribute(attribute);
}
-float AXPlatformNodeBase::GetFloatAttribute(
- ui::AXFloatAttribute attribute) const {
+float AXPlatformNodeBase::GetFloatAttribute(AXFloatAttribute attribute) const {
if (!delegate_)
return false;
return GetData().GetFloatAttribute(attribute);
}
-bool AXPlatformNodeBase::GetFloatAttribute(
- ui::AXFloatAttribute attribute, float* value) const {
+bool AXPlatformNodeBase::GetFloatAttribute(AXFloatAttribute attribute,
+ float* value) const {
if (!delegate_)
return false;
return GetData().GetFloatAttribute(attribute, value);
}
-bool AXPlatformNodeBase::HasIntAttribute(
- ui::AXIntAttribute attribute) const {
+bool AXPlatformNodeBase::HasIntAttribute(AXIntAttribute attribute) const {
if (!delegate_)
return false;
return GetData().HasIntAttribute(attribute);
}
-int AXPlatformNodeBase::GetIntAttribute(
- ui::AXIntAttribute attribute) const {
+int AXPlatformNodeBase::GetIntAttribute(AXIntAttribute attribute) const {
if (!delegate_)
return false;
return GetData().GetIntAttribute(attribute);
}
-bool AXPlatformNodeBase::GetIntAttribute(
- ui::AXIntAttribute attribute, int* value) const {
+bool AXPlatformNodeBase::GetIntAttribute(AXIntAttribute attribute,
+ int* value) const {
if (!delegate_)
return false;
return GetData().GetIntAttribute(attribute, value);
}
-bool AXPlatformNodeBase::HasStringAttribute(
- ui::AXStringAttribute attribute) const {
+bool AXPlatformNodeBase::HasStringAttribute(AXStringAttribute attribute) const {
if (!delegate_)
return false;
return GetData().HasStringAttribute(attribute);
}
const std::string& AXPlatformNodeBase::GetStringAttribute(
- ui::AXStringAttribute attribute) const {
+ AXStringAttribute attribute) const {
CR_DEFINE_STATIC_LOCAL(std::string, empty_data, ());
if (!delegate_)
return empty_data;
return GetData().GetStringAttribute(attribute);
}
-bool AXPlatformNodeBase::GetStringAttribute(
- ui::AXStringAttribute attribute, std::string* value) const {
+bool AXPlatformNodeBase::GetStringAttribute(AXStringAttribute attribute,
+ std::string* value) const {
if (!delegate_)
return false;
return GetData().GetStringAttribute(attribute, value);
}
base::string16 AXPlatformNodeBase::GetString16Attribute(
- ui::AXStringAttribute attribute) const {
+ AXStringAttribute attribute) const {
if (!delegate_)
return base::string16();
return GetData().GetString16Attribute(attribute);
}
-bool AXPlatformNodeBase::GetString16Attribute(
- ui::AXStringAttribute attribute,
- base::string16* value) const {
+bool AXPlatformNodeBase::GetString16Attribute(AXStringAttribute attribute,
+ base::string16* value) const {
if (!delegate_)
return false;
return GetData().GetString16Attribute(attribute, value);
}
bool AXPlatformNodeBase::HasIntListAttribute(
- ui::AXIntListAttribute attribute) const {
+ AXIntListAttribute attribute) const {
if (!delegate_)
return false;
return GetData().HasIntListAttribute(attribute);
}
const std::vector<int32_t>& AXPlatformNodeBase::GetIntListAttribute(
- ui::AXIntListAttribute attribute) const {
+ AXIntListAttribute attribute) const {
CR_DEFINE_STATIC_LOCAL(std::vector<int32_t>, empty_data, ());
if (!delegate_)
return empty_data;
@@ -231,7 +223,7 @@ const std::vector<int32_t>& AXPlatformNodeBase::GetIntListAttribute(
}
bool AXPlatformNodeBase::GetIntListAttribute(
- ui::AXIntListAttribute attribute,
+ AXIntListAttribute attribute,
std::vector<int32_t>* value) const {
if (!delegate_)
return false;
@@ -252,8 +244,8 @@ AXPlatformNodeBase* AXPlatformNodeBase::FromNativeViewAccessible(
}
bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) {
- ui::AXActionData action_data;
- action_data.action = ui::AX_ACTION_SET_SELECTION;
+ AXActionData action_data;
+ action_data.action = AX_ACTION_SET_SELECTION;
action_data.anchor_node_id = action_data.focus_node_id = GetData().id;
action_data.anchor_offset = start_offset;
action_data.focus_offset = end_offset;
@@ -264,13 +256,13 @@ bool AXPlatformNodeBase::SetTextSelection(int start_offset, int end_offset) {
}
bool AXPlatformNodeBase::IsTextOnlyObject() const {
- return GetData().role == ui::AX_ROLE_STATIC_TEXT ||
- GetData().role == ui::AX_ROLE_LINE_BREAK ||
- GetData().role == ui::AX_ROLE_INLINE_TEXT_BOX;
+ return GetData().role == AX_ROLE_STATIC_TEXT ||
+ GetData().role == AX_ROLE_LINE_BREAK ||
+ GetData().role == AX_ROLE_INLINE_TEXT_BOX;
}
bool AXPlatformNodeBase::IsNativeTextControl() const {
- const std::string& html_tag = GetStringAttribute(ui::AX_ATTR_HTML_TAG);
+ const std::string& html_tag = GetStringAttribute(AX_ATTR_HTML_TAG);
if (html_tag == "input") {
std::string input_type;
if (!GetData().GetHtmlAttribute("type", &input_type))
@@ -287,11 +279,11 @@ bool AXPlatformNodeBase::IsSimpleTextControl() const {
// Time fields, color wells and spinner buttons might also use text fields as
// constituent parts, but they are not considered text fields as a whole.
switch (GetData().role) {
- case ui::AX_ROLE_COMBO_BOX:
- case ui::AX_ROLE_SEARCH_BOX:
+ case AX_ROLE_COMBO_BOX:
+ case AX_ROLE_SEARCH_BOX:
return true;
- case ui::AX_ROLE_TEXT_FIELD:
- return !GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE);
+ case AX_ROLE_TEXT_FIELD:
+ return !GetData().HasState(AX_STATE_RICHLY_EDITABLE);
default:
return false;
}
@@ -304,13 +296,13 @@ bool AXPlatformNodeBase::IsRichTextControl() {
if (!parent)
return false;
- return GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE) &&
- (!parent || !parent->GetData().HasState(ui::AX_STATE_RICHLY_EDITABLE));
+ return GetData().HasState(AX_STATE_RICHLY_EDITABLE) &&
+ (!parent || !parent->GetData().HasState(AX_STATE_RICHLY_EDITABLE));
}
base::string16 AXPlatformNodeBase::GetInnerText() {
if (IsTextOnlyObject())
- return GetString16Attribute(ui::AX_ATTR_NAME);
+ return GetString16Attribute(AX_ATTR_NAME);
base::string16 text;
for (int i = 0; i < GetChildCount(); ++i) {
@@ -326,13 +318,13 @@ base::string16 AXPlatformNodeBase::GetInnerText() {
bool AXPlatformNodeBase::IsRangeValueSupported() const {
switch (GetData().role) {
- case ui::AX_ROLE_PROGRESS_INDICATOR:
- case ui::AX_ROLE_SLIDER:
- case ui::AX_ROLE_SPIN_BUTTON:
- case ui::AX_ROLE_SCROLL_BAR:
+ case AX_ROLE_PROGRESS_INDICATOR:
+ case AX_ROLE_SLIDER:
+ case AX_ROLE_SPIN_BUTTON:
+ case AX_ROLE_SCROLL_BAR:
return true;
- case ui::AX_ROLE_SPLITTER:
- return GetData().HasState(ui::AX_STATE_FOCUSABLE);
+ case AX_ROLE_SPLITTER:
+ return GetData().HasState(AX_STATE_FOCUSABLE);
default:
return false;
}
@@ -340,9 +332,9 @@ bool AXPlatformNodeBase::IsRangeValueSupported() const {
base::string16 AXPlatformNodeBase::GetRangeValueText() {
float fval;
- base::string16 value = GetString16Attribute(ui::AX_ATTR_VALUE);
+ base::string16 value = GetString16Attribute(AX_ATTR_VALUE);
- if (value.empty() && GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) {
+ if (value.empty() && GetFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, &fval)) {
value = base::UTF8ToUTF16(base::DoubleToString(fval));
}
return value;
@@ -352,7 +344,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTable() const {
if (!delegate_)
return nullptr;
AXPlatformNodeBase* table = const_cast<AXPlatformNodeBase*>(this);
- while (table && !ui::IsTableLikeRole(table->GetData().role)) {
+ while (table && !IsTableLikeRole(table->GetData().role)) {
gfx::NativeViewAccessible parent_accessible = table->GetParent();
AXPlatformNodeBase* parent = FromNativeViewAccessible(parent_accessible);
@@ -364,15 +356,15 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTable() const {
AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int index) const {
if (!delegate_)
return nullptr;
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return nullptr;
AXPlatformNodeBase* table = GetTable();
if (!table)
return nullptr;
const std::vector<int32_t>& unique_cell_ids =
- table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
+ table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS);
if (index < 0 || index >= static_cast<int>(unique_cell_ids.size()))
return nullptr;
@@ -382,8 +374,8 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int index) const {
AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int row,
int column) const {
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return nullptr;
if (row < 0 || row >= GetTableRowCount() || column < 0 ||
@@ -398,7 +390,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int row,
// In contrast to unique cell IDs, these are duplicated whenever a cell spans
// multiple columns or rows.
const std::vector<int32_t>& cell_ids =
- table->GetIntListAttribute(ui::AX_ATTR_CELL_IDS);
+ table->GetIntListAttribute(AX_ATTR_CELL_IDS);
DCHECK_EQ(GetTableRowCount() * GetTableColumnCount(),
static_cast<int>(cell_ids.size()));
int position = row * GetTableColumnCount() + column;
@@ -410,7 +402,7 @@ AXPlatformNodeBase* AXPlatformNodeBase::GetTableCell(int row,
}
int AXPlatformNodeBase::GetTableCellIndex() const {
- if (!ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsCellOrTableHeaderRole(GetData().role))
return -1;
AXPlatformNodeBase* table = GetTable();
@@ -418,7 +410,7 @@ int AXPlatformNodeBase::GetTableCellIndex() const {
return -1;
const std::vector<int32_t>& unique_cell_ids =
- table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
+ table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS);
auto iter =
std::find(unique_cell_ids.begin(), unique_cell_ids.end(), GetData().id);
if (iter == unique_cell_ids.end())
@@ -428,7 +420,7 @@ int AXPlatformNodeBase::GetTableCellIndex() const {
}
int AXPlatformNodeBase::GetTableColumn() const {
- return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_INDEX);
+ return GetIntAttribute(AX_ATTR_TABLE_CELL_COLUMN_INDEX);
}
int AXPlatformNodeBase::GetTableColumnCount() const {
@@ -436,21 +428,21 @@ int AXPlatformNodeBase::GetTableColumnCount() const {
if (!table)
return 0;
- return table->GetIntAttribute(ui::AX_ATTR_TABLE_COLUMN_COUNT);
+ return table->GetIntAttribute(AX_ATTR_TABLE_COLUMN_COUNT);
}
int AXPlatformNodeBase::GetTableColumnSpan() const {
- if (!ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsCellOrTableHeaderRole(GetData().role))
return 0;
int column_span;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_COLUMN_SPAN, &column_span))
+ if (GetIntAttribute(AX_ATTR_TABLE_CELL_COLUMN_SPAN, &column_span))
return column_span;
return 1;
}
int AXPlatformNodeBase::GetTableRow() const {
- return GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_INDEX);
+ return GetIntAttribute(AX_ATTR_TABLE_CELL_ROW_INDEX);
}
int AXPlatformNodeBase::GetTableRowCount() const {
@@ -458,15 +450,15 @@ int AXPlatformNodeBase::GetTableRowCount() const {
if (!table)
return 0;
- return table->GetIntAttribute(ui::AX_ATTR_TABLE_ROW_COUNT);
+ return table->GetIntAttribute(AX_ATTR_TABLE_ROW_COUNT);
}
int AXPlatformNodeBase::GetTableRowSpan() const {
- if (!ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsCellOrTableHeaderRole(GetData().role))
return 0;
int row_span;
- if (GetIntAttribute(ui::AX_ATTR_TABLE_CELL_ROW_SPAN, &row_span))
+ if (GetIntAttribute(AX_ATTR_TABLE_CELL_ROW_SPAN, &row_span))
return row_span;
return 1;
}
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_base.h b/chromium/ui/accessibility/platform/ax_platform_node_base.h
index 98aa7f5623e..1481ed97e87 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_base.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_base.h
@@ -40,33 +40,31 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
AXPlatformNodeBase* GetNextSibling();
bool IsDescendant(AXPlatformNodeBase* descendant);
- bool HasBoolAttribute(ui::AXBoolAttribute attr) const;
- bool GetBoolAttribute(ui::AXBoolAttribute attr) const;
- bool GetBoolAttribute(ui::AXBoolAttribute attr, bool* value) const;
-
- bool HasFloatAttribute(ui::AXFloatAttribute attr) const;
- float GetFloatAttribute(ui::AXFloatAttribute attr) const;
- bool GetFloatAttribute(ui::AXFloatAttribute attr, float* value) const;
-
- bool HasIntAttribute(ui::AXIntAttribute attribute) const;
- int GetIntAttribute(ui::AXIntAttribute attribute) const;
- bool GetIntAttribute(ui::AXIntAttribute attribute, int* value) const;
-
- bool HasStringAttribute(
- ui::AXStringAttribute attribute) const;
- const std::string& GetStringAttribute(ui::AXStringAttribute attribute) const;
- bool GetStringAttribute(ui::AXStringAttribute attribute,
+ bool HasBoolAttribute(AXBoolAttribute attr) const;
+ bool GetBoolAttribute(AXBoolAttribute attr) const;
+ bool GetBoolAttribute(AXBoolAttribute attr, bool* value) const;
+
+ bool HasFloatAttribute(AXFloatAttribute attr) const;
+ float GetFloatAttribute(AXFloatAttribute attr) const;
+ bool GetFloatAttribute(AXFloatAttribute attr, float* value) const;
+
+ bool HasIntAttribute(AXIntAttribute attribute) const;
+ int GetIntAttribute(AXIntAttribute attribute) const;
+ bool GetIntAttribute(AXIntAttribute attribute, int* value) const;
+
+ bool HasStringAttribute(AXStringAttribute attribute) const;
+ const std::string& GetStringAttribute(AXStringAttribute attribute) const;
+ bool GetStringAttribute(AXStringAttribute attribute,
std::string* value) const;
- bool GetString16Attribute(ui::AXStringAttribute attribute,
+ bool GetString16Attribute(AXStringAttribute attribute,
base::string16* value) const;
- base::string16 GetString16Attribute(
- ui::AXStringAttribute attribute) const;
+ base::string16 GetString16Attribute(AXStringAttribute attribute) const;
- bool HasIntListAttribute(ui::AXIntListAttribute attribute) const;
+ bool HasIntListAttribute(AXIntListAttribute attribute) const;
const std::vector<int32_t>& GetIntListAttribute(
- ui::AXIntListAttribute attribute) const;
+ AXIntListAttribute attribute) const;
- bool GetIntListAttribute(ui::AXIntListAttribute attribute,
+ bool GetIntListAttribute(AXIntListAttribute attribute,
std::vector<int32_t>* value) const;
// Returns the table or ARIA grid if inside one.
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_delegate.h b/chromium/ui/accessibility/platform/ax_platform_node_delegate.h
index 052eeb1adf6..ad548c90726 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_delegate.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_delegate.h
@@ -38,7 +38,7 @@ class AX_EXPORT AXPlatformNodeDelegate {
virtual const AXNodeData& GetData() const = 0;
// Get the accessibility tree data for this node.
- virtual const ui::AXTreeData& GetTreeData() const = 0;
+ virtual const AXTreeData& GetTreeData() const = 0;
// Get the window the node is contained in.
virtual gfx::NativeWindow GetTopLevelWidget() = 0;
@@ -73,7 +73,7 @@ class AX_EXPORT AXPlatformNodeDelegate {
// has focus.
virtual gfx::NativeViewAccessible GetFocus() = 0;
- virtual ui::AXPlatformNode* GetFromNodeID(int32_t id) = 0;
+ virtual AXPlatformNode* GetFromNodeID(int32_t id) = 0;
//
// Events.
@@ -87,9 +87,9 @@ class AX_EXPORT AXPlatformNodeDelegate {
// Actions.
//
- // Perform an accessibility action, switching on the ui::AXAction
+ // Perform an accessibility action, switching on the AXAction
// provided in |data|.
- virtual bool AccessibilityPerformAction(const ui::AXActionData& data) = 0;
+ virtual bool AccessibilityPerformAction(const AXActionData& data) = 0;
//
// Testing.
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_mac.h b/chromium/ui/accessibility/platform/ax_platform_node_mac.h
index 73657fb986d..36ee00335e2 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_mac.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_mac.h
@@ -36,6 +36,10 @@ class AXPlatformNodeMac : public AXPlatformNodeBase {
DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeMac);
};
+// Convenience function to determine whether an internal object role should
+// expose its accessible name in AXValue (as opposed to AXTitle/AXDescription).
+AX_EXPORT bool IsNameExposedInAXValueForRole(AXRole role);
+
} // namespace ui
AX_EXPORT
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_mac.mm b/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
index c2513cb46d8..bb310ebbb84 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
+++ b/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
@@ -36,7 +36,6 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_AUDIO, NSAccessibilityGroupRole},
{ui::AX_ROLE_BANNER, NSAccessibilityGroupRole},
{ui::AX_ROLE_BLOCKQUOTE, NSAccessibilityGroupRole},
- {ui::AX_ROLE_BUSY_INDICATOR, NSAccessibilityBusyIndicatorRole},
{ui::AX_ROLE_BUTTON, NSAccessibilityButtonRole},
{ui::AX_ROLE_CANVAS, NSAccessibilityImageRole},
{ui::AX_ROLE_CAPTION, NSAccessibilityGroupRole},
@@ -69,7 +68,9 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_FOOTER, NSAccessibilityGroupRole},
{ui::AX_ROLE_FORM, NSAccessibilityGroupRole},
{ui::AX_ROLE_GENERIC_CONTAINER, NSAccessibilityGroupRole},
- {ui::AX_ROLE_GRID, NSAccessibilityGridRole},
+ // Should be NSAccessibilityGridRole but VoiceOver treating it like
+ // a list as of 10.12.6, so following WebKit and using table role:
+ {ui::AX_ROLE_GRID, NSAccessibilityTableRole}, // crbug.com/753925
{ui::AX_ROLE_GROUP, NSAccessibilityGroupRole},
{ui::AX_ROLE_HEADING, @"AXHeading"},
{ui::AX_ROLE_IFRAME, NSAccessibilityGroupRole},
@@ -77,7 +78,6 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_IGNORED, NSAccessibilityUnknownRole},
{ui::AX_ROLE_IMAGE, NSAccessibilityImageRole},
{ui::AX_ROLE_IMAGE_MAP, NSAccessibilityGroupRole},
- {ui::AX_ROLE_IMAGE_MAP_LINK, NSAccessibilityLinkRole},
{ui::AX_ROLE_INPUT_TIME, @"AXTimeField"},
{ui::AX_ROLE_LABEL_TEXT, NSAccessibilityGroupRole},
{ui::AX_ROLE_LEGEND, NSAccessibilityGroupRole},
@@ -104,7 +104,6 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_NAVIGATION, NSAccessibilityGroupRole},
{ui::AX_ROLE_NONE, NSAccessibilityGroupRole},
{ui::AX_ROLE_NOTE, NSAccessibilityGroupRole},
- {ui::AX_ROLE_OUTLINE, NSAccessibilityOutlineRole},
{ui::AX_ROLE_PARAGRAPH, NSAccessibilityGroupRole},
{ui::AX_ROLE_POP_UP_BUTTON, NSAccessibilityPopUpButtonRole},
{ui::AX_ROLE_PRE, NSAccessibilityGroupRole},
@@ -116,7 +115,6 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_ROOT_WEB_AREA, @"AXWebArea"},
{ui::AX_ROLE_ROW, NSAccessibilityRowRole},
{ui::AX_ROLE_ROW_HEADER, @"AXCell"},
- {ui::AX_ROLE_RULER, NSAccessibilityRulerRole},
{ui::AX_ROLE_SCROLL_BAR, NSAccessibilityScrollBarRole},
{ui::AX_ROLE_SEARCH, NSAccessibilityGroupRole},
{ui::AX_ROLE_SEARCH_BOX, NSAccessibilityTextFieldRole},
@@ -146,10 +144,6 @@ RoleMap BuildRoleMap() {
{ui::AX_ROLE_VIDEO, NSAccessibilityGroupRole},
{ui::AX_ROLE_WEB_AREA, @"AXWebArea"},
{ui::AX_ROLE_WINDOW, NSAccessibilityWindowRole},
-
- // TODO(dtseng): we don't correctly support the attributes for these
- // roles.
- // { ui::AX_ROLE_SCROLL_AREA, NSAccessibilityScrollAreaRole },
};
return RoleMap(begin(roles), end(roles));
@@ -636,14 +630,13 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
}
- (id)AXValue {
- switch (node_->GetData().role) {
- case ui::AX_ROLE_TAB:
- return [self AXSelected];
- case ui::AX_ROLE_STATIC_TEXT:
- return [self AXTitle];
- default:
- break;
- }
+ ui::AXRole role = node_->GetData().role;
+ if (role == ui::AX_ROLE_TAB)
+ return [self AXSelected];
+
+ if (ui::IsNameExposedInAXValueForRole(role))
+ return [self getStringAttribute:ui::AX_ATTR_NAME];
+
return [self getStringAttribute:ui::AX_ATTR_VALUE];
}
@@ -693,6 +686,9 @@ bool AlsoUseShowMenuActionForDefaultAction(const ui::AXNodeData& data) {
}
- (NSString*)AXTitle {
+ if (ui::IsNameExposedInAXValueForRole(node_->GetData().role))
+ return @"";
+
return [self getStringAttribute:ui::AX_ATTR_NAME];
}
@@ -860,4 +856,16 @@ int AXPlatformNodeMac::GetIndexInParent() {
return -1;
}
+bool IsNameExposedInAXValueForRole(AXRole role) {
+ switch (role) {
+ case AX_ROLE_LIST_BOX_OPTION:
+ case AX_ROLE_LIST_MARKER:
+ case AX_ROLE_MENU_LIST_OPTION:
+ case AX_ROLE_STATIC_TEXT:
+ return true;
+ default:
+ return false;
+ }
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win.cc b/chromium/ui/accessibility/platform/ax_platform_node_win.cc
index 25c8c227dd9..57db0173a5a 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win.cc
@@ -2,12 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <atlbase.h>
-#include <atlcom.h>
-#include <limits.h>
-#include <oleacc.h>
-#include <stdint.h>
-
+#include "ui/accessibility/platform/ax_platform_node_win.h"
#include "base/containers/hash_tables.h"
#include "base/lazy_instance.h"
#include "base/strings/string_number_conversions.h"
@@ -19,12 +14,13 @@
#include "third_party/iaccessible2/ia2_api_all.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_action_data.h"
+#include "ui/accessibility/ax_mode_observer.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_role_properties.h"
#include "ui/accessibility/ax_text_utils.h"
#include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
-#include "ui/accessibility/platform/ax_platform_node_win.h"
+#include "ui/accessibility/platform/ax_platform_unique_id.h"
#include "ui/base/win/atl_module.h"
#include "ui/gfx/geometry/rect_conversions.h"
@@ -155,6 +151,12 @@ base::LazyInstance<base::ObserverList<IAccessible2UsageObserver>>::
} // namespace
+// There is no easy way to decouple |kScreenReader| and |kHTML| accessibility
+// modes when Windows screen readers are used. For example, certain roles use
+// the HTML tag name. Input fields require their type attribute to be exposed.
+const uint32_t kScreenReaderAndHTMLAccessibilityModes =
+ AXMode::kScreenReader | AXMode::kHTML;
+
//
// IAccessible2UsageObserver
//
@@ -172,7 +174,7 @@ base::ObserverList<IAccessible2UsageObserver>&
}
AXPlatformNodeRelationWin::AXPlatformNodeRelationWin() {
- ui::win::CreateATLModuleIfNeeded();
+ win::CreateATLModuleIfNeeded();
}
AXPlatformNodeRelationWin::~AXPlatformNodeRelationWin() {}
@@ -205,16 +207,16 @@ STDMETHODIMP AXPlatformNodeRelationWin::get_relationType(BSTR* relation_type) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeRelationWin::get_nTargets(long* n_targets) {
+STDMETHODIMP AXPlatformNodeRelationWin::get_nTargets(LONG* n_targets) {
if (!n_targets)
return E_INVALIDARG;
if (!owner_->delegate_)
return E_FAIL;
- *n_targets = static_cast<long>(target_ids_.size());
+ *n_targets = static_cast<LONG>(target_ids_.size());
- for (long i = *n_targets - 1; i >= 0; --i) {
+ for (LONG i = *n_targets - 1; i >= 0; --i) {
AXPlatformNodeWin* result = static_cast<AXPlatformNodeWin*>(
owner_->delegate_->GetFromNodeID(target_ids_[i]));
if (!result || !result->delegate_) {
@@ -225,7 +227,7 @@ STDMETHODIMP AXPlatformNodeRelationWin::get_nTargets(long* n_targets) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeRelationWin::get_target(long target_index,
+STDMETHODIMP AXPlatformNodeRelationWin::get_target(LONG target_index,
IUnknown** target) {
if (!target)
return E_INVALIDARG;
@@ -234,7 +236,7 @@ STDMETHODIMP AXPlatformNodeRelationWin::get_target(long target_index,
return E_FAIL;
if (target_index < 0 ||
- target_index >= static_cast<long>(target_ids_.size())) {
+ target_index >= static_cast<LONG>(target_ids_.size())) {
return E_INVALIDARG;
}
@@ -248,16 +250,16 @@ STDMETHODIMP AXPlatformNodeRelationWin::get_target(long target_index,
return S_OK;
}
-STDMETHODIMP AXPlatformNodeRelationWin::get_targets(long max_targets,
+STDMETHODIMP AXPlatformNodeRelationWin::get_targets(LONG max_targets,
IUnknown** targets,
- long* n_targets) {
+ LONG* n_targets) {
if (!targets || !n_targets)
return E_INVALIDARG;
if (!owner_->delegate_)
return E_FAIL;
- long count = static_cast<long>(target_ids_.size());
+ LONG count = static_cast<LONG>(target_ids_.size());
if (count > max_targets)
count = max_targets;
@@ -265,7 +267,7 @@ STDMETHODIMP AXPlatformNodeRelationWin::get_targets(long max_targets,
if (count == 0)
return S_FALSE;
- for (long i = 0; i < count; ++i) {
+ for (LONG i = 0; i < count; ++i) {
HRESULT result = get_target(i, &targets[i]);
if (result != S_OK)
return result;
@@ -286,7 +288,7 @@ AXPlatformNodeRelationWin::get_localizedRelationType(BSTR* relation_type) {
// static
AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
// Make sure ATL is initialized in this module.
- ui::win::CreateATLModuleIfNeeded();
+ win::CreateATLModuleIfNeeded();
CComObject<AXPlatformNodeWin>* instance = nullptr;
HRESULT hr = CComObject<AXPlatformNodeWin>::CreateInstance(&instance);
@@ -306,33 +308,50 @@ AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
return ax_platform_node.Get();
}
+using UniqueIdMap = base::hash_map<int32_t, AXPlatformNode*>;
+// Map from each AXPlatformNode's unique id to its instance.
+base::LazyInstance<UniqueIdMap>::DestructorAtExit g_unique_id_map =
+ LAZY_INSTANCE_INITIALIZER;
+
+// static
+AXPlatformNode* AXPlatformNodeWin::GetFromUniqueId(int32_t unique_id) {
+ UniqueIdMap* unique_ids = g_unique_id_map.Pointer();
+ auto iter = unique_ids->find(unique_id);
+ if (iter != unique_ids->end())
+ return iter->second;
+
+ return nullptr;
+}
//
// AXPlatformNodeWin
//
-AXPlatformNodeWin::AXPlatformNodeWin() {
+AXPlatformNodeWin::AXPlatformNodeWin()
+ : unique_id_(GetNextAXPlatformNodeUniqueId()) {
+ g_unique_id_map.Get()[unique_id_] = this;
}
AXPlatformNodeWin::~AXPlatformNodeWin() {
- for (ui::AXPlatformNodeRelationWin* relation : relations_)
+ for (AXPlatformNodeRelationWin* relation : relations_)
relation->Release();
+ if (unique_id_)
+ g_unique_id_map.Get().erase(unique_id_);
}
void AXPlatformNodeWin::CalculateRelationships() {
ClearOwnRelations();
AddBidirectionalRelations(IA2_RELATION_CONTROLLER_FOR,
- IA2_RELATION_CONTROLLED_BY,
- ui::AX_ATTR_CONTROLS_IDS);
+ IA2_RELATION_CONTROLLED_BY, AX_ATTR_CONTROLS_IDS);
AddBidirectionalRelations(IA2_RELATION_DESCRIBED_BY,
IA2_RELATION_DESCRIPTION_FOR,
- ui::AX_ATTR_DESCRIBEDBY_IDS);
+ AX_ATTR_DESCRIBEDBY_IDS);
AddBidirectionalRelations(IA2_RELATION_FLOWS_TO, IA2_RELATION_FLOWS_FROM,
- ui::AX_ATTR_FLOWTO_IDS);
+ AX_ATTR_FLOWTO_IDS);
AddBidirectionalRelations(IA2_RELATION_LABELLED_BY, IA2_RELATION_LABEL_FOR,
- ui::AX_ATTR_LABELLEDBY_IDS);
+ AX_ATTR_LABELLEDBY_IDS);
int32_t details_id;
- if (GetIntAttribute(ui::AX_ATTR_DETAILS_ID, &details_id)) {
+ if (GetIntAttribute(AX_ATTR_DETAILS_ID, &details_id)) {
std::vector<int32_t> details_ids;
details_ids.push_back(details_id);
AddBidirectionalRelations(IA2_RELATION_DETAILS, IA2_RELATION_DETAILS_FOR,
@@ -340,11 +359,11 @@ void AXPlatformNodeWin::CalculateRelationships() {
}
int member_of_id;
- if (GetIntAttribute(ui::AX_ATTR_MEMBER_OF_ID, &member_of_id))
+ if (GetIntAttribute(AX_ATTR_MEMBER_OF_ID, &member_of_id))
AddRelation(IA2_RELATION_MEMBER_OF, member_of_id);
int error_message_id;
- if (GetIntAttribute(ui::AX_ATTR_ERRORMESSAGE_ID, &error_message_id))
+ if (GetIntAttribute(AX_ATTR_ERRORMESSAGE_ID, &error_message_id))
AddRelation(IA2_RELATION_ERROR_MESSAGE, error_message_id);
}
@@ -354,9 +373,8 @@ void AXPlatformNodeWin::AddRelation(const base::string16& relation_type,
if (target_id == GetData().id)
return;
- CComObject<ui::AXPlatformNodeRelationWin>* relation;
- HRESULT hr =
- CComObject<ui::AXPlatformNodeRelationWin>::CreateInstance(&relation);
+ CComObject<AXPlatformNodeRelationWin>* relation;
+ HRESULT hr = CComObject<AXPlatformNodeRelationWin>::CreateInstance(&relation);
DCHECK(SUCCEEDED(hr));
relation->AddRef();
relation->Initialize(this, relation_type);
@@ -367,7 +385,7 @@ void AXPlatformNodeWin::AddRelation(const base::string16& relation_type,
void AXPlatformNodeWin::AddBidirectionalRelations(
const base::string16& relation_type,
const base::string16& reverse_relation_type,
- ui::AXIntListAttribute attribute) {
+ AXIntListAttribute attribute) {
if (!HasIntListAttribute(attribute))
return;
@@ -388,9 +406,8 @@ void AXPlatformNodeWin::AddBidirectionalRelations(
if (filtered_target_ids.empty())
return;
- CComObject<ui::AXPlatformNodeRelationWin>* relation;
- HRESULT hr =
- CComObject<ui::AXPlatformNodeRelationWin>::CreateInstance(&relation);
+ CComObject<AXPlatformNodeRelationWin>* relation;
+ HRESULT hr = CComObject<AXPlatformNodeRelationWin>::CreateInstance(&relation);
DCHECK(SUCCEEDED(hr));
relation->AddRef();
relation->Initialize(this, relation_type);
@@ -423,7 +440,7 @@ void AXPlatformNodeWin::ClearOwnRelations() {
relations_.erase(
std::remove_if(relations_.begin(), relations_.end(),
- [](ui::AXPlatformNodeRelationWin* relation) {
+ [](AXPlatformNodeRelationWin* relation) {
if (relation->get_type() == IA2_RELATION_MEMBER_OF) {
relation->Release();
return true;
@@ -437,7 +454,7 @@ void AXPlatformNodeWin::RemoveBidirectionalRelationsOfType(
const base::string16& relation_type,
const base::string16& reverse_relation_type) {
for (auto iter = relations_.begin(); iter != relations_.end();) {
- ui::AXPlatformNodeRelationWin* relation = *iter;
+ AXPlatformNodeRelationWin* relation = *iter;
DCHECK(relation);
if (relation->get_type() == relation_type) {
for (int target_id : relation->get_target_ids()) {
@@ -460,7 +477,7 @@ void AXPlatformNodeWin::RemoveTargetFromRelation(
const base::string16& relation_type,
int target_id) {
for (auto iter = relations_.begin(); iter != relations_.end();) {
- ui::AXPlatformNodeRelationWin* relation = *iter;
+ AXPlatformNodeRelationWin* relation = *iter;
DCHECK(relation);
if (relation->get_type() == relation_type) {
// If |target_id| is not present, |RemoveTarget| will do nothing.
@@ -492,7 +509,7 @@ void AXPlatformNodeWin::SanitizeStringAttributeForIA2(
void AXPlatformNodeWin::StringAttributeToIA2(
std::vector<base::string16>& attributes,
- ui::AXStringAttribute attribute,
+ AXStringAttribute attribute,
const char* ia2_attr) {
base::string16 value;
if (GetString16Attribute(attribute, &value)) {
@@ -503,7 +520,7 @@ void AXPlatformNodeWin::StringAttributeToIA2(
void AXPlatformNodeWin::BoolAttributeToIA2(
std::vector<base::string16>& attributes,
- ui::AXBoolAttribute attribute,
+ AXBoolAttribute attribute,
const char* ia2_attr) {
bool value;
if (GetBoolAttribute(attribute, &value)) {
@@ -514,7 +531,7 @@ void AXPlatformNodeWin::BoolAttributeToIA2(
void AXPlatformNodeWin::IntAttributeToIA2(
std::vector<base::string16>& attributes,
- ui::AXIntAttribute attribute,
+ AXIntAttribute attribute,
const char* ia2_attr) {
int value;
if (GetIntAttribute(attribute, &value)) {
@@ -532,7 +549,13 @@ void AXPlatformNodeWin::Dispose() {
}
void AXPlatformNodeWin::Destroy() {
+ g_unique_id_map.Get().erase(unique_id_);
+ unique_id_ = 0;
+
RemoveAlertTarget();
+
+ // This will end up calling Dispose() which may result in deleting this object
+ // if there are no more outstanding references.
AXPlatformNodeBase::Destroy();
}
@@ -544,16 +567,15 @@ gfx::NativeViewAccessible AXPlatformNodeWin::GetNativeViewAccessible() {
return this;
}
-void AXPlatformNodeWin::NotifyAccessibilityEvent(ui::AXEvent event_type) {
+void AXPlatformNodeWin::NotifyAccessibilityEvent(AXEvent event_type) {
HWND hwnd = delegate_->GetTargetForNativeAccessibilityEvent();
if (!hwnd)
return;
// Menu items fire selection events but Windows screen readers work reliably
// with focus events. Remap here.
- if (event_type == ui::AX_EVENT_SELECTION &&
- GetData().role == ui::AX_ROLE_MENU_ITEM)
- event_type = ui::AX_EVENT_FOCUS;
+ if (event_type == AX_EVENT_SELECTION && GetData().role == AX_ROLE_MENU_ITEM)
+ event_type = AX_EVENT_FOCUS;
int native_event = MSAAEvent(event_type);
if (native_event < EVENT_MIN)
@@ -562,7 +584,7 @@ void AXPlatformNodeWin::NotifyAccessibilityEvent(ui::AXEvent event_type) {
::NotifyWinEvent(native_event, hwnd, OBJID_CLIENT, -unique_id_);
// Keep track of objects that are a target of an alert event.
- if (event_type == ui::AX_EVENT_ALERT)
+ if (event_type == AX_EVENT_ALERT)
AddAlertTarget();
}
@@ -645,7 +667,7 @@ HRESULT AXPlatformNodeWin::accDoDefaultAction(VARIANT var_id) {
AXPlatformNodeWin* target;
COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
AXActionData data;
- data.action = ui::AX_ACTION_DO_DEFAULT;
+ data.action = AX_ACTION_DO_DEFAULT;
if (target->delegate_->AccessibilityPerformAction(data))
return S_OK;
@@ -712,8 +734,8 @@ STDMETHODIMP AXPlatformNodeWin::accNavigate(
case NAVDIR_DOWN: {
// This direction is not implemented except in tables.
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return E_NOTIMPL;
AXPlatformNodeBase* next = target->GetTableCell(
@@ -727,8 +749,8 @@ STDMETHODIMP AXPlatformNodeWin::accNavigate(
case NAVDIR_UP: {
// This direction is not implemented except in tables.
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return E_NOTIMPL;
AXPlatformNodeBase* next =
@@ -742,8 +764,8 @@ STDMETHODIMP AXPlatformNodeWin::accNavigate(
case NAVDIR_LEFT: {
// This direction is not implemented except in tables.
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return E_NOTIMPL;
AXPlatformNodeBase* next =
@@ -758,8 +780,8 @@ STDMETHODIMP AXPlatformNodeWin::accNavigate(
case NAVDIR_RIGHT: {
// This direction is not implemented except in tables.
- if (!ui::IsTableLikeRole(GetData().role) &&
- !ui::IsCellOrTableHeaderRole(GetData().role))
+ if (!IsTableLikeRole(GetData().role) &&
+ !IsCellOrTableHeaderRole(GetData().role))
return E_NOTIMPL;
AXPlatformNodeBase* next = target->GetTableCell(
@@ -798,7 +820,6 @@ STDMETHODIMP AXPlatformNodeWin::get_accChild(VARIANT var_child,
STDMETHODIMP AXPlatformNodeWin::get_accChildCount(LONG* child_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_CHILD_COUNT);
-
COM_OBJECT_VALIDATE_1_ARG(child_count);
*child_count = delegate_->GetChildCount();
return S_OK;
@@ -809,6 +830,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accDefaultAction(
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_DEFAULT_ACTION);
AXPlatformNodeWin* target;
COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, def_action, target);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
int action;
if (!target->GetIntAttribute(AX_ATTR_DEFAULT_ACTION_VERB, &action)) {
@@ -834,7 +856,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accDescription(
AXPlatformNodeWin* target;
COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, desc, target);
- return target->GetStringAttributeAsBstr(ui::AX_ATTR_DESCRIPTION, desc);
+ return target->GetStringAttributeAsBstr(AX_ATTR_DESCRIPTION, desc);
}
STDMETHODIMP AXPlatformNodeWin::get_accFocus(VARIANT* focus_child) {
@@ -862,7 +884,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accKeyboardShortcut(
AXPlatformNodeWin* target;
COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, acc_key, target);
- return target->GetStringAttributeAsBstr(ui::AX_ATTR_KEY_SHORTCUTS, acc_key);
+ return target->GetStringAttributeAsBstr(AX_ATTR_KEY_SHORTCUTS, acc_key);
}
STDMETHODIMP AXPlatformNodeWin::get_accName(
@@ -871,7 +893,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accName(
AXPlatformNodeWin* target;
COM_OBJECT_VALIDATE_VAR_ID_1_ARG_AND_GET_TARGET(var_id, name, target);
- HRESULT result = target->GetStringAttributeAsBstr(ui::AX_ATTR_NAME, name);
+ HRESULT result = target->GetStringAttributeAsBstr(AX_ATTR_NAME, name);
if (FAILED(result) && MSAARole() == ROLE_SYSTEM_DOCUMENT && GetParent()) {
// Hack: Some versions of JAWS crash if they get an empty name on
// a document that's the child of an iframe, so always return a
@@ -956,9 +978,9 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
//
// Color Well special case (Use AX_ATTR_COLOR_VALUE)
//
- if (target->GetData().role == ui::AX_ROLE_COLOR_WELL) {
+ if (target->GetData().role == AX_ROLE_COLOR_WELL) {
unsigned int color = static_cast<unsigned int>(target->GetIntAttribute(
- ui::AX_ATTR_COLOR_VALUE)); // todo, why the static cast?
+ AX_ATTR_COLOR_VALUE)); // todo, why the static cast?
unsigned int red = SkColorGetR(color);
unsigned int green = SkColorGetG(color);
@@ -975,8 +997,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
//
// Document special case (Use the document's url)
//
- if (target->GetData().role == ui::AX_ROLE_ROOT_WEB_AREA ||
- target->GetData().role == ui::AX_ROLE_WEB_AREA) {
+ if (target->GetData().role == AX_ROLE_ROOT_WEB_AREA ||
+ target->GetData().role == AX_ROLE_WEB_AREA) {
result = base::UTF8ToUTF16(target->delegate_->GetTreeData().url);
*value = SysAllocString(result.c_str());
DCHECK(*value);
@@ -986,9 +1008,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
//
// Links (Use AX_ATTR_URL)
//
- if (target->GetData().role == ui::AX_ROLE_LINK ||
- target->GetData().role == ui::AX_ROLE_IMAGE_MAP_LINK) {
- result = target->GetString16Attribute(ui::AX_ATTR_URL);
+ if (target->GetData().role == AX_ROLE_LINK) {
+ result = target->GetString16Attribute(AX_ATTR_URL);
*value = SysAllocString(result.c_str());
DCHECK(*value);
return S_OK;
@@ -997,14 +1018,14 @@ STDMETHODIMP AXPlatformNodeWin::get_accValue(VARIANT var_id, BSTR* value) {
// After this point, the role based special cases should test for an empty
// result.
- result = target->GetString16Attribute(ui::AX_ATTR_VALUE);
+ result = target->GetString16Attribute(AX_ATTR_VALUE);
//
// RangeValue (Use AX_ATTR_VALUE_FOR_RANGE)
//
if (result.empty() && target->IsRangeValueSupported()) {
float fval;
- if (target->GetFloatAttribute(ui::AX_ATTR_VALUE_FOR_RANGE, &fval)) {
+ if (target->GetFloatAttribute(AX_ATTR_VALUE_FOR_RANGE, &fval)) {
result = base::UTF8ToUTF16(base::DoubleToString(fval));
*value = SysAllocString(result.c_str());
DCHECK(*value);
@@ -1030,7 +1051,7 @@ STDMETHODIMP AXPlatformNodeWin::put_accValue(VARIANT var_id,
COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
AXActionData data;
- data.action = ui::AX_ACTION_SET_VALUE;
+ data.action = AX_ACTION_SET_VALUE;
data.value = new_value;
if (target->delegate_->AccessibilityPerformAction(data))
return S_OK;
@@ -1041,7 +1062,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACC_SELECTION);
COM_OBJECT_VALIDATE_1_ARG(selected);
- if (GetData().role != ui::AX_ROLE_LIST_BOX)
+ if (GetData().role != AX_ROLE_LIST_BOX)
return E_NOTIMPL;
unsigned long selected_count = 0;
@@ -1049,7 +1070,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
- if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED))
+ if (node && node->GetData().HasState(AX_STATE_SELECTED))
++selected_count;
}
@@ -1063,7 +1084,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
- if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED)) {
+ if (node && node->GetData().HasState(AX_STATE_SELECTED)) {
selected->vt = VT_DISPATCH;
selected->pdispVal = node;
node->AddRef();
@@ -1081,7 +1102,7 @@ STDMETHODIMP AXPlatformNodeWin::get_accSelection(VARIANT* selected) {
AXPlatformNodeWin* node = static_cast<AXPlatformNodeWin*>(
FromNativeViewAccessible(delegate_->ChildAtIndex(i)));
- if (node && node->GetData().state & (1 << ui::AX_STATE_SELECTED)) {
+ if (node && node->GetData().HasState(AX_STATE_SELECTED)) {
enum_variant->ItemAt(index)->vt = VT_DISPATCH;
enum_variant->ItemAt(index)->pdispVal = node;
node->AddRef();
@@ -1101,8 +1122,8 @@ STDMETHODIMP AXPlatformNodeWin::accSelect(
COM_OBJECT_VALIDATE_VAR_ID_AND_GET_TARGET(var_id, target);
if (flagsSelect & SELFLAG_TAKEFOCUS) {
- ui::AXActionData action_data;
- action_data.action = ui::AX_ACTION_FOCUS;
+ AXActionData action_data;
+ action_data.action = AX_ACTION_FOCUS;
target->delegate_->AccessibilityPerformAction(action_data);
return S_OK;
}
@@ -1151,27 +1172,30 @@ STDMETHODIMP AXPlatformNodeWin::role(LONG* role) {
STDMETHODIMP AXPlatformNodeWin::get_states(AccessibleStates* states) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_STATES);
COM_OBJECT_VALIDATE_1_ARG(states);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
*states = ComputeIA2State();
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_uniqueID(LONG* unique_id) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_UNIQUE_ID);
COM_OBJECT_VALIDATE_1_ARG(unique_id);
*unique_id = -unique_id_;
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_windowHandle(HWND* window_handle) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_WINDOW_HANDLE);
COM_OBJECT_VALIDATE_1_ARG(window_handle);
*window_handle = delegate_->GetTargetForNativeAccessibilityEvent();
return *window_handle ? S_OK : S_FALSE;
}
-STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(
- BSTR type_bstr,
- long max_targets,
- IUnknown ***targets,
- long *n_targets) {
+STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(BSTR type_bstr,
+ LONG max_targets,
+ IUnknown*** targets,
+ LONG* n_targets) {
COM_OBJECT_VALIDATE_2_ARGS(targets, n_targets);
*n_targets = 0;
@@ -1193,7 +1217,7 @@ STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(
alert_targets.push_back(target);
}
- long count = static_cast<long>(alert_targets.size());
+ LONG count = static_cast<LONG>(alert_targets.size());
if (count == 0)
return S_FALSE;
@@ -1208,7 +1232,7 @@ STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(
// Allocate COM memory for the result array and populate it.
*targets = static_cast<IUnknown**>(
CoTaskMemAlloc(count * sizeof(IUnknown*)));
- for (long i = 0; i < count; ++i) {
+ for (LONG i = 0; i < count; ++i) {
(*targets)[i] = static_cast<IAccessible*>(alert_targets[i]);
(*targets)[i]->AddRef();
}
@@ -1216,17 +1240,18 @@ STDMETHODIMP AXPlatformNodeWin::get_relationTargetsOfType(
}
STDMETHODIMP AXPlatformNodeWin::get_attributes(BSTR* attributes) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IA2_GET_ATTRIBUTES);
COM_OBJECT_VALIDATE_1_ARG(attributes);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+ *attributes = nullptr;
+
base::string16 attributes_str;
+ std::vector<base::string16> computed_attributes = ComputeIA2Attributes();
+ for (const base::string16& attribute : computed_attributes)
+ attributes_str += attribute + L';';
- // Text fields need to report the attribute "text-model:a1" to instruct
- // screen readers to use IAccessible2 APIs to handle text editing in this
- // object (as opposed to treating it like a native Windows text box).
- // The text-model:a1 attribute is documented here:
- // http://www.linuxfoundation.org/collaborate/workgroups/accessibility/ia2/ia2_implementation_guide
- if (GetData().role == ui::AX_ROLE_TEXT_FIELD) {
- attributes_str = L"text-model:a1;";
- }
+ if (attributes_str.empty())
+ return S_FALSE;
*attributes = SysAllocString(attributes_str.c_str());
DCHECK(*attributes);
@@ -1234,6 +1259,7 @@ STDMETHODIMP AXPlatformNodeWin::get_attributes(BSTR* attributes) {
}
STDMETHODIMP AXPlatformNodeWin::get_indexInParent(LONG* index_in_parent) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT);
COM_OBJECT_VALIDATE_1_ARG(index_in_parent);
*index_in_parent = GetIndexInParent();
if (*index_in_parent < 0)
@@ -1243,16 +1269,20 @@ STDMETHODIMP AXPlatformNodeWin::get_indexInParent(LONG* index_in_parent) {
}
STDMETHODIMP AXPlatformNodeWin::get_nRelations(LONG* n_relations) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_RELATIONS);
COM_OBJECT_VALIDATE_1_ARG(n_relations);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
*n_relations = static_cast<LONG>(relations_.size());
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_relation(LONG relation_index,
IAccessibleRelation** relation) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATION);
COM_OBJECT_VALIDATE_1_ARG(relation);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (relation_index < 0 ||
- relation_index >= static_cast<long>(relations_.size())) {
+ relation_index >= static_cast<LONG>(relations_.size())) {
return E_INVALIDARG;
}
@@ -1264,13 +1294,16 @@ STDMETHODIMP AXPlatformNodeWin::get_relation(LONG relation_index,
STDMETHODIMP AXPlatformNodeWin::get_relations(LONG max_relations,
IAccessibleRelation** relations,
LONG* n_relations) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_RELATIONS);
COM_OBJECT_VALIDATE_2_ARGS(relations, n_relations);
- long count = static_cast<long>(relations_.size());
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
+ LONG count = static_cast<LONG>(relations_.size());
*n_relations = count;
if (count == 0)
return S_FALSE;
- for (long i = 0; i < count; ++i) {
+ for (LONG i = 0; i < count; ++i) {
relations_[i]->AddRef();
relations[i] = relations_[i];
}
@@ -1278,6 +1311,33 @@ STDMETHODIMP AXPlatformNodeWin::get_relations(LONG max_relations,
return S_OK;
}
+STDMETHODIMP AXPlatformNodeWin::get_groupPosition(LONG* group_level,
+ LONG* similar_items_in_group,
+ LONG* position_in_group) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_GROUP_POSITION);
+ COM_OBJECT_VALIDATE_3_ARGS(group_level, similar_items_in_group,
+ position_in_group);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
+ *group_level = GetIntAttribute(ui::AX_ATTR_HIERARCHICAL_LEVEL);
+ *similar_items_in_group = GetIntAttribute(ui::AX_ATTR_SET_SIZE);
+ *position_in_group = GetIntAttribute(ui::AX_ATTR_POS_IN_SET);
+
+ if (*group_level == *similar_items_in_group == *position_in_group == 0)
+ return S_FALSE;
+ return S_OK;
+}
+
+STDMETHODIMP AXPlatformNodeWin::get_localizedExtendedRole(
+ BSTR* localized_extended_role) {
+ WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_EXTENDED_ROLE);
+ COM_OBJECT_VALIDATE_1_ARG(localized_extended_role);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
+ return GetStringAttributeAsBstr(ui::AX_ATTR_ROLE_DESCRIPTION,
+ localized_extended_role);
+}
+
//
// IAccessible2 methods not implemented.
//
@@ -1300,17 +1360,6 @@ STDMETHODIMP AXPlatformNodeWin::scrollToPoint(
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::get_groupPosition(LONG* group_level,
- LONG* similar_items_in_group,
- LONG* position_in_group) {
- return E_NOTIMPL;
-}
-
-STDMETHODIMP AXPlatformNodeWin::get_localizedExtendedRole(
- BSTR* localized_extended_role) {
- return E_NOTIMPL;
-}
-
STDMETHODIMP AXPlatformNodeWin::get_nExtendedStates(LONG* n_extended_states) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_EXTENDED_STATES);
return E_NOTIMPL;
@@ -1338,7 +1387,7 @@ STDMETHODIMP AXPlatformNodeWin::get_locale(IA2Locale* locale) {
}
STDMETHODIMP AXPlatformNodeWin::get_accessibleWithCaret(IUnknown** accessible,
- long* caret_offset) {
+ LONG* caret_offset) {
return E_NOTIMPL;
}
@@ -1346,10 +1395,12 @@ STDMETHODIMP AXPlatformNodeWin::get_accessibleWithCaret(IUnknown** accessible,
// IAccessibleTable methods.
//
-STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(long row,
- long column,
+STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(LONG row,
+ LONG column,
IUnknown** accessible) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ACCESSIBLE_AT);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!accessible)
return E_INVALIDARG;
@@ -1369,6 +1420,8 @@ STDMETHODIMP AXPlatformNodeWin::get_accessibleAt(long row,
STDMETHODIMP AXPlatformNodeWin::get_caption(IUnknown** accessible) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CAPTION);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!accessible)
return E_INVALIDARG;
@@ -1377,14 +1430,17 @@ STDMETHODIMP AXPlatformNodeWin::get_caption(IUnknown** accessible) {
return S_FALSE;
}
-STDMETHODIMP AXPlatformNodeWin::get_childIndex(long row,
- long column,
- long* cell_index) {
+STDMETHODIMP AXPlatformNodeWin::get_childIndex(LONG row,
+ LONG column,
+ LONG* cell_index) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_CHILD_INDEX);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!cell_index)
return E_INVALIDARG;
- auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
+ AXPlatformNodeBase* cell =
+ GetTableCell(static_cast<int>(row), static_cast<int>(column));
if (cell) {
*cell_index = static_cast<LONG>(cell->GetTableCellIndex());
return S_OK;
@@ -1394,9 +1450,11 @@ STDMETHODIMP AXPlatformNodeWin::get_childIndex(long row,
return E_INVALIDARG;
}
-STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column,
+STDMETHODIMP AXPlatformNodeWin::get_columnDescription(LONG column,
BSTR* description) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_DESCRIPTION);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!description)
return E_INVALIDARG;
@@ -1410,16 +1468,16 @@ STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column,
return S_FALSE;
}
- for (int i = 0; i < rows; ++i) {
- auto* cell = GetTableCell(i, column);
- if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER) {
- base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME);
+ for (int r = 0; r < rows; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, column);
+ if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER) {
+ base::string16 cell_name = cell->GetString16Attribute(AX_ATTR_NAME);
if (cell_name.size() > 0) {
*description = SysAllocString(cell_name.c_str());
return S_OK;
}
- cell_name = cell->GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
+ cell_name = cell->GetString16Attribute(AX_ATTR_DESCRIPTION);
if (cell_name.size() > 0) {
*description = SysAllocString(cell_name.c_str());
return S_OK;
@@ -1431,14 +1489,17 @@ STDMETHODIMP AXPlatformNodeWin::get_columnDescription(long column,
return S_FALSE;
}
-STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(long row,
- long column,
- long* n_columns_spanned) {
+STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(LONG row,
+ LONG column,
+ LONG* n_columns_spanned) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_EXTENT_AT);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!n_columns_spanned)
return E_INVALIDARG;
- auto* cell = GetTableCell(static_cast<int>(row), static_cast<int>(column));
+ AXPlatformNodeBase* cell =
+ GetTableCell(static_cast<int>(row), static_cast<int>(column));
if (!cell)
return E_INVALIDARG;
@@ -1448,27 +1509,33 @@ STDMETHODIMP AXPlatformNodeWin::get_columnExtentAt(long row,
STDMETHODIMP AXPlatformNodeWin::get_columnHeader(
IAccessibleTable** accessible_table,
- long* starting_row_index) {
+ LONG* starting_row_index) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_HEADER);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
// TODO(dmazzoni): implement
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long cell_index,
- long* column_index) {
+STDMETHODIMP AXPlatformNodeWin::get_columnIndex(LONG cell_index,
+ LONG* column_index) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_COLUMN_INDEX);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!column_index)
return E_INVALIDARG;
- auto* cell = GetTableCell(cell_index);
+ AXPlatformNodeBase* cell = GetTableCell(cell_index);
if (!cell)
return E_INVALIDARG;
*column_index = cell->GetTableColumn();
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_nColumns(long* column_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nColumns(LONG* column_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_COLUMNS);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!column_count)
return E_INVALIDARG;
@@ -1476,8 +1543,10 @@ STDMETHODIMP AXPlatformNodeWin::get_nColumns(long* column_count) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_nRows(long* row_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nRows(LONG* row_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_ROWS);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row_count)
return E_INVALIDARG;
@@ -1485,37 +1554,96 @@ STDMETHODIMP AXPlatformNodeWin::get_nRows(long* row_count) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(long* cell_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nSelectedChildren(LONG* cell_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_CHILDREN);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!cell_count)
return E_INVALIDARG;
-
- // TODO(dmazzoni): add support for selected cells/rows/columns in tables.
*cell_count = 0;
- return S_FALSE;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0)
+ return S_FALSE;
+
+ LONG result = 0;
+ for (int r = 0; r < rows; ++r) {
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (cell && cell->GetData().HasState(AX_STATE_SELECTED))
+ result++;
+ }
+ }
+ *cell_count = result;
+ return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(long* column_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nSelectedColumns(LONG* column_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_COLUMNS);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!column_count)
return E_INVALIDARG;
-
*column_count = 0;
- return S_FALSE;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0)
+ return S_FALSE;
+
+ // If every cell in a column is selected, then that column is selected.
+ LONG result = 0;
+ for (int c = 0; c < columns; ++c) {
+ bool selected = true;
+ for (int r = 0; r < rows && selected == true; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ selected = false;
+ }
+ if (selected)
+ result++;
+ }
+
+ *column_count = result;
+ return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(long* row_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nSelectedRows(LONG* row_count) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_N_SELECTED_ROWS);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row_count)
return E_INVALIDARG;
-
*row_count = 0;
- return S_FALSE;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0)
+ return S_FALSE;
+
+ // If every cell in a row is selected, then that row is selected.
+ LONG result = 0;
+ for (int r = 0; r < rows; ++r) {
+ bool selected = true;
+ for (int c = 0; c < columns && selected == true; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ selected = false;
+ }
+ if (selected)
+ result++;
+ }
+
+ *row_count = result;
+ return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row,
+STDMETHODIMP AXPlatformNodeWin::get_rowDescription(LONG row,
BSTR* description) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_DESCRIPTION);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!description)
return E_INVALIDARG;
@@ -1528,15 +1656,15 @@ STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row,
return S_FALSE;
}
- for (int i = 0; i < columns; ++i) {
- auto* cell = GetTableCell(row, i);
- if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER) {
- base::string16 cell_name = cell->GetString16Attribute(ui::AX_ATTR_NAME);
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(row, c);
+ if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER) {
+ base::string16 cell_name = cell->GetString16Attribute(AX_ATTR_NAME);
if (cell_name.size() > 0) {
*description = SysAllocString(cell_name.c_str());
return S_OK;
}
- cell_name = cell->GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
+ cell_name = cell->GetString16Attribute(AX_ATTR_DESCRIPTION);
if (cell_name.size() > 0) {
*description = SysAllocString(cell_name.c_str());
return S_OK;
@@ -1548,14 +1676,16 @@ STDMETHODIMP AXPlatformNodeWin::get_rowDescription(long row,
return S_FALSE;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(long row,
- long column,
- long* n_rows_spanned) {
+STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(LONG row,
+ LONG column,
+ LONG* n_rows_spanned) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_EXTENT_AT);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!n_rows_spanned)
return E_INVALIDARG;
- auto* cell = GetTableCell(row, column);
+ AXPlatformNodeBase* cell = GetTableCell(row, column);
if (!cell)
return E_INVALIDARG;
@@ -1565,17 +1695,22 @@ STDMETHODIMP AXPlatformNodeWin::get_rowExtentAt(long row,
STDMETHODIMP AXPlatformNodeWin::get_rowHeader(
IAccessibleTable** accessible_table,
- long* starting_column_index) {
+ LONG* starting_column_index) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_ROW_HEADER);
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
// TODO(dmazzoni): implement
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long cell_index, long* row_index) {
+STDMETHODIMP AXPlatformNodeWin::get_rowIndex(LONG cell_index, LONG* row_index) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row_index)
return E_INVALIDARG;
- auto* cell = GetTableCell(cell_index);
+ AXPlatformNodeBase* cell = GetTableCell(cell_index);
if (!cell)
return E_INVALIDARG;
@@ -1583,40 +1718,95 @@ STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long cell_index, long* row_index) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_selectedChildren(long max_children,
- long** children,
- long* n_children) {
- if (!children || !n_children)
+STDMETHODIMP AXPlatformNodeWin::get_selectedChildren(LONG max_children,
+ LONG** children,
+ LONG* n_children) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
+ if (!children || !n_children || max_children <= 0)
return E_INVALIDARG;
- // TODO(dmazzoni): Implement this.
- *n_children = 0;
- return S_FALSE;
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0)
+ return S_FALSE;
+
+ std::vector<LONG> results;
+ for (int r = 0; r < rows; ++r) {
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (cell && cell->GetData().HasState(AX_STATE_SELECTED))
+ // index is row index * column count + column index.
+ results.push_back(r * columns + c);
+ }
+ }
+
+ return AllocateComArrayFromVector(results, max_children, children,
+ n_children);
}
-STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(long max_columns,
- long** columns,
- long* n_columns) {
- if (!columns || !n_columns)
+STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(LONG max_columns,
+ LONG** columns,
+ LONG* n_columns) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
+ if (!columns || !n_columns || max_columns <= 0)
return E_INVALIDARG;
- // TODO(dmazzoni): Implement this.
- *n_columns = 0;
- return S_FALSE;
+ int column_count = GetTableColumnCount();
+ int row_count = GetTableRowCount();
+ if (column_count <= 0 || row_count <= 0)
+ return S_FALSE;
+
+ std::vector<LONG> results;
+ for (int c = 0; c < column_count; ++c) {
+ bool selected = true;
+ for (int r = 0; r < row_count && selected == true; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ selected = false;
+ }
+ if (selected)
+ results.push_back(c);
+ }
+
+ return AllocateComArrayFromVector(results, max_columns, columns, n_columns);
}
-STDMETHODIMP AXPlatformNodeWin::get_selectedRows(long max_rows,
- long** rows,
- long* n_rows) {
- if (!rows || !n_rows)
+STDMETHODIMP AXPlatformNodeWin::get_selectedRows(LONG max_rows,
+ LONG** rows,
+ LONG* n_rows) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+ if (!rows || !n_rows || max_rows <= 0)
return E_INVALIDARG;
- // TODO(dmazzoni): Implement this.
- *n_rows = 0;
- return S_FALSE;
+ int column_count = GetTableColumnCount();
+ int row_count = GetTableRowCount();
+ if (column_count <= 0 || row_count <= 0)
+ return S_FALSE;
+
+ std::vector<LONG> results;
+ for (int r = 0; r < row_count; ++r) {
+ bool selected = true;
+ for (int c = 0; c < column_count && selected == true; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ selected = false;
+ }
+ if (selected)
+ results.push_back(r);
+ }
+
+ return AllocateComArrayFromVector(results, max_rows, rows, n_rows);
}
STDMETHODIMP AXPlatformNodeWin::get_summary(IUnknown** accessible) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!accessible)
return E_INVALIDARG;
@@ -1625,48 +1815,88 @@ STDMETHODIMP AXPlatformNodeWin::get_summary(IUnknown** accessible) {
return S_FALSE;
}
-STDMETHODIMP AXPlatformNodeWin::get_isColumnSelected(long column,
+STDMETHODIMP AXPlatformNodeWin::get_isColumnSelected(LONG column,
boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!is_selected)
return E_INVALIDARG;
-
- // TODO(dmazzoni): Implement this.
*is_selected = false;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0 || column >= columns || column < 0)
+ return S_FALSE;
+
+ for (int r = 0; r < rows; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, column);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ return S_OK;
+ }
+
+ *is_selected = true;
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_isRowSelected(long row,
+STDMETHODIMP AXPlatformNodeWin::get_isRowSelected(LONG row,
boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!is_selected)
return E_INVALIDARG;
-
- // TODO(dmazzoni): Implement this.
*is_selected = false;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0 || row >= rows || row < 0)
+ return S_FALSE;
+
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(row, c);
+ if (!cell || !(cell->GetData().HasState(AX_STATE_SELECTED)))
+ return S_OK;
+ }
+
+ *is_selected = true;
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_isSelected(long row,
- long column,
+STDMETHODIMP AXPlatformNodeWin::get_isSelected(LONG row,
+ LONG column,
boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!is_selected)
return E_INVALIDARG;
-
- // TODO(dmazzoni): Implement this.
*is_selected = false;
+
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0 || row >= rows || row < 0 ||
+ column >= columns || column < 0)
+ return S_FALSE;
+
+ AXPlatformNodeBase* cell = GetTableCell(row, column);
+ if (cell && cell->GetData().HasState(AX_STATE_SELECTED))
+ *is_selected = true;
+
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtentsAtIndex(
- long index,
- long* row,
- long* column,
- long* row_extents,
- long* column_extents,
+ LONG index,
+ LONG* row,
+ LONG* column,
+ LONG* row_extents,
+ LONG* column_extents,
boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row || !column || !row_extents || !column_extents || !is_selected)
return E_INVALIDARG;
- auto* cell = GetTableCell(index);
+ AXPlatformNodeBase* cell = GetTableCell(index);
if (!cell)
return E_INVALIDARG;
@@ -1679,24 +1909,37 @@ STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtentsAtIndex(
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::selectRow(long row) {
+STDMETHODIMP AXPlatformNodeWin::selectRow(LONG row) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::selectColumn(long column) {
+STDMETHODIMP AXPlatformNodeWin::selectColumn(LONG column) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::unselectRow(long row) {
+STDMETHODIMP AXPlatformNodeWin::unselectRow(LONG row) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
return E_NOTIMPL;
}
-STDMETHODIMP AXPlatformNodeWin::unselectColumn(long column) {
+STDMETHODIMP AXPlatformNodeWin::unselectColumn(LONG column) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
return E_NOTIMPL;
}
STDMETHODIMP
AXPlatformNodeWin::get_modelChange(IA2TableModelChange* model_change) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
return E_NOTIMPL;
}
@@ -1704,9 +1947,11 @@ AXPlatformNodeWin::get_modelChange(IA2TableModelChange* model_change) {
// IAccessibleTable2 methods.
//
-STDMETHODIMP AXPlatformNodeWin::get_cellAt(long row,
- long column,
+STDMETHODIMP AXPlatformNodeWin::get_cellAt(LONG row,
+ LONG column,
IUnknown** cell) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(AXMode::kScreenReader);
if (!cell)
return E_INVALIDARG;
@@ -1723,44 +1968,65 @@ STDMETHODIMP AXPlatformNodeWin::get_cellAt(long row,
return E_INVALIDARG;
}
-STDMETHODIMP AXPlatformNodeWin::get_nSelectedCells(long* cell_count) {
+STDMETHODIMP AXPlatformNodeWin::get_nSelectedCells(LONG* cell_count) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ // Note that this method does not need to set any ax mode since it
+ // calls into get_nSelectedChildren() which does.
return get_nSelectedChildren(cell_count);
}
STDMETHODIMP AXPlatformNodeWin::get_selectedCells(IUnknown*** cells,
- long* n_selected_cells) {
+ LONG* n_selected_cells) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!cells || !n_selected_cells)
return E_INVALIDARG;
- // TODO(dmazzoni): Implement this.
+ *cells = nullptr;
*n_selected_cells = 0;
- return S_OK;
-}
-STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(long** columns,
- long* n_columns) {
- if (!columns || !n_columns)
- return E_INVALIDARG;
+ int columns = GetTableColumnCount();
+ int rows = GetTableRowCount();
+ if (columns <= 0 || rows <= 0)
+ return S_FALSE;
- // TODO(dmazzoni): Implement this.
- *n_columns = 0;
+ std::vector<AXPlatformNodeBase*> selected;
+ for (int r = 0; r < rows; ++r) {
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(r, c);
+ if (cell && cell->GetData().HasState(AX_STATE_SELECTED))
+ selected.push_back(cell);
+ }
+ }
+
+ *n_selected_cells = static_cast<LONG>(selected.size());
+ *cells = static_cast<IUnknown**>(
+ CoTaskMemAlloc((*n_selected_cells) * sizeof(cells[0])));
+
+ for (size_t i = 0; i < selected.size(); ++i) {
+ auto* node_win = static_cast<AXPlatformNodeWin*>(selected[i]);
+ node_win->AddRef();
+ (*cells)[i] = static_cast<IAccessible*>(node_win);
+ }
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_selectedRows(long** rows, long* n_rows) {
- if (!rows || !n_rows)
- return E_INVALIDARG;
+STDMETHODIMP AXPlatformNodeWin::get_selectedColumns(LONG** columns,
+ LONG* n_columns) {
+ return get_selectedColumns(INT_MAX, columns, n_columns);
+}
- // TODO(dmazzoni): Implement this.
- *n_rows = 0;
- return S_OK;
+STDMETHODIMP AXPlatformNodeWin::get_selectedRows(LONG** rows, LONG* n_rows) {
+ return get_selectedRows(INT_MAX, rows, n_rows);
}
//
// IAccessibleTableCell methods.
//
-STDMETHODIMP AXPlatformNodeWin::get_columnExtent(long* n_columns_spanned) {
+STDMETHODIMP AXPlatformNodeWin::get_columnExtent(LONG* n_columns_spanned) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!n_columns_spanned)
return E_INVALIDARG;
@@ -1770,12 +2036,14 @@ STDMETHODIMP AXPlatformNodeWin::get_columnExtent(long* n_columns_spanned) {
STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells(
IUnknown*** cell_accessibles,
- long* n_column_header_cells) {
+ LONG* n_column_header_cells) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
if (!cell_accessibles || !n_column_header_cells)
return E_INVALIDARG;
*n_column_header_cells = 0;
- auto* table = GetTable();
+ AXPlatformNodeBase* table = GetTable();
if (!table) {
return S_FALSE;
}
@@ -1786,18 +2054,18 @@ STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells(
if (columns <= 0 || rows <= 0 || column < 0 || column >= columns)
return S_FALSE;
- for (int i = 0; i < rows; ++i) {
- auto* cell = GetTableCell(i, column);
- if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER)
+ for (int r = 0; r < rows; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, column);
+ if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER)
(*n_column_header_cells)++;
}
*cell_accessibles = static_cast<IUnknown**>(
CoTaskMemAlloc((*n_column_header_cells) * sizeof(cell_accessibles[0])));
int index = 0;
- for (int i = 0; i < rows; ++i) {
- AXPlatformNodeBase* cell = GetTableCell(i, column);
- if (cell && cell->GetData().role == ui::AX_ROLE_COLUMN_HEADER) {
+ for (int r = 0; r < rows; ++r) {
+ AXPlatformNodeBase* cell = GetTableCell(r, column);
+ if (cell && cell->GetData().role == AX_ROLE_COLUMN_HEADER) {
auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
node_win->AddRef();
@@ -1809,7 +2077,10 @@ STDMETHODIMP AXPlatformNodeWin::get_columnHeaderCells(
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long* column_index) {
+STDMETHODIMP AXPlatformNodeWin::get_columnIndex(LONG* column_index) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!column_index)
return E_INVALIDARG;
@@ -1817,7 +2088,10 @@ STDMETHODIMP AXPlatformNodeWin::get_columnIndex(long* column_index) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowExtent(long* n_rows_spanned) {
+STDMETHODIMP AXPlatformNodeWin::get_rowExtent(LONG* n_rows_spanned) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!n_rows_spanned)
return E_INVALIDARG;
@@ -1826,12 +2100,15 @@ STDMETHODIMP AXPlatformNodeWin::get_rowExtent(long* n_rows_spanned) {
}
STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles,
- long* n_row_header_cells) {
+ LONG* n_row_header_cells) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!cell_accessibles || !n_row_header_cells)
return E_INVALIDARG;
*n_row_header_cells = 0;
- auto* table = GetTable();
+ AXPlatformNodeBase* table = GetTable();
if (!table) {
return S_FALSE;
}
@@ -1842,18 +2119,18 @@ STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles,
if (columns <= 0 || rows <= 0 || row < 0 || row >= rows)
return S_FALSE;
- for (int i = 0; i < columns; ++i) {
- auto* cell = GetTableCell(row, i);
- if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER)
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(row, c);
+ if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER)
(*n_row_header_cells)++;
}
*cell_accessibles = static_cast<IUnknown**>(
CoTaskMemAlloc((*n_row_header_cells) * sizeof(cell_accessibles[0])));
int index = 0;
- for (int i = 0; i < columns; ++i) {
- AXPlatformNodeBase* cell = GetTableCell(row, i);
- if (cell && cell->GetData().role == ui::AX_ROLE_ROW_HEADER) {
+ for (int c = 0; c < columns; ++c) {
+ AXPlatformNodeBase* cell = GetTableCell(row, c);
+ if (cell && cell->GetData().role == AX_ROLE_ROW_HEADER) {
auto* node_win = static_cast<AXPlatformNodeWin*>(cell);
node_win->AddRef();
@@ -1865,7 +2142,10 @@ STDMETHODIMP AXPlatformNodeWin::get_rowHeaderCells(IUnknown*** cell_accessibles,
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long* row_index) {
+STDMETHODIMP AXPlatformNodeWin::get_rowIndex(LONG* row_index) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row_index)
return E_INVALIDARG;
@@ -1874,6 +2154,9 @@ STDMETHODIMP AXPlatformNodeWin::get_rowIndex(long* row_index) {
}
STDMETHODIMP AXPlatformNodeWin::get_isSelected(boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!is_selected)
return E_INVALIDARG;
@@ -1881,11 +2164,14 @@ STDMETHODIMP AXPlatformNodeWin::get_isSelected(boolean* is_selected) {
return S_OK;
}
-STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtents(long* row_index,
- long* column_index,
- long* row_extents,
- long* column_extents,
+STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtents(LONG* row_index,
+ LONG* column_index,
+ LONG* row_extents,
+ LONG* column_extents,
boolean* is_selected) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!row_index || !column_index || !row_extents || !column_extents ||
!is_selected) {
return E_INVALIDARG;
@@ -1901,10 +2187,13 @@ STDMETHODIMP AXPlatformNodeWin::get_rowColumnExtents(long* row_index,
}
STDMETHODIMP AXPlatformNodeWin::get_table(IUnknown** table) {
+ // TODO(dougt) WIN_ACCESSIBILITY_API_HISTOGRAM?
+ AXPlatformNode::NotifyAddAXModeFlags(kScreenReaderAndHTMLAccessibilityModes);
+
if (!table)
return E_INVALIDARG;
- auto* find_table = GetTable();
+ AXPlatformNodeBase* find_table = GetTable();
if (!find_table) {
*table = nullptr;
return S_FALSE;
@@ -1933,14 +2222,14 @@ STDMETHODIMP AXPlatformNodeWin::get_nCharacters(LONG* n_characters) {
STDMETHODIMP AXPlatformNodeWin::get_caretOffset(LONG* offset) {
COM_OBJECT_VALIDATE_1_ARG(offset);
- *offset = static_cast<LONG>(GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END));
+ *offset = static_cast<LONG>(GetIntAttribute(AX_ATTR_TEXT_SEL_END));
return S_OK;
}
STDMETHODIMP AXPlatformNodeWin::get_nSelections(LONG* n_selections) {
COM_OBJECT_VALIDATE_1_ARG(n_selections);
- int sel_start = GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START);
- int sel_end = GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END);
+ int sel_start = GetIntAttribute(AX_ATTR_TEXT_SEL_START);
+ int sel_end = GetIntAttribute(AX_ATTR_TEXT_SEL_END);
if (sel_start != sel_end)
*n_selections = 1;
else
@@ -1955,10 +2244,8 @@ STDMETHODIMP AXPlatformNodeWin::get_selection(LONG selection_index,
if (selection_index != 0)
return E_INVALIDARG;
- *start_offset = static_cast<LONG>(
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START));
- *end_offset = static_cast<LONG>(
- GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END));
+ *start_offset = static_cast<LONG>(GetIntAttribute(AX_ATTR_TEXT_SEL_START));
+ *end_offset = static_cast<LONG>(GetIntAttribute(AX_ATTR_TEXT_SEL_END));
return S_OK;
}
@@ -1966,7 +2253,7 @@ STDMETHODIMP AXPlatformNodeWin::get_text(LONG start_offset,
LONG end_offset,
BSTR* text) {
COM_OBJECT_VALIDATE_1_ARG(text);
- int sel_end = GetIntAttribute(ui::AX_ATTR_TEXT_SEL_START);
+ int sel_end = GetIntAttribute(AX_ATTR_TEXT_SEL_START);
base::string16 text_str = TextForIAccessibleText();
LONG len = static_cast<LONG>(text_str.size());
@@ -2022,10 +2309,10 @@ STDMETHODIMP AXPlatformNodeWin::get_textAtOffset(
const base::string16& text_str = TextForIAccessibleText();
- *start_offset = FindBoundary(
- text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
- *end_offset = FindBoundary(
- text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
+ *start_offset =
+ FindBoundary(text_str, boundary_type, offset, BACKWARDS_DIRECTION);
+ *end_offset =
+ FindBoundary(text_str, boundary_type, offset, FORWARDS_DIRECTION);
return get_text(*start_offset, *end_offset, text);
}
@@ -2048,8 +2335,8 @@ STDMETHODIMP AXPlatformNodeWin::get_textBeforeOffset(
const base::string16& text_str = TextForIAccessibleText();
- *start_offset = FindBoundary(
- text_str, boundary_type, offset, ui::BACKWARDS_DIRECTION);
+ *start_offset =
+ FindBoundary(text_str, boundary_type, offset, BACKWARDS_DIRECTION);
*end_offset = offset;
return get_text(*start_offset, *end_offset, text);
}
@@ -2074,8 +2361,8 @@ STDMETHODIMP AXPlatformNodeWin::get_textAfterOffset(
const base::string16& text_str = TextForIAccessibleText();
*start_offset = offset;
- *end_offset = FindBoundary(
- text_str, boundary_type, offset, ui::FORWARDS_DIRECTION);
+ *end_offset =
+ FindBoundary(text_str, boundary_type, offset, FORWARDS_DIRECTION);
return get_text(*start_offset, *end_offset, text);
}
@@ -2099,7 +2386,7 @@ STDMETHODIMP AXPlatformNodeWin::removeSelection(LONG selection_index) {
return E_INVALIDARG;
// Simply collapse the selection to the position of the caret if a caret is
// visible, otherwise set the selection to 0.
- return setCaretOffset(GetIntAttribute(ui::AX_ATTR_TEXT_SEL_END));
+ return setCaretOffset(GetIntAttribute(AX_ATTR_TEXT_SEL_END));
}
STDMETHODIMP AXPlatformNodeWin::setCaretOffset(LONG offset) {
@@ -2205,326 +2492,314 @@ int AXPlatformNodeWin::MSAARole() {
// If this is a web area for a presentational iframe, give it a role of
// something other than DOCUMENT so that the fact that it's a separate doc
// is not exposed to AT.
- if (IsWebAreaForPresentationalIframe()) {
+ if (IsWebAreaForPresentationalIframe())
return ROLE_SYSTEM_GROUPING;
- }
switch (GetData().role) {
- case ui::AX_ROLE_ALERT:
+ case AX_ROLE_ALERT:
return ROLE_SYSTEM_ALERT;
- case ui::AX_ROLE_ALERT_DIALOG:
+ case AX_ROLE_ALERT_DIALOG:
return ROLE_SYSTEM_DIALOG;
- case ui::AX_ROLE_ANCHOR:
+ case AX_ROLE_ANCHOR:
return ROLE_SYSTEM_LINK;
- case ui::AX_ROLE_APPLICATION:
+ case AX_ROLE_APPLICATION:
return ROLE_SYSTEM_APPLICATION;
- case ui::AX_ROLE_ARTICLE:
+ case AX_ROLE_ARTICLE:
return ROLE_SYSTEM_DOCUMENT;
- case ui::AX_ROLE_AUDIO:
+ case AX_ROLE_AUDIO:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_BANNER:
+ case AX_ROLE_BANNER:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_BUSY_INDICATOR:
- return ROLE_SYSTEM_ANIMATION;
-
- case ui::AX_ROLE_BUTTON:
+ case AX_ROLE_BUTTON:
return ROLE_SYSTEM_PUSHBUTTON;
- case ui::AX_ROLE_CANVAS:
+ case AX_ROLE_CANVAS:
return ROLE_SYSTEM_GRAPHIC;
- case ui::AX_ROLE_CAPTION:
+ case AX_ROLE_CAPTION:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_CELL:
+ case AX_ROLE_CELL:
return ROLE_SYSTEM_CELL;
- case ui::AX_ROLE_CHECK_BOX:
+ case AX_ROLE_CHECK_BOX:
return ROLE_SYSTEM_CHECKBUTTON;
- case ui::AX_ROLE_COLOR_WELL:
+ case AX_ROLE_COLOR_WELL:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_COLUMN:
+ case AX_ROLE_COLUMN:
return ROLE_SYSTEM_COLUMN;
- case ui::AX_ROLE_COLUMN_HEADER:
+ case AX_ROLE_COLUMN_HEADER:
return ROLE_SYSTEM_COLUMNHEADER;
- case ui::AX_ROLE_COMBO_BOX:
+ case AX_ROLE_COMBO_BOX:
return ROLE_SYSTEM_COMBOBOX;
- case ui::AX_ROLE_COMPLEMENTARY:
+ case AX_ROLE_COMPLEMENTARY:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_CONTENT_INFO:
+ case AX_ROLE_CONTENT_INFO:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_DATE:
- case ui::AX_ROLE_DATE_TIME:
+ case AX_ROLE_DATE:
+ case AX_ROLE_DATE_TIME:
return ROLE_SYSTEM_DROPLIST;
- case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
+ case AX_ROLE_DESCRIPTION_LIST_DETAIL:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_DESCRIPTION_LIST:
+ case AX_ROLE_DESCRIPTION_LIST:
return ROLE_SYSTEM_LIST;
- case ui::AX_ROLE_DESCRIPTION_LIST_TERM:
+ case AX_ROLE_DESCRIPTION_LIST_TERM:
return ROLE_SYSTEM_LISTITEM;
- case ui::AX_ROLE_DETAILS:
+ case AX_ROLE_DETAILS:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_DIALOG:
+ case AX_ROLE_DIALOG:
return ROLE_SYSTEM_DIALOG;
- case ui::AX_ROLE_DISCLOSURE_TRIANGLE:
+ case AX_ROLE_DISCLOSURE_TRIANGLE:
return ROLE_SYSTEM_PUSHBUTTON;
- case ui::AX_ROLE_DOCUMENT:
- case ui::AX_ROLE_ROOT_WEB_AREA:
- case ui::AX_ROLE_WEB_AREA:
+ case AX_ROLE_DOCUMENT:
+ case AX_ROLE_ROOT_WEB_AREA:
+ case AX_ROLE_WEB_AREA:
return ROLE_SYSTEM_DOCUMENT;
- case ui::AX_ROLE_EMBEDDED_OBJECT:
+ case AX_ROLE_EMBEDDED_OBJECT:
if (delegate_->GetChildCount()) {
return ROLE_SYSTEM_GROUPING;
} else {
return ROLE_SYSTEM_CLIENT;
}
- case ui::AX_ROLE_FIGURE:
+ case AX_ROLE_FIGURE:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_FEED:
+ case AX_ROLE_FEED:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_GENERIC_CONTAINER:
+ case AX_ROLE_GENERIC_CONTAINER:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_GRID:
+ case AX_ROLE_GRID:
return ROLE_SYSTEM_TABLE;
- case ui::AX_ROLE_GROUP:
+ case AX_ROLE_GROUP:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_HEADING:
+ case AX_ROLE_HEADING:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_IFRAME:
+ case AX_ROLE_IFRAME:
return ROLE_SYSTEM_DOCUMENT;
- case ui::AX_ROLE_IFRAME_PRESENTATIONAL:
+ case AX_ROLE_IFRAME_PRESENTATIONAL:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_IMAGE:
+ case AX_ROLE_IMAGE:
return ROLE_SYSTEM_GRAPHIC;
- case ui::AX_ROLE_IMAGE_MAP_LINK:
- return ROLE_SYSTEM_LINK;
-
- case ui::AX_ROLE_INPUT_TIME:
+ case AX_ROLE_INPUT_TIME:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_LABEL_TEXT:
- case ui::AX_ROLE_LEGEND:
+ case AX_ROLE_LABEL_TEXT:
+ case AX_ROLE_LEGEND:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_LINK:
+ case AX_ROLE_LINK:
return ROLE_SYSTEM_LINK;
- case ui::AX_ROLE_LIST:
+ case AX_ROLE_LIST:
return ROLE_SYSTEM_LIST;
- case ui::AX_ROLE_LIST_BOX:
+ case AX_ROLE_LIST_BOX:
return ROLE_SYSTEM_LIST;
- case ui::AX_ROLE_LIST_BOX_OPTION:
+ case AX_ROLE_LIST_BOX_OPTION:
return ROLE_SYSTEM_LISTITEM;
- case ui::AX_ROLE_LIST_ITEM:
+ case AX_ROLE_LIST_ITEM:
return ROLE_SYSTEM_LISTITEM;
- case ui::AX_ROLE_MAIN:
+ case AX_ROLE_MAIN:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_MARK:
+ case AX_ROLE_MARK:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_MARQUEE:
+ case AX_ROLE_MARQUEE:
return ROLE_SYSTEM_ANIMATION;
- case ui::AX_ROLE_MATH:
+ case AX_ROLE_MATH:
return ROLE_SYSTEM_EQUATION;
- case ui::AX_ROLE_MENU:
- case ui::AX_ROLE_MENU_BUTTON:
+ case AX_ROLE_MENU:
+ case AX_ROLE_MENU_BUTTON:
return ROLE_SYSTEM_MENUPOPUP;
- case ui::AX_ROLE_MENU_BAR:
+ case AX_ROLE_MENU_BAR:
return ROLE_SYSTEM_MENUBAR;
- case ui::AX_ROLE_MENU_ITEM:
+ case AX_ROLE_MENU_ITEM:
return ROLE_SYSTEM_MENUITEM;
- case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
+ case AX_ROLE_MENU_ITEM_CHECK_BOX:
return ROLE_SYSTEM_MENUITEM;
- case ui::AX_ROLE_MENU_ITEM_RADIO:
+ case AX_ROLE_MENU_ITEM_RADIO:
return ROLE_SYSTEM_MENUITEM;
case ui::AX_ROLE_MENU_LIST_POPUP:
+ if (IsAncestorComboBox())
+ return ROLE_SYSTEM_LIST;
return ROLE_SYSTEM_MENUPOPUP;
case ui::AX_ROLE_MENU_LIST_OPTION:
+ if (IsAncestorComboBox())
+ return ROLE_SYSTEM_LISTITEM;
return ROLE_SYSTEM_MENUITEM;
- case ui::AX_ROLE_METER:
+ case AX_ROLE_METER:
return ROLE_SYSTEM_PROGRESSBAR;
- case ui::AX_ROLE_NAVIGATION:
+ case AX_ROLE_NAVIGATION:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_NOTE:
+ case AX_ROLE_NOTE:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_OUTLINE:
- return ROLE_SYSTEM_OUTLINE;
-
- case ui::AX_ROLE_POP_UP_BUTTON: {
- std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG);
+ case AX_ROLE_POP_UP_BUTTON: {
+ std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG);
if (html_tag == "select")
return ROLE_SYSTEM_COMBOBOX;
return ROLE_SYSTEM_BUTTONMENU;
}
- case ui::AX_ROLE_PRE:
+ case AX_ROLE_PRE:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_PROGRESS_INDICATOR:
+ case AX_ROLE_PROGRESS_INDICATOR:
return ROLE_SYSTEM_PROGRESSBAR;
- case ui::AX_ROLE_RADIO_BUTTON:
+ case AX_ROLE_RADIO_BUTTON:
return ROLE_SYSTEM_RADIOBUTTON;
- case ui::AX_ROLE_RADIO_GROUP:
+ case AX_ROLE_RADIO_GROUP:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_REGION: {
- std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG);
+ case AX_ROLE_REGION: {
+ std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG);
if (html_tag == "section")
return ROLE_SYSTEM_GROUPING;
return ROLE_SYSTEM_PANE;
}
- case ui::AX_ROLE_ROW: {
+ case AX_ROLE_ROW: {
// Role changes depending on whether row is inside a treegrid
// https://www.w3.org/TR/core-aam-1.1/#role-map-row
return IsInTreeGrid() ? ROLE_SYSTEM_OUTLINEITEM : ROLE_SYSTEM_ROW;
}
- case ui::AX_ROLE_ROW_HEADER:
+ case AX_ROLE_ROW_HEADER:
return ROLE_SYSTEM_ROWHEADER;
- case ui::AX_ROLE_RUBY:
+ case AX_ROLE_RUBY:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_RULER:
- return ROLE_SYSTEM_CLIENT;
-
- case ui::AX_ROLE_SCROLL_AREA:
- return ROLE_SYSTEM_CLIENT;
-
- case ui::AX_ROLE_SCROLL_BAR:
+ case AX_ROLE_SCROLL_BAR:
return ROLE_SYSTEM_SCROLLBAR;
- case ui::AX_ROLE_SEARCH:
+ case AX_ROLE_SEARCH:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_SLIDER:
+ case AX_ROLE_SLIDER:
return ROLE_SYSTEM_SLIDER;
- case ui::AX_ROLE_SPIN_BUTTON:
+ case AX_ROLE_SPIN_BUTTON:
return ROLE_SYSTEM_SPINBUTTON;
- case ui::AX_ROLE_SPIN_BUTTON_PART:
+ case AX_ROLE_SPIN_BUTTON_PART:
return ROLE_SYSTEM_PUSHBUTTON;
- case ui::AX_ROLE_ANNOTATION:
- case ui::AX_ROLE_LIST_MARKER:
- case ui::AX_ROLE_STATIC_TEXT:
+ case AX_ROLE_ANNOTATION:
+ case AX_ROLE_LIST_MARKER:
+ case AX_ROLE_STATIC_TEXT:
return ROLE_SYSTEM_STATICTEXT;
- case ui::AX_ROLE_STATUS:
+ case AX_ROLE_STATUS:
return ROLE_SYSTEM_STATUSBAR;
- case ui::AX_ROLE_SPLITTER:
+ case AX_ROLE_SPLITTER:
return ROLE_SYSTEM_SEPARATOR;
- case ui::AX_ROLE_SVG_ROOT:
+ case AX_ROLE_SVG_ROOT:
return ROLE_SYSTEM_GRAPHIC;
- case ui::AX_ROLE_TAB:
+ case AX_ROLE_TAB:
return ROLE_SYSTEM_PAGETAB;
- case ui::AX_ROLE_TABLE:
+ case AX_ROLE_TABLE:
return ROLE_SYSTEM_TABLE;
- case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
+ case AX_ROLE_TABLE_HEADER_CONTAINER:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_TAB_LIST:
+ case AX_ROLE_TAB_LIST:
return ROLE_SYSTEM_PAGETABLIST;
- case ui::AX_ROLE_TAB_PANEL:
+ case AX_ROLE_TAB_PANEL:
return ROLE_SYSTEM_PROPERTYPAGE;
- case ui::AX_ROLE_TERM:
+ case AX_ROLE_TERM:
return ROLE_SYSTEM_LISTITEM;
- case ui::AX_ROLE_TOGGLE_BUTTON:
+ case AX_ROLE_TOGGLE_BUTTON:
return ROLE_SYSTEM_PUSHBUTTON;
- case ui::AX_ROLE_TEXT_FIELD:
- case ui::AX_ROLE_SEARCH_BOX:
+ case AX_ROLE_TEXT_FIELD:
+ case AX_ROLE_SEARCH_BOX:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_ABBR:
- case ui::AX_ROLE_TIME:
+ case AX_ROLE_ABBR:
+ case AX_ROLE_TIME:
return ROLE_SYSTEM_TEXT;
- case ui::AX_ROLE_TIMER:
+ case AX_ROLE_TIMER:
return ROLE_SYSTEM_CLOCK;
- case ui::AX_ROLE_TOOLBAR:
+ case AX_ROLE_TOOLBAR:
return ROLE_SYSTEM_TOOLBAR;
- case ui::AX_ROLE_TOOLTIP:
+ case AX_ROLE_TOOLTIP:
return ROLE_SYSTEM_TOOLTIP;
- case ui::AX_ROLE_TREE:
+ case AX_ROLE_TREE:
return ROLE_SYSTEM_OUTLINE;
- case ui::AX_ROLE_TREE_GRID:
+ case AX_ROLE_TREE_GRID:
return ROLE_SYSTEM_OUTLINE;
- case ui::AX_ROLE_TREE_ITEM:
+ case AX_ROLE_TREE_ITEM:
return ROLE_SYSTEM_OUTLINEITEM;
- case ui::AX_ROLE_LINE_BREAK:
+ case AX_ROLE_LINE_BREAK:
return ROLE_SYSTEM_WHITESPACE;
- case ui::AX_ROLE_VIDEO:
+ case AX_ROLE_VIDEO:
return ROLE_SYSTEM_GROUPING;
- case ui::AX_ROLE_WINDOW:
+ case AX_ROLE_WINDOW:
return ROLE_SYSTEM_WINDOW;
// TODO(dmazzoni): figure out the proper MSAA role for roles listed below.
@@ -2547,10 +2822,8 @@ int AXPlatformNodeWin::MSAARole() {
case AX_ROLE_PANE:
case AX_ROLE_PARAGRAPH:
case AX_ROLE_PRESENTATIONAL:
- case AX_ROLE_SEAMLESS_WEB_AREA:
case AX_ROLE_SLIDER_THUMB:
case AX_ROLE_SWITCH:
- case AX_ROLE_TAB_GROUP:
case AX_ROLE_TITLE_BAR:
case AX_ROLE_UNKNOWN:
case AX_ROLE_WEB_VIEW:
@@ -2562,40 +2835,40 @@ int AXPlatformNodeWin::MSAARole() {
}
std::string AXPlatformNodeWin::StringOverrideForMSAARole() {
- std::string html_tag = GetData().GetStringAttribute(ui::AX_ATTR_HTML_TAG);
+ std::string html_tag = GetData().GetStringAttribute(AX_ATTR_HTML_TAG);
switch (GetData().role) {
- case ui::AX_ROLE_BLOCKQUOTE:
- case ui::AX_ROLE_DEFINITION:
- case ui::AX_ROLE_IMAGE_MAP:
+ case AX_ROLE_BLOCKQUOTE:
+ case AX_ROLE_DEFINITION:
+ case AX_ROLE_IMAGE_MAP:
return html_tag;
- case ui::AX_ROLE_CANVAS:
- if (GetData().GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
+ case AX_ROLE_CANVAS:
+ if (GetData().GetBoolAttribute(AX_ATTR_CANVAS_HAS_FALLBACK)) {
return html_tag;
}
break;
- case ui::AX_ROLE_FORM:
+ case AX_ROLE_FORM:
// This could be a div with the role of form
// so we return just the string "form".
return "form";
- case ui::AX_ROLE_HEADING:
+ case AX_ROLE_HEADING:
if (!html_tag.empty())
return html_tag;
break;
- case ui::AX_ROLE_PARAGRAPH:
+ case AX_ROLE_PARAGRAPH:
return html_tag;
- case ui::AX_ROLE_GENERIC_CONTAINER:
+ case AX_ROLE_GENERIC_CONTAINER:
// TODO(dougt) why can't we always use div in this case?
if (html_tag.empty())
return "div";
return html_tag;
- case ui::AX_ROLE_SWITCH:
+ case AX_ROLE_SWITCH:
return "switch";
default:
@@ -2606,16 +2879,16 @@ std::string AXPlatformNodeWin::StringOverrideForMSAARole() {
}
bool AXPlatformNodeWin::IsWebAreaForPresentationalIframe() {
- if (GetData().role != ui::AX_ROLE_WEB_AREA &&
- GetData().role != ui::AX_ROLE_ROOT_WEB_AREA) {
+ if (GetData().role != AX_ROLE_WEB_AREA &&
+ GetData().role != AX_ROLE_ROOT_WEB_AREA) {
return false;
}
- auto* parent = FromNativeViewAccessible(GetParent());
+ AXPlatformNodeBase* parent = FromNativeViewAccessible(GetParent());
if (!parent)
return false;
- return parent->GetData().role == ui::AX_ROLE_IFRAME_PRESENTATIONAL;
+ return parent->GetData().role == AX_ROLE_IFRAME_PRESENTATIONAL;
}
int32_t AXPlatformNodeWin::ComputeIA2State() {
@@ -2623,57 +2896,54 @@ int32_t AXPlatformNodeWin::ComputeIA2State() {
int32_t ia2_state = IA2_STATE_OPAQUE;
- const auto checked_state = static_cast<ui::AXCheckedState>(
- GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
+ const auto checked_state =
+ static_cast<AXCheckedState>(GetIntAttribute(AX_ATTR_CHECKED_STATE));
if (checked_state) {
ia2_state |= IA2_STATE_CHECKABLE;
}
- if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) &&
- GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE)
+ if (HasIntAttribute(AX_ATTR_INVALID_STATE) &&
+ GetIntAttribute(AX_ATTR_INVALID_STATE) != AX_INVALID_STATE_FALSE)
ia2_state |= IA2_STATE_INVALID_ENTRY;
- if (data.HasState(ui::AX_STATE_REQUIRED))
+ if (data.HasState(AX_STATE_REQUIRED))
ia2_state |= IA2_STATE_REQUIRED;
- if (data.HasState(ui::AX_STATE_VERTICAL))
+ if (data.HasState(AX_STATE_VERTICAL))
ia2_state |= IA2_STATE_VERTICAL;
- if (data.HasState(ui::AX_STATE_HORIZONTAL))
+ if (data.HasState(AX_STATE_HORIZONTAL))
ia2_state |= IA2_STATE_HORIZONTAL;
- const bool is_editable = data.HasState(ui::AX_STATE_EDITABLE);
+ const bool is_editable = data.HasState(AX_STATE_EDITABLE);
if (is_editable)
ia2_state |= IA2_STATE_EDITABLE;
- if (IsRichTextControl() || ui::IsEditField(data.role)) {
+ if (IsRichTextControl() || IsEditField(data.role)) {
// Support multi/single line states if root editable or appropriate role.
// We support the edit box roles even if the area is not actually editable,
// because it is technically feasible for JS to implement the edit box
// by controlling selection.
- if (data.HasState(ui::AX_STATE_MULTILINE)) {
+ if (data.HasState(AX_STATE_MULTILINE)) {
ia2_state |= IA2_STATE_MULTI_LINE;
} else {
ia2_state |= IA2_STATE_SINGLE_LINE;
}
}
- if (!GetStringAttribute(ui::AX_ATTR_AUTO_COMPLETE).empty())
+ if (!GetStringAttribute(AX_ATTR_AUTO_COMPLETE).empty())
ia2_state |= IA2_STATE_SUPPORTS_AUTOCOMPLETION;
- if (GetBoolAttribute(ui::AX_ATTR_MODAL))
+ if (GetBoolAttribute(AX_ATTR_MODAL))
ia2_state |= IA2_STATE_MODAL;
switch (data.role) {
- case ui::AX_ROLE_MENU_LIST_POPUP:
+ case AX_ROLE_MENU_LIST_POPUP:
ia2_state &= ~(IA2_STATE_EDITABLE);
break;
- case ui::AX_ROLE_MENU_LIST_OPTION:
+ case AX_ROLE_MENU_LIST_OPTION:
ia2_state &= ~(IA2_STATE_EDITABLE);
break;
- case ui::AX_ROLE_SCROLL_AREA:
- ia2_state &= ~(IA2_STATE_EDITABLE);
- break;
- case ui::AX_ROLE_TEXT_FIELD:
- case ui::AX_ROLE_SEARCH_BOX:
- if (data.HasState(ui::AX_STATE_MULTILINE)) {
+ case AX_ROLE_TEXT_FIELD:
+ case AX_ROLE_SEARCH_BOX:
+ if (data.HasState(AX_STATE_MULTILINE)) {
ia2_state |= IA2_STATE_MULTI_LINE;
} else {
ia2_state |= IA2_STATE_SINGLE_LINE;
@@ -2699,123 +2969,117 @@ int32_t AXPlatformNodeWin::ComputeIA2Role() {
int32_t ia2_role = 0;
switch (GetData().role) {
- case ui::AX_ROLE_BANNER:
+ case AX_ROLE_BANNER:
ia2_role = IA2_ROLE_HEADER;
break;
- case ui::AX_ROLE_BLOCKQUOTE:
+ case AX_ROLE_BLOCKQUOTE:
ia2_role = IA2_ROLE_SECTION;
break;
- case ui::AX_ROLE_CANVAS:
- if (GetBoolAttribute(ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
+ case AX_ROLE_CANVAS:
+ if (GetBoolAttribute(AX_ATTR_CANVAS_HAS_FALLBACK)) {
ia2_role = IA2_ROLE_CANVAS;
}
break;
- case ui::AX_ROLE_CAPTION:
+ case AX_ROLE_CAPTION:
ia2_role = IA2_ROLE_CAPTION;
break;
- case ui::AX_ROLE_COLOR_WELL:
+ case AX_ROLE_COLOR_WELL:
ia2_role = IA2_ROLE_COLOR_CHOOSER;
break;
- case ui::AX_ROLE_COMPLEMENTARY:
+ case AX_ROLE_COMPLEMENTARY:
ia2_role = IA2_ROLE_NOTE;
break;
- case ui::AX_ROLE_CONTENT_INFO:
+ case AX_ROLE_CONTENT_INFO:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_DATE:
- case ui::AX_ROLE_DATE_TIME:
+ case AX_ROLE_DATE:
+ case AX_ROLE_DATE_TIME:
ia2_role = IA2_ROLE_DATE_EDITOR;
break;
- case ui::AX_ROLE_DEFINITION:
+ case AX_ROLE_DEFINITION:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_DESCRIPTION_LIST_DETAIL:
+ case AX_ROLE_DESCRIPTION_LIST_DETAIL:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_EMBEDDED_OBJECT:
+ case AX_ROLE_EMBEDDED_OBJECT:
if (!delegate_->GetChildCount()) {
ia2_role = IA2_ROLE_EMBEDDED_OBJECT;
}
break;
- case ui::AX_ROLE_FIGCAPTION:
+ case AX_ROLE_FIGCAPTION:
ia2_role = IA2_ROLE_CAPTION;
break;
- case ui::AX_ROLE_FORM:
+ case AX_ROLE_FORM:
ia2_role = IA2_ROLE_FORM;
break;
- case ui::AX_ROLE_FOOTER:
+ case AX_ROLE_FOOTER:
ia2_role = IA2_ROLE_FOOTER;
break;
- case ui::AX_ROLE_GENERIC_CONTAINER:
+ case AX_ROLE_GENERIC_CONTAINER:
ia2_role = IA2_ROLE_SECTION;
break;
- case ui::AX_ROLE_HEADING:
+ case AX_ROLE_HEADING:
ia2_role = IA2_ROLE_HEADING;
break;
- case ui::AX_ROLE_IFRAME:
+ case AX_ROLE_IFRAME:
ia2_role = IA2_ROLE_INTERNAL_FRAME;
break;
- case ui::AX_ROLE_IMAGE_MAP:
+ case AX_ROLE_IMAGE_MAP:
ia2_role = IA2_ROLE_IMAGE_MAP;
break;
- case ui::AX_ROLE_LABEL_TEXT:
- case ui::AX_ROLE_LEGEND:
+ case AX_ROLE_LABEL_TEXT:
+ case AX_ROLE_LEGEND:
ia2_role = IA2_ROLE_LABEL;
break;
- case ui::AX_ROLE_MAIN:
+ case AX_ROLE_MAIN:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_MARK:
+ case AX_ROLE_MARK:
ia2_role = IA2_ROLE_TEXT_FRAME;
break;
- case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
+ case AX_ROLE_MENU_ITEM_CHECK_BOX:
ia2_role = IA2_ROLE_CHECK_MENU_ITEM;
break;
- case ui::AX_ROLE_MENU_ITEM_RADIO:
+ case AX_ROLE_MENU_ITEM_RADIO:
ia2_role = IA2_ROLE_RADIO_MENU_ITEM;
break;
- case ui::AX_ROLE_NAVIGATION:
+ case AX_ROLE_NAVIGATION:
ia2_role = IA2_ROLE_SECTION;
break;
- case ui::AX_ROLE_NOTE:
+ case AX_ROLE_NOTE:
ia2_role = IA2_ROLE_NOTE;
break;
- case ui::AX_ROLE_PARAGRAPH:
+ case AX_ROLE_PARAGRAPH:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_PRE:
+ case AX_ROLE_PRE:
ia2_role = IA2_ROLE_PARAGRAPH;
break;
- case ui::AX_ROLE_REGION: {
- base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG);
+ case AX_ROLE_REGION: {
+ base::string16 html_tag = GetString16Attribute(AX_ATTR_HTML_TAG);
if (html_tag == L"section") {
ia2_role = IA2_ROLE_SECTION;
}
} break;
- case ui::AX_ROLE_RUBY:
+ case AX_ROLE_RUBY:
ia2_role = IA2_ROLE_TEXT_FRAME;
break;
- case ui::AX_ROLE_RULER:
- ia2_role = IA2_ROLE_RULER;
- break;
- case ui::AX_ROLE_SCROLL_AREA:
- ia2_role = IA2_ROLE_SCROLL_PANE;
- break;
- case ui::AX_ROLE_SEARCH:
+ case AX_ROLE_SEARCH:
ia2_role = IA2_ROLE_SECTION;
break;
- case ui::AX_ROLE_SWITCH:
+ case AX_ROLE_SWITCH:
ia2_role = IA2_ROLE_TOGGLE_BUTTON;
break;
- case ui::AX_ROLE_TABLE_HEADER_CONTAINER:
+ case AX_ROLE_TABLE_HEADER_CONTAINER:
ia2_role = IA2_ROLE_SECTION;
break;
- case ui::AX_ROLE_TOGGLE_BUTTON:
+ case AX_ROLE_TOGGLE_BUTTON:
ia2_role = IA2_ROLE_TOGGLE_BUTTON;
break;
- case ui::AX_ROLE_ABBR:
- case ui::AX_ROLE_TIME:
+ case AX_ROLE_ABBR:
+ case AX_ROLE_TIME:
ia2_role = IA2_ROLE_TEXT_FRAME;
break;
default:
@@ -2831,84 +3095,83 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
// historical reasons. Aside from that virtually every ARIA attribute
// is exposed in a really straightforward way, i.e. "aria-foo" is exposed
// as "foo".
- StringAttributeToIA2(result, ui::AX_ATTR_DISPLAY, "display");
- StringAttributeToIA2(result, ui::AX_ATTR_HTML_TAG, "tag");
- StringAttributeToIA2(result, ui::AX_ATTR_ROLE, "xml-roles");
- StringAttributeToIA2(result, ui::AX_ATTR_PLACEHOLDER, "placeholder");
+ StringAttributeToIA2(result, AX_ATTR_DISPLAY, "display");
+ StringAttributeToIA2(result, AX_ATTR_HTML_TAG, "tag");
+ StringAttributeToIA2(result, AX_ATTR_ROLE, "xml-roles");
+ StringAttributeToIA2(result, AX_ATTR_PLACEHOLDER, "placeholder");
- StringAttributeToIA2(result, ui::AX_ATTR_AUTO_COMPLETE, "autocomplete");
- StringAttributeToIA2(result, ui::AX_ATTR_ROLE_DESCRIPTION, "roledescription");
- StringAttributeToIA2(result, ui::AX_ATTR_KEY_SHORTCUTS, "keyshortcuts");
+ StringAttributeToIA2(result, AX_ATTR_AUTO_COMPLETE, "autocomplete");
+ StringAttributeToIA2(result, AX_ATTR_ROLE_DESCRIPTION, "roledescription");
+ StringAttributeToIA2(result, AX_ATTR_KEY_SHORTCUTS, "keyshortcuts");
- IntAttributeToIA2(result, ui::AX_ATTR_HIERARCHICAL_LEVEL, "level");
- IntAttributeToIA2(result, ui::AX_ATTR_SET_SIZE, "setsize");
- IntAttributeToIA2(result, ui::AX_ATTR_POS_IN_SET, "posinset");
+ IntAttributeToIA2(result, AX_ATTR_HIERARCHICAL_LEVEL, "level");
+ IntAttributeToIA2(result, AX_ATTR_SET_SIZE, "setsize");
+ IntAttributeToIA2(result, AX_ATTR_POS_IN_SET, "posinset");
- if (HasIntAttribute(ui::AX_ATTR_CHECKED_STATE))
+ if (HasIntAttribute(AX_ATTR_CHECKED_STATE))
result.push_back(L"checkable:true");
// Expose live region attributes.
- StringAttributeToIA2(result, ui::AX_ATTR_LIVE_STATUS, "live");
- StringAttributeToIA2(result, ui::AX_ATTR_LIVE_RELEVANT, "relevant");
- BoolAttributeToIA2(result, ui::AX_ATTR_LIVE_ATOMIC, "atomic");
- BoolAttributeToIA2(result, ui::AX_ATTR_LIVE_BUSY, "busy");
+ StringAttributeToIA2(result, AX_ATTR_LIVE_STATUS, "live");
+ StringAttributeToIA2(result, AX_ATTR_LIVE_RELEVANT, "relevant");
+ BoolAttributeToIA2(result, AX_ATTR_LIVE_ATOMIC, "atomic");
+ // Busy is usually associated with live regions but can occur anywhere:
+ BoolAttributeToIA2(result, AX_ATTR_BUSY, "busy");
// Expose container live region attributes.
- StringAttributeToIA2(result, ui::AX_ATTR_CONTAINER_LIVE_STATUS,
- "container-live");
- StringAttributeToIA2(result, ui::AX_ATTR_CONTAINER_LIVE_RELEVANT,
+ StringAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_STATUS, "container-live");
+ StringAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_RELEVANT,
"container-relevant");
- BoolAttributeToIA2(result, ui::AX_ATTR_CONTAINER_LIVE_ATOMIC,
- "container-atomic");
- BoolAttributeToIA2(result, ui::AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy");
+ BoolAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_ATOMIC, "container-atomic");
+ BoolAttributeToIA2(result, AX_ATTR_CONTAINER_LIVE_BUSY, "container-busy");
// Expose the non-standard explicit-name IA2 attribute.
int name_from;
- if (GetIntAttribute(ui::AX_ATTR_NAME_FROM, &name_from) &&
- name_from != ui::AX_NAME_FROM_CONTENTS) {
+ if (GetIntAttribute(AX_ATTR_NAME_FROM, &name_from) &&
+ name_from != AX_NAME_FROM_CONTENTS) {
result.push_back(L"explicit-name:true");
}
// Expose the aria-current attribute.
int32_t aria_current_state;
- if (GetIntAttribute(ui::AX_ATTR_ARIA_CURRENT_STATE, &aria_current_state)) {
- switch (static_cast<ui::AXAriaCurrentState>(aria_current_state)) {
- case ui::AX_ARIA_CURRENT_STATE_NONE:
+ if (GetIntAttribute(AX_ATTR_ARIA_CURRENT_STATE, &aria_current_state)) {
+ switch (static_cast<AXAriaCurrentState>(aria_current_state)) {
+ case AX_ARIA_CURRENT_STATE_NONE:
break;
- case ui::AX_ARIA_CURRENT_STATE_FALSE:
+ case AX_ARIA_CURRENT_STATE_FALSE:
result.push_back(L"current:false");
break;
- case ui::AX_ARIA_CURRENT_STATE_TRUE:
+ case AX_ARIA_CURRENT_STATE_TRUE:
result.push_back(L"current:true");
break;
- case ui::AX_ARIA_CURRENT_STATE_PAGE:
+ case AX_ARIA_CURRENT_STATE_PAGE:
result.push_back(L"current:page");
break;
- case ui::AX_ARIA_CURRENT_STATE_STEP:
+ case AX_ARIA_CURRENT_STATE_STEP:
result.push_back(L"current:step");
break;
- case ui::AX_ARIA_CURRENT_STATE_LOCATION:
+ case AX_ARIA_CURRENT_STATE_LOCATION:
result.push_back(L"current:location");
break;
- case ui::AX_ARIA_CURRENT_STATE_DATE:
+ case AX_ARIA_CURRENT_STATE_DATE:
result.push_back(L"current:date");
break;
- case ui::AX_ARIA_CURRENT_STATE_TIME:
+ case AX_ARIA_CURRENT_STATE_TIME:
result.push_back(L"current:time");
break;
}
}
// Expose table cell index.
- if (ui::IsCellOrTableHeaderRole(GetData().role)) {
+ if (IsCellOrTableHeaderRole(GetData().role)) {
AXPlatformNodeBase* table = FromNativeViewAccessible(GetParent());
- while (table && !ui::IsTableLikeRole(table->GetData().role))
+ while (table && !IsTableLikeRole(table->GetData().role))
table = FromNativeViewAccessible(table->GetParent());
if (table) {
const std::vector<int32_t>& unique_cell_ids =
- table->GetIntListAttribute(ui::AX_ATTR_UNIQUE_CELL_IDS);
+ table->GetIntListAttribute(AX_ATTR_UNIQUE_CELL_IDS);
for (size_t i = 0; i < unique_cell_ids.size(); ++i) {
if (unique_cell_ids[i] == GetData().id) {
result.push_back(base::string16(L"table-cell-index:") +
@@ -2919,43 +3182,43 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
}
// Expose aria-colcount and aria-rowcount in a table, grid or treegrid.
- if (ui::IsTableLikeRole(GetData().role)) {
- IntAttributeToIA2(result, ui::AX_ATTR_ARIA_COLUMN_COUNT, "colcount");
- IntAttributeToIA2(result, ui::AX_ATTR_ARIA_ROW_COUNT, "rowcount");
+ if (IsTableLikeRole(GetData().role)) {
+ IntAttributeToIA2(result, AX_ATTR_ARIA_COLUMN_COUNT, "colcount");
+ IntAttributeToIA2(result, AX_ATTR_ARIA_ROW_COUNT, "rowcount");
}
// Expose aria-colindex and aria-rowindex in a cell or row.
- if (ui::IsCellOrTableHeaderRole(GetData().role) ||
- GetData().role == ui::AX_ROLE_ROW) {
- if (GetData().role != ui::AX_ROLE_ROW)
- IntAttributeToIA2(result, ui::AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex");
- IntAttributeToIA2(result, ui::AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex");
+ if (IsCellOrTableHeaderRole(GetData().role) ||
+ GetData().role == AX_ROLE_ROW) {
+ if (GetData().role != AX_ROLE_ROW)
+ IntAttributeToIA2(result, AX_ATTR_ARIA_CELL_COLUMN_INDEX, "colindex");
+ IntAttributeToIA2(result, AX_ATTR_ARIA_CELL_ROW_INDEX, "rowindex");
}
// Expose row or column header sort direction.
int32_t sort_direction;
if ((MSAARole() == ROLE_SYSTEM_COLUMNHEADER ||
MSAARole() == ROLE_SYSTEM_ROWHEADER) &&
- GetIntAttribute(ui::AX_ATTR_SORT_DIRECTION, &sort_direction)) {
- switch (static_cast<ui::AXSortDirection>(sort_direction)) {
- case ui::AX_SORT_DIRECTION_NONE:
+ GetIntAttribute(AX_ATTR_SORT_DIRECTION, &sort_direction)) {
+ switch (static_cast<AXSortDirection>(sort_direction)) {
+ case AX_SORT_DIRECTION_NONE:
break;
- case ui::AX_SORT_DIRECTION_UNSORTED:
+ case AX_SORT_DIRECTION_UNSORTED:
result.push_back(L"sort:none");
break;
- case ui::AX_SORT_DIRECTION_ASCENDING:
+ case AX_SORT_DIRECTION_ASCENDING:
result.push_back(L"sort:ascending");
break;
- case ui::AX_SORT_DIRECTION_DESCENDING:
+ case AX_SORT_DIRECTION_DESCENDING:
result.push_back(L"sort:descending");
break;
- case ui::AX_SORT_DIRECTION_OTHER:
+ case AX_SORT_DIRECTION_OTHER:
result.push_back(L"sort:other");
break;
}
}
- if (ui::IsCellOrTableHeaderRole(GetData().role)) {
+ if (IsCellOrTableHeaderRole(GetData().role)) {
// Expose colspan attribute.
base::string16 colspan;
if (GetData().GetHtmlAttribute("aria-colspan", &colspan)) {
@@ -3000,7 +3263,7 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
// Expose datetime attribute.
base::string16 datetime;
- if (GetData().role == ui::AX_ROLE_TIME &&
+ if (GetData().role == AX_ROLE_TIME &&
GetData().GetHtmlAttribute("datetime", &datetime)) {
SanitizeStringAttributeForIA2(datetime, &datetime);
result.push_back(L"datetime:" + datetime);
@@ -3015,15 +3278,24 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
// Expose src attribute.
base::string16 src;
- if (GetData().role == ui::AX_ROLE_IMAGE &&
+ if (GetData().role == AX_ROLE_IMAGE &&
GetData().GetHtmlAttribute("src", &src)) {
SanitizeStringAttributeForIA2(src, &src);
result.push_back(L"src:" + src);
}
+ // Text fields need to report the attribute "text-model:a1" to instruct
+ // screen readers to use IAccessible2 APIs to handle text editing in this
+ // object (as opposed to treating it like a native Windows text box).
+ // The text-model:a1 attribute is documented here:
+ // http://www.linuxfoundation.org/collaborate/workgroups/accessibility/ia2/ia2_implementation_guide
+ if (GetData().role == AX_ROLE_TEXT_FIELD) {
+ result.push_back(L"text-model:a1;");
+ }
+
// Expose input-text type attribute.
base::string16 type;
- base::string16 html_tag = GetString16Attribute(ui::AX_ATTR_HTML_TAG);
+ base::string16 html_tag = GetString16Attribute(AX_ATTR_HTML_TAG);
if (IsSimpleTextControl() && html_tag == L"input" &&
GetData().GetHtmlAttribute("type", &type)) {
SanitizeStringAttributeForIA2(type, &type);
@@ -3036,30 +3308,26 @@ std::vector<base::string16> AXPlatformNodeWin::ComputeIA2Attributes() {
bool AXPlatformNodeWin::ShouldNodeHaveReadonlyStateByDefault(
const AXNodeData& data) const {
switch (data.role) {
- case ui::AX_ROLE_ARTICLE:
- case ui::AX_ROLE_BUSY_INDICATOR:
- case ui::AX_ROLE_DEFINITION:
- case ui::AX_ROLE_DESCRIPTION_LIST:
- case ui::AX_ROLE_DESCRIPTION_LIST_TERM:
- case ui::AX_ROLE_DOCUMENT:
- case ui::AX_ROLE_IFRAME:
- case ui::AX_ROLE_IMAGE:
- case ui::AX_ROLE_IMAGE_MAP:
- case ui::AX_ROLE_IMAGE_MAP_LINK:
- case ui::AX_ROLE_LIST:
- case ui::AX_ROLE_LIST_ITEM:
- case ui::AX_ROLE_PROGRESS_INDICATOR:
- case ui::AX_ROLE_ROOT_WEB_AREA:
- case ui::AX_ROLE_RULER:
- case ui::AX_ROLE_SCROLL_AREA:
- case ui::AX_ROLE_TERM:
- case ui::AX_ROLE_TIMER:
- case ui::AX_ROLE_TOOLBAR:
- case ui::AX_ROLE_TOOLTIP:
- case ui::AX_ROLE_WEB_AREA:
+ case AX_ROLE_ARTICLE:
+ case AX_ROLE_DEFINITION:
+ case AX_ROLE_DESCRIPTION_LIST:
+ case AX_ROLE_DESCRIPTION_LIST_TERM:
+ case AX_ROLE_DOCUMENT:
+ case AX_ROLE_IFRAME:
+ case AX_ROLE_IMAGE:
+ case AX_ROLE_IMAGE_MAP:
+ case AX_ROLE_LIST:
+ case AX_ROLE_LIST_ITEM:
+ case AX_ROLE_PROGRESS_INDICATOR:
+ case AX_ROLE_ROOT_WEB_AREA:
+ case AX_ROLE_TERM:
+ case AX_ROLE_TIMER:
+ case AX_ROLE_TOOLBAR:
+ case AX_ROLE_TOOLTIP:
+ case AX_ROLE_WEB_AREA:
return true;
- case ui::AX_ROLE_GRID:
+ case AX_ROLE_GRID:
// TODO(aleventhal) this changed between ARIA 1.0 and 1.1,
// need to determine whether grids/treegrids should really be readonly
// or editable by default
@@ -3075,24 +3343,24 @@ bool AXPlatformNodeWin::ShouldNodeHaveReadonlyStateByDefault(
bool AXPlatformNodeWin::ShouldNodeHaveFocusableState(
const AXNodeData& data) const {
switch (data.role) {
- case ui::AX_ROLE_DOCUMENT:
- case ui::AX_ROLE_ROOT_WEB_AREA:
- case ui::AX_ROLE_WEB_AREA:
+ case AX_ROLE_DOCUMENT:
+ case AX_ROLE_ROOT_WEB_AREA:
+ case AX_ROLE_WEB_AREA:
return true;
- case ui::AX_ROLE_IFRAME:
+ case AX_ROLE_IFRAME:
return false;
- case ui::AX_ROLE_LIST_BOX_OPTION:
- case ui::AX_ROLE_MENU_LIST_OPTION:
- if (data.HasState(ui::AX_STATE_SELECTABLE))
+ case AX_ROLE_LIST_BOX_OPTION:
+ case AX_ROLE_MENU_LIST_OPTION:
+ if (data.HasState(AX_STATE_SELECTABLE))
return true;
default:
break;
}
- return data.HasState(ui::AX_STATE_FOCUSABLE);
+ return data.HasState(AX_STATE_FOCUSABLE);
}
int AXPlatformNodeWin::MSAAState() {
@@ -3102,29 +3370,29 @@ int AXPlatformNodeWin::MSAAState() {
// Map the AXState to MSAA state. Note that some of the states are not
// currently handled.
- if (data.HasState(ui::AX_STATE_BUSY))
+ if (data.GetBoolAttribute(AX_ATTR_BUSY))
msaa_state |= STATE_SYSTEM_BUSY;
- if (data.HasState(ui::AX_STATE_COLLAPSED))
+ if (data.HasState(AX_STATE_COLLAPSED))
msaa_state |= STATE_SYSTEM_COLLAPSED;
- if (data.HasState(ui::AX_STATE_DEFAULT))
+ if (data.HasState(AX_STATE_DEFAULT))
msaa_state |= STATE_SYSTEM_DEFAULT;
// TODO(dougt) unhandled ux::AX_STATE_EDITABLE
- if (data.HasState(ui::AX_STATE_EXPANDED))
+ if (data.HasState(AX_STATE_EXPANDED))
msaa_state |= STATE_SYSTEM_EXPANDED;
if (ShouldNodeHaveFocusableState(data))
msaa_state |= STATE_SYSTEM_FOCUSABLE;
- if (data.HasState(ui::AX_STATE_HASPOPUP))
+ if (data.HasState(AX_STATE_HASPOPUP))
msaa_state |= STATE_SYSTEM_HASPOPUP;
// TODO(dougt) unhandled ux::AX_STATE_HORIZONTAL
- if (data.HasState(ui::AX_STATE_HOVERED)) {
+ if (data.HasState(AX_STATE_HOVERED)) {
// Expose whether or not the mouse is over an element, but suppress
// this for tests because it can make the test results flaky depending
// on the position of the mouse.
@@ -3133,52 +3401,50 @@ int AXPlatformNodeWin::MSAAState() {
}
// TODO(dougt) Why do we set any state on AX_ROLE_IGNORED?
- if (data.HasState(ui::AX_STATE_INVISIBLE) ||
- GetData().role == ui::AX_ROLE_IGNORED) {
+ if (data.HasState(AX_STATE_INVISIBLE) || GetData().role == AX_ROLE_IGNORED) {
msaa_state |= STATE_SYSTEM_INVISIBLE;
}
- if (data.HasState(ui::AX_STATE_LINKED))
+ if (data.HasState(AX_STATE_LINKED))
msaa_state |= STATE_SYSTEM_LINKED;
// TODO(dougt) unhandled ux::AX_STATE_MULTILINE
- if (data.HasState(ui::AX_STATE_MULTISELECTABLE)) {
+ if (data.HasState(AX_STATE_MULTISELECTABLE)) {
msaa_state |= STATE_SYSTEM_EXTSELECTABLE;
msaa_state |= STATE_SYSTEM_MULTISELECTABLE;
}
- if (data.HasState(ui::AX_STATE_OFFSCREEN))
+ if (data.HasState(AX_STATE_OFFSCREEN))
msaa_state |= STATE_SYSTEM_OFFSCREEN;
- if (data.HasState(ui::AX_STATE_PROTECTED))
+ if (data.HasState(AX_STATE_PROTECTED))
msaa_state |= STATE_SYSTEM_PROTECTED;
// TODO(dougt) unhandled ux::AX_STATE_REQUIRED
// TODO(dougt) unhandled ux::AX_STATE_RICHLY_EDITABLE
- if (data.HasState(ui::AX_STATE_SELECTABLE))
+ if (data.HasState(AX_STATE_SELECTABLE))
msaa_state |= STATE_SYSTEM_SELECTABLE;
- if (data.HasState(ui::AX_STATE_SELECTED))
+ if (data.HasState(AX_STATE_SELECTED))
msaa_state |= STATE_SYSTEM_SELECTED;
// TODO(dougt) unhandled VERTICAL
- if (data.HasState(ui::AX_STATE_VISITED))
+ if (data.HasState(AX_STATE_VISITED))
msaa_state |= STATE_SYSTEM_TRAVERSED;
//
// Checked state
//
- const auto checked_state = static_cast<ui::AXCheckedState>(
- GetIntAttribute(ui::AX_ATTR_CHECKED_STATE));
+ const auto checked_state =
+ static_cast<AXCheckedState>(GetIntAttribute(AX_ATTR_CHECKED_STATE));
switch (checked_state) {
- case ui::AX_CHECKED_STATE_TRUE:
- msaa_state |= data.role == ui::AX_ROLE_TOGGLE_BUTTON
- ? STATE_SYSTEM_PRESSED
- : STATE_SYSTEM_CHECKED;
+ case AX_CHECKED_STATE_TRUE:
+ msaa_state |= data.role == AX_ROLE_TOGGLE_BUTTON ? STATE_SYSTEM_PRESSED
+ : STATE_SYSTEM_CHECKED;
break;
- case ui::AX_CHECKED_STATE_MIXED:
+ case AX_CHECKED_STATE_MIXED:
msaa_state |= STATE_SYSTEM_MIXED;
break;
default:
@@ -3186,12 +3452,12 @@ int AXPlatformNodeWin::MSAAState() {
}
const auto restriction =
- static_cast<ui::AXRestriction>(GetIntAttribute(ui::AX_ATTR_RESTRICTION));
+ static_cast<AXRestriction>(GetIntAttribute(AX_ATTR_RESTRICTION));
switch (restriction) {
- case ui::AX_RESTRICTION_DISABLED:
+ case AX_RESTRICTION_DISABLED:
msaa_state |= STATE_SYSTEM_UNAVAILABLE;
break;
- case ui::AX_RESTRICTION_READ_ONLY:
+ case AX_RESTRICTION_READ_ONLY:
msaa_state |= STATE_SYSTEM_READONLY;
break;
default:
@@ -3218,54 +3484,50 @@ int AXPlatformNodeWin::MSAAState() {
// TODO(dmazzoni): this should probably check if focus is actually inside
// the menu bar, but we don't currently track focus inside menu pop-ups,
// and Chrome only has one menu visible at a time so this works for now.
- if (data.role == ui::AX_ROLE_MENU_BAR &&
- !(data.HasState(ui::AX_STATE_INVISIBLE))) {
+ if (data.role == AX_ROLE_MENU_BAR && !(data.HasState(AX_STATE_INVISIBLE))) {
msaa_state |= STATE_SYSTEM_FOCUSED;
}
// Handle STATE_SYSTEM_LINKED
- if (GetData().role == ui::AX_ROLE_IMAGE_MAP_LINK ||
- GetData().role == ui::AX_ROLE_LINK) {
+ if (GetData().role == AX_ROLE_LINK)
msaa_state |= STATE_SYSTEM_LINKED;
- }
return msaa_state;
}
-int AXPlatformNodeWin::MSAAEvent(ui::AXEvent event) {
+int AXPlatformNodeWin::MSAAEvent(AXEvent event) {
switch (event) {
- case ui::AX_EVENT_ALERT:
+ case AX_EVENT_ALERT:
return EVENT_SYSTEM_ALERT;
- case ui::AX_EVENT_FOCUS:
+ case AX_EVENT_FOCUS:
return EVENT_OBJECT_FOCUS;
- case ui::AX_EVENT_MENU_START:
+ case AX_EVENT_MENU_START:
return EVENT_SYSTEM_MENUSTART;
- case ui::AX_EVENT_MENU_END:
+ case AX_EVENT_MENU_END:
return EVENT_SYSTEM_MENUEND;
- case ui::AX_EVENT_MENU_POPUP_START:
+ case AX_EVENT_MENU_POPUP_START:
return EVENT_SYSTEM_MENUPOPUPSTART;
- case ui::AX_EVENT_MENU_POPUP_END:
+ case AX_EVENT_MENU_POPUP_END:
return EVENT_SYSTEM_MENUPOPUPEND;
- case ui::AX_EVENT_SELECTION:
+ case AX_EVENT_SELECTION:
return EVENT_OBJECT_SELECTION;
- case ui::AX_EVENT_SELECTION_ADD:
+ case AX_EVENT_SELECTION_ADD:
return EVENT_OBJECT_SELECTIONADD;
- case ui::AX_EVENT_SELECTION_REMOVE:
+ case AX_EVENT_SELECTION_REMOVE:
return EVENT_OBJECT_SELECTIONREMOVE;
- case ui::AX_EVENT_TEXT_CHANGED:
+ case AX_EVENT_TEXT_CHANGED:
return EVENT_OBJECT_NAMECHANGE;
- case ui::AX_EVENT_TEXT_SELECTION_CHANGED:
+ case AX_EVENT_TEXT_SELECTION_CHANGED:
return IA2_EVENT_TEXT_CARET_MOVED;
- case ui::AX_EVENT_VALUE_CHANGED:
+ case AX_EVENT_VALUE_CHANGED:
return EVENT_OBJECT_VALUECHANGE;
default:
return -1;
}
}
-HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr(
- ui::AXStringAttribute attribute,
- BSTR* value_bstr) const {
+HRESULT AXPlatformNodeWin::GetStringAttributeAsBstr(AXStringAttribute attribute,
+ BSTR* value_bstr) const {
base::string16 str;
if (!GetString16Attribute(attribute, &str))
@@ -3287,9 +3549,9 @@ void AXPlatformNodeWin::RemoveAlertTarget() {
}
base::string16 AXPlatformNodeWin::TextForIAccessibleText() {
- if (GetData().role == ui::AX_ROLE_TEXT_FIELD)
- return GetString16Attribute(ui::AX_ATTR_VALUE);
- return GetString16Attribute(ui::AX_ATTR_NAME);
+ if (GetData().role == AX_ROLE_TEXT_FIELD)
+ return GetString16Attribute(AX_ATTR_VALUE);
+ return GetString16Attribute(AX_ATTR_NAME);
}
void AXPlatformNodeWin::HandleSpecialTextOffset(LONG* offset) {
@@ -3300,32 +3562,37 @@ void AXPlatformNodeWin::HandleSpecialTextOffset(LONG* offset) {
}
}
-ui::TextBoundaryType AXPlatformNodeWin::IA2TextBoundaryToTextBoundary(
+TextBoundaryType AXPlatformNodeWin::IA2TextBoundaryToTextBoundary(
IA2TextBoundaryType ia2_boundary) {
switch(ia2_boundary) {
- case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY;
- case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY;
- case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY;
- case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY;
- case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY;
- case IA2_TEXT_BOUNDARY_ALL: return ui::ALL_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_CHAR:
+ return CHAR_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_WORD:
+ return WORD_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_LINE:
+ return LINE_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_SENTENCE:
+ return SENTENCE_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_PARAGRAPH:
+ return PARAGRAPH_BOUNDARY;
+ case IA2_TEXT_BOUNDARY_ALL:
+ return ALL_BOUNDARY;
default:
NOTREACHED();
- return ui::CHAR_BOUNDARY;
+ return CHAR_BOUNDARY;
}
}
-LONG AXPlatformNodeWin::FindBoundary(
- const base::string16& text,
- IA2TextBoundaryType ia2_boundary,
- LONG start_offset,
- ui::TextBoundaryDirection direction) {
+LONG AXPlatformNodeWin::FindBoundary(const base::string16& text,
+ IA2TextBoundaryType ia2_boundary,
+ LONG start_offset,
+ TextBoundaryDirection direction) {
HandleSpecialTextOffset(&start_offset);
- ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
+ TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary);
std::vector<int32_t> line_breaks;
- return static_cast<LONG>(ui::FindAccessibleTextBoundary(
- text, line_breaks, boundary, start_offset, direction,
- AX_TEXT_AFFINITY_DOWNSTREAM));
+ return static_cast<LONG>(
+ FindAccessibleTextBoundary(text, line_breaks, boundary, start_offset,
+ direction, AX_TEXT_AFFINITY_DOWNSTREAM));
}
AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID(
@@ -3362,16 +3629,45 @@ AXPlatformNodeWin* AXPlatformNodeWin::GetTargetFromChildID(
}
bool AXPlatformNodeWin::IsInTreeGrid() {
- auto* container = FromNativeViewAccessible(GetParent());
+ AXPlatformNodeBase* container = FromNativeViewAccessible(GetParent());
// If parent was a rowgroup, we need to look at the grandparent
- if (container && container->GetData().role == ui::AX_ROLE_GROUP)
+ if (container && container->GetData().role == AX_ROLE_GROUP)
container = FromNativeViewAccessible(container->GetParent());
if (!container)
return false;
- return container->GetData().role == ui::AX_ROLE_TREE_GRID;
+ return container->GetData().role == AX_ROLE_TREE_GRID;
+}
+
+HRESULT AXPlatformNodeWin::AllocateComArrayFromVector(
+ std::vector<LONG>& results,
+ LONG max,
+ LONG** selected,
+ LONG* n_selected) {
+ DCHECK_GT(max, 0);
+ DCHECK(selected);
+ DCHECK(n_selected);
+
+ auto count = std::min((LONG)results.size(), max);
+ *n_selected = count;
+ *selected = static_cast<LONG*>(CoTaskMemAlloc(sizeof(LONG) * count));
+
+ for (LONG i = 0; i < count; i++)
+ (*selected)[i] = results[i];
+ return S_OK;
+}
+
+// TODO(dmazzoni): Remove this function once combo box refactoring is complete.
+bool AXPlatformNodeWin::IsAncestorComboBox() {
+ auto* parent =
+ static_cast<AXPlatformNodeWin*>(FromNativeViewAccessible(GetParent()));
+ if (!parent)
+ return false;
+ if (parent->MSAARole() == ROLE_SYSTEM_COMBOBOX)
+ return true;
+ return parent->IsAncestorComboBox();
}
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win.h b/chromium/ui/accessibility/platform/ax_platform_node_win.h
index e85a3c1855b..ecf7e8062b4 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win.h
@@ -224,17 +224,17 @@ class AXPlatformNodeRelationWin : public CComObjectRootEx<CComMultiThreadModel>,
AXPlatformNodeRelationWin();
virtual ~AXPlatformNodeRelationWin();
- void Initialize(ui::AXPlatformNodeWin* owner, const base::string16& type);
+ void Initialize(AXPlatformNodeWin* owner, const base::string16& type);
void AddTarget(int target_id);
void RemoveTarget(int target_id);
// IAccessibleRelation methods.
STDMETHODIMP get_relationType(BSTR* relation_type) override;
- STDMETHODIMP get_nTargets(long* n_targets) override;
- STDMETHODIMP get_target(long target_index, IUnknown** target) override;
- STDMETHODIMP get_targets(long max_targets,
+ STDMETHODIMP get_nTargets(LONG* n_targets) override;
+ STDMETHODIMP get_target(LONG target_index, IUnknown** target) override;
+ STDMETHODIMP get_targets(LONG max_targets,
IUnknown** targets,
- long* n_targets) override;
+ LONG* n_targets) override;
STDMETHODIMP get_localizedRelationType(BSTR* relation_type) override;
// Accessors.
@@ -243,22 +243,21 @@ class AXPlatformNodeRelationWin : public CComObjectRootEx<CComMultiThreadModel>,
private:
base::string16 type_;
- base::win::ScopedComPtr<ui::AXPlatformNodeWin> owner_;
+ base::win::ScopedComPtr<AXPlatformNodeWin> owner_;
std::vector<int> target_ids_;
};
class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
- AXPlatformNodeWin
- : public NON_EXPORTED_BASE(CComObjectRootEx<CComMultiThreadModel>),
- public IDispatchImpl<IAccessible2_2,
- &IID_IAccessible2,
- &LIBID_IAccessible2Lib>,
- public IAccessibleText,
- public IAccessibleTable,
- public IAccessibleTable2,
- public IAccessibleTableCell,
- public IServiceProvider,
- public AXPlatformNodeBase {
+ AXPlatformNodeWin : public CComObjectRootEx<CComMultiThreadModel>,
+ public IDispatchImpl<IAccessible2_2,
+ &IID_IAccessible2,
+ &LIBID_IAccessible2Lib>,
+ public IAccessibleText,
+ public IAccessibleTable,
+ public IAccessibleTable2,
+ public IAccessibleTableCell,
+ public IServiceProvider,
+ public AXPlatformNodeBase {
public:
BEGIN_COM_MAP(AXPlatformNodeWin)
COM_INTERFACE_ENTRY2(IDispatch, IAccessible2_2)
@@ -277,10 +276,12 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Clear node's current relationships and set them to the default values.
void CalculateRelationships();
+ static AXPlatformNode* GetFromUniqueId(int32_t unique_id);
+ int32_t unique_id() const { return unique_id_; }
// AXPlatformNode overrides.
gfx::NativeViewAccessible GetNativeViewAccessible() override;
- void NotifyAccessibilityEvent(ui::AXEvent event_type) override;
+ void NotifyAccessibilityEvent(AXEvent event_type) override;
// AXPlatformNodeBase overrides.
void Destroy() override;
@@ -368,9 +369,9 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
STDMETHODIMP get_windowHandle(HWND* window_handle) override;
STDMETHODIMP get_relationTargetsOfType(BSTR type,
- long max_targets,
+ LONG max_targets,
IUnknown*** targets,
- long* n_targets) override;
+ LONG* n_targets) override;
STDMETHODIMP get_attributes(BSTR* attributes) override;
@@ -409,7 +410,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
LONG* n_localized_extended_states) override;
STDMETHODIMP get_locale(IA2Locale* locale) override;
STDMETHODIMP get_accessibleWithCaret(IUnknown** accessible,
- long* caret_offset) override;
+ LONG* caret_offset) override;
//
// IAccessibleText methods.
@@ -458,87 +459,87 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// get_description - also used by IAccessibleImage
- STDMETHODIMP get_accessibleAt(long row,
- long column,
+ STDMETHODIMP get_accessibleAt(LONG row,
+ LONG column,
IUnknown** accessible) override;
STDMETHODIMP get_caption(IUnknown** accessible) override;
- STDMETHODIMP get_childIndex(long row_index,
- long column_index,
- long* cell_index) override;
+ STDMETHODIMP get_childIndex(LONG row_index,
+ LONG column_index,
+ LONG* cell_index) override;
- STDMETHODIMP get_columnDescription(long column, BSTR* description) override;
+ STDMETHODIMP get_columnDescription(LONG column, BSTR* description) override;
STDMETHODIMP
- get_columnExtentAt(long row, long column, long* n_columns_spanned) override;
+ get_columnExtentAt(LONG row, LONG column, LONG* n_columns_spanned) override;
STDMETHODIMP
get_columnHeader(IAccessibleTable** accessible_table,
- long* starting_row_index) override;
+ LONG* starting_row_index) override;
- STDMETHODIMP get_columnIndex(long cell_index, long* column_index) override;
+ STDMETHODIMP get_columnIndex(LONG cell_index, LONG* column_index) override;
- STDMETHODIMP get_nColumns(long* column_count) override;
+ STDMETHODIMP get_nColumns(LONG* column_count) override;
- STDMETHODIMP get_nRows(long* row_count) override;
+ STDMETHODIMP get_nRows(LONG* row_count) override;
- STDMETHODIMP get_nSelectedChildren(long* cell_count) override;
+ STDMETHODIMP get_nSelectedChildren(LONG* cell_count) override;
- STDMETHODIMP get_nSelectedColumns(long* column_count) override;
+ STDMETHODIMP get_nSelectedColumns(LONG* column_count) override;
- STDMETHODIMP get_nSelectedRows(long* row_count) override;
+ STDMETHODIMP get_nSelectedRows(LONG* row_count) override;
- STDMETHODIMP get_rowDescription(long row, BSTR* description) override;
+ STDMETHODIMP get_rowDescription(LONG row, BSTR* description) override;
- STDMETHODIMP get_rowExtentAt(long row,
- long column,
- long* n_rows_spanned) override;
+ STDMETHODIMP get_rowExtentAt(LONG row,
+ LONG column,
+ LONG* n_rows_spanned) override;
STDMETHODIMP
get_rowHeader(IAccessibleTable** accessible_table,
- long* starting_column_index) override;
+ LONG* starting_column_index) override;
- STDMETHODIMP get_rowIndex(long cell_index, long* row_index) override;
+ STDMETHODIMP get_rowIndex(LONG cell_index, LONG* row_index) override;
- STDMETHODIMP get_selectedChildren(long max_children,
- long** children,
- long* n_children) override;
+ STDMETHODIMP get_selectedChildren(LONG max_children,
+ LONG** children,
+ LONG* n_children) override;
- STDMETHODIMP get_selectedColumns(long max_columns,
- long** columns,
- long* n_columns) override;
+ STDMETHODIMP get_selectedColumns(LONG max_columns,
+ LONG** columns,
+ LONG* n_columns) override;
- STDMETHODIMP get_selectedRows(long max_rows,
- long** rows,
- long* n_rows) override;
+ STDMETHODIMP get_selectedRows(LONG max_rows,
+ LONG** rows,
+ LONG* n_rows) override;
STDMETHODIMP get_summary(IUnknown** accessible) override;
STDMETHODIMP
- get_isColumnSelected(long column, boolean* is_selected) override;
+ get_isColumnSelected(LONG column, boolean* is_selected) override;
- STDMETHODIMP get_isRowSelected(long row, boolean* is_selected) override;
+ STDMETHODIMP get_isRowSelected(LONG row, boolean* is_selected) override;
- STDMETHODIMP get_isSelected(long row,
- long column,
+ STDMETHODIMP get_isSelected(LONG row,
+ LONG column,
boolean* is_selected) override;
STDMETHODIMP
- get_rowColumnExtentsAtIndex(long index,
- long* row,
- long* column,
- long* row_extents,
- long* column_extents,
+ get_rowColumnExtentsAtIndex(LONG index,
+ LONG* row,
+ LONG* column,
+ LONG* row_extents,
+ LONG* column_extents,
boolean* is_selected) override;
- STDMETHODIMP selectRow(long row) override;
+ STDMETHODIMP selectRow(LONG row) override;
- STDMETHODIMP selectColumn(long column) override;
+ STDMETHODIMP selectColumn(LONG column) override;
- STDMETHODIMP unselectRow(long row) override;
+ STDMETHODIMP unselectRow(LONG row) override;
- STDMETHODIMP unselectColumn(long column) override;
+ STDMETHODIMP unselectColumn(LONG column) override;
STDMETHODIMP
get_modelChange(IA2TableModelChange* model_change) override;
@@ -550,45 +551,45 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// unique ones are included here.)
//
- STDMETHODIMP get_cellAt(long row, long column, IUnknown** cell) override;
+ STDMETHODIMP get_cellAt(LONG row, LONG column, IUnknown** cell) override;
- STDMETHODIMP get_nSelectedCells(long* cell_count) override;
+ STDMETHODIMP get_nSelectedCells(LONG* cell_count) override;
STDMETHODIMP
- get_selectedCells(IUnknown*** cells, long* n_selected_cells) override;
+ get_selectedCells(IUnknown*** cells, LONG* n_selected_cells) override;
- STDMETHODIMP get_selectedColumns(long** columns, long* n_columns) override;
+ STDMETHODIMP get_selectedColumns(LONG** columns, LONG* n_columns) override;
- STDMETHODIMP get_selectedRows(long** rows, long* n_rows) override;
+ STDMETHODIMP get_selectedRows(LONG** rows, LONG* n_rows) override;
//
// IAccessibleTableCell methods.
//
STDMETHODIMP
- get_columnExtent(long* n_columns_spanned) override;
+ get_columnExtent(LONG* n_columns_spanned) override;
STDMETHODIMP
get_columnHeaderCells(IUnknown*** cell_accessibles,
- long* n_column_header_cells) override;
+ LONG* n_column_header_cells) override;
- STDMETHODIMP get_columnIndex(long* column_index) override;
+ STDMETHODIMP get_columnIndex(LONG* column_index) override;
- STDMETHODIMP get_rowExtent(long* n_rows_spanned) override;
+ STDMETHODIMP get_rowExtent(LONG* n_rows_spanned) override;
STDMETHODIMP
get_rowHeaderCells(IUnknown*** cell_accessibles,
- long* n_row_header_cells) override;
+ LONG* n_row_header_cells) override;
- STDMETHODIMP get_rowIndex(long* row_index) override;
+ STDMETHODIMP get_rowIndex(LONG* row_index) override;
STDMETHODIMP get_isSelected(boolean* is_selected) override;
STDMETHODIMP
- get_rowColumnExtents(long* row,
- long* column,
- long* row_extents,
- long* column_extents,
+ get_rowColumnExtents(LONG* row,
+ LONG* column,
+ LONG* row_extents,
+ LONG* column_extents,
boolean* is_selected) override;
STDMETHODIMP get_table(IUnknown** table) override;
@@ -650,14 +651,15 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
void Dispose() override;
private:
- int MSAAEvent(ui::AXEvent event);
+ int32_t unique_id_;
+
+ int MSAAEvent(AXEvent event);
bool IsWebAreaForPresentationalIframe();
bool ShouldNodeHaveReadonlyStateByDefault(const AXNodeData& data) const;
bool ShouldNodeHaveFocusableState(const AXNodeData& data) const;
- HRESULT GetStringAttributeAsBstr(
- ui::AXStringAttribute attribute,
- BSTR* value_bstr) const;
+ HRESULT GetStringAttributeAsBstr(AXStringAttribute attribute,
+ BSTR* value_bstr) const;
// Escapes characters in string attributes as required by the IA2 Spec.
// It's okay for input to be the same as output.
@@ -670,19 +672,19 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// If the string attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |ia2_attr|.
void StringAttributeToIA2(std::vector<base::string16>& attributes,
- ui::AXStringAttribute attribute,
+ AXStringAttribute attribute,
const char* ia2_attr);
// If the bool attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |ia2_attr|.
void BoolAttributeToIA2(std::vector<base::string16>& attributes,
- ui::AXBoolAttribute attribute,
+ AXBoolAttribute attribute,
const char* ia2_attr);
// If the int attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |ia2_attr|.
void IntAttributeToIA2(std::vector<base::string16>& attributes,
- ui::AXIntAttribute attribute,
+ AXIntAttribute attribute,
const char* ia2_attr);
void AddAlertTarget();
@@ -695,8 +697,8 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// value of offset and returns, otherwise offset remains unchanged.
void HandleSpecialTextOffset(LONG* offset);
- // Convert from a IA2TextBoundaryType to a ui::TextBoundaryType.
- ui::TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
+ // Convert from a IA2TextBoundaryType to a TextBoundaryType.
+ TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
// Search forwards (direction == 1) or backwards (direction == -1)
// from the given offset until the given boundary is found, and
@@ -704,7 +706,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
LONG FindBoundary(const base::string16& text,
IA2TextBoundaryType ia2_boundary,
LONG start_offset,
- ui::TextBoundaryDirection direction);
+ TextBoundaryDirection 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.
@@ -722,7 +724,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
void AddRelation(const base::string16& relation_type, int target_id);
void AddBidirectionalRelations(const base::string16& relation_type,
const base::string16& reverse_relation_type,
- ui::AXIntListAttribute attribute);
+ AXIntListAttribute attribute);
void AddBidirectionalRelations(const base::string16& relation_type,
const base::string16& reverse_relation_type,
const std::vector<int32_t>& target_ids);
@@ -736,8 +738,17 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
void RemoveTargetFromRelation(const base::string16& relation_type,
int target_id);
+ // Helper method for returning selected indicies. It is expected that the
+ // caller ensures that the input has been validated.
+ HRESULT AllocateComArrayFromVector(std::vector<LONG>& results,
+ LONG max,
+ LONG** selected,
+ LONG* n_selected);
+
+ bool IsAncestorComboBox();
+
// Relationships between this node and other nodes.
- std::vector<ui::AXPlatformNodeRelationWin*> relations_;
+ std::vector<AXPlatformNodeRelationWin*> relations_;
};
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
index 9fe0108e065..8fcf2ee718a 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
@@ -148,14 +148,14 @@ class AXPlatformNodeWinTest : public testing::Test {
void CheckIUnknownHasName(ScopedComPtr<IUnknown> unknown,
const wchar_t* expected_name) {
ScopedComPtr<IAccessible2> accessible = ToIAccessible2(unknown);
- ASSERT_NE(nullptr, accessible);
+ ASSERT_NE(nullptr, accessible.Get());
ScopedBstr name;
EXPECT_EQ(S_OK, accessible->get_accName(SELF, name.Receive()));
EXPECT_STREQ(expected_name, name);
}
- void Build3X3Table() {
+ AXTreeUpdate Build3X3Table() {
/*
Build a table the looks like:
@@ -170,7 +170,7 @@ class AXPlatformNodeWinTest : public testing::Test {
AXNodeData table;
table.id = 0;
- table.role = ui::AX_ROLE_TABLE;
+ table.role = AX_ROLE_TABLE;
table.AddIntAttribute(AX_ATTR_TABLE_ROW_COUNT, 3);
table.AddIntAttribute(AX_ATTR_TABLE_COLUMN_COUNT, 3);
@@ -190,23 +190,23 @@ class AXPlatformNodeWinTest : public testing::Test {
// Table column header
AXNodeData table_row_header;
table_row_header.id = 50;
- table_row_header.role = ui::AX_ROLE_ROW;
+ table_row_header.role = AX_ROLE_ROW;
table_row_header.child_ids.push_back(51);
table_row_header.child_ids.push_back(52);
table_row_header.child_ids.push_back(53);
AXNodeData table_column_header_1;
table_column_header_1.id = 51;
- table_column_header_1.role = ui::AX_ROLE_COLUMN_HEADER;
+ table_column_header_1.role = AX_ROLE_COLUMN_HEADER;
AXNodeData table_column_header_2;
table_column_header_2.id = 52;
- table_column_header_2.role = ui::AX_ROLE_COLUMN_HEADER;
+ table_column_header_2.role = AX_ROLE_COLUMN_HEADER;
table_column_header_2.AddStringAttribute(AX_ATTR_NAME, "column header 1");
AXNodeData table_column_header_3;
table_column_header_3.id = 53;
- table_column_header_3.role = ui::AX_ROLE_COLUMN_HEADER;
+ table_column_header_3.role = AX_ROLE_COLUMN_HEADER;
// Either AX_ATTR_NAME -or- AX_ATTR_DESCRIPTION is acceptable for a
// description
table_column_header_3.AddStringAttribute(AX_ATTR_DESCRIPTION,
@@ -215,72 +215,75 @@ class AXPlatformNodeWinTest : public testing::Test {
// Row 1
AXNodeData table_row_1;
table_row_1.id = 1;
- table_row_1.role = ui::AX_ROLE_ROW;
+ table_row_1.role = AX_ROLE_ROW;
table_row_1.child_ids.push_back(2);
table_row_1.child_ids.push_back(3);
table_row_1.child_ids.push_back(4);
AXNodeData table_row_header_1;
table_row_header_1.id = 2;
- table_row_header_1.role = ui::AX_ROLE_ROW_HEADER;
+ table_row_header_1.role = AX_ROLE_ROW_HEADER;
table_row_header_1.AddStringAttribute(AX_ATTR_NAME, "row header 1");
AXNodeData table_cell_1;
table_cell_1.id = 3;
- table_cell_1.role = ui::AX_ROLE_CELL;
+ table_cell_1.role = AX_ROLE_CELL;
table_cell_1.AddStringAttribute(AX_ATTR_NAME, "1");
AXNodeData table_cell_2;
table_cell_2.id = 4;
- table_cell_2.role = ui::AX_ROLE_CELL;
+ table_cell_2.role = AX_ROLE_CELL;
table_cell_2.AddStringAttribute(AX_ATTR_NAME, "2");
// Row 2
AXNodeData table_row_2;
table_row_2.id = 10;
- table_row_2.role = ui::AX_ROLE_ROW;
+ table_row_2.role = AX_ROLE_ROW;
table_row_2.child_ids.push_back(11);
table_row_2.child_ids.push_back(12);
table_row_2.child_ids.push_back(13);
AXNodeData table_row_header_2;
table_row_header_2.id = 11;
- table_row_header_2.role = ui::AX_ROLE_ROW_HEADER;
+ table_row_header_2.role = AX_ROLE_ROW_HEADER;
// Either AX_ATTR_NAME -or- AX_ATTR_DESCRIPTION is acceptable for a
// description
table_row_header_2.AddStringAttribute(AX_ATTR_DESCRIPTION, "row header 2");
AXNodeData table_cell_3;
table_cell_3.id = 12;
- table_cell_3.role = ui::AX_ROLE_CELL;
+ table_cell_3.role = AX_ROLE_CELL;
table_cell_3.AddStringAttribute(AX_ATTR_NAME, "3");
AXNodeData table_cell_4;
table_cell_4.id = 13;
- table_cell_4.role = ui::AX_ROLE_CELL;
+ table_cell_4.role = AX_ROLE_CELL;
table_cell_4.AddStringAttribute(AX_ATTR_NAME, "4");
AXTreeUpdate update;
update.root_id = table.id;
- update.nodes.push_back(table);
+ // Some of the table testing code will index into |nodes|
+ // and change the state of the given node. If you reorder
+ // these, you're going to need to update the tests.
+ update.nodes.push_back(table); // 0
- update.nodes.push_back(table_row_header);
- update.nodes.push_back(table_column_header_1);
- update.nodes.push_back(table_column_header_2);
- update.nodes.push_back(table_column_header_3);
+ update.nodes.push_back(table_row_header); // 1
+ update.nodes.push_back(table_column_header_1); // 2
+ update.nodes.push_back(table_column_header_2); // 3
+ update.nodes.push_back(table_column_header_3); // 4
- update.nodes.push_back(table_row_1);
- update.nodes.push_back(table_row_header_1);
- update.nodes.push_back(table_cell_1);
- update.nodes.push_back(table_cell_2);
+ update.nodes.push_back(table_row_1); // 5
+ update.nodes.push_back(table_row_header_1); // 6
+ update.nodes.push_back(table_cell_1); // 7
+ update.nodes.push_back(table_cell_2); // 8
- update.nodes.push_back(table_row_2);
- update.nodes.push_back(table_row_header_2);
- update.nodes.push_back(table_cell_3);
- update.nodes.push_back(table_cell_4);
+ update.nodes.push_back(table_row_2); // 9
+ update.nodes.push_back(table_row_header_2); // 10
+ update.nodes.push_back(table_cell_3); // 11
+ update.nodes.push_back(table_cell_4); // 12
- Init(update);
+ return update;
}
ScopedComPtr<IAccessibleTableCell> GetCellInTable() {
@@ -483,7 +486,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionOneSelected) {
AXNodeData list_item_2;
list_item_2.id = 2;
list_item_2.role = AX_ROLE_LIST_BOX_OPTION;
- list_item_2.state = 1 << ui::AX_STATE_SELECTED;
+ list_item_2.state = 1 << AX_STATE_SELECTED;
list_item_2.AddStringAttribute(AX_ATTR_NAME, "Name2");
AXNodeData list_item_3;
@@ -516,13 +519,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionMultipleSelected) {
AXNodeData list_item_2;
list_item_2.id = 2;
list_item_2.role = AX_ROLE_LIST_BOX_OPTION;
- list_item_2.state = 1 << ui::AX_STATE_SELECTED;
+ list_item_2.state = 1 << AX_STATE_SELECTED;
list_item_2.AddStringAttribute(AX_ATTR_NAME, "Name2");
AXNodeData list_item_3;
list_item_3.id = 3;
list_item_3.role = AX_ROLE_LIST_BOX_OPTION;
- list_item_3.state = 1 << ui::AX_STATE_SELECTED;
+ list_item_3.state = 1 << AX_STATE_SELECTED;
list_item_3.AddStringAttribute(AX_ATTR_NAME, "Name3");
AXNodeData list_item_4;
@@ -682,7 +685,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
ScopedComPtr<IDispatch> result;
EXPECT_EQ(S_OK,
root_iaccessible->get_accChild(SELF, result.GetAddressOf()));
- EXPECT_EQ(result.Get(), root_iaccessible);
+ EXPECT_EQ(result.Get(), root_iaccessible.Get());
}
{
@@ -690,7 +693,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
ScopedVariant child1(1);
EXPECT_EQ(S_OK,
root_iaccessible->get_accChild(child1, result.GetAddressOf()));
- EXPECT_EQ(result.Get(), button_iaccessible);
+ EXPECT_EQ(result.Get(), button_iaccessible.Get());
}
{
@@ -698,7 +701,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
ScopedVariant child2(2);
EXPECT_EQ(S_OK,
root_iaccessible->get_accChild(child2, result.GetAddressOf()));
- EXPECT_EQ(result.Get(), checkbox_iaccessible);
+ EXPECT_EQ(result.Get(), checkbox_iaccessible.Get());
}
{
@@ -720,7 +723,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
ScopedVariant button_id_variant(button_unique_id);
EXPECT_EQ(S_OK, root_iaccessible->get_accChild(button_id_variant,
result.GetAddressOf()));
- EXPECT_EQ(result.Get(), button_iaccessible);
+ EXPECT_EQ(result.Get(), button_iaccessible.Get());
}
// We shouldn't be able to ask for the root node by its unique ID
@@ -741,13 +744,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
{
ScopedComPtr<IDispatch> result;
EXPECT_EQ(S_OK, button_iaccessible->get_accParent(result.GetAddressOf()));
- EXPECT_EQ(result.Get(), root_iaccessible);
+ EXPECT_EQ(result.Get(), root_iaccessible.Get());
}
{
ScopedComPtr<IDispatch> result;
EXPECT_EQ(S_OK, checkbox_iaccessible->get_accParent(result.GetAddressOf()));
- EXPECT_EQ(result.Get(), root_iaccessible);
+ EXPECT_EQ(result.Get(), root_iaccessible.Get());
}
{
@@ -887,8 +890,8 @@ TEST_F(AXPlatformNodeWinTest, TestAccNavigate) {
TEST_F(AXPlatformNodeWinTest, TestIAccessible2SetSelection) {
AXNodeData text_field_node;
text_field_node.id = 1;
- text_field_node.role = ui::AX_ROLE_TEXT_FIELD;
- text_field_node.state = 1 << ui::AX_STATE_EDITABLE;
+ text_field_node.role = AX_ROLE_TEXT_FIELD;
+ text_field_node.state = 1 << AX_STATE_EDITABLE;
text_field_node.SetValue("Hi");
Init(text_field_node);
@@ -896,7 +899,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2SetSelection) {
ToIAccessible2(GetRootIAccessible());
ScopedComPtr<IAccessibleText> text_field;
ia2_text_field.CopyTo(text_field.GetAddressOf());
- ASSERT_NE(nullptr, text_field);
+ ASSERT_NE(nullptr, text_field.Get());
EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 0, 1));
EXPECT_HRESULT_SUCCEEDED(text_field->setSelection(0, 1, 0));
@@ -909,13 +912,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2SetSelection) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetAccessibilityAt) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
ScopedComPtr<IUnknown> cell_1;
EXPECT_EQ(S_OK, result->get_accessibleAt(1, 1, cell_1.GetAddressOf()));
@@ -936,13 +939,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetAccessibilityAt) {
TEST_F(AXPlatformNodeWinTest,
TestIAccessibleTableGetAccessibilityAtOutOfBounds) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
{
ScopedComPtr<IUnknown> cell;
@@ -970,13 +973,13 @@ TEST_F(AXPlatformNodeWinTest,
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetChildIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long id;
EXPECT_EQ(S_OK, result->get_childIndex(0, 0, &id));
@@ -998,13 +1001,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetChildIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnDescription) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
{
ScopedBstr name;
@@ -1026,13 +1029,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnDescription) {
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnExtentAt) {
// TODO(dougt) This table doesn't have any spanning cells. This test
// tests get_columnExtentAt for (1) and an invalid input.
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long columns_spanned;
EXPECT_EQ(S_OK, result->get_columnExtentAt(1, 1, &columns_spanned));
@@ -1042,13 +1045,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnExtentAt) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long index;
EXPECT_EQ(S_OK, result->get_columnIndex(1, &index));
@@ -1058,13 +1061,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNColumns) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long count;
EXPECT_EQ(S_OK, result->get_nColumns(&count));
@@ -1072,13 +1075,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNColumns) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNRows) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long count;
EXPECT_EQ(S_OK, result->get_nRows(&count));
@@ -1086,13 +1089,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNRows) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowDescription) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
{
ScopedBstr name;
@@ -1114,13 +1117,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowDescription) {
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowExtentAt) {
// TODO(dougt) This table doesn't have any spanning cells. This test
// tests get_rowExtentAt for (1) and an invalid input.
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long rows_spanned;
EXPECT_EQ(S_OK, result->get_rowExtentAt(0, 1, &rows_spanned));
@@ -1130,13 +1133,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowExtentAt) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long index;
EXPECT_EQ(S_OK, result->get_rowIndex(1, &index));
@@ -1146,13 +1149,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowColumnExtentsAtIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
long row, column, row_extents, column_extents;
boolean is_selected;
@@ -1171,13 +1174,13 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowColumnExtentsAtIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetCellAt) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
ScopedComPtr<IAccessibleTable2> result;
root_obj.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
{
ScopedComPtr<IUnknown> cell;
@@ -1192,10 +1195,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetCellAt) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnExtent) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
long column_spanned;
EXPECT_EQ(S_OK, cell->get_columnExtent(&column_spanned));
@@ -1203,10 +1206,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnExtent) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnHeaderCells) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
IUnknown** cell_accessibles;
@@ -1217,10 +1220,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnHeaderCells) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
long index;
EXPECT_EQ(S_OK, cell->get_columnIndex(&index));
@@ -1228,10 +1231,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowExtent) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
long rows_spanned;
EXPECT_EQ(S_OK, cell->get_rowExtent(&rows_spanned));
@@ -1239,10 +1242,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowExtent) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowHeaderCells) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
IUnknown** cell_accessibles;
@@ -1255,10 +1258,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowHeaderCells) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowIndex) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
long index;
EXPECT_EQ(S_OK, cell->get_rowIndex(&index));
@@ -1266,10 +1269,10 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowIndex) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowColumnExtent) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
long row, column, row_extents, column_extents;
boolean is_selected;
@@ -1282,17 +1285,17 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowColumnExtent) {
}
TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetTable) {
- Build3X3Table();
+ Init(Build3X3Table());
ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
- ASSERT_NE(nullptr, cell);
+ ASSERT_NE(nullptr, cell.Get());
ScopedComPtr<IUnknown> table;
EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
ScopedComPtr<IAccessibleTable> result;
table.CopyTo(result.GetAddressOf());
- ASSERT_NE(nullptr, result);
+ ASSERT_NE(nullptr, result.Get());
// Check to make sure that this is the right table by checking one cell.
ScopedComPtr<IUnknown> cell_1;
@@ -1304,22 +1307,22 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetNRelations) {
// This is is a duplicated of
// BrowserAccessibilityTest::TestIAccessible2Relations but without the
// specific COM/BrowserAccessibility knowledge.
- ui::AXNodeData root;
+ AXNodeData root;
root.id = 1;
- root.role = ui::AX_ROLE_ROOT_WEB_AREA;
+ root.role = AX_ROLE_ROOT_WEB_AREA;
std::vector<int32_t> describedby_ids = {1, 2, 3};
- root.AddIntListAttribute(ui::AX_ATTR_DESCRIBEDBY_IDS, describedby_ids);
+ root.AddIntListAttribute(AX_ATTR_DESCRIBEDBY_IDS, describedby_ids);
- ui::AXNodeData child1;
+ AXNodeData child1;
child1.id = 2;
- child1.role = ui::AX_ROLE_STATIC_TEXT;
+ child1.role = AX_ROLE_STATIC_TEXT;
root.child_ids.push_back(2);
- ui::AXNodeData child2;
+ AXNodeData child2;
child2.id = 3;
- child2.role = ui::AX_ROLE_STATIC_TEXT;
+ child2.role = AX_ROLE_STATIC_TEXT;
root.child_ids.push_back(3);
@@ -1413,4 +1416,674 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetNRelations) {
// TODO(dougt): Try adding one more relation.
}
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenZero) {
+ Init(Build3X3Table());
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedChildren;
+ EXPECT_EQ(S_OK, result->get_nSelectedChildren(&selectedChildren));
+ EXPECT_EQ(0, selectedChildren);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenOne) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedChildren;
+ EXPECT_EQ(S_OK, result->get_nSelectedChildren(&selectedChildren));
+ EXPECT_EQ(1, selectedChildren);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenMany) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ // 11 == table_cell_3
+ // 12 == table_cell_4
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedChildren;
+ EXPECT_EQ(S_OK, result->get_nSelectedChildren(&selectedChildren));
+ EXPECT_EQ(4, selectedChildren);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsZero) {
+ Init(Build3X3Table());
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedColumns;
+ EXPECT_EQ(S_OK, result->get_nSelectedColumns(&selectedColumns));
+ EXPECT_EQ(0, selectedColumns);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsOne) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 3 == table_column_header_2
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[3].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedColumns;
+ EXPECT_EQ(S_OK, result->get_nSelectedColumns(&selectedColumns));
+ EXPECT_EQ(1, selectedColumns);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsMany) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 3 == table_column_header_2
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[3].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ // 4 == table_column_header_3
+ // 8 == table_cell_2
+ // 12 == table_cell_4
+ update.nodes[4].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedColumns;
+ EXPECT_EQ(S_OK, result->get_nSelectedColumns(&selectedColumns));
+ EXPECT_EQ(2, selectedColumns);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsZero) {
+ Init(Build3X3Table());
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedRows;
+ EXPECT_EQ(S_OK, result->get_nSelectedRows(&selectedRows));
+ EXPECT_EQ(0, selectedRows);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsOne) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_1
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedRows;
+ EXPECT_EQ(S_OK, result->get_nSelectedRows(&selectedRows));
+ EXPECT_EQ(1, selectedRows);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsMany) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_3
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ // 10 == table_row_header_3
+ // 11 == table_cell_1
+ // 12 == table_cell_2
+ update.nodes[10].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG selectedRows;
+ EXPECT_EQ(S_OK, result->get_nSelectedRows(&selectedRows));
+ EXPECT_EQ(2, selectedRows);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildren) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ // 12 == table_cell_4
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG max = 10;
+ LONG* indices;
+ LONG count;
+ EXPECT_EQ(S_OK, result->get_selectedChildren(max, &indices, &count));
+ EXPECT_EQ(2, count);
+ EXPECT_EQ(4, indices[0]);
+ EXPECT_EQ(8, indices[1]);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildrenZeroMax) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ // 12 == table_cell_4
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ LONG* indices;
+ LONG count;
+ EXPECT_EQ(E_INVALIDARG, result->get_selectedChildren(0, &indices, &count));
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsZero) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_columns = 10;
+ long* columns;
+ long n_columns;
+ EXPECT_EQ(S_OK,
+ result->get_selectedColumns(max_columns, &columns, &n_columns));
+ EXPECT_EQ(0, n_columns);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsOne) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 3 == table_column_header_2
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[3].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_columns = 10;
+ long* columns;
+ long n_columns;
+ EXPECT_EQ(S_OK,
+ result->get_selectedColumns(max_columns, &columns, &n_columns));
+ EXPECT_EQ(1, n_columns);
+ EXPECT_EQ(1, columns[0]);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsMany) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 3 == table_column_header_2
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[3].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ // 4 == table_column_header_3
+ // 8 == table_cell_2
+ // 12 == table_cell_4
+ update.nodes[4].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_columns = 10;
+ long* columns;
+ long n_columns;
+ EXPECT_EQ(S_OK,
+ result->get_selectedColumns(max_columns, &columns, &n_columns));
+ EXPECT_EQ(2, n_columns);
+ EXPECT_EQ(1, columns[0]);
+ EXPECT_EQ(2, columns[1]);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsZero) {
+ Init(Build3X3Table());
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_rows = 10;
+ long* rows;
+ long n_rows;
+ EXPECT_EQ(S_OK, result->get_selectedRows(max_rows, &rows, &n_rows));
+ EXPECT_EQ(0, n_rows);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsOne) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_1
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_rows = 10;
+ long* rows;
+ long n_rows;
+ EXPECT_EQ(S_OK, result->get_selectedRows(max_rows, &rows, &n_rows));
+ EXPECT_EQ(1, n_rows);
+ EXPECT_EQ(1, rows[0]);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsMany) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_3
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ // 10 == table_row_header_3
+ // 11 == table_cell_1
+ // 12 == table_cell_2
+ update.nodes[10].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ long max_rows = 10;
+ long* rows;
+ long n_rows;
+ EXPECT_EQ(S_OK, result->get_selectedRows(max_rows, &rows, &n_rows));
+ EXPECT_EQ(2, n_rows);
+ EXPECT_EQ(1, rows[0]);
+ EXPECT_EQ(2, rows[1]);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsColumnSelected) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 3 == table_column_header_2
+ // 7 == table_cell_1
+ // 11 == table_cell_3
+ update.nodes[3].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[11].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ boolean selected;
+ EXPECT_EQ(S_OK, result->get_isColumnSelected(0, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isColumnSelected(1, &selected));
+ EXPECT_TRUE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isColumnSelected(2, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_FALSE, result->get_isColumnSelected(3, &selected));
+ EXPECT_EQ(S_FALSE, result->get_isColumnSelected(-3, &selected));
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsRowSelected) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_3
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ boolean selected;
+ EXPECT_EQ(S_OK, result->get_isRowSelected(0, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isRowSelected(1, &selected));
+ EXPECT_TRUE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isRowSelected(2, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_FALSE, result->get_isRowSelected(3, &selected));
+ EXPECT_EQ(S_FALSE, result->get_isRowSelected(-3, &selected));
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsSelected) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 6 == table_row_header_3
+ // 7 == table_cell_1
+ // 8 == table_cell_2
+ update.nodes[6].state = 1 << AX_STATE_SELECTED;
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[8].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ boolean selected;
+
+ EXPECT_EQ(S_OK, result->get_isSelected(0, 0, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isSelected(0, 1, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isSelected(0, 2, &selected));
+ EXPECT_FALSE(selected);
+
+ EXPECT_EQ(S_FALSE, result->get_isSelected(0, 4, &selected));
+
+ EXPECT_EQ(S_OK, result->get_isSelected(1, 0, &selected));
+ EXPECT_TRUE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isSelected(1, 1, &selected));
+ EXPECT_TRUE(selected);
+
+ EXPECT_EQ(S_OK, result->get_isSelected(1, 2, &selected));
+ EXPECT_TRUE(selected);
+
+ EXPECT_EQ(S_FALSE, result->get_isSelected(1, 4, &selected));
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildrenZero) {
+ Init(Build3X3Table());
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable2> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ IUnknown** cell_accessibles;
+ LONG count;
+ EXPECT_EQ(S_OK, result->get_selectedCells(&cell_accessibles, &count));
+ EXPECT_EQ(0, count);
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildren) {
+ AXTreeUpdate update = Build3X3Table();
+
+ // 7 == table_cell_1
+ // 12 == table_cell_4
+ update.nodes[7].state = 1 << AX_STATE_SELECTED;
+ update.nodes[12].state = 1 << AX_STATE_SELECTED;
+
+ Init(update);
+
+ ScopedComPtr<IAccessibleTableCell> cell = GetCellInTable();
+ ASSERT_NE(nullptr, cell.Get());
+
+ ScopedComPtr<IUnknown> table;
+ EXPECT_EQ(S_OK, cell->get_table(table.GetAddressOf()));
+
+ ScopedComPtr<IAccessibleTable2> result;
+ table.CopyTo(result.GetAddressOf());
+ ASSERT_NE(nullptr, result.Get());
+
+ IUnknown** cell_accessibles;
+ LONG count;
+ EXPECT_EQ(S_OK, result->get_selectedCells(&cell_accessibles, &count));
+ EXPECT_EQ(2, count);
+
+ ScopedComPtr<IUnknown> table_cell_1(cell_accessibles[0]);
+ CheckIUnknownHasName(table_cell_1, L"1");
+
+ ScopedComPtr<IUnknown> table_cell_4(cell_accessibles[1]);
+ CheckIUnknownHasName(table_cell_4, L"4");
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetGroupPosition) {
+ AXNodeData root;
+ root.id = 1;
+ root.AddIntAttribute(AX_ATTR_HIERARCHICAL_LEVEL, 1);
+ root.AddIntAttribute(AX_ATTR_SET_SIZE, 1);
+ root.AddIntAttribute(AX_ATTR_POS_IN_SET, 1);
+ Init(root);
+
+ ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
+ ScopedComPtr<IAccessible2> iaccessible2 = ToIAccessible2(root_obj);
+ LONG level, similar, position;
+ EXPECT_EQ(S_OK, iaccessible2->get_groupPosition(&level, &similar, &position));
+ EXPECT_EQ(1, level);
+ EXPECT_EQ(1, similar);
+ EXPECT_EQ(1, position);
+
+ EXPECT_EQ(E_INVALIDARG,
+ iaccessible2->get_groupPosition(nullptr, nullptr, nullptr));
+}
+
+TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetLocalizedExtendedRole) {
+ AXNodeData root;
+ root.id = 1;
+ root.AddStringAttribute(AX_ATTR_ROLE_DESCRIPTION, "extended role");
+ Init(root);
+
+ ScopedComPtr<IAccessible> root_obj(GetRootIAccessible());
+ ScopedComPtr<IAccessible2> iaccessible2 = ToIAccessible2(root_obj);
+ ScopedBstr role;
+ EXPECT_EQ(S_OK, iaccessible2->get_localizedExtendedRole(role.Receive()));
+ EXPECT_STREQ(L"extended role", role);
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.cc b/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.cc
index 1d62fefc5ef..4d0bfe41d93 100644
--- a/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.cc
+++ b/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.cc
@@ -23,7 +23,7 @@ namespace {
bool HasFocusableChild(const AXNode* node) {
for (auto* child : node->children()) {
- if ((child->data().state & ui::AX_STATE_FOCUSABLE) != 0 ||
+ if (child->data().HasState(AX_STATE_FOCUSABLE) ||
HasFocusableChild(child)) {
return true;
}
@@ -40,13 +40,13 @@ bool HasOnlyTextChildren(const AXNode* node) {
}
// TODO(muyuanli): share with BrowserAccessibility.
-bool IsSimpleTextControl(AXRole role, uint32_t state) {
- switch (role) {
- case ui::AX_ROLE_COMBO_BOX:
- case ui::AX_ROLE_SEARCH_BOX:
+bool IsSimpleTextControl(const AXNode* node, uint32_t state) {
+ switch (node->data().role) {
+ case AX_ROLE_COMBO_BOX:
+ case AX_ROLE_SEARCH_BOX:
return true;
- case ui::AX_ROLE_TEXT_FIELD:
- return (state & ui::AX_STATE_RICHLY_EDITABLE) == 0;
+ case AX_ROLE_TEXT_FIELD:
+ return !node->data().HasState(AX_STATE_RICHLY_EDITABLE);
default:
return false;
}
@@ -54,14 +54,13 @@ bool IsSimpleTextControl(AXRole role, uint32_t state) {
bool IsRichTextEditable(const AXNode* node) {
const AXNode* parent = node->parent();
- return (node->data().state & ui::AX_STATE_RICHLY_EDITABLE) != 0 &&
- (!parent ||
- (parent->data().state & ui::AX_STATE_RICHLY_EDITABLE) == 0);
+ return node->data().HasState(AX_STATE_RICHLY_EDITABLE) &&
+ (!parent || !parent->data().HasState(AX_STATE_RICHLY_EDITABLE));
}
bool IsNativeTextControl(const AXNode* node) {
const std::string& html_tag =
- node->data().GetStringAttribute(ui::AX_ATTR_HTML_TAG);
+ node->data().GetStringAttribute(AX_ATTR_HTML_TAG);
if (html_tag == "input") {
std::string input_type;
if (!node->data().GetHtmlAttribute("type", &input_type))
@@ -83,15 +82,15 @@ bool IsLeaf(const AXNode* node) {
}
switch (node->data().role) {
- case ui::AX_ROLE_IMAGE:
- case ui::AX_ROLE_METER:
- case ui::AX_ROLE_SCROLL_BAR:
- case ui::AX_ROLE_SLIDER:
- case ui::AX_ROLE_SPLITTER:
- case ui::AX_ROLE_PROGRESS_INDICATOR:
- case ui::AX_ROLE_DATE:
- case ui::AX_ROLE_DATE_TIME:
- case ui::AX_ROLE_INPUT_TIME:
+ case AX_ROLE_IMAGE:
+ case AX_ROLE_METER:
+ case AX_ROLE_SCROLL_BAR:
+ case AX_ROLE_SLIDER:
+ case AX_ROLE_SPLITTER:
+ case AX_ROLE_PROGRESS_INDICATOR:
+ case AX_ROLE_DATE:
+ case AX_ROLE_DATE_TIME:
+ case AX_ROLE_INPUT_TIME:
return true;
default:
return false;
@@ -100,7 +99,7 @@ bool IsLeaf(const AXNode* node) {
base::string16 GetInnerText(const AXNode* node) {
if (node->IsTextNode()) {
- return node->data().GetString16Attribute(ui::AX_ATTR_NAME);
+ return node->data().GetString16Attribute(AX_ATTR_NAME);
}
base::string16 text;
for (auto* child : node->children()) {
@@ -110,16 +109,16 @@ base::string16 GetInnerText(const AXNode* node) {
}
base::string16 GetValue(const AXNode* node, bool show_password) {
- base::string16 value = node->data().GetString16Attribute(ui::AX_ATTR_VALUE);
+ base::string16 value = node->data().GetString16Attribute(AX_ATTR_VALUE);
if (value.empty() &&
- (IsSimpleTextControl(node->data().role, node->data().state) ||
+ (IsSimpleTextControl(node, node->data().state) ||
IsRichTextEditable(node)) &&
!IsNativeTextControl(node)) {
value = GetInnerText(node);
}
- if ((node->data().state & ui::AX_STATE_PROTECTED) != 0) {
+ if (node->data().HasState(AX_STATE_PROTECTED)) {
if (!show_password) {
value = base::string16(value.size(), kSecurePasswordBullet);
}
@@ -130,8 +129,8 @@ base::string16 GetValue(const AXNode* node, bool show_password) {
bool HasOnlyTextAndImageChildren(const AXNode* node) {
for (auto* child : node->children()) {
- if (child->data().role != ui::AX_ROLE_STATIC_TEXT &&
- child->data().role != ui::AX_ROLE_IMAGE) {
+ if (child->data().role != AX_ROLE_STATIC_TEXT &&
+ child->data().role != AX_ROLE_IMAGE) {
return false;
}
}
@@ -139,24 +138,24 @@ bool HasOnlyTextAndImageChildren(const AXNode* node) {
}
bool IsFocusable(const AXNode* node) {
- if (node->data().role == ui::AX_ROLE_IFRAME ||
- node->data().role == ui::AX_ROLE_IFRAME_PRESENTATIONAL ||
- (node->data().role == ui::AX_ROLE_ROOT_WEB_AREA && node->parent())) {
- return node->data().HasStringAttribute(ui::AX_ATTR_NAME);
+ if (node->data().role == AX_ROLE_IFRAME ||
+ node->data().role == AX_ROLE_IFRAME_PRESENTATIONAL ||
+ (node->data().role == AX_ROLE_ROOT_WEB_AREA && node->parent())) {
+ return node->data().HasStringAttribute(AX_ATTR_NAME);
}
- return (node->data().state & ui::AX_STATE_FOCUSABLE) != 0;
+ return node->data().HasState(AX_STATE_FOCUSABLE);
}
base::string16 GetText(const AXNode* node, bool show_password) {
- if (node->data().role == ui::AX_ROLE_WEB_AREA ||
- node->data().role == ui::AX_ROLE_IFRAME ||
- node->data().role == ui::AX_ROLE_IFRAME_PRESENTATIONAL) {
+ if (node->data().role == AX_ROLE_WEB_AREA ||
+ node->data().role == AX_ROLE_IFRAME ||
+ node->data().role == AX_ROLE_IFRAME_PRESENTATIONAL) {
return base::string16();
}
- if (node->data().role == ui::AX_ROLE_LIST_ITEM &&
- node->data().GetIntAttribute(ui::AX_ATTR_NAME_FROM) ==
- ui::AX_NAME_FROM_CONTENTS) {
+ if (node->data().role == AX_ROLE_LIST_ITEM &&
+ node->data().GetIntAttribute(AX_ATTR_NAME_FROM) ==
+ AX_NAME_FROM_CONTENTS) {
if (node->child_count() > 0 && !HasOnlyTextChildren(node))
return base::string16();
}
@@ -164,22 +163,22 @@ base::string16 GetText(const AXNode* node, bool show_password) {
base::string16 value = GetValue(node, show_password);
if (!value.empty()) {
- if ((node->data().state & ui::AX_STATE_EDITABLE) != 0)
+ if (node->data().HasState(AX_STATE_EDITABLE))
return value;
switch (node->data().role) {
- case ui::AX_ROLE_COMBO_BOX:
- case ui::AX_ROLE_POP_UP_BUTTON:
- case ui::AX_ROLE_TEXT_FIELD:
+ case AX_ROLE_COMBO_BOX:
+ case AX_ROLE_POP_UP_BUTTON:
+ case AX_ROLE_TEXT_FIELD:
return value;
default:
break;
}
}
- if (node->data().role == ui::AX_ROLE_COLOR_WELL) {
+ if (node->data().role == AX_ROLE_COLOR_WELL) {
unsigned int color = static_cast<unsigned int>(
- node->data().GetIntAttribute(ui::AX_ATTR_COLOR_VALUE));
+ node->data().GetIntAttribute(AX_ATTR_COLOR_VALUE));
unsigned int red = color >> 16 & 0xFF;
unsigned int green = color >> 8 & 0xFF;
unsigned int blue = color >> 0 & 0xFF;
@@ -187,9 +186,9 @@ base::string16 GetText(const AXNode* node, bool show_password) {
base::StringPrintf("#%02X%02X%02X", red, green, blue));
}
- base::string16 text = node->data().GetString16Attribute(ui::AX_ATTR_NAME);
+ base::string16 text = node->data().GetString16Attribute(AX_ATTR_NAME);
base::string16 description =
- node->data().GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
+ node->data().GetString16Attribute(AX_ATTR_DESCRIPTION);
if (!description.empty()) {
if (!text.empty())
text += base::ASCIIToUTF16(" ");
@@ -199,7 +198,7 @@ base::string16 GetText(const AXNode* node, bool show_password) {
if (text.empty())
text = value;
- if (node->data().role == ui::AX_ROLE_ROOT_WEB_AREA)
+ if (node->data().role == AX_ROLE_ROOT_WEB_AREA)
return text;
if (text.empty() &&
@@ -211,8 +210,8 @@ base::string16 GetText(const AXNode* node, bool show_password) {
}
if (text.empty() && (AXSnapshotNodeAndroid::AXRoleIsLink(node->data().role) ||
- node->data().role == ui::AX_ROLE_IMAGE)) {
- base::string16 url = node->data().GetString16Attribute(ui::AX_ATTR_URL);
+ node->data().role == AX_ROLE_IMAGE)) {
+ base::string16 url = node->data().GetString16Attribute(AX_ATTR_URL);
text = AXSnapshotNodeAndroid::AXUrlBaseText(url);
}
return text;
@@ -271,7 +270,7 @@ AX_EXPORT AXSnapshotNodeAndroid::~AXSnapshotNodeAndroid() = default;
AX_EXPORT std::unique_ptr<AXSnapshotNodeAndroid> AXSnapshotNodeAndroid::Create(
const AXTreeUpdate& update,
bool show_password) {
- auto tree = base::MakeUnique<ui::AXSerializableTree>();
+ auto tree = base::MakeUnique<AXSerializableTree>();
if (!tree->Unserialize(update)) {
LOG(FATAL) << tree->error();
}
@@ -286,7 +285,7 @@ AX_EXPORT std::unique_ptr<AXSnapshotNodeAndroid> AXSnapshotNodeAndroid::Create(
// static
AX_EXPORT bool AXSnapshotNodeAndroid::AXRoleIsLink(AXRole role) {
- return role == ui::AX_ROLE_LINK || role == ui::AX_ROLE_IMAGE_MAP_LINK;
+ return role == AX_ROLE_LINK;
}
// static
@@ -315,55 +314,55 @@ AX_EXPORT const char* AXSnapshotNodeAndroid::AXRoleToAndroidClassName(
AXRole role,
bool has_parent) {
switch (role) {
- case ui::AX_ROLE_SEARCH_BOX:
- case ui::AX_ROLE_SPIN_BUTTON:
- case ui::AX_ROLE_TEXT_FIELD:
- return ui::kAXEditTextClassname;
- case ui::AX_ROLE_SLIDER:
- return ui::kAXSeekBarClassname;
- case ui::AX_ROLE_COLOR_WELL:
- case ui::AX_ROLE_COMBO_BOX:
- case ui::AX_ROLE_DATE:
- case ui::AX_ROLE_POP_UP_BUTTON:
- case ui::AX_ROLE_INPUT_TIME:
- return ui::kAXSpinnerClassname;
- case ui::AX_ROLE_BUTTON:
- case ui::AX_ROLE_MENU_BUTTON:
- return ui::kAXButtonClassname;
- case ui::AX_ROLE_CHECK_BOX:
- case ui::AX_ROLE_SWITCH:
- return ui::kAXCheckBoxClassname;
- case ui::AX_ROLE_RADIO_BUTTON:
- return ui::kAXRadioButtonClassname;
- case ui::AX_ROLE_TOGGLE_BUTTON:
- return ui::kAXToggleButtonClassname;
- case ui::AX_ROLE_CANVAS:
- case ui::AX_ROLE_IMAGE:
- case ui::AX_ROLE_SVG_ROOT:
- return ui::kAXImageClassname;
- case ui::AX_ROLE_METER:
- case ui::AX_ROLE_PROGRESS_INDICATOR:
- return ui::kAXProgressBarClassname;
- case ui::AX_ROLE_TAB_LIST:
- return ui::kAXTabWidgetClassname;
- case ui::AX_ROLE_GRID:
- case ui::AX_ROLE_TREE_GRID:
- case ui::AX_ROLE_TABLE:
- return ui::kAXGridViewClassname;
- case ui::AX_ROLE_LIST:
- case ui::AX_ROLE_LIST_BOX:
- case ui::AX_ROLE_DESCRIPTION_LIST:
- return ui::kAXListViewClassname;
- case ui::AX_ROLE_DIALOG:
- return ui::kAXDialogClassname;
- case ui::AX_ROLE_ROOT_WEB_AREA:
- return has_parent ? ui::kAXViewClassname : ui::kAXWebViewClassname;
- case ui::AX_ROLE_MENU_ITEM:
- case ui::AX_ROLE_MENU_ITEM_CHECK_BOX:
- case ui::AX_ROLE_MENU_ITEM_RADIO:
- return ui::kAXMenuItemClassname;
+ case AX_ROLE_SEARCH_BOX:
+ case AX_ROLE_SPIN_BUTTON:
+ case AX_ROLE_TEXT_FIELD:
+ return kAXEditTextClassname;
+ case AX_ROLE_SLIDER:
+ return kAXSeekBarClassname;
+ case AX_ROLE_COLOR_WELL:
+ case AX_ROLE_COMBO_BOX:
+ case AX_ROLE_DATE:
+ case AX_ROLE_POP_UP_BUTTON:
+ case AX_ROLE_INPUT_TIME:
+ return kAXSpinnerClassname;
+ case AX_ROLE_BUTTON:
+ case AX_ROLE_MENU_BUTTON:
+ return kAXButtonClassname;
+ case AX_ROLE_CHECK_BOX:
+ case AX_ROLE_SWITCH:
+ return kAXCheckBoxClassname;
+ case AX_ROLE_RADIO_BUTTON:
+ return kAXRadioButtonClassname;
+ case AX_ROLE_TOGGLE_BUTTON:
+ return kAXToggleButtonClassname;
+ case AX_ROLE_CANVAS:
+ case AX_ROLE_IMAGE:
+ case AX_ROLE_SVG_ROOT:
+ return kAXImageClassname;
+ case AX_ROLE_METER:
+ case AX_ROLE_PROGRESS_INDICATOR:
+ return kAXProgressBarClassname;
+ case AX_ROLE_TAB_LIST:
+ return kAXTabWidgetClassname;
+ case AX_ROLE_GRID:
+ case AX_ROLE_TREE_GRID:
+ case AX_ROLE_TABLE:
+ return kAXGridViewClassname;
+ case AX_ROLE_LIST:
+ case AX_ROLE_LIST_BOX:
+ case AX_ROLE_DESCRIPTION_LIST:
+ return kAXListViewClassname;
+ case AX_ROLE_DIALOG:
+ return kAXDialogClassname;
+ case AX_ROLE_ROOT_WEB_AREA:
+ return has_parent ? kAXViewClassname : kAXWebViewClassname;
+ case AX_ROLE_MENU_ITEM:
+ case AX_ROLE_MENU_ITEM_CHECK_BOX:
+ case AX_ROLE_MENU_ITEM_RADIO:
+ return kAXMenuItemClassname;
default:
- return ui::kAXViewClassname;
+ return kAXViewClassname;
}
}
@@ -372,7 +371,7 @@ std::unique_ptr<AXSnapshotNodeAndroid>
AXSnapshotNodeAndroid::WalkAXTreeDepthFirst(
const AXNode* node,
gfx::Rect rect,
- const ui::AXTreeUpdate& update,
+ const AXTreeUpdate& update,
const AXTree* tree,
AXSnapshotNodeAndroid::WalkAXTreeConfig& config) {
auto result =
@@ -390,21 +389,20 @@ AXSnapshotNodeAndroid::WalkAXTreeDepthFirst(
result->line_through = 0;
result->underline = 0;
- if (node->data().HasFloatAttribute(ui::AX_ATTR_FONT_SIZE)) {
+ if (node->data().HasFloatAttribute(AX_ATTR_FONT_SIZE)) {
gfx::RectF text_size_rect(
- 0, 0, 1, node->data().GetFloatAttribute(ui::AX_ATTR_FONT_SIZE));
+ 0, 0, 1, node->data().GetFloatAttribute(AX_ATTR_FONT_SIZE));
gfx::Rect scaled_text_size_rect =
gfx::ToEnclosingRect(tree->RelativeToTreeBounds(node, text_size_rect));
result->text_size = scaled_text_size_rect.height();
- const int text_style = node->data().GetIntAttribute(ui::AX_ATTR_TEXT_STYLE);
- result->color = node->data().GetIntAttribute(ui::AX_ATTR_COLOR);
- result->bgcolor =
- node->data().GetIntAttribute(ui::AX_ATTR_BACKGROUND_COLOR);
- result->bold = (text_style & ui::AX_TEXT_STYLE_BOLD) != 0;
- result->italic = (text_style & ui::AX_TEXT_STYLE_ITALIC) != 0;
- result->line_through = (text_style & ui::AX_TEXT_STYLE_LINE_THROUGH) != 0;
- result->underline = (text_style & ui::AX_TEXT_STYLE_UNDERLINE) != 0;
+ const int text_style = node->data().GetIntAttribute(AX_ATTR_TEXT_STYLE);
+ result->color = node->data().GetIntAttribute(AX_ATTR_COLOR);
+ result->bgcolor = node->data().GetIntAttribute(AX_ATTR_BACKGROUND_COLOR);
+ result->bold = (text_style & AX_TEXT_STYLE_BOLD) != 0;
+ result->italic = (text_style & AX_TEXT_STYLE_ITALIC) != 0;
+ result->line_through = (text_style & AX_TEXT_STYLE_LINE_THROUGH) != 0;
+ result->underline = (text_style & AX_TEXT_STYLE_UNDERLINE) != 0;
}
const gfx::Rect& absolute_rect =
diff --git a/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.h b/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.h
index 7314a2e0e03..be01b51bcee 100644
--- a/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.h
+++ b/chromium/ui/accessibility/platform/ax_snapshot_node_android_platform.h
@@ -71,7 +71,7 @@ struct AXSnapshotNodeAndroid {
static std::unique_ptr<AXSnapshotNodeAndroid> WalkAXTreeDepthFirst(
const AXNode* node,
gfx::Rect rect,
- const ui::AXTreeUpdate& update,
+ const AXTreeUpdate& update,
const AXTree* tree,
WalkAXTreeConfig& config);
diff --git a/chromium/ui/accessibility/platform/ax_system_caret_win.cc b/chromium/ui/accessibility/platform/ax_system_caret_win.cc
index d09bc04b8f7..b4a1d38c872 100644
--- a/chromium/ui/accessibility/platform/ax_system_caret_win.cc
+++ b/chromium/ui/accessibility/platform/ax_system_caret_win.cc
@@ -55,8 +55,8 @@ const AXNodeData& AXSystemCaretWin::GetData() const {
return data_;
}
-const ui::AXTreeData& AXSystemCaretWin::GetTreeData() const {
- CR_DEFINE_STATIC_LOCAL(ui::AXTreeData, empty_data, ());
+const AXTreeData& AXSystemCaretWin::GetTreeData() const {
+ CR_DEFINE_STATIC_LOCAL(AXTreeData, empty_data, ());
return empty_data;
}
@@ -103,8 +103,7 @@ AXSystemCaretWin::GetTargetForNativeAccessibilityEvent() {
return event_target_;
}
-bool AXSystemCaretWin::AccessibilityPerformAction(
- const ui::AXActionData& data) {
+bool AXSystemCaretWin::AccessibilityPerformAction(const AXActionData& data) {
return false;
}
diff --git a/chromium/ui/accessibility/platform/ax_system_caret_win.h b/chromium/ui/accessibility/platform/ax_system_caret_win.h
index ec093e48e29..6c2d51dfdf8 100644
--- a/chromium/ui/accessibility/platform/ax_system_caret_win.h
+++ b/chromium/ui/accessibility/platform/ax_system_caret_win.h
@@ -35,7 +35,7 @@ class AX_EXPORT AXSystemCaretWin : private AXPlatformNodeDelegate {
private:
// |AXPlatformNodeDelegate| members.
const AXNodeData& GetData() const override;
- const ui::AXTreeData& GetTreeData() const override;
+ const AXTreeData& GetTreeData() const override;
gfx::NativeWindow GetTopLevelWidget() override;
gfx::NativeViewAccessible GetParent() override;
int GetChildCount() override;
@@ -43,9 +43,9 @@ class AX_EXPORT AXSystemCaretWin : private AXPlatformNodeDelegate {
gfx::Rect GetScreenBoundsRect() const override;
gfx::NativeViewAccessible HitTestSync(int x, int y) override;
gfx::NativeViewAccessible GetFocus() override;
- ui::AXPlatformNode* GetFromNodeID(int32_t id) override;
+ AXPlatformNode* GetFromNodeID(int32_t id) override;
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
- bool AccessibilityPerformAction(const ui::AXActionData& data) override;
+ bool AccessibilityPerformAction(const AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override;
AXPlatformNodeWin* caret_;
diff --git a/chromium/ui/accessibility/platform/test_ax_node_wrapper.cc b/chromium/ui/accessibility/platform/test_ax_node_wrapper.cc
index e0b153ef512..bfb7b4f1d99 100644
--- a/chromium/ui/accessibility/platform/test_ax_node_wrapper.cc
+++ b/chromium/ui/accessibility/platform/test_ax_node_wrapper.cc
@@ -24,8 +24,8 @@ class TestAXTreeDelegate : public AXTreeDelegate {
const AXNodeData& old_node_data,
const AXNodeData& new_node_data) override {}
void OnTreeDataChanged(AXTree* tree,
- const ui::AXTreeData& old_data,
- const ui::AXTreeData& new_data) override {}
+ const AXTreeData& old_data,
+ const AXTreeData& new_data) override {}
void OnNodeWillBeDeleted(AXTree* tree, AXNode* node) override {
auto iter = g_node_to_wrapper_map.find(node);
if (iter != g_node_to_wrapper_map.end()) {
@@ -76,7 +76,7 @@ const AXNodeData& TestAXNodeWrapper::GetData() const {
return node_->data();
}
-const ui::AXTreeData& TestAXNodeWrapper::GetTreeData() const {
+const AXTreeData& TestAXNodeWrapper::GetTreeData() const {
return tree_->data();
}
@@ -171,8 +171,7 @@ TestAXNodeWrapper::GetTargetForNativeAccessibilityEvent() {
return gfx::kNullAcceleratedWidget;
}
-bool TestAXNodeWrapper::AccessibilityPerformAction(
- const ui::AXActionData& data) {
+bool TestAXNodeWrapper::AccessibilityPerformAction(const AXActionData& data) {
return true;
}
diff --git a/chromium/ui/accessibility/platform/test_ax_node_wrapper.h b/chromium/ui/accessibility/platform/test_ax_node_wrapper.h
index 9ce258e31ed..a65b0c05281 100644
--- a/chromium/ui/accessibility/platform/test_ax_node_wrapper.h
+++ b/chromium/ui/accessibility/platform/test_ax_node_wrapper.h
@@ -32,7 +32,7 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegate {
// AXPlatformNodeDelegate.
const AXNodeData& GetData() const override;
- const ui::AXTreeData& GetTreeData() const override;
+ const AXTreeData& GetTreeData() const override;
gfx::NativeWindow GetTopLevelWidget() override;
gfx::NativeViewAccessible GetParent() override;
int GetChildCount() override;
@@ -40,9 +40,9 @@ class TestAXNodeWrapper : public AXPlatformNodeDelegate {
gfx::Rect GetScreenBoundsRect() const override;
gfx::NativeViewAccessible HitTestSync(int x, int y) override;
gfx::NativeViewAccessible GetFocus() override;
- ui::AXPlatformNode* GetFromNodeID(int32_t id) override;
+ AXPlatformNode* GetFromNodeID(int32_t id) override;
gfx::AcceleratedWidget GetTargetForNativeAccessibilityEvent() override;
- bool AccessibilityPerformAction(const ui::AXActionData& data) override;
+ bool AccessibilityPerformAction(const AXActionData& data) override;
bool ShouldIgnoreHoveredStateForTesting() override;
private: