Bug 1222980 - End the synchronous section and asynchronously await a stable state when the src is not set. r?jwwang. draft
authorctai <ctai@mozilla.com>
Fri, 18 Nov 2016 11:28:46 +0800
changeset 448660 cc56430f4c75e4edf4e35b40c107d6a278df13cf
parent 448659 571f68c1d33287ed144f620f26acfa8a170f48f8
child 448661 737e1dd9f890f87364e67d4e589c815da7b23291
push id38391
push userbmo:ctai@mozilla.com
push dateMon, 12 Dec 2016 06:04:36 +0000
reviewersjwwang
bugs1222980
milestone53.0a1
Bug 1222980 - End the synchronous section and asynchronously await a stable state when the src is not set. r?jwwang. When the src get errors, we need to end the synchronous section. MozReview-Commit-ID: EQ0jVIMnqoZ
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2128,54 +2128,54 @@ void HTMLMediaElement::LoadFromSourceChi
       ReportLoadError("MediaLoadExhaustedCandidates");
       return;
     }
 
     // Must have src attribute.
     nsAutoString src;
     if (!child->GetAttr(kNameSpaceID_None, nsGkAtoms::src, src)) {
       ReportLoadError("MediaLoadSourceMissingSrc");
-      DispatchAsyncSourceError(child);
-      continue;
+      DealingFailWithElements(child);
+      return;
     }
 
     // If we have a type attribute, it must be a supported type.
     nsAutoString type;
     if (child->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type)) {
       DecoderDoctorDiagnostics diagnostics;
       CanPlayStatus canPlay = GetCanPlay(type, &diagnostics);
       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;
+        DealingFailWithElements(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;
+      DealingFailWithElements(child);
+      return;
     }
     LOG(LogLevel::Debug, ("%p Trying load from <source>=%s type=%s media=%s", this,
       NS_ConvertUTF16toUTF8(src).get(), NS_ConvertUTF16toUTF8(type).get(),
       NS_ConvertUTF16toUTF8(media).get()));
 
     nsCOMPtr<nsIURI> uri;
     NewURIFromString(src, getter_AddRefs(uri));
     if (!uri) {
-      DispatchAsyncSourceError(child);
       const char16_t* params[] = { src.get() };
       ReportLoadError("MediaLoadInvalidURI", params, ArrayLength(params));
-      continue;
+      DealingFailWithElements(child);
+      return;
     }
 
     RemoveMediaElementFromURITable();
     mLoadingSrc = uri;
     mMediaSource = childSrc->GetSrcMediaSource();
     NS_ASSERTION(mNetworkState == nsIDOMHTMLMediaElement::NETWORK_LOADING,
                  "Network state should be loading");