mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1222980 - Dispatch |QueueLoadFromSourceTask| to main thread. And end the synchronous section and asynchronously await a stable state when the src is not set. r=jwwang.
Dispatch |QueueLoadFromSourceTask| to main thread to make sure the task will be executed later than loadstart event. And when the src get errors, we need to end the synchronous section. MozReview-Commit-ID: EQ0jVIMnqoZ --HG-- extra : rebase_source : 6651826ad8de361deda5bdc0a49b2c68dcf86220
This commit is contained in:
parent
bce016bed3
commit
d44c8978b2
@ -2068,6 +2068,14 @@ void HTMLMediaElement::NotifyMediaStreamTracksAvailable(DOMMediaStream* aStream)
|
||||
mWatchManager.ManualNotify(&HTMLMediaElement::UpdateReadyStateInternal);
|
||||
}
|
||||
|
||||
void HTMLMediaElement::DealWithFailedElement(nsIContent* aSourceElement)
|
||||
{
|
||||
DispatchAsyncSourceError(aSourceElement);
|
||||
nsCOMPtr<nsIRunnable> event =
|
||||
NewRunnableMethod(this, &HTMLMediaElement::QueueLoadFromSourceTask);
|
||||
NS_DispatchToMainThread(event);
|
||||
}
|
||||
|
||||
void
|
||||
HTMLMediaElement::NotifyOutputTrackStopped(DOMMediaStream* aOwningStream,
|
||||
TrackID aDestinationTrackID)
|
||||
@ -2125,8 +2133,8 @@ void HTMLMediaElement::LoadFromSourceChildren()
|
||||
nsAutoString src;
|
||||
if (!child->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
|
||||
ReportLoadError("MediaLoadSourceMissingSrc");
|
||||
DispatchAsyncSourceError(child);
|
||||
continue;
|
||||
DealWithFailedElement(child);
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have a type attribute, it must be a supported type.
|
||||
@ -2137,20 +2145,20 @@ void HTMLMediaElement::LoadFromSourceChildren()
|
||||
diagnostics.StoreFormatDiagnostics(
|
||||
OwnerDoc(), type, canPlay != CANPLAY_NO, __func__);
|
||||
if (canPlay == CANPLAY_NO) {
|
||||
DispatchAsyncSourceError(child);
|
||||
const char16_t* params[] = { type.get(), src.get() };
|
||||
ReportLoadError("MediaLoadUnsupportedTypeAttribute", params, ArrayLength(params));
|
||||
continue;
|
||||
DealWithFailedElement(child);
|
||||
return;
|
||||
}
|
||||
}
|
||||
nsAutoString media;
|
||||
HTMLSourceElement *childSrc = HTMLSourceElement::FromContent(child);
|
||||
MOZ_ASSERT(childSrc, "Expect child to be HTMLSourceElement");
|
||||
if (childSrc && !childSrc->MatchesCurrentMedia()) {
|
||||
DispatchAsyncSourceError(child);
|
||||
const char16_t* params[] = { media.get(), src.get() };
|
||||
ReportLoadError("MediaLoadSourceMediaNotMatched", params, ArrayLength(params));
|
||||
continue;
|
||||
DealWithFailedElement(child);
|
||||
return;
|
||||
}
|
||||
LOG(LogLevel::Debug, ("%p Trying load from <source>=%s type=%s media=%s", this,
|
||||
NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get(),
|
||||
@ -2159,10 +2167,10 @@ void HTMLMediaElement::LoadFromSourceChildren()
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
NewURIFromString(src, getter_AddRefs(uri));
|
||||
if (!uri) {
|
||||
DispatchAsyncSourceError(child);
|
||||
const char16_t* params[] = { src.get() };
|
||||
ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
|
||||
continue;
|
||||
DealWithFailedElement(child);
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveMediaElementFromURITable();
|
||||
|
@ -964,6 +964,14 @@ protected:
|
||||
*/
|
||||
void NoSupportedMediaSourceError(const nsACString& aErrorDetails = nsCString());
|
||||
|
||||
/**
|
||||
* Per spec, Failed with elements: Queue a task, using the DOM manipulation
|
||||
* task source, to fire a simple event named error at the candidate element.
|
||||
* So dispatch |QueueLoadFromSourceTask| to main thread to make sure the task
|
||||
* will be executed later than loadstart event.
|
||||
*/
|
||||
void DealWithFailedElement(nsIContent* aSourceElement);
|
||||
|
||||
/**
|
||||
* Attempts to load resources from the <source> children. This is a
|
||||
* substep of the resource selection algorithm. Do not call this directly,
|
||||
|
Loading…
Reference in New Issue
Block a user