Bug 1785089 - Minor drive-by clean-ups. r=alwu
Differential Revision: https://phabricator.services.mozilla.com/D154800
This commit is contained in:
@@ -2461,13 +2461,12 @@ static nsCString DocumentOrigin(Document* aDoc) {
|
||||
void HTMLMediaElement::Load() {
|
||||
LOG(LogLevel::Debug,
|
||||
("%p Load() hasSrcAttrStream=%d hasSrcAttr=%d hasSourceChildren=%d "
|
||||
"handlingInput=%d hasAutoplayAttr=%d IsAllowedToPlay=%d "
|
||||
"handlingInput=%d hasAutoplayAttr=%d AllowedToPlay=%d "
|
||||
"ownerDoc=%p (%s) ownerDocUserActivated=%d "
|
||||
"muted=%d volume=%f",
|
||||
this, !!mSrcAttrStream, HasAttr(kNameSpaceID_None, nsGkAtoms::src),
|
||||
HasSourceChildren(this), UserActivation::IsHandlingUserInput(),
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay),
|
||||
AutoplayPolicy::IsAllowedToPlay(*this), OwnerDoc(),
|
||||
HasAttr(nsGkAtoms::autoplay), AllowedToPlay(), OwnerDoc(),
|
||||
DocumentOrigin(OwnerDoc()).get(),
|
||||
OwnerDoc()->HasBeenUserGestureActivated(), mMuted, mVolume));
|
||||
|
||||
@@ -2497,9 +2496,9 @@ void HTMLMediaElement::DoLoad() {
|
||||
// intent to play by calling load() in the click handler of a "catalog
|
||||
// view" of a gallery of videos.
|
||||
mIsBlessed = true;
|
||||
// Mark the channel as urgent-start when autopaly so that it will play the
|
||||
// Mark the channel as urgent-start when autoplay so that it will play the
|
||||
// media from src after loading enough resource.
|
||||
if (HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
|
||||
if (HasAttr(nsGkAtoms::autoplay)) {
|
||||
mUseUrgentStartForChannel = true;
|
||||
}
|
||||
}
|
||||
@@ -2934,9 +2933,7 @@ void HTMLMediaElement::UpdatePreloadAction() {
|
||||
PreloadAction nextAction = PRELOAD_UNDEFINED;
|
||||
// If autoplay is set, or we're playing, we should always preload data,
|
||||
// as we'll need it to play.
|
||||
if ((AutoplayPolicy::IsAllowedToPlay(*this) &&
|
||||
HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) ||
|
||||
!mPaused) {
|
||||
if ((AllowedToPlay() && HasAttr(nsGkAtoms::autoplay)) || !mPaused) {
|
||||
nextAction = HTMLMediaElement::PRELOAD_ENOUGH;
|
||||
} else {
|
||||
// Find the appropriate preload action by looking at the attribute.
|
||||
@@ -3429,7 +3426,7 @@ void HTMLMediaElement::PauseIfShouldNotBePlaying() {
|
||||
if (GetPaused()) {
|
||||
return;
|
||||
}
|
||||
if (!AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
if (!AllowedToPlay()) {
|
||||
AUTOPLAY_LOG("pause because not allowed to play, element=%p", this);
|
||||
ErrorResult rv;
|
||||
Pause(rv);
|
||||
@@ -3904,7 +3901,7 @@ RefPtr<GenericNonExclusivePromise> HTMLMediaElement::GetAllowedToPlayPromise() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(!mOutputStreams.IsEmpty(),
|
||||
"This method should only be called during stream capturing!");
|
||||
if (AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
if (AllowedToPlay()) {
|
||||
AUTOPLAY_LOG("MediaElement %p has allowed to play, resolve promise", this);
|
||||
return GenericNonExclusivePromise::CreateAndResolve(true, __func__);
|
||||
}
|
||||
@@ -4417,7 +4414,7 @@ already_AddRefed<Promise> HTMLMediaElement::Play(ErrorResult& aRv) {
|
||||
const bool handlingUserInput = UserActivation::IsHandlingUserInput();
|
||||
mPendingPlayPromises.AppendElement(promise);
|
||||
|
||||
if (AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
if (AllowedToPlay()) {
|
||||
AUTOPLAY_LOG("allow MediaElement %p to play", this);
|
||||
mAllowedToPlayPromise.ResolveIfExists(true, __func__);
|
||||
PlayInternal(handlingUserInput);
|
||||
@@ -5971,7 +5968,7 @@ void HTMLMediaElement::ChangeReadyState(nsMediaReadyState aState) {
|
||||
DispatchAsyncEvent(u"canplay"_ns);
|
||||
if (!mPaused) {
|
||||
if (mDecoder && !mSuspendedByInactiveDocOrDocshell) {
|
||||
MOZ_ASSERT(AutoplayPolicy::IsAllowedToPlay(*this));
|
||||
MOZ_ASSERT(AllowedToPlay());
|
||||
mDecoder->Play();
|
||||
}
|
||||
NotifyAboutPlaying();
|
||||
@@ -6074,7 +6071,7 @@ void HTMLMediaElement::CheckAutoplayDataReady() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
if (!AllowedToPlay()) {
|
||||
DispatchEventsWhenPlayWasNotAllowed();
|
||||
return;
|
||||
}
|
||||
@@ -6400,8 +6397,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aSuspendElement) {
|
||||
// when it comes back from the bfcache, we would notify front end to show
|
||||
// the blocking icon in order to inform user that the site is still being
|
||||
// blocked.
|
||||
if (mHasEverBeenBlockedForAutoplay &&
|
||||
!AutoplayPolicy::IsAllowedToPlay(*this)) {
|
||||
if (mHasEverBeenBlockedForAutoplay && !AllowedToPlay()) {
|
||||
MaybeNotifyAutoplayBlocked();
|
||||
}
|
||||
StartMediaControlKeyListenerIfNeeded();
|
||||
|
||||
Reference in New Issue
Block a user