Bug 1382574 - part3 : remove HTMLMediaElement::mHasUserInteraction.
We won't need to check the whether the media element is interacted with user for
autoplay anymore.
MozReview-Commit-ID: 2tll9LtGyVR
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -1967,23 +1967,17 @@ NS_IMETHODIMP HTMLMediaElement::Load()
}
void HTMLMediaElement::DoLoad()
{
if (mIsRunningLoadMethod) {
return;
}
- // Detect if user has interacted with element so that play will not be
- // blocked when initiated by a script. This enables sites to capture user
- // intent to play by calling load() in the click handler of a "catalog
- // view" of a gallery of videos.
if (EventStateManager::IsHandlingUserInput()) {
- mHasUserInteraction = true;
-
// Mark the channel as urgent-start when autopaly so that it will play the
// media from src after loading enough resource.
if (HasAttr(kNameSpaceID_None, nsGkAtoms::autoplay)) {
mUseUrgentStartForChannel = true;
}
}
SetPlayedOrSeeked(false);
@@ -2749,22 +2743,16 @@ HTMLMediaElement::Seek(double aTime,
MOZ_ASSERT(!mozilla::IsNaN(aTime));
RefPtr<Promise> promise = CreateDOMPromise(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
- // Detect if user has interacted with element by seeking so that
- // play will not be blocked when initiated by a script.
- if (EventStateManager::IsHandlingUserInput()) {
- mHasUserInteraction = true;
- }
-
StopSuspendingAfterFirstFrame();
if (mSrcStream) {
// do nothing since media streams have an empty Seekable range.
promise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return promise.forget();
}
@@ -4038,17 +4026,16 @@ HTMLMediaElement::HTMLMediaElement(alrea
mShuttingDown(false),
mSuspendedForPreloadNone(false),
mSrcStreamIsPlaying(false),
mMediaSecurityVerified(false),
mCORSMode(CORS_NONE),
mIsEncrypted(false),
mWaitingForKey(NOT_WAITING_FOR_KEY),
mDisableVideo(false),
- mHasUserInteraction(false),
mFirstFrameLoaded(false),
mDefaultPlaybackStartPosition(0.0),
mHasSuspendTaint(false),
mMediaTracksConstructed(false),
mVisibilityState(Visibility::UNTRACKED),
mErrorSink(new ErrorSink(this)),
mAudioChannelWrapper(new AudioChannelAgentCallback(this))
{
@@ -4223,19 +4210,16 @@ HTMLMediaElement::PlayInternal(ErrorResu
// Let promise be a new promise and append promise to the list of pending
// play promises.
RefPtr<Promise> promise = CreateDOMPromise(aRv);
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
mPendingPlayPromises.AppendElement(promise);
- // Play was not blocked so assume user interacted with the element.
- mHasUserInteraction = true;
-
if (mPreloadAction == HTMLMediaElement::PRELOAD_NONE) {
// The media load algorithm will be initiated by a user interaction.
// We want to boost the channel priority for better responsiveness.
// Note this must be done before UpdatePreloadAction() which will
// update |mPreloadAction|.
mUseUrgentStartForChannel = true;
}
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -1772,20 +1772,16 @@ private:
TimeDurationAccumulator mPlayTime;
// Total time a video has spent playing while hidden.
TimeDurationAccumulator mHiddenPlayTime;
// Total time a video has (or would have) spent in video-decode-suspend mode.
TimeDurationAccumulator mVideoDecodeSuspendTime;
- // Indicates if user has interacted with the element.
- // Used to block autoplay when disabled.
- bool mHasUserInteraction;
-
// True if the first frame has been successfully loaded.
bool mFirstFrameLoaded;
// Media elements also have a default playback start position, which must
// initially be set to zero seconds. This time is used to allow the element to
// be seeked even before the media is loaded.
double mDefaultPlaybackStartPosition;