Bug 1804186: Use RelationType in mReverseRelations map instead of uint64_t r=nlapre

Differential Revision: https://phabricator.services.mozilla.com/D164268
This commit is contained in:
Morgan Rae Reschenberg 2022-12-16 23:08:43 +00:00
Родитель 160dde8228
Коммит 8ca309681e
2 изменённых файлов: 7 добавлений и 10 удалений

Просмотреть файл

@ -343,7 +343,7 @@ class DocAccessibleParent : public RemoteAccessible,
// Tracks cached reverse relations (ie. those not set explicitly by an
// attribute like aria-labelledby) for accessibles in this doc. This map is of
// the form: {accID, {relationType, [targetAccID, targetAccID, ...]}}
nsTHashMap<uint64_t, nsTHashMap<uint64_t, nsTArray<uint64_t>>>
nsTHashMap<uint64_t, nsTHashMap<RelationType, nsTArray<uint64_t>>>
mReverseRelations;
// Computed from the viewport cache, the accs referenced by these ids

Просмотреть файл

@ -839,8 +839,7 @@ Relation RemoteAccessibleBase<Derived>::RelationByType(
}
if (auto accRelMapEntry = mDoc->mReverseRelations.Lookup(ID())) {
if (auto reverseIdsEntry =
accRelMapEntry.Data().Lookup(static_cast<uint64_t>(aType))) {
if (auto reverseIdsEntry = accRelMapEntry.Data().Lookup(aType)) {
rel.AppendIter(new RemoteAccIterator(reverseIdsEntry.Data(), Document()));
}
}
@ -934,8 +933,8 @@ nsTArray<bool> RemoteAccessibleBase<Derived>::PreProcessRelations(
// we know the acc and `this` are still alive in the doc. If we hit
// the following assert, we don't have parity on implicit/explicit
// rels and something is wrong.
nsTArray<uint64_t>& reverseRelIDs = reverseRels->LookupOrInsert(
static_cast<uint64_t>(data.mReverseType));
nsTArray<uint64_t>& reverseRelIDs =
reverseRels->LookupOrInsert(data.mReverseType);
// There might be other reverse relations stored for this acc, so
// remove our ID instead of deleting the array entirely.
DebugOnly<bool> removed = reverseRelIDs.RemoveElement(ID());
@ -967,10 +966,9 @@ void RemoteAccessibleBase<Derived>::PostProcessRelations(
const nsTArray<uint64_t>& newIDs =
*mCachedFields->GetAttribute<nsTArray<uint64_t>>(data.mAtom);
for (uint64_t id : newIDs) {
nsTHashMap<nsUint64HashKey, nsTArray<uint64_t>>& relations =
nsTHashMap<RelationType, nsTArray<uint64_t>>& relations =
Document()->mReverseRelations.LookupOrInsert(id);
nsTArray<uint64_t>& ids =
relations.LookupOrInsert(static_cast<uint64_t>(data.mReverseType));
nsTArray<uint64_t>& ids = relations.LookupOrInsert(data.mReverseType);
ids.AppendElement(ID());
}
}
@ -985,8 +983,7 @@ void RemoteAccessibleBase<Derived>::PruneRelationsOnShutdown() {
}
for (auto const& data : kRelationTypeAtoms) {
// Fetch the list of targets for this reverse relation
auto reverseTargetList =
reverseRels->Lookup(static_cast<uint64_t>(data.mReverseType));
auto reverseTargetList = reverseRels->Lookup(data.mReverseType);
if (!reverseTargetList) {
continue;
}