bug 1221551 - unbind child documents before rebinding them r=davidb

It seems possible that a child document could be bound to a parent document
without first being unbound.  Some evidence for this being possible is that
OuterDocAccessible::InsertChildAt() explicitly checks for this and does
something similar if it already has a child.
This commit is contained in:
Trevor Saunders 2015-11-06 15:17:40 -05:00
parent 0afd6bcdf9
commit 1def7d87c4
2 changed files with 5 additions and 1 deletions

View File

@ -206,6 +206,7 @@ DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uin
MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());
auto childDoc = static_cast<DocAccessibleParent*>(aChildDoc);
childDoc->Unbind();
bool result = AddChildDoc(childDoc, aID, false);
MOZ_ASSERT(result);
MOZ_DIAGNOSTIC_ASSERT(CheckDocTree());

View File

@ -64,7 +64,10 @@ public:
void Unbind()
{
mParent = nullptr;
ParentDoc()->mChildDocs.RemoveElement(this);
if (DocAccessibleParent* parent = ParentDoc()) {
parent->mChildDocs.RemoveElement(this);
}
mParentDoc = nullptr;
}