Bug 1239899. Part 2 - per spec. await a stable state to pause the element when it is removed from the document. r=cpearce

MozReview-Commit-ID: BCCWgXmUchU
This commit is contained in:
JW Wang
2016-09-23 16:16:43 +08:00
parent 19ae50ff0f
commit 4e413b1c9f

View File

@@ -3653,16 +3653,21 @@ void HTMLMediaElement::UnbindFromTree(bool aDeep,
{
mUnboundFromTree = true;
if (!mPaused && mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
Pause();
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
if (mDecoder) {
MOZ_ASSERT(IsHidden());
mDecoder->NotifyOwnerActivityChanged(false);
}
RefPtr<HTMLMediaElement> self(this);
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction([self] () {
if (self->mUnboundFromTree &&
self->mNetworkState != nsIDOMHTMLMediaElement::NETWORK_EMPTY) {
self->Pause();
}
});
RunInStableState(task);
}
/* static */