mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1321935: Make ProxyAccessibleBase::SetChildDoc tolerate replacing one document with another, and add a new ClearChildDoc for removing that document; r=tbsaunde
MozReview-Commit-ID: 2GgiUPf4gi0
This commit is contained in:
parent
30bb933346
commit
2c794979ff
@ -111,7 +111,7 @@ public:
|
||||
*/
|
||||
void RemoveChildDoc(DocAccessibleParent* aChildDoc)
|
||||
{
|
||||
aChildDoc->Parent()->SetChildDoc(nullptr);
|
||||
aChildDoc->Parent()->ClearChildDoc(aChildDoc);
|
||||
mChildDocs.RemoveElement(aChildDoc);
|
||||
aChildDoc->mParentDoc = nullptr;
|
||||
MOZ_ASSERT(aChildDoc->mChildDocs.Length() == 0);
|
||||
|
@ -52,15 +52,31 @@ ProxyAccessibleBase<Derived>::Shutdown()
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
ProxyAccessibleBase<Derived>::SetChildDoc(DocAccessibleParent* aParent)
|
||||
ProxyAccessibleBase<Derived>::SetChildDoc(DocAccessibleParent* aChildDoc)
|
||||
{
|
||||
if (aParent) {
|
||||
MOZ_ASSERT(mChildren.IsEmpty());
|
||||
mChildren.AppendElement(aParent);
|
||||
mOuterDoc = true;
|
||||
// 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 {
|
||||
MOZ_ASSERT(mChildren.Length() == 1);
|
||||
mChildren.Clear();
|
||||
mChildren.ReplaceElementAt(0, aChildDoc);
|
||||
}
|
||||
mOuterDoc = true;
|
||||
}
|
||||
|
||||
template <class Derived>
|
||||
void
|
||||
ProxyAccessibleBase<Derived>::ClearChildDoc(DocAccessibleParent* aChildDoc)
|
||||
{
|
||||
MOZ_ASSERT(aChildDoc);
|
||||
// This is possible if we're replacing one document with another: Doc 1
|
||||
// has not had a chance to remove itself, but was already replaced by Doc 2
|
||||
// in SetChildDoc(). This could result in two subsequent calls to
|
||||
// ClearChildDoc() even though mChildren.Length() == 1.
|
||||
MOZ_ASSERT(mChildren.Length() <= 1);
|
||||
if (mChildren.RemoveElement(aChildDoc)) {
|
||||
mOuterDoc = false;
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ public:
|
||||
|
||||
void Shutdown();
|
||||
|
||||
void SetChildDoc(DocAccessibleParent*);
|
||||
void SetChildDoc(DocAccessibleParent* aChildDoc);
|
||||
void ClearChildDoc(DocAccessibleParent* aChildDoc);
|
||||
|
||||
/**
|
||||
* Remove The given child.
|
||||
|
Loading…
Reference in New Issue
Block a user