Bug 1431255 - Part XIV, Move the creation of video element in synthetic media document
This patch moves the call into CreateSyntheticVideoDocument() from
VideoDocument::StartDocumentLoad() to VideoDocument::SetScriptGlobalObject()
because there isn't a inner window at the time of document load,
thus the UAWidgetBindToTree event will not be dispatched
(see EventDispatcher::Dispatch()).
This is modeled after where ImageDocument::CreateSyntheticDocument() is called.
Although it is unclear to me why it was being done differently in
bug 448603.
MozReview-Commit-ID: F3IJo4Ewe6d
--- a/dom/html/VideoDocument.cpp
+++ b/dom/html/VideoDocument.cpp
@@ -62,34 +62,34 @@ VideoDocument::StartDocumentLoad(const c
nsIContentSink* aSink)
{
nsresult rv =
MediaDocument::StartDocumentLoad(aCommand, aChannel, aLoadGroup, aContainer,
aDocListener, aReset, aSink);
NS_ENSURE_SUCCESS(rv, rv);
mStreamListener = new MediaDocumentStreamListener(this);
+ NS_ADDREF(*aDocListener = mStreamListener);
- // Create synthetic document
- rv = CreateSyntheticVideoDocument(aChannel,
- getter_AddRefs(mStreamListener->mNextStream));
- NS_ENSURE_SUCCESS(rv, rv);
-
- NS_ADDREF(*aDocListener = mStreamListener);
return rv;
}
void
VideoDocument::SetScriptGlobalObject(nsIScriptGlobalObject* aScriptGlobalObject)
{
// Set the script global object on the superclass before doing
// anything that might require it....
MediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
if (aScriptGlobalObject && !InitialSetupHasBeenDone()) {
+ // Create synthetic document
+ DebugOnly<nsresult> rv = CreateSyntheticVideoDocument(mChannel,
+ getter_AddRefs(mStreamListener->mNextStream));
+ NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create synthetic document");
+
if (!nsContentUtils::IsChildOfSameType(this)) {
LinkStylesheet(NS_LITERAL_STRING("resource://content-accessible/TopLevelVideoDocument.css"));
LinkStylesheet(NS_LITERAL_STRING("chrome://global/skin/media/TopLevelVideoDocument.css"));
LinkScript(NS_LITERAL_STRING("chrome://global/content/TopLevelVideoDocument.js"));
}
InitialSetupDone();
}
}