Bug 1673509 - part2 : 'deactivated' should be the last event for media controller. r=chunmin

We should not dispatch any other events (except `deactivated`) after controller is deactivated.

Differential Revision: https://phabricator.services.mozilla.com/D95358
This commit is contained in:
alwu 2020-11-19 00:33:24 +00:00
Родитель 08b35cc74e
Коммит 08c42352f1
1 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -521,16 +521,22 @@ void MediaController::HandleMetadataChanged(
}
void MediaController::DispatchAsyncEvent(const nsAString& aName) {
LOG("Dispatch event %s", NS_ConvertUTF16toUTF8(aName).get());
RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, aName, CanBubble::eYes);
asyncDispatcher->PostDOMEvent();
RefPtr<Event> event = NS_NewDOMEvent(this, nullptr, nullptr);
event->InitEvent(aName, false, false);
event->SetTrusted(true);
DispatchAsyncEvent(event);
}
void MediaController::DispatchAsyncEvent(Event* aEvent) {
MOZ_ASSERT(aEvent);
nsAutoString eventType;
aEvent->GetType(eventType);
if (!mIsActive && !eventType.EqualsLiteral("deactivated")) {
LOG("Only 'deactivated' can be dispatched on a deactivated controller, not "
"'%s'",
NS_ConvertUTF16toUTF8(eventType).get());
return;
}
LOG("Dispatch event %s", NS_ConvertUTF16toUTF8(eventType).get());
RefPtr<AsyncEventDispatcher> asyncDispatcher =
new AsyncEventDispatcher(this, aEvent);