Bug 1508000 - Dispatch UAWidgetUnbindFromTree event before calling nsGenericHTMLElement::UnbindFromTree() r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D12205
This commit is contained in:
Timothy Guan-tin Chien
2018-11-28 02:29:38 +00:00
parent d3f77c28a9
commit 416f9229e7
5 changed files with 90 additions and 37 deletions

View File

@@ -4693,18 +4693,24 @@ HTMLMediaElement::UnbindFromTree(bool aDeep, bool aNullParent)
mUnboundFromTree = true;
mVisibilityState = Visibility::UNTRACKED;
if (GetShadowRoot() && IsInComposedDoc()) {
nsContentUtils::AddScriptRunner(NS_NewRunnableFunction(
"HTMLMediaElement::UnbindFromTree::UAWidgetUnbindFromTree",
[self = RefPtr<Element>(this)]() {
nsContentUtils::DispatchChromeEvent(
self->OwnerDoc(), self,
NS_LITERAL_STRING("UAWidgetUnbindFromTree"),
CanBubble::eYes, Cancelable::eNo);
self->UnattachShadow();
})
);
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
MOZ_ASSERT(IsHidden());
NotifyDecoderActivityChanges();
AsyncEventDispatcher* dispatcher =
new AsyncEventDispatcher(this,
NS_LITERAL_STRING("UAWidgetUnbindFromTree"),
CanBubble::eYes,
ChromeOnlyDispatch::eYes);
dispatcher->RunDOMEventWhenSafe();
RefPtr<HTMLMediaElement> self(this);
nsCOMPtr<nsIRunnable> task =
NS_NewRunnableFunction("dom::HTMLMediaElement::UnbindFromTree", [self]() {