summaryrefslogtreecommitdiffstats
path: root/accessible/base/ARIAMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'accessible/base/ARIAMap.cpp')
-rw-r--r--accessible/base/ARIAMap.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/accessible/base/ARIAMap.cpp b/accessible/base/ARIAMap.cpp
index 01cc5d0417..bfc41db82e 100644
--- a/accessible/base/ARIAMap.cpp
+++ b/accessible/base/ARIAMap.cpp
@@ -733,7 +733,7 @@ static const nsRoleMapEntry sWAIRoleMaps[] = {
},
{ // grid
nsGkAtoms::grid,
- roles::TABLE,
+ roles::GRID,
kUseMapRole,
eNoValue,
eNoAction,
@@ -1480,7 +1480,8 @@ const nsRoleMapEntry* aria::GetRoleMap(dom::Element* aEl) {
return GetRoleMapFromIndex(GetRoleMapIndex(aEl));
}
-uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
+uint8_t aria::GetFirstValidRoleMapIndexExcluding(
+ dom::Element* aEl, std::initializer_list<nsStaticAtom*> aRolesToSkip) {
nsAutoString roles;
if (!aEl || !nsAccUtils::GetARIAAttr(aEl, nsGkAtoms::role, roles) ||
roles.IsEmpty()) {
@@ -1492,6 +1493,19 @@ uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
while (tokenizer.hasMoreTokens()) {
// Do a binary search through table for the next role in role list
const nsDependentSubstring role = tokenizer.nextToken();
+
+ // Skip any roles that we aren't interested in.
+ bool shouldSkip = false;
+ for (nsStaticAtom* atomRole : aRolesToSkip) {
+ if (role.Equals(atomRole->GetUTF16String())) {
+ shouldSkip = true;
+ break;
+ }
+ }
+ if (shouldSkip) {
+ continue;
+ }
+
size_t idx;
auto comparator = [&role](const nsRoleMapEntry& aEntry) {
return Compare(role, aEntry.ARIARoleString(),
@@ -1508,6 +1522,11 @@ uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
}
+uint8_t aria::GetRoleMapIndex(dom::Element* aEl) {
+ // Get the rolemap index of the first valid role, excluding nothing.
+ return GetFirstValidRoleMapIndexExcluding(aEl, {});
+}
+
const nsRoleMapEntry* aria::GetRoleMapFromIndex(uint8_t aRoleMapIndex) {
switch (aRoleMapIndex) {
case NO_ROLE_MAP_ENTRY_INDEX: