Bug 1813980: Check IsDoc before Parent in RemoteAccessibleBase::ApplyCrossDocOffset. r=morgan

We call this function on every ancestor when calculating bounds.
RemoteParent() currently requires a hash lookup, so it's more efficient to early return for !IsDoc() first.
This is a micro-optimisation, but it might have some impact given that we call this on every ancestor, especially when hit testing, where we call Bounds() a lot.

As a bit of drive-by cleanup, use RemoteParent() rather than calling Parent() and IsRemote/AsRemote().

Differential Revision: https://phabricator.services.mozilla.com/D168346
This commit is contained in:
James Teh 2023-02-01 05:02:01 +00:00
Родитель 1278600686
Коммит 9dfda5ccb0
1 изменённых файлов: 6 добавлений и 6 удалений

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

@ -464,19 +464,19 @@ Maybe<nsRect> RemoteAccessibleBase<Derived>::RetrieveCachedBounds() const {
template <class Derived>
void RemoteAccessibleBase<Derived>::ApplyCrossDocOffset(nsRect& aBounds) const {
Accessible* parentAcc = Parent();
if (!parentAcc || !parentAcc->IsRemote() || !parentAcc->IsOuterDoc()) {
return;
}
if (!IsDoc()) {
// We should only apply cross-doc offsets to documents. If we're anything
// else, return early here.
return;
}
RemoteAccessible* parentAcc = RemoteParent();
if (!parentAcc || !parentAcc->IsOuterDoc()) {
return;
}
Maybe<const nsTArray<int32_t>&> maybeOffset =
parentAcc->AsRemote()->mCachedFields->GetAttribute<nsTArray<int32_t>>(
parentAcc->mCachedFields->GetAttribute<nsTArray<int32_t>>(
nsGkAtoms::crossorigin);
if (!maybeOffset) {
return;