This source file includes following definitions.
- GetInstance
- IAccessibleRoleToString
- IAccessible2RoleToString
- IAccessibleStateToStringVector
- IAccessibleStateToString
- IAccessible2StateToStringVector
- IAccessible2StateToString
#include "content/browser/accessibility/accessibility_tree_formatter_utils_win.h"
#include <oleacc.h>
#include <map>
#include <string>
#include "base/memory/singleton.h"
#include "base/strings/string_util.h"
#include "third_party/iaccessible2/ia2_api_all.h"
namespace content {
namespace {
class AccessibilityRoleStateMap {
public:
static AccessibilityRoleStateMap* GetInstance();
std::map<int32, base::string16> ia_role_string_map;
std::map<int32, base::string16> ia2_role_string_map;
std::map<int32, base::string16> ia_state_string_map;
std::map<int32, base::string16> ia2_state_string_map;
private:
AccessibilityRoleStateMap();
virtual ~AccessibilityRoleStateMap() {}
friend struct DefaultSingletonTraits<AccessibilityRoleStateMap>;
DISALLOW_COPY_AND_ASSIGN(AccessibilityRoleStateMap);
};
AccessibilityRoleStateMap* AccessibilityRoleStateMap::GetInstance() {
return Singleton<AccessibilityRoleStateMap,
LeakySingletonTraits<AccessibilityRoleStateMap> >::get();
}
AccessibilityRoleStateMap::AccessibilityRoleStateMap() {
#define IA_ROLE_MAP(x) ia_role_string_map[x] = L#x; \
ia2_role_string_map[x] = L#x;
#define IA2_ROLE_MAP(x) ia2_role_string_map[x] = L#x;
#define IA_STATE_MAP(x) ia_state_string_map[STATE_SYSTEM_##x] = L#x;
#define IA2_STATE_MAP(x) ia2_state_string_map[x] = L#x;
IA_ROLE_MAP(ROLE_SYSTEM_ALERT)
IA_ROLE_MAP(ROLE_SYSTEM_ANIMATION)
IA_ROLE_MAP(ROLE_SYSTEM_APPLICATION)
IA_ROLE_MAP(ROLE_SYSTEM_BORDER)
IA_ROLE_MAP(ROLE_SYSTEM_BUTTONDROPDOWN)
IA_ROLE_MAP(ROLE_SYSTEM_BUTTONDROPDOWNGRID)
IA_ROLE_MAP(ROLE_SYSTEM_BUTTONMENU)
IA_ROLE_MAP(ROLE_SYSTEM_CARET)
IA_ROLE_MAP(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IA2_ROLE_MAP(IA2_ROLE_TEXT_FRAME)
IA2_ROLE_MAP(IA2_ROLE_TOGGLE_BUTTON)
IA2_ROLE_MAP(IA2_ROLE_UNKNOWN)
IA2_ROLE_MAP(IA2_ROLE_VIEW_PORT)
IA_STATE_MAP(ALERT_HIGH)
IA_STATE_MAP(ALERT_LOW)
IA_STATE_MAP(ALERT_MEDIUM)
IA_STATE_MAP(ANIMATED)
IA_STATE_MAP(BUSY)
IA_STATE_MAP(CHECKED)
IA_STATE_MAP(COLLAPSED)
IA_STATE_MAP(DEFAULT)
IA_STATE_MAP(EXPANDED)
IA_STATE_MAP(EXTSELECTABLE)
IA_STATE_MAP(FLOATING)
IA_STATE_MAP(FOCUSABLE)
IA_STATE_MAP(FOCUSED)
IA_STATE_MAP(HASPOPUP)
IA_STATE_MAP(HOTTRACKED)
IA_STATE_MAP(INVISIBLE)
IA_STATE_MAP(LINKED)
IA_STATE_MAP(MARQUEED)
IA_STATE_MAP(MIXED)
IA_STATE_MAP(MOVEABLE)
IA_STATE_MAP(MULTISELECTABLE)
IA_STATE_MAP(OFFSCREEN)
IA_STATE_MAP(PRESSED)
IA_STATE_MAP(PROTECTED)
IA_STATE_MAP(READONLY)
IA_STATE_MAP(SELECTABLE)
IA_STATE_MAP(SELECTED)
IA_STATE_MAP(SELFVOICING)
IA_STATE_MAP(SIZEABLE)
IA_STATE_MAP(TRAVERSED)
IA_STATE_MAP(UNAVAILABLE)
IA2_STATE_MAP(IA2_STATE_ACTIVE)
IA2_STATE_MAP(IA2_STATE_ARMED)
IA2_STATE_MAP(IA2_STATE_DEFUNCT)
IA2_STATE_MAP(IA2_STATE_EDITABLE)
IA2_STATE_MAP(IA2_STATE_ICONIFIED)
IA2_STATE_MAP(IA2_STATE_INVALID_ENTRY)
IA2_STATE_MAP(IA2_STATE_MANAGES_DESCENDANTS)
IA2_STATE_MAP(IA2_STATE_MODAL)
IA2_STATE_MAP(IA2_STATE_MULTI_LINE)
IA2_STATE_MAP(IA2_STATE_REQUIRED)
IA2_STATE_MAP(IA2_STATE_SELECTABLE_TEXT)
IA2_STATE_MAP(IA2_STATE_SINGLE_LINE)
IA2_STATE_MAP(IA2_STATE_STALE)
IA2_STATE_MAP(IA2_STATE_SUPPORTS_AUTOCOMPLETION)
IA2_STATE_MAP(IA2_STATE_TRANSIENT)
}
}
base::string16 IAccessibleRoleToString(int32 ia_role) {
return AccessibilityRoleStateMap::GetInstance()->ia_role_string_map[ia_role];
}
base::string16 IAccessible2RoleToString(int32 ia_role) {
return AccessibilityRoleStateMap::GetInstance()->ia2_role_string_map[ia_role];
}
void IAccessibleStateToStringVector(int32 ia_state,
std::vector<base::string16>* result) {
const std::map<int32, base::string16>& state_string_map =
AccessibilityRoleStateMap::GetInstance()->ia_state_string_map;
std::map<int32, base::string16>::const_iterator it;
for (it = state_string_map.begin(); it != state_string_map.end(); ++it) {
if (it->first & ia_state)
result->push_back(it->second);
}
}
base::string16 IAccessibleStateToString(int32 ia_state) {
std::vector<base::string16> strings;
IAccessibleStateToStringVector(ia_state, &strings);
return JoinString(strings, ',');
}
void IAccessible2StateToStringVector(int32 ia2_state,
std::vector<base::string16>* result) {
const std::map<int32, base::string16>& state_string_map =
AccessibilityRoleStateMap::GetInstance()->ia2_state_string_map;
std::map<int32, base::string16>::const_iterator it;
for (it = state_string_map.begin(); it != state_string_map.end(); ++it) {
if (it->first & ia2_state)
result->push_back(it->second);
}
}
base::string16 IAccessible2StateToString(int32 ia2_state) {
std::vector<base::string16> strings;
IAccessible2StateToStringVector(ia2_state, &strings);
return JoinString(strings, ',');
}
}