Commit 664b9da8 authored by Martin Robinson's avatar Martin Robinson Committed by Commit Bot

Move IA2 attribute collection code to AXPlatformNodeBase

This will allow us to share this code with the Aura Linux implementation
in a future change. We also create a new abstract class to collect these
attributes while maintaining performance between the different
platforms. Currently there is only an implementation of this class for
Windows.

Bug: 866612
Change-Id: I5cb84b9f226e976ac2b199149ea897831a48d175
Reviewed-on: https://chromium-review.googlesource.com/1152977
Commit-Queue: Martin Robinson <mrobinson@igalia.com>
Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579353}
parent ab9952d0
...@@ -1689,4 +1689,11 @@ AtkAttributeSet* AXPlatformNodeAuraLinux::AddIntAttributeToAtkAttributeSet( ...@@ -1689,4 +1689,11 @@ AtkAttributeSet* AXPlatformNodeAuraLinux::AddIntAttributeToAtkAttributeSet(
return attributes; return attributes;
} }
void AXPlatformNodeAuraLinux::AddAttributeToList(
const char* name,
const char* value,
PlatformAttributeList* attributes) {
NOTREACHED();
}
} // namespace ui } // namespace ui
...@@ -90,6 +90,11 @@ class AXPlatformNodeAuraLinux : public AXPlatformNodeBase { ...@@ -90,6 +90,11 @@ class AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
void Init(AXPlatformNodeDelegate* delegate) override; void Init(AXPlatformNodeDelegate* delegate) override;
int GetIndexInParent() override; int GetIndexInParent() override;
protected:
void AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) override;
private: private:
enum AtkInterfaces { enum AtkInterfaces {
ATK_ACTION_INTERFACE, ATK_ACTION_INTERFACE,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ #ifndef UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_
#define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_ #define UI_ACCESSIBILITY_PLATFORM_AX_PLATFORM_NODE_BASE_H_
#include <string>
#include "base/macros.h" #include "base/macros.h"
#include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/platform/ax_platform_node.h" #include "ui/accessibility/platform/ax_platform_node.h"
...@@ -191,6 +193,46 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode { ...@@ -191,6 +193,46 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
// Sets the text selection in this object if possible. // Sets the text selection in this object if possible.
bool SetTextSelection(int start_offset, int end_offset); bool SetTextSelection(int start_offset, int end_offset);
// Compute the attributes exposed via platform accessibility objects and put
// them into an attribute list, |attributes|. Currently only used by
// IAccessible2 on Windows, but will soon be shared with other ports.
using PlatformAttributeList = std::vector<base::string16>;
void ComputeAttributes(PlatformAttributeList* attributes);
// If the string attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |name|.
void AddAttributeToList(const ax::mojom::StringAttribute attribute,
const char* name,
PlatformAttributeList* attributes);
// If the bool attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |name|.
void AddAttributeToList(const ax::mojom::BoolAttribute attribute,
const char* name,
PlatformAttributeList* attributes);
// If the int attribute |attribute| is present, add its value as an
// IAccessible2 attribute with the name |name|.
void AddAttributeToList(const ax::mojom::IntAttribute attribute,
const char* name,
PlatformAttributeList* attributes);
// A helper to add the given string value to |attributes|.
virtual void AddAttributeToList(const char* name,
const std::string& value,
PlatformAttributeList* attributes);
// A pure virtual method that subclasses use to actually add the attribute to
// |attributes|.
virtual void AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) = 0;
// Escapes characters in string attributes as required by the IA2 Spec
// and AT-SPI2. It's okay for input to be the same as output.
static void SanitizeStringAttribute(const std::string& input,
std::string* output);
private: private:
DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeBase); DISALLOW_COPY_AND_ASSIGN(AXPlatformNodeBase);
}; };
......
...@@ -29,6 +29,11 @@ class AXPlatformNodeMac : public AXPlatformNodeBase { ...@@ -29,6 +29,11 @@ class AXPlatformNodeMac : public AXPlatformNodeBase {
void Destroy() override; void Destroy() override;
int GetIndexInParent() override; int GetIndexInParent() override;
protected:
void AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) override;
private: private:
~AXPlatformNodeMac() override; ~AXPlatformNodeMac() override;
......
...@@ -1006,4 +1006,10 @@ bool IsNameExposedInAXValueForRole(ax::mojom::Role role) { ...@@ -1006,4 +1006,10 @@ bool IsNameExposedInAXValueForRole(ax::mojom::Role role) {
} }
} }
void AXPlatformNodeMac::AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) {
NOTREACHED();
}
} // namespace ui } // namespace ui
...@@ -925,6 +925,11 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) ...@@ -925,6 +925,11 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
// Convert from a IA2TextBoundaryType to a TextBoundaryType. // Convert from a IA2TextBoundaryType to a TextBoundaryType.
TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type); TextBoundaryType IA2TextBoundaryToTextBoundary(IA2TextBoundaryType type);
// A helper to add the given string value to |attributes|.
void AddAttributeToList(const char* name,
const char* value,
PlatformAttributeList* attributes) override;
private: private:
int MSAAEvent(ax::mojom::Event event); int MSAAEvent(ax::mojom::Event event);
bool IsWebAreaForPresentationalIframe(); bool IsWebAreaForPresentationalIframe();
...@@ -934,32 +939,9 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2")) ...@@ -934,32 +939,9 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute, HRESULT GetStringAttributeAsBstr(ax::mojom::StringAttribute attribute,
BSTR* value_bstr) const; 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.
static void SanitizeStringAttributeForIA2(const base::string16& input,
base::string16* output);
// Sets the selection given a start and end offset in IA2 Hypertext. // Sets the selection given a start and end offset in IA2 Hypertext.
void SetIA2HypertextSelection(LONG start_offset, LONG end_offset); void SetIA2HypertextSelection(LONG start_offset, LONG end_offset);
// 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,
ax::mojom::StringAttribute 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,
ax::mojom::BoolAttribute 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,
ax::mojom::IntAttribute attribute,
const char* ia2_attr);
// Escapes characters in string attributes as required by the UIA Aria // Escapes characters in string attributes as required by the UIA Aria
// Property Spec. It's okay for input to be the same as output. // Property Spec. It's okay for input to be the same as output.
static void SanitizeStringAttributeForUIAAriaProperty( static void SanitizeStringAttributeForUIAAriaProperty(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment