зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1820389: Gracefully handle unknown ARIA roles. r=eeejay,decoder
Differential Revision: https://phabricator.services.mozilla.com/D173651
This commit is contained in:
Родитель
98397ff4ea
Коммит
e0f1b9cd7d
|
@ -1470,10 +1470,22 @@ uint8_t aria::GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMapEntry) {
|
|||
} else if (aRoleMapEntry == &sLandmarkRoleMap) {
|
||||
return LANDMARK_ROLE_MAP_ENTRY_INDEX;
|
||||
} else {
|
||||
return aRoleMapEntry - sWAIRoleMaps;
|
||||
uint8_t index = aRoleMapEntry - sWAIRoleMaps;
|
||||
MOZ_ASSERT(aria::IsRoleMapIndexValid(index));
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
bool aria::IsRoleMapIndexValid(uint8_t aRoleMapIndex) {
|
||||
switch (aRoleMapIndex) {
|
||||
case NO_ROLE_MAP_ENTRY_INDEX:
|
||||
case EMPTY_ROLE_MAP_ENTRY_INDEX:
|
||||
case LANDMARK_ROLE_MAP_ENTRY_INDEX:
|
||||
return true;
|
||||
}
|
||||
return aRoleMapIndex < ArrayLength(sWAIRoleMaps);
|
||||
}
|
||||
|
||||
uint64_t aria::UniversalStatesFor(mozilla::dom::Element* aElement) {
|
||||
uint64_t state = 0;
|
||||
uint32_t index = 0;
|
||||
|
|
|
@ -266,6 +266,11 @@ const nsRoleMapEntry* GetRoleMapFromIndex(uint8_t aRoleMapIndex);
|
|||
*/
|
||||
uint8_t GetIndexFromRoleMap(const nsRoleMapEntry* aRoleMap);
|
||||
|
||||
/**
|
||||
* Determine whether a role map entry index is valid.
|
||||
*/
|
||||
bool IsRoleMapIndexValid(uint8_t aRoleMapIndex);
|
||||
|
||||
/**
|
||||
* Return accessible state from ARIA universal states applied to the given
|
||||
* element.
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "ARIAMap.h"
|
||||
#include "CachedTableAccessible.h"
|
||||
#include "DocAccessibleParent.h"
|
||||
#include "mozilla/a11y/Platform.h"
|
||||
|
@ -196,6 +197,10 @@ uint32_t DocAccessibleParent::AddSubtree(
|
|||
aParent->AddChildAt(aIdxInParent, newProxy);
|
||||
newProxy->SetParent(aParent);
|
||||
} else {
|
||||
if (!aria::IsRoleMapIndexValid(newChild.RoleMapEntryIndex())) {
|
||||
MOZ_ASSERT_UNREACHABLE("Invalid role map entry index");
|
||||
return 0;
|
||||
}
|
||||
newProxy = new RemoteAccessible(
|
||||
newChild.ID(), aParent, this, newChild.Role(), newChild.Type(),
|
||||
newChild.GenericTypes(), newChild.RoleMapEntryIndex());
|
||||
|
|
Загрузка…
Ссылка в новой задаче