Bug 1576627 - Move MaybeNotifyAutoplayBlocked from Document to HTMLMediaElement; r=alwu
Given that it is used only in HTMLMediaElement. Differential Revision: https://phabricator.services.mozilla.com/D43452
This commit is contained in:
@@ -3876,12 +3876,26 @@ void HTMLMediaElement::DispatchEventsWhenPlayWasNotAllowed() {
|
||||
ChromeOnlyDispatch::eYes);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
#endif
|
||||
OwnerDoc()->MaybeNotifyAutoplayBlocked();
|
||||
MaybeNotifyAutoplayBlocked();
|
||||
ReportToConsole(nsIScriptError::warningFlag, "BlockAutoplayError");
|
||||
mHasPlayEverBeenBlocked = true;
|
||||
mHasEverBeenBlockedForAutoplay = true;
|
||||
}
|
||||
|
||||
void HTMLMediaElement::MaybeNotifyAutoplayBlocked() {
|
||||
Document* topLevelDoc = OwnerDoc()->GetTopLevelContentDocument();
|
||||
if (!topLevelDoc) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This event is used to notify front-end side that we've blocked autoplay,
|
||||
// so front-end side should show blocking icon as well.
|
||||
RefPtr<AsyncEventDispatcher> asyncDispatcher = new AsyncEventDispatcher(
|
||||
topLevelDoc, NS_LITERAL_STRING("GloballyAutoplayBlocked"),
|
||||
CanBubble::eYes, ChromeOnlyDispatch::eYes);
|
||||
asyncDispatcher->PostDOMEvent();
|
||||
}
|
||||
|
||||
void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) {
|
||||
if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) {
|
||||
// The media load algorithm will be initiated by a user interaction.
|
||||
@@ -6099,7 +6113,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aPauseElement,
|
||||
// blocked.
|
||||
if (mHasEverBeenBlockedForAutoplay &&
|
||||
!AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
OwnerDoc()->MaybeNotifyAutoplayBlocked();
|
||||
MaybeNotifyAutoplayBlocked();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user