Bug 495883 - ASSERTION: Unable to get an nsIScriptGlobalObject from the ScriptGlobalObjectOwner, r=sicking

--HG--
extra : rebase_source : 7e0670c8165de7e761ed5adec653dac676e00982
This commit is contained in:
Olli Pettay 2009-08-19 12:09:26 +03:00
parent 321ef99a87
commit 2f12596208
5 changed files with 22 additions and 20 deletions

View File

@ -130,6 +130,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFrameLoader)
NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
nsFrameLoader*
nsFrameLoader::Create(nsIContent* aOwner)
{
NS_ENSURE_TRUE(aOwner, nsnull);
nsIDocument* doc = aOwner->GetCurrentDoc();
NS_ENSURE_TRUE(doc && !doc->GetDisplayDocument() &&
!doc->IsLoadedAsData(), nsnull);
return new nsFrameLoader(aOwner);
}
NS_IMETHODIMP NS_IMETHODIMP
nsFrameLoader::LoadFrame() nsFrameLoader::LoadFrame()
{ {

View File

@ -54,7 +54,7 @@ class nsIURI;
class nsFrameLoader : public nsIFrameLoader class nsFrameLoader : public nsIFrameLoader
{ {
public: protected:
nsFrameLoader(nsIContent *aOwner) : nsFrameLoader(nsIContent *aOwner) :
mOwnerContent(aOwner), mOwnerContent(aOwner),
mDepthTooGreat(PR_FALSE), mDepthTooGreat(PR_FALSE),
@ -64,11 +64,14 @@ public:
mInSwap(PR_FALSE) mInSwap(PR_FALSE)
{} {}
public:
~nsFrameLoader() { ~nsFrameLoader() {
mNeedsAsyncDestroy = PR_TRUE; mNeedsAsyncDestroy = PR_TRUE;
nsFrameLoader::Destroy(); nsFrameLoader::Destroy();
} }
static nsFrameLoader* Create(nsIContent* aOwner);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsFrameLoader) NS_DECL_CYCLE_COLLECTION_CLASS(nsFrameLoader)
NS_DECL_NSIFRAMELOADER NS_DECL_NSIFRAMELOADER

View File

@ -504,15 +504,11 @@ nsObjectLoadingContent::OnStartRequest(nsIRequest *aRequest,
break; break;
case eType_Document: { case eType_Document: {
if (!mFrameLoader) { if (!mFrameLoader) {
if (!thisContent->IsInDoc()) { mFrameLoader = nsFrameLoader::Create(thisContent);
// XXX frameloaders can't deal with not being in a document if (!mFrameLoader) {
Fallback(PR_FALSE); Fallback(PR_FALSE);
return NS_ERROR_UNEXPECTED; return NS_ERROR_UNEXPECTED;
} }
mFrameLoader = new nsFrameLoader(thisContent);
if (!mFrameLoader) {
return NS_ERROR_OUT_OF_MEMORY;
}
} }
rv = mFrameLoader->CheckForRecursiveLoad(uri); rv = mFrameLoader->CheckForRecursiveLoad(uri);
@ -1143,16 +1139,11 @@ nsObjectLoadingContent::LoadObject(nsIURI* aURI,
// Must have a frameloader before creating a frame, or the frame will // Must have a frameloader before creating a frame, or the frame will
// create its own. // create its own.
if (!mFrameLoader && newType == eType_Document) { if (!mFrameLoader && newType == eType_Document) {
if (!thisContent->IsInDoc()) { mFrameLoader = nsFrameLoader::Create(thisContent);
// XXX frameloaders can't deal with not being in a document if (!mFrameLoader) {
mURI = nsnull; mURI = nsnull;
return NS_OK; return NS_OK;
} }
mFrameLoader = new nsFrameLoader(thisContent);
if (!mFrameLoader) {
return NS_ERROR_OUT_OF_MEMORY;
}
} }
// Must notify here for plugins // Must notify here for plugins

View File

@ -2793,10 +2793,7 @@ nsGenericHTMLFrameElement::EnsureFrameLoader()
return NS_OK; return NS_OK;
} }
mFrameLoader = new nsFrameLoader(this); mFrameLoader = nsFrameLoader::Create(this);
if (!mFrameLoader)
return NS_ERROR_OUT_OF_MEMORY;
return NS_OK; return NS_OK;
} }

View File

@ -1997,8 +1997,8 @@ nsXULElement::LoadSrc()
nsXULSlots* slots = static_cast<nsXULSlots*>(GetSlots()); nsXULSlots* slots = static_cast<nsXULSlots*>(GetSlots());
NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(slots, NS_ERROR_OUT_OF_MEMORY);
if (!slots->mFrameLoader) { if (!slots->mFrameLoader) {
slots->mFrameLoader = new nsFrameLoader(this); slots->mFrameLoader = nsFrameLoader::Create(this);
NS_ENSURE_TRUE(slots->mFrameLoader, NS_ERROR_OUT_OF_MEMORY); NS_ENSURE_TRUE(slots->mFrameLoader, NS_OK);
} }
return slots->mFrameLoader->LoadFrame(); return slots->mFrameLoader->LoadFrame();