Bug 871747 - Load the TrackElement outside the document. r=rillian draft
authorbechen <bechen@mozilla.com>
Thu, 30 Jun 2016 13:49:03 +0800
changeset 383100 397a8d9999167660ca59277dedfa8beabff25bfb
parent 383092 7394c1cbb3af1e95fe562cceb94e92785076fa1d
child 383101 56a5b50360266a1e3ffa00d302ea3664ac4ef8df
push id21932
push userbechen@mozilla.com
push dateFri, 01 Jul 2016 07:49:57 +0000
reviewersrillian
bugs871747
milestone50.0a1
Bug 871747 - Load the TrackElement outside the document. r=rillian MozReview-Commit-ID: Cql1YAZnnnL
dom/html/HTMLTrackElement.cpp
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -234,20 +234,16 @@ HTMLTrackElement::BindToTree(nsIDocument
                              bool aCompileEventHandlers)
 {
   nsresult rv = nsGenericHTMLElement::BindToTree(aDocument,
                                                  aParent,
                                                  aBindingParent,
                                                  aCompileEventHandlers);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!aDocument) {
-    return NS_OK;
-  }
-
   LOG(LogLevel::Debug, ("Track Element bound to tree."));
   if (!aParent || !aParent->IsNodeOfType(nsINode::eMEDIA)) {
     return NS_OK;
   }
 
   // Store our parent so we can look up its frame for display.
   if (!mMediaParent) {
     mMediaParent = static_cast<HTMLMediaElement*>(aParent);
@@ -258,17 +254,17 @@ HTMLTrackElement::BindToTree(nsIDocument
 
     // We may already have a TextTrack at this point if GetTrack() has already
     // been called. This happens, for instance, if script tries to get the
     // TextTrack before its mTrackElement has been bound to the DOM tree.
     if (!mTrack) {
       CreateTextTrack();
     }
     RefPtr<Runnable> r = NewRunnableMethod(this, &HTMLTrackElement::LoadResource);
-    mMediaParent->RunInStableState(r);
+    nsContentUtils::RunInStableState(r.forget());
   }
 
   return NS_OK;
 }
 
 void
 HTMLTrackElement::UnbindFromTree(bool aDeep, bool aNullParent)
 {