From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- accessible/base/ARIAMap.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'accessible/base/ARIAMap.cpp') 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 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: -- cgit v1.2.3