Backed out changeset b54140961fa7 to fix more mochitest-a11y crashes (Bug 571459)
authorDrew Willcoxon <adw@mozilla.com>
Mon, 14 Jun 2010 16:19:10 -0700
changeset 43617 7523ad2f395e9295ec597de3b8de5329cb17a18a
parent 43616 a61249fe43d313980461dc83638b9972da091fe1
child 43618 eb0883ccdb63c62babbadb47e113a5efb43f8939
push id13810
push userdwillcoxon@mozilla.com
push dateMon, 14 Jun 2010 23:19:27 +0000
treeherdermozilla-central@7523ad2f395e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs571459
milestone1.9.3a6pre
backs outb54140961fa705b38f1e927a4e8aac626ca567ea
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset b54140961fa7 to fix more mochitest-a11y crashes (Bug 571459)
accessible/public/nsIAccessibilityService.h
accessible/src/base/nsAccDocManager.h
accessible/src/base/nsAccessibilityService.cpp
accessible/src/base/nsAccessibilityService.h
accessible/src/base/nsOuterDocAccessible.cpp
layout/base/nsPresShell.cpp
--- a/accessible/public/nsIAccessibilityService.h
+++ b/accessible/public/nsIAccessibilityService.h
@@ -46,20 +46,20 @@
 
 class nsAccessible;
 class nsIContent;
 class nsIDocument;
 class nsIFrame;
 class nsIPresShell;
 class nsObjectFrame;
 
-// 10ff6dca-b219-4b64-9a4c-67a62b86edce
+// 9f43b315-53c6-4d46-9818-9c8593e91984
 #define NS_IACCESSIBILITYSERVICE_IID \
-{ 0x10ff6dca, 0xb219, 0x4b64, \
- { 0x9a, 0x4c, 0x67, 0xa6, 0x2b, 0x86, 0xed, 0xce } }
+{0x9f43b315, 0x53c6, 0x4d46,         \
+  {0x98, 0x18, 0x9c, 0x85, 0x93, 0xe9, 0x19, 0x84} }
 
 class nsIAccessibilityService : public nsIAccessibleRetrieval
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IACCESSIBILITYSERVICE_IID)
 
   /**
    * Return an accessible object for a DOM node in the given pres shell.
@@ -169,22 +169,16 @@ public:
   /**
    * Fire accessible event of the given type for the given target.
    *
    * @param aEvent   [in] accessible event type
    * @param aTarget  [in] target of accessible event
    */
   virtual nsresult FireAccessibleEvent(PRUint32 aEvent,
                                        nsIAccessible *aTarget) = 0;
-
-  /**
-   * Notify the accessibility service that the given presshell is
-   * being destroyed.
-   */
-  virtual void PresShellDestroyed(nsIPresShell* aPresShell) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIAccessibilityService,
                               NS_IACCESSIBILITYSERVICE_IID)
 
 // for component registration
 // {DE401C37-9A7F-4278-A6F8-3DE2833989EF}
 #define NS_ACCESSIBILITY_SERVICE_CID \
--- a/accessible/src/base/nsAccDocManager.h
+++ b/accessible/src/base/nsAccDocManager.h
@@ -68,41 +68,36 @@ public:
   nsDocAccessible *GetDocAccessible(nsIDocument *aDocument);
 
   /**
    * Search through all document accessibles for an accessible with the given
    * unique id.
    */
   nsAccessible *FindAccessibleInCache(void *aUniqueID) const;
 
+  /**
+   * Shutdown document accessibles in the tree starting from the given one.
+   *
+   * @param  aDocument  [in] the DOM document of start document accessible
+   */
+  void ShutdownDocAccessiblesInTree(nsIDocument *aDocument);
+
 protected:
   nsAccDocManager() { };
 
   /**
    * Initialize the manager.
    */
   PRBool Init();
 
   /**
    * Shutdown the manager.
    */
   void Shutdown();
 
-  /**
-   * Shutdown the document accessible.
-   */
-  void ShutdownDocAccessible(nsIDocument *aDocument);
-
-  /**
-   * Shutdown document accessibles in the tree starting from the given one.
-   *
-   * @param  aDocument  [in] the DOM document of start document accessible
-   */
-  void ShutdownDocAccessiblesInTree(nsIDocument *aDocument);
-
 private:
   nsAccDocManager(const nsAccDocManager&);
   nsAccDocManager& operator =(const nsAccDocManager&);
 
 private:
   /**
    * Create an accessible document if it was't created and fire accessibility
    * events if needed.
@@ -148,16 +143,21 @@ private:
   nsDocAccessible *CreateDocOrRootAccessible(nsIDocument *aDocument);
 
   /**
    * Shutdown document accessibles in the tree starting from given tree item.
    */
   void ShutdownDocAccessiblesInTree(nsIDocShellTreeItem *aTreeItem,
                                     nsIDocument *aDocument);
 
