Index: Source/modules/accessibility/AXObject.cpp |
diff --git a/Source/modules/accessibility/AXObject.cpp b/Source/modules/accessibility/AXObject.cpp |
index d4d99c2affaec06beb3b5ba635a6332c91b0ebb0..0ff6324709296111937c24e39865e5582bff5442 100644 |
--- a/Source/modules/accessibility/AXObject.cpp |
+++ b/Source/modules/accessibility/AXObject.cpp |
@@ -49,6 +49,7 @@ namespace blink { |
using namespace HTMLNames; |
+namespace { |
typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap; |
struct RoleEntry { |
@@ -56,9 +57,9 @@ struct RoleEntry { |
AccessibilityRole webcoreRole; |
}; |
-static ARIARoleMap* createARIARoleMap() |
+void fillRoles(Vector<RoleEntry>* rolesVector) |
{ |
- const RoleEntry roles[] = { |
+ RoleEntry roles[] = { |
adamk
2014/12/17 22:52:46
seems like this could just be a file-level static
aboxhall
2014/12/19 00:02:08
Done.
|
{ "alert", AlertRole }, |
{ "alertdialog", AlertDialogRole }, |
{ "application", ApplicationRole }, |
@@ -86,7 +87,6 @@ static ARIARoleMap* createARIARoleMap() |
{ "listitem", ListItemRole }, |
{ "listbox", ListBoxRole }, |
{ "log", LogRole }, |
- // "option" isn't here because it may map to different roles depending on the parent element's role |
{ "main", MainRole }, |
{ "marquee", MarqueeRole }, |
{ "math", MathRole }, |
@@ -123,13 +123,41 @@ static ARIARoleMap* createARIARoleMap() |
{ "treegrid", TreeGridRole }, |
{ "treeitem", TreeItemRole } |
}; |
+ size_t numRoles = WTF_ARRAY_LENGTH(roles); |
+ rolesVector->resize(numRoles); |
+ for (size_t i = 0; i < numRoles; ++i) |
+ rolesVector->at(i) = roles[i]; |
+} |
+ |
+static ARIARoleMap* createARIARoleMap() |
+{ |
ARIARoleMap* roleMap = new ARIARoleMap; |
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(roles); ++i) |
+ Vector<RoleEntry> roles; |
+ fillRoles(&roles); |
+ for (size_t i = 0; i < roles.size(); ++i) |
adamk
2014/12/17 22:52:46
This loop could stay a loop over the file-static a
aboxhall
2014/12/19 00:02:08
Done.
|
roleMap->set(roles[i].ariaRole, roles[i].webcoreRole); |
return roleMap; |
} |
+static Vector<AtomicString>* createRoleNameVector() |
adamk
2014/12/17 17:47:00
I suggested an alternative to the vector, but didn
aboxhall
2014/12/18 04:34:47
Acknowledged.
|
+{ |
+ Vector<AtomicString>* roleNameVector = new Vector<AtomicString>; |
+ roleNameVector->resize(NumRoles); |
adamk
2014/12/17 22:52:46
You can just use:
new Vector<AtomicString>(NumRol
aboxhall
2014/12/19 00:02:08
Oh yeah :)
|
+ for (int i = 0; i < NumRoles; i++) |
+ roleNameVector->at(i) = nullAtom; |
adamk
2014/12/17 22:52:46
Ah, this was what I missed the first time, that yo
aboxhall
2014/12/19 00:02:08
Oh yeah, and for good reason (as I found out when
|
+ |
+ Vector<RoleEntry> roles; |
+ fillRoles(&roles); |
+ |
+ for (size_t i = 0; i < roles.size(); ++i) |
adamk
2014/12/17 22:52:46
Same here as in createARIARoleMap, this could just
aboxhall
2014/12/19 00:02:08
Done.
|
+ (*roleNameVector)[roles[i].webcoreRole] = AtomicString(roles[i].ariaRole); |
+ |
+ return roleNameVector; |
+} |
+ |
+} // namespace |
+ |
AXObject::AXObject(AXObjectCacheImpl* axObjectCache) |
: m_id(0) |
, m_haveChildren(false) |
@@ -954,4 +982,11 @@ AccessibilityRole AXObject::buttonRoleType() const |
return ButtonRole; |
} |
+const AtomicString& AXObject::roleName(AccessibilityRole role) |
+{ |
+ static const Vector<AtomicString>* roleNameVector = createRoleNameVector(); |
+ |
+ return roleNameVector->at(role); |
+} |
+ |
} // namespace blink |