Bug 1326084 - Unbind accessible child doc before replacing with new one. r=trevor

We need to update mChildDocs on child document removal.  This also cleans up some code related to setting a new child doc when one is already set -- we now assert that this cannot happen.
This commit is contained in:
David Parks 2017-04-07 13:26:45 -07:00
parent ce9afcdc80
commit 6a3359a108
2 changed files with 7 additions and 8 deletions

View File

@ -451,6 +451,11 @@ DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
return IPC_FAIL(this, "binding to proxy that can't be a outerDoc!");
}
if (outerDoc->ChildrenCount() == 1) {
MOZ_ASSERT(outerDoc->ChildAt(0)->AsDoc());
outerDoc->ChildAt(0)->AsDoc()->Unbind();
}
aChildDoc->SetParent(outerDoc);
outerDoc->SetChildDoc(aChildDoc);
mChildDocs.AppendElement(aChildDoc->mActorID);

View File

@ -54,15 +54,9 @@ template <class Derived>
void
ProxyAccessibleBase<Derived>::SetChildDoc(DocAccessibleParent* aChildDoc)
{
// DocAccessibleParent::AddChildDoc tolerates replacing one document with
// another. We must reflect that here.
MOZ_ASSERT(aChildDoc);
MOZ_ASSERT(mChildren.Length() <= 1);
if (mChildren.IsEmpty()) {
mChildren.AppendElement(aChildDoc);
} else {
mChildren.ReplaceElementAt(0, aChildDoc);
}
MOZ_ASSERT(mChildren.Length() == 0);
mChildren.AppendElement(aChildDoc);
mOuterDoc = true;
}