Bug 760038 - crash in NotificationController::WillRefresh, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Sat, 02 Jun 2012 14:14:42 +0900
changeset 95614 63271af1e3dc2c957c31d0efd8871b47468aeae0
parent 95613 8afb4681648239abc2a6c8c9ffbe3e44069d58c5
child 95615 26b8f229240509c93626029ed991f9f7e6d307e0
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerstbsaunde
bugs760038
milestone15.0a1
Bug 760038 - crash in NotificationController::WillRefresh, r=tbsaunde
accessible/src/generic/DocAccessible-inl.h
accessible/src/generic/DocAccessible.cpp
accessible/src/generic/DocAccessible.h
--- a/accessible/src/generic/DocAccessible-inl.h
+++ b/accessible/src/generic/DocAccessible-inl.h
@@ -6,22 +6,16 @@
 
 #ifndef mozilla_a11y_DocAccessible_inl_h_
 #define mozilla_a11y_DocAccessible_inl_h_
 
 #include "DocAccessible.h"
 #include "nsAccessibilityService.h"
 #include "NotificationController.h"
 
-inline DocAccessible*
-DocAccessible::ParentDocument() const
-{
-  return GetAccService()->GetDocAccessible(mDocument->GetParentDocument());
-}
-
 inline void
 DocAccessible::BindChildDocument(DocAccessible* aDocument)
 {
   mNotificationController->ScheduleChildDocBinding(aDocument);
 }
 
 template<class Class, class Arg>
 inline void
--- a/accessible/src/generic/DocAccessible.cpp
+++ b/accessible/src/generic/DocAccessible.cpp
@@ -2038,17 +2038,21 @@ DocAccessible::IsLoadEventTarget() const
     do_QueryInterface(container);
   NS_ASSERTION(docShellTreeItem, "No document shell for document!");
 
   nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
   docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem));
 
   // Return true if it's not a root document (either tab document or
   // frame/iframe document) and its parent document is not in loading state.
-  if (parentTreeItem)
-    return ParentDocument()->HasLoadState(eCompletelyLoaded);
+  // Note: we can get notifications while document is loading (and thus
+  // while there's no parent document yet).
+  if (parentTreeItem) {
+    DocAccessible* parentDoc = ParentDocument();
+    return parentDoc && parentDoc->HasLoadState(eCompletelyLoaded);
+  }
 
   // It's content (not chrome) root document.
   PRInt32 contentType;
   docShellTreeItem->GetItemType(&contentType);
   return (contentType == nsIDocShellTreeItem::typeContent);
 }
 
--- a/accessible/src/generic/DocAccessible.h
+++ b/accessible/src/generic/DocAccessible.h
@@ -147,17 +147,18 @@ public:
   /**
    * Return a native window handler or pointer depending on platform.
    */
   virtual void* GetNativeWindow() const;
 
   /**
    * Return the parent document.
    */
-  DocAccessible* ParentDocument() const;
+  DocAccessible* ParentDocument() const
+    { return mParent ? mParent->Document() : nsnull; }
 
   /**
    * Return the child document count.
    */
   PRUint32 ChildDocumentCount() const
     { return mChildDocuments.Length(); }
 
   /**