Chromium Code Reviews| Index: Source/modules/accessibility/AXObject.cpp |
| diff --git a/Source/modules/accessibility/AXObject.cpp b/Source/modules/accessibility/AXObject.cpp |
| index 301c43574572699b9ae04c7ab1d163555605a9ca..265063ef975d69b433df499543931813bbe55d57 100644 |
| --- a/Source/modules/accessibility/AXObject.cpp |
| +++ b/Source/modules/accessibility/AXObject.cpp |
| @@ -40,6 +40,7 @@ |
| #include "modules/accessibility/AXObjectCacheImpl.h" |
| #include "platform/UserGestureIndicator.h" |
| #include "platform/text/PlatformLocale.h" |
| +#include "wtf/HashSet.h" |
| #include "wtf/StdLibExtras.h" |
| #include "wtf/text/WTFString.h" |
| @@ -51,6 +52,7 @@ using namespace HTMLNames; |
| namespace { |
| typedef HashMap<String, AccessibilityRole, CaseFoldingHash> ARIARoleMap; |
| +typedef HashSet<String, CaseFoldingHash> ARIAWidgetSet; |
| struct RoleEntry { |
| const char* ariaRole; |
| @@ -143,6 +145,91 @@ static Vector<AtomicString>* createRoleNameVector() |
| return roleNameVector; |
| } |
| +/* FIXME -- seems like this would be a more natural way to list the roles, |
| + but this generates a "needs global destructor" error. |
|
dmazzoni
2015/01/30 07:30:41
Did you try const char* instead of String?
Donn Denman
2015/02/02 19:31:14
That worked, thanks -- don't know why I didn't thi
|
| +const String ariaWidgets[] = { |
| + // From http://www.w3.org/TR/wai-aria/roles#widget_roles |
| + "alert", |
| + "alertdialog", |
| + "button", |
| + "checkbox", |
| + "dialog", |
| + "gridcell", |
| + "link", |
| + "log", |
| + "marquee", |
| + "menuitem", |
| + "menuitemcheckbox", |
| + "menuitemradio", |
| + "option", |
| + "progressbar", |
| + "radio", |
| + "scrollbar", |
| + "slider", |
| + "spinbutton", |
| + "status", |
| + "tab", |
| + "tabpanel", |
| + "textbox", |
| + "timer", |
| + "tooltip", |
| + "treeitem", |
| + //The following roles act as composite user interface widgets. These roles typically act as containers that manage other, contained widgets. |
| + "combobox", |
| + "grid", |
| + "listbox", |
| + "menu", |
| + "menubar", |
| + "radiogroup", |
| + "tablist", |
| + "tree", |
| + "treegrid" |
| +}; |
| +*/ |
| + |
| +static ARIAWidgetSet* createARIARoleWidgetSet() |
| +{ |
| + ARIAWidgetSet* widgetSet = new HashSet<String, CaseFoldingHash>(); |
| + |
| + // From http://www.w3.org/TR/wai-aria/roles#widget_roles |
| + widgetSet->add("alert"); |
| + widgetSet->add("alertdialog"); |
| + widgetSet->add("button"); |
| + widgetSet->add("checkbox"); |
| + widgetSet->add("dialog"); |
| + widgetSet->add("gridcell"); |
| + widgetSet->add("link"); |
| + widgetSet->add("log"); |
| + widgetSet->add("marquee"); |
| + widgetSet->add("menuitem"); |
| + widgetSet->add("menuitemcheckbox"); |
| + widgetSet->add("menuitemradio"); |
| + widgetSet->add("option"); |
| + widgetSet->add("progressbar"); |
| + widgetSet->add("radio"); |
| + widgetSet->add("scrollbar"); |
| + widgetSet->add("slider"); |
| + widgetSet->add("spinbutton"); |
| + widgetSet->add("status"); |
| + widgetSet->add("tab"); |
| + widgetSet->add("tabpanel"); |
| + widgetSet->add("textbox"); |
| + widgetSet->add("timer"); |
| + widgetSet->add("tooltip"); |
| + widgetSet->add("treeitem"); |
| + // The following roles act as composite user interface widgets. These roles typically act as containers that manage other, contained widgets. |
| + widgetSet->add("combobox"); |
| + widgetSet->add("grid"); |
| + widgetSet->add("menu"); |
| + widgetSet->add("menubar"); |
| + widgetSet->add("radiogroup"); |
| + widgetSet->add("tablist"); |
| + widgetSet->add("tree"); |
| + widgetSet->add("treegrid"); |
| + |
| + return widgetSet; |
| +} |
| + |
| } // namespace |
| AXObject::AXObject(AXObjectCacheImpl* axObjectCache) |
| @@ -956,6 +1043,22 @@ AccessibilityRole AXObject::ariaRoleToWebCoreRole(const String& value) |
| return role; |
| } |
| +bool AXObject::includesARIAWidgetRole(const String& role) |
| +{ |
| + static const HashSet<String, CaseFoldingHash>* roleSet = createARIARoleWidgetSet(); |
| + |
| + Vector<String> roleVector; |
| + role.split(' ', roleVector); |
| + unsigned size = roleVector.size(); |
| + for (unsigned i = 0; i < size; ++i) { |
| + String roleName = roleVector[i]; |
| + if (roleSet->contains(roleName)) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| AccessibilityRole AXObject::buttonRoleType() const |
| { |
| // If aria-pressed is present, then it should be exposed as a toggle button. |