summaryrefslogtreecommitdiffstats
path: root/accessible/base/ARIAMap.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /accessible/base/ARIAMap.cpp
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz
firefox-adbda400be353e676059e335c3c0aaf99e719475.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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: