From 6b859eef4194048cd2390d3f50e79489dbdda9de Mon Sep 17 00:00:00 2001 From: "bzbarsky@mit.edu" Date: Wed, 23 May 2007 12:53:31 -0700 Subject: [PATCH] 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 | 38 ++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/content/base/src/nsObjectLoadingContent.cpp b/content/base/src/nsObjectLoadingContent.cpp index 4ea6d901a203..831786ced12e 100644 --- a/content/base/src/nsObjectLoadingContent.cpp +++ b/content/base/src/nsObjectLoadingContent.cpp @@ -1294,20 +1294,34 @@ nsObjectLoadingContent::GetFrame() 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 + } - nsIFrame* frame = shell->GetPrimaryFrameFor(thisContent); - if (!frame) { - return nsnull; - } + 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);