зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1547892 - Load video element in VideoDocument slightly later during load. r=bzbarsky
Currently when we create the video inside a VideoDocument, the PresShell isn't created yet. This means the video element can't access information about the compositor, which means it doesn't know whether it can create a hardware accelerated video decoder, and so we end up falling back to using a software decoder. So this patch moves the creation of the video element to slightly later in the load of a VideoDocument, so that the PresShell is available when we create the VideoDocument's video element. This means VideoDocuments's video decoder can be hardware accelerated Differential Revision: https://phabricator.services.mozilla.com/D30614 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4b20fc81c7
Коммит
9048acc338
|
@ -53,7 +53,7 @@ class MediaDocument : public nsHTMLDocument {
|
|||
virtual nsresult CreateSyntheticDocument();
|
||||
|
||||
friend class MediaDocumentStreamListener;
|
||||
nsresult StartLayout();
|
||||
virtual nsresult StartLayout();
|
||||
|
||||
void GetFileName(nsAString& aResult, nsIChannel* aChannel);
|
||||
|
||||
|
|
|
@ -47,8 +47,6 @@ class PluginDocument final : public MediaDocument, public nsIPluginDocument {
|
|||
const nsCString& GetType() const { return mMimeType; }
|
||||
Element* GetPluginContent() { return mPluginContent; }
|
||||
|
||||
void StartLayout() { MediaDocument::StartLayout(); }
|
||||
|
||||
virtual void Destroy() override {
|
||||
if (mStreamListener) {
|
||||
mStreamListener->DropDocumentRef();
|
||||
|
|
|
@ -38,12 +38,13 @@ class VideoDocument final : public MediaDocument {
|
|||
MediaDocument::Destroy();
|
||||
}
|
||||
|
||||
nsresult StartLayout() override;
|
||||
|
||||
protected:
|
||||
nsresult CreateVideoElement();
|
||||
// Sets document <title> to reflect the file name and description.
|
||||
void UpdateTitle(nsIChannel* aChannel);
|
||||
|
||||
nsresult CreateSyntheticVideoDocument();
|
||||
|
||||
RefPtr<MediaDocumentStreamListener> mStreamListener;
|
||||
};
|
||||
|
||||
|
@ -62,6 +63,22 @@ nsresult VideoDocument::StartDocumentLoad(const char* aCommand,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult VideoDocument::StartLayout() {
|
||||
// Create video element, and begin loading the media resource. Note we
|
||||
// delay creating the video element until now (we're called from
|
||||
// MediaDocumentStreamListener::OnStartRequest) as the PresShell is likely
|
||||
// to have been created by now, so the MediaDecoder will be able to tell
|
||||
// what kind of compositor we have, so the video element knows whether
|
||||
// it can create a hardware accelerated video decoder or not.
|
||||
nsresult rv = CreateVideoElement();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = MediaDocument::StartLayout();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void VideoDocument::SetScriptGlobalObject(
|
||||
nsIScriptGlobalObject* aScriptGlobalObject) {
|
||||
// Set the script global object on the superclass before doing
|
||||
|
@ -69,11 +86,7 @@ void VideoDocument::SetScriptGlobalObject(
|
|||
MediaDocument::SetScriptGlobalObject(aScriptGlobalObject);
|
||||
|
||||
if (aScriptGlobalObject && !InitialSetupHasBeenDone()) {
|
||||
// Create synthetic document
|
||||
#ifdef DEBUG
|
||||
nsresult rv =
|
||||
#endif
|
||||
CreateSyntheticVideoDocument();
|
||||
DebugOnly<nsresult> rv = CreateSyntheticDocument();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to create synthetic video document");
|
||||
|
||||
if (!nsContentUtils::IsChildOfSameType(this)) {
|
||||
|
@ -88,11 +101,7 @@ void VideoDocument::SetScriptGlobalObject(
|
|||
}
|
||||
}
|
||||
|
||||
nsresult VideoDocument::CreateSyntheticVideoDocument() {
|
||||
// make our generic document
|
||||
nsresult rv = MediaDocument::CreateSyntheticDocument();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsresult VideoDocument::CreateVideoElement() {
|
||||
Element* body = GetBodyElement();
|
||||
if (!body) {
|
||||
NS_WARNING("no body on video document!");
|
||||
|
|
Загрузка…
Ссылка в новой задаче