Make sure we flush out content before we try to set up the plug-in, sincethat's going to perform DOM access that can flush. Bug 377070, r+sr=biesi
authorbzbarsky@mit.edu
Wed, 23 May 2007 12:53:31 -0700
changeset 1792 384c2f37c53a66dea7059cddedd7195b84714654
parent 1791 405c37075debcc1170f0794ae06bf22e87ff821a
child 1793 6f48c3aeba88f31332e5a0c7a7a09df370d62334
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs377070
milestone1.9a5pre
Make sure we flush out content before we try to set up the plug-in, sincethat's going to perform DOM access that can flush. Bug 377070, r+sr=biesi
content/base/src/nsObjectLoadingContent.cpp
--- a/content/base/src/nsObjectLoadingContent.cpp
+++ b/content/base/src/nsObjectLoadingContent.cpp
@@ -1289,30 +1289,44 @@ nsObjectLoadingContent::GetObjectBaseURI
 
 nsIObjectFrame*
 nsObjectLoadingContent::GetFrame()
 {
   nsCOMPtr<nsIContent> thisContent = 
     do_QueryInterface(NS_STATIC_CAST(nsIImageLoadingContent*, this));
   NS_ASSERTION(thisContent, "must be a content");
 
-  nsIDocument* doc = thisContent->GetCurrentDoc();
-  if (!doc) {
-    return nsnull; // No current doc -> no frame
-  }
+  PRBool flushed = PR_FALSE;
+  nsIFrame* frame;
+  do {
+    nsIDocument* doc = thisContent->GetCurrentDoc();
+    if (!doc) {
+      return nsnull; // No current doc -> no frame
+    }
+
+    nsIPresShell* shell = doc->GetPrimaryShell();
+    if (!shell) {
+      return nsnull; // No presentation -> no frame
+    }
 
-  nsIPresShell* shell = doc->GetPrimaryShell();
-  if (!shell) {
-    return nsnull; // No presentation -> no frame
-  }
+    frame = shell->GetPrimaryFrameFor(thisContent);
+    if (!frame) {
+      return nsnull;
+    }
 
-  nsIFrame* frame = shell->GetPrimaryFrameFor(thisContent);
-  if (!frame) {
-    return nsnull;
-  }
+    if (flushed) {
+      break;
+    }
+    
+    // OK, let's flush out and try again.  Note that we want to reget
+    // the document, etc, since flushing might run script.
+    doc->FlushPendingNotifications(Flush_ContentAndNotify);
+
+    flushed = PR_TRUE;
+  } while (1);
 
   nsIObjectFrame* objFrame;
   CallQueryInterface(frame, &objFrame);
   return objFrame;
 }
 
 nsresult
 nsObjectLoadingContent::Instantiate(const nsACString& aMIMEType, nsIURI* aURI)