diff --git a/layout/base/nsDocumentViewer.cpp b/layout/base/nsDocumentViewer.cpp index 0035a2f0c66..a5eadd33539 100644 --- a/layout/base/nsDocumentViewer.cpp +++ b/layout/base/nsDocumentViewer.cpp @@ -33,6 +33,7 @@ #include "nsIDOMHTMLElement.h" #include "nsContentUtils.h" #include "nsLayoutStylesheetCache.h" +#include "mozilla/a11y/DocAccessible.h" #include "mozilla/BasicEvents.h" #include "mozilla/Preferences.h" #include "mozilla/dom/EncodingUtils.h" @@ -1549,6 +1550,16 @@ nsDocumentViewer::Destroy() // cache ourselves. shEntry->SyncPresentationState(); + // Shut down accessibility for the document before we start to tear it down. +#ifdef ACCESSIBILITY + if (mPresShell) { + a11y::DocAccessible* docAcc = mPresShell->GetDocAccessible(); + if (docAcc) { + docAcc->Shutdown(); + } + } +#endif + // Break the link from the document/presentation to the docshell, so that // link traversals cannot affect the currently-loaded document. // When the presentation is restored, Open() and InitInternal() will reset