From 5136f8703ceece05061ef66aa8667e944b959847 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Sun, 17 Oct 2010 08:57:50 +1300 Subject: [PATCH] Bug 604067 - Ensure media loads-from-channels propagate their errors so the controls work correctly. r=roc a=blocking2.0 --- content/html/content/public/nsHTMLMediaElement.h | 4 ++-- content/html/content/src/nsHTMLMediaElement.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/nsHTMLMediaElement.h index f405e5bff49..115a95d1887 100644 --- a/content/html/content/public/nsHTMLMediaElement.h +++ b/content/html/content/public/nsHTMLMediaElement.h @@ -653,8 +653,8 @@ protected: // PR_TRUE if we're running the "load()" method. PRPackedBool mIsRunningLoadMethod; - // PR_TRUE if we're loading exclusively from the src attribute's resource. - PRPackedBool mIsLoadingFromSrcAttribute; + // PR_TRUE if we're loading the resource from the child source elements. + PRPackedBool mIsLoadingFromSourceChildren; // PR_TRUE if we're delaying the "load" event. They are delayed until either // an error occurs, or the first frame is loaded. diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp index 9ef52f1565d..e1b01623bec 100644 --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp @@ -491,7 +491,7 @@ void nsHTMLMediaElement::AbortExistingLoads() mError = nsnull; mLoadedFirstFrame = PR_FALSE; mAutoplaying = PR_TRUE; - mIsLoadingFromSrcAttribute = PR_FALSE; + mIsLoadingFromSourceChildren = PR_FALSE; mSuspendedAfterFirstFrame = PR_FALSE; mAllowSuspendAfterFirstFrame = PR_TRUE; mSourcePointer = nsnull; @@ -654,7 +654,8 @@ void nsHTMLMediaElement::SelectResource() nsresult rv = NewURIFromString(src, getter_AddRefs(uri)); if (NS_SUCCEEDED(rv)) { LOG(PR_LOG_DEBUG, ("%p Trying load from src=%s", this, NS_ConvertUTF16toUTF8(src).get())); - mIsLoadingFromSrcAttribute = PR_TRUE; + NS_ASSERTION(!mIsLoadingFromSourceChildren, + "Should think we're not loading from source children by default"); mLoadingSrc = uri; if (mPreloadAction == nsHTMLMediaElement::PRELOAD_NONE) { // preload:none media, suspend the load here before we make any @@ -673,6 +674,7 @@ void nsHTMLMediaElement::SelectResource() NoSupportedMediaSourceError(); } else { // Otherwise, the source elements will be used. + mIsLoadingFromSourceChildren = PR_TRUE; LoadFromSourceChildren(); } mIsRunningSelectResource = PR_FALSE; @@ -680,7 +682,7 @@ void nsHTMLMediaElement::SelectResource() void nsHTMLMediaElement::NotifyLoadError() { - if (mIsLoadingFromSrcAttribute) { + if (!mIsLoadingFromSourceChildren) { LOG(PR_LOG_DEBUG, ("NotifyLoadError(), no supported media error")); NoSupportedMediaSourceError(); } else { @@ -733,7 +735,7 @@ void nsHTMLMediaElement::LoadFromSourceChildren() { NS_ASSERTION(mDelayingLoadEvent, "Should delay load event (if in document) during load"); - NS_ASSERTION(!mIsLoadingFromSrcAttribute, + NS_ASSERTION(mIsLoadingFromSourceChildren, "Must remember we're loading from source children"); while (PR_TRUE) { nsresult rv; @@ -809,7 +811,7 @@ void nsHTMLMediaElement::ResumeLoad(PreloadAction aAction) mPreloadAction = aAction; ChangeDelayLoadStatus(PR_TRUE); mNetworkState = nsIDOMHTMLMediaElement::NETWORK_LOADING; - if (mIsLoadingFromSrcAttribute) { + if (!mIsLoadingFromSourceChildren) { // We were loading from the element's src attribute. if (NS_FAILED(LoadResource(uri))) { NoSupportedMediaSourceError(); @@ -1286,7 +1288,7 @@ nsHTMLMediaElement::nsHTMLMediaElement(already_AddRefed aNodeInfo, mWaitingFired(PR_FALSE), mIsBindingToTree(PR_FALSE), mIsRunningLoadMethod(PR_FALSE), - mIsLoadingFromSrcAttribute(PR_FALSE), + mIsLoadingFromSourceChildren(PR_FALSE), mDelayingLoadEvent(PR_FALSE), mIsRunningSelectResource(PR_FALSE), mSuspendedAfterFirstFrame(PR_FALSE), @@ -1981,7 +1983,7 @@ void nsHTMLMediaElement::NetworkError() void nsHTMLMediaElement::DecodeError() { - if (!mIsLoadingFromSrcAttribute) { + if (mIsLoadingFromSourceChildren) { NS_ASSERTION(mSourceLoadCandidate, "Must know the source we were loading from!"); if (mDecoder) { mDecoder->Shutdown();