+  /**
+   * Shutdown the document accessible.
+   */
+  void ShutdownDocAccessible(nsIDocument *aDocument);
+
   typedef nsRefPtrHashtable<nsVoidPtrHashKey, nsDocAccessible>
     nsDocAccessibleHashtable;
 
   /**
    * Shutdown and remove the document accessible from cache.
    */
   static PLDHashOperator
     ClearDocCacheEntry(const void* aKey,
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -181,28 +181,16 @@ nsresult
 nsAccessibilityService::FireAccessibleEvent(PRUint32 aEvent,
                                             nsIAccessible *aTarget)
 {
   nsRefPtr<nsAccessible> accessible(do_QueryObject(aTarget));
   nsEventShell::FireEvent(aEvent, accessible);
   return NS_OK;
 }
 
-void
-nsAccessibilityService::PresShellDestroyed(nsIPresShell* aPresShell)
-{
-  //  Presshell destruction will automatically destroy shells for
-  //  descendant documents, so no need to worry about those.  Just
-  //  shut down the accessible for this one document.  That keeps us
-  //  from having bad behavior in case of deep bushy subtrees.
-  nsIDocument* doc = aPresShell->GetDocument();
-  if (doc)
-    ShutdownDocAccessible(doc);
-}
-
 // nsAccessibilityService private
 nsresult
 nsAccessibilityService::GetInfo(nsIFrame *aFrame, nsIWeakReference **aShell,
                                 nsIContent **aContent)
 {
   NS_ASSERTION(aFrame,"Error -- 1st argument (aFrame) is null!!");
   if (!aFrame) {
     return NS_ERROR_FAILURE;
--- a/accessible/src/base/nsAccessibilityService.h
+++ b/accessible/src/base/nsAccessibilityService.h
@@ -121,18 +121,16 @@ public:
   virtual nsresult InvalidateSubtreeFor(nsIPresShell *aPresShell,
                                         nsIContent *aContent,
                                         PRUint32 aChangeType);
 
   virtual void NotifyOfAnchorJumpTo(nsIContent *aTarget);
 
   virtual nsresult FireAccessibleEvent(PRUint32 aEvent, nsIAccessible *aTarget);
 
-  virtual void PresShellDestroyed(nsIPresShell* aPresShell);
-
   // nsAccessibiltiyService
 
   /**
    * Return true if accessibility service has been shutdown.
    */
   static PRBool IsShutdown() { return gIsShutdown; }
 
   /**
--- a/accessible/src/base/nsOuterDocAccessible.cpp
+++ b/accessible/src/base/nsOuterDocAccessible.cpp
@@ -154,30 +154,44 @@ nsOuterDocAccessible::DoAction(PRUint8 a
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessNode public
 
 void
 nsOuterDocAccessible::Shutdown()
 {
+  // Shutdown child document if any.
+  nsAccessible *childAcc = mChildren.SafeElementAt(0, nsnull);
+  if (childAcc) {
+    nsRefPtr<nsDocAccessible> docAcc(do_QueryObject(childAcc));
+    NS_LOG_ACCDOCDESTROY_FOR("outerdoc document shutdown",
+                             docAcc->GetDOMDocument(), docAcc.get())
+    GetAccService()->ShutdownDocAccessiblesInTree(docAcc->GetDOMDocument());
+  }
+
   nsAccessible::InvalidateChildren();
 
   nsAccessibleWrap::Shutdown();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessible public
 
 void
 nsOuterDocAccessible::InvalidateChildren()
 {
-  // Do not invalidate children because nsAccDocManager is responsible
-  // for document accessible lifetime when DOM document or its
-  // presshell is created or destroyed.
+  // Do not invalidate children because nsAccDocManager is responsible for
+  // document accessible lifetime when DOM document is created or destroyed. If
+  // DOM document isn't destroyed but its presshell is destroyed (for example,
+  // when DOM node of outerdoc accessible is hidden), then outerdoc accessible
+  // notifies nsAccDocManager about this. If presshell is created for existing
+  // DOM document (for example when DOM node of outerdoc accessible is shown)
+  // then allow nsAccDocManager to handle this case since the document
+  // accessible is created and appended as a child when it's requested.
 
   mAreChildrenInitialized = PR_FALSE;
 }
 
 PRBool
 nsOuterDocAccessible::AppendChild(nsAccessible *aAccessible)
 {
   NS_ASSERTION(!mChildren.Length(),
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1811,26 +1811,16 @@ PresShell::Destroy()
     delete mReflowCountMgr;
     mReflowCountMgr = nsnull;
   }
 #endif
 
   if (mHaveShutDown)
     return;
 
-#ifdef ACCESSIBILITY
-  if (gIsAccessibilityActive) {
-    nsCOMPtr<nsIAccessibilityService> accService =
-      do_GetService("@mozilla.org/accessibilityService;1");
-    if (accService) {
-      accService->PresShellDestroyed(this);
-    }
-  }
-#endif // ACCESSIBILITY
-
   MaybeReleaseCapturingContent();
 
   mContentToScrollTo = nsnull;
 
   if (mPresContext) {
     // We need to notify the destroying the nsPresContext to ESM for
     // suppressing to use from ESM.
     mPresContext->EventStateManager()->NotifyDestroyPresContext(mPresContext);