Bug 1705542: Don't assume an OuterDoc RemoteAccessible has a child document. r=eeejay

An OuterDoc RemoteAccessible can have no child document for a short time if the embedded doc is changed.
As part of this, get rid of the mOuterDoc variable, since it is now redundant and somewhat misleading.
Instead, use IsOuterDoc(), since RemoteAccessible now has acc types.

Differential Revision: https://phabricator.services.mozilla.com/D114431
This commit is contained in:
James Teh 2021-05-11 23:17:08 +00:00
parent 8839b94d54
commit 5dda669781
3 changed files with 17 additions and 14 deletions

View File

@ -32,7 +32,7 @@ void RemoteAccessibleBase<Derived>::Shutdown() {
// XXX Ideally this wouldn't be necessary, but it seems OuterDoc accessibles
// can be destroyed before the doc they own.
uint32_t childCount = mChildren.Length();
if (!mOuterDoc) {
if (!IsOuterDoc()) {
for (uint32_t idx = 0; idx < childCount; idx++) mChildren[idx]->Shutdown();
} else {
if (childCount > 1) {
@ -53,7 +53,6 @@ void RemoteAccessibleBase<Derived>::SetChildDoc(
MOZ_ASSERT(aChildDoc);
MOZ_ASSERT(mChildren.Length() == 0);
mChildren.AppendElement(aChildDoc);
mOuterDoc = true;
}
template <class Derived>

View File

@ -180,8 +180,7 @@ class RemoteAccessibleBase : public Accessible {
mDoc(aDoc),
mWrapper(0),
mID(aID),
mRole(aRole),
mOuterDoc(false) {}
mRole(aRole) {}
explicit RemoteAccessibleBase(DocAccessibleParent* aThisAsDoc)
: Accessible(),
@ -189,8 +188,7 @@ class RemoteAccessibleBase : public Accessible {
mDoc(aThisAsDoc),
mWrapper(0),
mID(0),
mRole(roles::DOCUMENT),
mOuterDoc(false) {
mRole(roles::DOCUMENT) {
mGenericTypes = eDocument | eHyperText;
}
@ -212,9 +210,6 @@ class RemoteAccessibleBase : public Accessible {
// XXX DocAccessibleParent gets to change this to change the role of
// documents.
role mRole : 27;
private:
bool mOuterDoc : 1;
};
extern template class RemoteAccessibleBase<RemoteAccessible>;

View File

@ -772,13 +772,15 @@ double RemoteAccessible::Step() {
void RemoteAccessible::TakeFocus() { Unused << mDoc->SendTakeFocus(mID); }
RemoteAccessible* RemoteAccessible::FocusedChild() {
if (mOuterDoc) {
if (IsOuterDoc()) {
// If FocusedChild was called on an outer doc, it should behave
// like a non-doc accessible and return its focused child, or null.
// If the inner doc is OOP (fission), calling FocusedChild on the outer
// doc would return null.
MOZ_ASSERT(ChildCount() == 1);
RemoteAccessible* child = RemoteFirstChild();
if (!child) {
return (State() & states::FOCUSED) ? this : nullptr;
}
MOZ_ASSERT(child->IsDoc());
return (child->State() & states::FOCUSED) ? child : nullptr;
}
@ -812,8 +814,15 @@ Accessible* RemoteAccessible::ChildAtPoint(
int32_t aX, int32_t aY, LocalAccessible::EWhichChildAtPoint aWhichChild) {
RemoteAccessible* target = this;
do {
if (target->mOuterDoc) {
MOZ_ASSERT(target->ChildCount() == 1);
if (target->IsOuterDoc()) {
if (target->ChildCount() == 0) {
// Return the OuterDoc if the requested point is within its bounds.
nsIntRect rect = target->Bounds();
if (rect.Contains(aX, aY)) {
return target;
}
return nullptr;
}
DocAccessibleParent* childDoc = target->RemoteChildAt(0)->AsDoc();
MOZ_ASSERT(childDoc);
if (childDoc->IsTopLevelInContentProcess()) {
@ -839,7 +848,7 @@ Accessible* RemoteAccessible::ChildAtPoint(
// If resultDoc is null, this means there is no child at this point.
auto useDoc = static_cast<DocAccessibleParent*>(resultDoc);
target = resultDoc ? useDoc->GetAccessible(resultID) : nullptr;
} while (target && target->mOuterDoc &&
} while (target && target->IsOuterDoc() &&
aWhichChild == Accessible::EWhichChildAtPoint::DeepestChild);
return target;
}