Bug 1583052 - Remove an optimization introduced in bug 1555946 which is not sound. r=smaug
Tasks dispatched from RunInStableState() can be cancelled if there's a load in between, so this is not sound. See nsSyncSection::IsCancelled(). This is the only patch in this bug that is worth uplifting IMO. Differential Revision: https://phabricator.services.mozilla.com/D46773
This commit is contained in:
@@ -4452,21 +4452,25 @@ void HTMLMediaElement::UnbindFromTree(bool aNullParent) {
|
||||
MOZ_ASSERT(IsHidden());
|
||||
NotifyDecoderActivityChanges();
|
||||
|
||||
// https://html.spec.whatwg.org/#playing-the-media-resource:remove-an-element-from-a-document
|
||||
//
|
||||
// Dispatch a task to run once we're in a stable state which ensures we're
|
||||
// paused if we're no longer in a document. Note we set a flag here to
|
||||
// ensure we don't dispatch redundant tasks.
|
||||
if (!mDispatchedTaskToPauseIfNotInDocument) {
|
||||
mDispatchedTaskToPauseIfNotInDocument = true;
|
||||
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
|
||||
"dom::HTMLMediaElement::UnbindFromTree",
|
||||
[self = RefPtr<HTMLMediaElement>(this)]() {
|
||||
self->mDispatchedTaskToPauseIfNotInDocument = false;
|
||||
if (!self->IsInComposedDoc()) {
|
||||
self->Pause();
|
||||
}
|
||||
});
|
||||
RunInStableState(task);
|
||||
}
|
||||
// paused if we're no longer in a document. Note that we need to dispatch this
|
||||
// even if there are other tasks in flight for this because these can be
|
||||
// cancelled if there's a new load.
|
||||
//
|
||||
// FIXME(emilio): Per that spec section, we should only do this if we used to
|
||||
// be connected, though other browsers match our current behavior...
|
||||
//
|
||||
// Also, https://github.com/whatwg/html/issues/4928
|
||||
nsCOMPtr<nsIRunnable> task = NS_NewRunnableFunction(
|
||||
"dom::HTMLMediaElement::UnbindFromTree",
|
||||
[self = RefPtr<HTMLMediaElement>(this)]() {
|
||||
if (!self->IsInComposedDoc()) {
|
||||
self->Pause();
|
||||
}
|
||||
});
|
||||
RunInStableState(task);
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
||||
Reference in New Issue
Block a user