зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1653390 - part5 : remove 'StopListeningMediaControlKeyIfNeeded()'. r=bryce
First, rename `Stop()` to `StopIfNeeded()`. Second, we have already have a check [1] in `StopIfNeeded()` to ensure that that function is only workable when the listener starts, so we don't need `StopListeningMediaControlKeyIfNeeded()` and can call `StopIfNeeded()` directly. [1] https://searchfox.org/mozilla-central/rev/9b282b34b5aa0f836beb735656c55efb2cc4c617/dom/html/HTMLMediaElement.cpp#425-427 Differential Revision: https://phabricator.services.mozilla.com/D84117
This commit is contained in:
Родитель
ba2335182a
Коммит
8e044f4e3a
|
@ -426,7 +426,12 @@ class HTMLMediaElement::MediaControlKeyListener final
|
|||
return true;
|
||||
}
|
||||
|
||||
void Stop() {
|
||||
/**
|
||||
* Stop listening to the media control keys which would make media not be able
|
||||
* to be controlled via pressing media control keys. If we haven't started
|
||||
* listening to the media control keys, then nothing would happen.
|
||||
*/
|
||||
void StopIfNeeded() {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
if (!IsStarted()) {
|
||||
// We have already been stopped, do not notify stop twice.
|
||||
|
@ -539,7 +544,7 @@ class HTMLMediaElement::MediaControlKeyListener final
|
|||
// `eStart` to the new browsing context. If the media was playing before,
|
||||
// we would also notify `ePlayed`.
|
||||
bool wasInPlayingState = mState == MediaPlaybackState::ePlayed;
|
||||
Stop();
|
||||
StopIfNeeded();
|
||||
Unused << Start();
|
||||
if (wasInPlayingState) {
|
||||
NotifyMediaStartedPlaying();
|
||||
|
@ -2006,7 +2011,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLMediaElement,
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSeekDOMPromise)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSetMediaKeysDOMPromise)
|
||||
if (tmp->mMediaControlKeyListener) {
|
||||
tmp->StopListeningMediaControlKeyIfNeeded();
|
||||
tmp->mMediaControlKeyListener->StopIfNeeded();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_WEAK_PTR
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
@ -2340,7 +2345,7 @@ void HTMLMediaElement::AbortExistingLoads() {
|
|||
// resume a paused media element.
|
||||
ClearResumeDelayedMediaPlaybackAgentIfNeeded();
|
||||
|
||||
StopListeningMediaControlKeyIfNeeded();
|
||||
mMediaControlKeyListener->StopIfNeeded();
|
||||
|
||||
// We may have changed mPaused, mAutoplaying, and other
|
||||
// things which can affect AddRemoveSelfReference
|
||||
|
@ -4267,7 +4272,7 @@ HTMLMediaElement::~HTMLMediaElement() {
|
|||
mResumeDelayedPlaybackAgent = nullptr;
|
||||
}
|
||||
|
||||
StopListeningMediaControlKeyIfNeeded();
|
||||
mMediaControlKeyListener->StopIfNeeded();
|
||||
mMediaControlKeyListener = nullptr;
|
||||
|
||||
WakeLockRelease();
|
||||
|
@ -6526,7 +6531,7 @@ void HTMLMediaElement::SuspendOrResumeElement(bool aSuspendElement) {
|
|||
mEventDeliveryPaused = true;
|
||||
// We won't want to resume media element from the bfcache.
|
||||
ClearResumeDelayedMediaPlaybackAgentIfNeeded();
|
||||
StopListeningMediaControlKeyIfNeeded();
|
||||
mMediaControlKeyListener->StopIfNeeded();
|
||||
} else {
|
||||
if (!mPaused) {
|
||||
mCurrentLoadPlayTime.Start();
|
||||
|
@ -7875,12 +7880,6 @@ void HTMLMediaElement::StartListeningMediaControlKeyIfNeeded() {
|
|||
}
|
||||
}
|
||||
|
||||
void HTMLMediaElement::StopListeningMediaControlKeyIfNeeded() {
|
||||
if (mMediaControlKeyListener->IsStarted()) {
|
||||
mMediaControlKeyListener->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void HTMLMediaElement::UpdateMediaControlAfterPictureInPictureModeChanged() {
|
||||
// Hasn't started to connect with media control, no need to update anything.
|
||||
if (!mMediaControlKeyListener->IsStarted()) {
|
||||
|
|
|
@ -1930,7 +1930,6 @@ class HTMLMediaElement : public nsGenericHTMLElement,
|
|||
// We use MediaControlKeyListener to listen media control key, by which we
|
||||
// would play or pause media element.
|
||||
void StartListeningMediaControlKeyIfNeeded();
|
||||
void StopListeningMediaControlKeyIfNeeded();
|
||||
RefPtr<MediaControlKeyListener> mMediaControlKeyListener;
|
||||
|
||||
// Return true if the media element is being used in picture in picture mode.
|
||||
|
|
Загрузка…
Ссылка в новой задаче