bug 1128751 - handle unbinding and rebinding of documents in content processes r=davidb

The code for managing document lifetimes assumed documents could not be
rebound to parents, however that is not the case.
This commit is contained in:
Trevor Saunders 2015-03-24 13:52:59 -04:00
parent 473f2ceb3c
commit f8ab3722d7
6 changed files with 44 additions and 10 deletions

View File

@ -280,12 +280,19 @@ NotificationController::WillRefresh(mozilla::TimeStamp aTime)
size_t newDocCount = newChildDocs.Length();
for (size_t i = 0; i < newDocCount; i++) {
DocAccessible* childDoc = newChildDocs[i];
DocAccessibleChild* ipcDoc = new DocAccessibleChild(childDoc);
Accessible* parent = childDoc->Parent();
DocAccessibleChild* parentIPCDoc = mDocument->IPCDoc();
uint64_t id = reinterpret_cast<uintptr_t>(parent->UniqueID());
MOZ_ASSERT(id);
DocAccessibleChild* ipcDoc = childDoc->IPCDoc();
if (ipcDoc) {
parentIPCDoc->SendBindChildDoc(ipcDoc, id);
continue;
}
ipcDoc = new DocAccessibleChild(childDoc);
childDoc->SetIPCDoc(ipcDoc);
auto contentChild = dom::ContentChild::GetSingleton();
DocAccessibleChild* parentIPCDoc = mDocument->IPCDoc();
uint64_t id = reinterpret_cast<uintptr_t>(childDoc->Parent()->UniqueID());
MOZ_ASSERT(id);
contentChild->SendPDocAccessibleConstructor(ipcDoc, parentIPCDoc, id);
}
}

View File

@ -279,8 +279,6 @@ GetAccService()
inline bool
IPCAccessibilityActive()
{
// XXX reenable when crashes are fixed
return false;
#ifdef MOZ_B2G
return false;
#else

View File

@ -137,9 +137,19 @@ DocAccessibleParent::RecvEvent(const uint64_t& aID, const uint32_t& aEventType)
ProxyEvent(e->mProxy, aEventType);
return true;
}
bool
DocAccessibleParent::RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID)
{
auto childDoc = static_cast<DocAccessibleParent*>(aChildDoc);
DebugOnly<bool> result = AddChildDoc(childDoc, aID, false);
MOZ_ASSERT(result);
return true;
}
bool
DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
uint64_t aParentID)
uint64_t aParentID, bool aCreating)
{
ProxyAccessible* outerDoc = mAccessibles.GetEntry(aParentID)->mProxy;
if (!outerDoc)
@ -149,7 +159,11 @@ DocAccessibleParent::AddChildDoc(DocAccessibleParent* aChildDoc,
outerDoc->SetChildDoc(aChildDoc);
mChildDocs.AppendElement(aChildDoc);
aChildDoc->mParentDoc = this;
ProxyCreated(aChildDoc, 0);
if (aCreating) {
ProxyCreated(aChildDoc, 0);
}
return true;
}

View File

@ -45,6 +45,14 @@ public:
virtual bool RecvShowEvent(const ShowEventData& aData) override;
virtual bool RecvHideEvent(const uint64_t& aRootID) override;
virtual bool RecvBindChildDoc(PDocAccessibleParent* aChildDoc, const uint64_t& aID) override;
void Unbind()
{
mParent = nullptr;
mParentDoc->mChildDocs.RemoveElement(this);
mParentDoc = nullptr;
}
void Destroy();
virtual void ActorDestroy(ActorDestroyReason aWhy) override
{
@ -62,7 +70,8 @@ public:
* Called when a document in a content process notifies the main process of a
* new child document.
*/
bool AddChildDoc(DocAccessibleParent* aChildDoc, uint64_t aParentID);
bool AddChildDoc(DocAccessibleParent* aChildDoc, uint64_t aParentID,
bool aCreating = true);
/*
* Called when the document in the content process this object represents

View File

@ -57,6 +57,12 @@ parent:
ShowEvent(ShowEventData data);
HideEvent(uint64_t aRootID);
/*
* Tell the parent document to bind the existing document as a new child
* document.
*/
BindChildDoc(PDocAccessible aChildDoc, uint64_t aID);
child:
// Accessible
prio(high) sync State(uint64_t aID) returns(uint64_t states);

View File

@ -29,7 +29,7 @@ ProxyAccessible::Shutdown()
if (mChildren.Length() != 1)
MOZ_CRASH("outer doc doesn't own adoc!");
static_cast<DocAccessibleParent*>(mChildren[0])->Destroy();
static_cast<DocAccessibleParent*>(mChildren[0])->Unbind();
}
mChildren.Clear();