mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 14:52:16 +00:00
Bug 1774043: [Part 3] Make remote ::Relations and ::RelationByType functions to use cache r=Jamie
Differential Revision: https://phabricator.services.mozilla.com/D152102
This commit is contained in:
parent
2cd46a7d14
commit
8180b70ae7
@ -626,6 +626,50 @@ LayoutDeviceIntRect RemoteAccessibleBase<Derived>::Bounds() const {
|
||||
return BoundsWithOffset(Nothing());
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
nsTArray<RemoteAccessible*> RemoteAccessibleBase<Derived>::RelationByType(
|
||||
RelationType aType) const {
|
||||
nsTArray<RemoteAccessible*> accs;
|
||||
|
||||
if (!mCachedFields) {
|
||||
return accs;
|
||||
}
|
||||
|
||||
for (auto data : kRelationTypeAtoms) {
|
||||
if (data.mType != aType ||
|
||||
(data.mValidTag && TagName() != data.mValidTag)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto maybeIds =
|
||||
mCachedFields->GetAttribute<nsTArray<uint64_t>>(data.mAtom)) {
|
||||
for (uint64_t id : *maybeIds) {
|
||||
if (RemoteAccessible* acc = mDoc->GetAccessible(id)) {
|
||||
accs.AppendElement(acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Each relation type has only one relevant cached attribute,
|
||||
// so break after we've handled the attr for this type,
|
||||
// even if we didn't find any targets.
|
||||
break;
|
||||
}
|
||||
|
||||
if (auto accRelMapEntry = mDoc->mReverseRelations.Lookup(ID())) {
|
||||
if (auto reverseIdsEntry =
|
||||
accRelMapEntry.Data().Lookup(static_cast<uint64_t>(aType))) {
|
||||
nsTArray<uint64_t>& reverseIds = reverseIdsEntry.Data();
|
||||
for (uint64_t id : reverseIds) {
|
||||
if (RemoteAccessible* acc = mDoc->GetAccessible(id)) {
|
||||
accs.AppendElement(acc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return accs;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void RemoteAccessibleBase<Derived>::AppendTextTo(nsAString& aText,
|
||||
uint32_t aStartOffset,
|
||||
|
@ -183,6 +183,8 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
|
||||
|
||||
virtual nsRect BoundsInAppUnits() const override;
|
||||
|
||||
virtual nsTArray<RemoteAccessible*> RelationByType(RelationType aType) const;
|
||||
|
||||
virtual uint64_t State() override;
|
||||
|
||||
virtual already_AddRefed<AccAttributes> Attributes() override;
|
||||
|
@ -51,13 +51,8 @@ virtual already_AddRefed<AccAttributes> Attributes() override;
|
||||
/**
|
||||
* Return set of targets of given relation type.
|
||||
*/
|
||||
nsTArray<RemoteAccessible*> RelationByType(RelationType aType) const;
|
||||
|
||||
/**
|
||||
* Get all relations for this accessible.
|
||||
*/
|
||||
void Relations(nsTArray<RelationType>* aTypes,
|
||||
nsTArray<nsTArray<RemoteAccessible*>>* aTargetSets) const;
|
||||
virtual nsTArray<RemoteAccessible*> RelationByType(
|
||||
RelationType aType) const override;
|
||||
|
||||
bool IsSearchbox() const;
|
||||
|
||||
|
@ -78,6 +78,10 @@ already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
|
||||
|
||||
nsTArray<RemoteAccessible*> RemoteAccessible::RelationByType(
|
||||
RelationType aType) const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::RelationByType(aType);
|
||||
}
|
||||
|
||||
nsTArray<uint64_t> targetIDs;
|
||||
Unused << mDoc->SendRelationByType(mID, static_cast<uint32_t>(aType),
|
||||
&targetIDs);
|
||||
|
@ -77,6 +77,12 @@ class RemoteAccessible : public RemoteAccessibleBase<RemoteAccessible> {
|
||||
|
||||
virtual bool TableIsProbablyForLayout() override;
|
||||
|
||||
/**
|
||||
* Get all relations for this accessible.
|
||||
*/
|
||||
void Relations(nsTArray<RelationType>* aTypes,
|
||||
nsTArray<nsTArray<RemoteAccessible*>>* aTargetSets) const;
|
||||
|
||||
protected:
|
||||
explicit RemoteAccessible(DocAccessibleParent* aThisAsDoc)
|
||||
: RemoteAccessibleBase(aThisAsDoc) {
|
||||
|
@ -392,6 +392,10 @@ already_AddRefed<AccAttributes> RemoteAccessible::Attributes() {
|
||||
|
||||
nsTArray<RemoteAccessible*> RemoteAccessible::RelationByType(
|
||||
RelationType aType) const {
|
||||
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
|
||||
return RemoteAccessibleBase<RemoteAccessible>::RelationByType(aType);
|
||||
}
|
||||
|
||||
RefPtr<IAccessible2_2> acc = QueryInterface<IAccessible2_2>(this);
|
||||
if (!acc) {
|
||||
return nsTArray<RemoteAccessible*>();
|
||||
|
Loading…
Reference in New Issue
Block a user