diff --git a/accessible/src/generic/DocAccessible.cpp b/accessible/src/generic/DocAccessible.cpp index 6a1dd16770d..107d616ab5a 100644 --- a/accessible/src/generic/DocAccessible.cpp +++ b/accessible/src/generic/DocAccessible.cpp @@ -1917,7 +1917,10 @@ DocAccessible::ShutdownChildrenInSubtree(Accessible* aAccessible) jdx++; } - ShutdownChildrenInSubtree(child); + // Don't cross document boundaries. The outerdoc shutdown takes care about + // its subdocument. + if (!child->IsDoc()) + ShutdownChildrenInSubtree(child); } UnbindFromDocument(aAccessible); diff --git a/accessible/src/generic/OuterDocAccessible.cpp b/accessible/src/generic/OuterDocAccessible.cpp index d8a43e3ea6b..c1dc2d3d6f1 100644 --- a/accessible/src/generic/OuterDocAccessible.cpp +++ b/accessible/src/generic/OuterDocAccessible.cpp @@ -7,7 +7,7 @@ #include "Accessible-inl.h" #include "nsAccUtils.h" -#include "DocAccessible.h" +#include "DocAccessible-inl.h" #include "Role.h" #include "States.h" @@ -109,22 +109,25 @@ OuterDocAccessible::Shutdown() { // XXX: sometimes outerdoc accessible is shutdown because of layout style // change however the presshell of underlying document isn't destroyed and - // the document doesn't get pagehide events. Shutdown underlying document if - // any to avoid hanging document accessible. + // the document doesn't get pagehide events. Schedule a document rebind + // to its parent document. Otherwise a document accessible may be lost if its + // outerdoc has being recreated (see bug 862863 for details). + #ifdef A11Y_LOG if (logging::IsEnabled(logging::eDocDestroy)) logging::OuterDocDestroy(this); #endif - Accessible* childAcc = mChildren.SafeElementAt(0, nullptr); - if (childAcc) { + Accessible* child = mChildren.SafeElementAt(0, nullptr); + if (child) { #ifdef A11Y_LOG if (logging::IsEnabled(logging::eDocDestroy)) { - logging::DocDestroy("outerdoc's child document shutdown", - childAcc->AsDoc()->DocumentNode()); + logging::DocDestroy("outerdoc's child document rebind is scheduled", + child->AsDoc()->DocumentNode()); } #endif - childAcc->Shutdown(); + RemoveChild(child); + mDoc->BindChildDocument(child->AsDoc()); } AccessibleWrap::Shutdown();