Bug 681905 - Crash [@ nsDocAccessible::ProcessContentInserted], r=davidb
authorAlexander Surkov <surkov.alexander@gmail.com>
Thu, 01 Sep 2011 16:12:51 +0900
changeset 76372 e2a69e20bbc508fa9467c2381f1074ed10f97537
parent 76371 4e3d2bb73029fe01ba9011dae4f3b88c8d54a39e
child 76373 bd97d56b0785823388fcae28bcd409fb63e81faf
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersdavidb
bugs681905
milestone9.0a1
Bug 681905 - Crash [@ nsDocAccessible::ProcessContentInserted], r=davidb
accessible/src/base/NotificationController.cpp
accessible/src/base/nsDocAccessible.cpp
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -676,20 +676,25 @@ NotificationController::TextEnumerator(n
         if (atomid)
           atomid->ToUTF8String(id);
       }
 
       printf("\npending text node insertion: container: %s@id='%s', index in container: %d\n\n",
              tag.get(), id.get(), index);
 #endif
 
+    // Make sure the text node is in accessible document still.
     nsAccessible* container = document->GetAccessibleOrContainer(containerNode);
-    nsTArray<nsCOMPtr<nsIContent> > insertedContents;
-    insertedContents.AppendElement(textNode);
-    document->ProcessContentInserted(container, &insertedContents);
+    NS_ASSERTION(container,
+                 "Text node having rendered text hasn't accessible document!");
+    if (container) {
+      nsTArray<nsCOMPtr<nsIContent> > insertedContents;
+      insertedContents.AppendElement(textNode);
+      document->ProcessContentInserted(container, &insertedContents);
+    }
   }
 
   return PL_DHASH_NEXT;
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // NotificationController: content inserted notification
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -1412,21 +1412,19 @@ nsDocAccessible::ContentRemoved(nsIConte
 void
 nsDocAccessible::RecreateAccessible(nsIContent* aContent)
 {
   // XXX: we shouldn't recreate whole accessible subtree, instead we should
   // subclass hide and show events to handle them separately and implement their
   // coalescence with normal hide and show events. Note, in this case they
   // should be coalesced with normal show/hide events.
 
-  // Check if the node is in DOM still.
-  nsIContent* parentContent = aContent->GetParent();
-  if (parentContent && parentContent->IsInDoc()) {
-    nsAccessible* container = GetAccessibleOrContainer(parentContent);
-
+  // Check if the node is in accessible document.
+  nsAccessible* container = GetContainerAccessible(aContent);
+  if (container) {
     // Remove and reinsert.
     UpdateTree(container, aContent, false);
     container->UpdateChildren();
     UpdateTree(container, aContent, true);
   }
 }
 
 void
@@ -1435,18 +1433,16 @@ nsDocAccessible::ProcessInvalidationList
   // Invalidate children of container accessible for each element in
   // invalidation list. Allow invalidation list insertions while container
   // children are recached.
   for (PRUint32 idx = 0; idx < mInvalidationList.Length(); idx++) {
     nsIContent* content = mInvalidationList[idx];
     nsAccessible* accessible = GetAccessible(content);
     if (!accessible) {
       nsAccessible* container = GetContainerAccessible(content);
-      NS_ASSERTION(container,
-                   "Got a referenced element that is not in document!");
       if (container) {
         container->UpdateChildren();
         accessible = GetAccessible(content);
       }
     }
 
     // Make sure the subtree is created.
     if (accessible)