bug 1325834 - create the DocAccessibleChild in DocAccessible::DoInitialUpdate() r=davidb

It seems likely that some documents are created in content processes without
  a DocAccessibleChild actor because there is no docshell or tabchild
  associated with the document.  However DocAccessible::DoInitialUpdate()
  already calls functions that assume the document is associated with a
  docshell.  So hopefully trying to create the child actor there will mean it
  is more successful.
This commit is contained in:
Trevor Saunders 2017-01-16 19:59:06 -05:00
parent 79a95a8db1
commit 6798a4c8ce
2 changed files with 19 additions and 29 deletions

View File

@ -521,34 +521,6 @@ DocManager::CreateDocOrRootAccessible(nsIDocument* aDocument)
docAcc->FireDelayedEvent(nsIAccessibleEvent::EVENT_REORDER,
ApplicationAcc());
if (IPCAccessibilityActive()) {
nsIDocShell* docShell = aDocument->GetDocShell();
if (docShell) {
nsCOMPtr<nsITabChild> tabChild = docShell->GetTabChild();
// XXX We may need to handle the case that we don't have a tab child
// differently. It may be that this will cause us to fail to notify
// the parent process about important accessible documents.
if (tabChild) {
DocAccessibleChild* ipcDoc = new DocAccessibleChild(docAcc);
docAcc->SetIPCDoc(ipcDoc);
#if defined(XP_WIN)
IAccessibleHolder holder(CreateHolderFromAccessible(docAcc));
#endif
static_cast<TabChild*>(tabChild.get())->
SendPDocAccessibleConstructor(ipcDoc, nullptr, 0,
#if defined(XP_WIN)
AccessibleWrap::GetChildIDFor(docAcc),
holder
#else
0, 0
#endif
);
}
}
}
} else {
parentDocAcc->BindChildDocument(docAcc);
}

View File

@ -46,6 +46,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
#include "mozilla/EventStates.h"
#include "mozilla/dom/TabChild.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h"
@ -1460,8 +1461,25 @@ DocAccessible::NotifyOfLoading(bool aIsReloading)
void
DocAccessible::DoInitialUpdate()
{
if (nsCoreUtils::IsTabDocument(mDocumentNode))
if (nsCoreUtils::IsTabDocument(mDocumentNode)) {
mDocFlags |= eTabDocument;
if (IPCAccessibilityActive()) {
nsIDocShell* docShell = mDocumentNode->GetDocShell();
if (RefPtr<dom::TabChild> tabChild = dom::TabChild::GetFrom(docShell)) {
DocAccessibleChild* ipcDoc = new DocAccessibleChild(this);
SetIPCDoc(ipcDoc);
#if defined(XP_WIN)
IAccessibleHolder holder(CreateHolderFromAccessible(docAcc));
int32_t childID = AccessibleWrap::GetChildIDFor(docAcc);
#else
int32_t holder = 0, childID = 0;
#endif
tabChild->SendPDocAccessibleConstructor(ipcDoc, nullptr, 0, childID,
holder);
}
}
}
mLoadState |= eTreeConstructed;