Bug 1382574 - part3 : remove HTMLMediaElement::mHasUserInteraction. r=jwwang
authorAlastor Wu <alwu@mozilla.com>
Wed, 22 Nov 2017 00:33:23 +0800
changeset 392960 356b50c5becf41a2839ecb895e7c2219223f55b5
parent 392959 8938ef573e4f7ade3f40209038bc2c6c26de8923
child 392961 4a35428990925d014a83d267fd1fdab696eb0aea
push id32947
push useraciure@mozilla.com
push dateWed, 22 Nov 2017 09:57:59 +0000
treeherdermozilla-central@5378dcb45044 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1382574
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382574 - part3 : remove HTMLMediaElement::mHasUserInteraction. r=jwwang We won't need to check the whether the media element is interacted with user for autoplay anymore. MozReview-Commit-ID: 2tll9LtGyVR
dom/html/HTMLMediaElement.cpp
dom/html/HTMLMediaElement.h
--- 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;