Bug 472239. Make sure to set up our listener before trying to call OnStartRequest on it. r+sr=jst

This commit is contained in:
Boris Zbarsky 2009-01-09 12:54:23 -05:00
Родитель 73a6fab34b
Коммит f049147c23
1 изменённых файлов: 29 добавлений и 15 удалений

Просмотреть файл

@ -75,6 +75,8 @@ public:
mWillHandleInstantiation = PR_FALSE;
}
void StartLayout() { nsMediaDocument::StartLayout(); }
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsPluginDocument, nsMediaDocument)
protected:
nsresult CreateSyntheticPluginDocument();
@ -91,22 +93,35 @@ protected:
class nsPluginStreamListener : public nsMediaDocumentStreamListener
{
public:
nsPluginStreamListener(nsPluginDocument* doc) :
nsMediaDocumentStreamListener(doc), mPluginDoc(doc) {}
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt);
private:
nsRefPtr<nsPluginDocument> mPluginDoc;
public:
nsPluginStreamListener(nsPluginDocument* doc) :
nsMediaDocumentStreamListener(doc), mPluginDoc(doc) {}
NS_IMETHOD OnStartRequest(nsIRequest* request, nsISupports *ctxt);
private:
nsresult SetupPlugin();
nsRefPtr<nsPluginDocument> mPluginDoc;
};
NS_IMETHODIMP
nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
{
nsresult rv = nsMediaDocumentStreamListener::OnStartRequest(request, ctxt);
if (NS_FAILED(rv)) {
return rv;
}
// Have to set up our plugin stuff before we call OnStartRequest, so
// that the plugin listener can get that call.
nsresult rv = SetupPlugin();
NS_ASSERTION(NS_FAILED(rv) || mNextStream,
"We should have a listener by now");
nsresult rv2 = nsMediaDocumentStreamListener::OnStartRequest(request, ctxt);
return NS_SUCCEEDED(rv) ? rv2 : rv;
}
nsresult
nsPluginStreamListener::SetupPlugin()
{
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
mPluginDoc->StartLayout();
nsCOMPtr<nsIContent> embed = mPluginDoc->GetPluginContent();
@ -126,7 +141,7 @@ nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
nsIFrame* frame = shell->GetPrimaryFrameFor(embed);
if (!frame) {
mPluginDoc->AllowNormalInstantiation();
return rv;
return NS_OK;
}
nsIObjectFrame* objFrame;
@ -136,8 +151,8 @@ nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
return NS_ERROR_UNEXPECTED;
}
rv = objFrame->Instantiate(mPluginDoc->GetType().get(),
mDocument->nsIDocument::GetDocumentURI());
nsresult rv = objFrame->Instantiate(mPluginDoc->GetType().get(),
mDocument->nsIDocument::GetDocumentURI());
if (NS_FAILED(rv)) {
return rv;
}
@ -146,8 +161,7 @@ nsPluginStreamListener::OnStartRequest(nsIRequest* request, nsISupports *ctxt)
// (say if there's a reframe of this entire presentation).
mPluginDoc->AllowNormalInstantiation();
NS_ASSERTION(mNextStream, "We should have a listener by now");
return mNextStream->OnStartRequest(request, ctxt);
return NS_OK;
}