Bug 371976 Create synthetic plugin document content later (like image documents) r=smaug

This commit is contained in:
Neil Rashbrook 2009-09-25 21:58:47 +01:00
Родитель 944e2f0620
Коммит 422a04d6d3
1 изменённых файлов: 27 добавлений и 19 удалений

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

@ -192,11 +192,22 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsPluginDocument, nsMediaDocument,
void
nsPluginDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
{
if (!aScriptGlobalObject) {
// Set the script global object on the superclass before doing
// anything that might require it....
nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject) {
if (!mPluginContent) {
// Create synthetic document
#ifdef DEBUG
nsresult rv =
#endif
CreateSyntheticPluginDocument();
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create synthetic document");
}
} else {
mStreamListener = nsnull;
}
nsMediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
}
@ -218,6 +229,17 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
PRBool aReset,
nsIContentSink* aSink)
{
// do not allow message panes to host full-page plugins
// returning an error causes helper apps to take over
nsCOMPtr<nsIDocShellTreeItem> dsti (do_QueryInterface(aContainer));
if (dsti) {
PRBool isMsgPane = PR_FALSE;
dsti->NameEquals(NS_LITERAL_STRING("messagepane").get(), &isMsgPane);
if (isMsgPane) {
return NS_ERROR_FAILURE;
}
}
nsresult rv =
nsMediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup,
aContainer, aDocListener, aReset,
@ -231,12 +253,6 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
return rv;
}
// Create synthetic document
rv = CreateSyntheticPluginDocument();
if (NS_FAILED(rv)) {
return rv;
}
mStreamListener = new nsPluginStreamListener(this);
if (!mStreamListener) {
return NS_ERROR_OUT_OF_MEMORY;
@ -250,16 +266,8 @@ nsPluginDocument::StartDocumentLoad(const char* aCommand,
nsresult
nsPluginDocument::CreateSyntheticPluginDocument()
{
// do not allow message panes to host full-page plugins
// returning an error causes helper apps to take over
nsCOMPtr<nsIDocShellTreeItem> dsti (do_QueryReferent(mDocumentContainer));
if (dsti) {
PRBool isMsgPane = PR_FALSE;
dsti->NameEquals(NS_LITERAL_STRING("messagepane").get(), &isMsgPane);
if (isMsgPane) {
return NS_ERROR_FAILURE;
}
}
NS_ASSERTION(!GetPrimaryShell() || !GetPrimaryShell->DidInitialReflow(),
"Creating synthetic plugin document content too late");
// make our generic document
nsresult rv = nsMediaDocument::CreateSyntheticDocument();