@@ -2526,6 +2526,7 @@ void HTMLMediaElement::AbortExistingLoads() {
25262526 // indirectly which depends on mPaused. So we need to update mPaused first.
25272527 if (!mPaused ) {
25282528 mPaused = true ;
2529+ UpdatePlaybackPseudoClasses ();
25292530 PlayPromise::RejectPromises (TakePendingPlayPromises (),
25302531 NS_ERROR_DOM_MEDIA_ABORT_ERR);
25312532 }
@@ -3626,6 +3627,7 @@ void HTMLMediaElement::PauseInternal() {
36263627 }
36273628 bool oldPaused = mPaused ;
36283629 mPaused = true ;
3630+ UpdatePlaybackPseudoClasses ();
36293631 // Step 1,
36303632 // https://html.spec.whatwg.org/multipage/media.html#internal-pause-steps
36313633 mCanAutoplayFlag = false ;
@@ -4761,6 +4763,7 @@ void HTMLMediaElement::Init() {
47614763
47624764 OwnerDoc ()->SetDocTreeHadMedia ();
47634765 mShutdownObserver ->Subscribe (this );
4766+ UpdatePlaybackPseudoClasses ();
47644767 mInitialized = true ;
47654768}
47664769
@@ -5008,6 +5011,7 @@ void HTMLMediaElement::PlayInternal(bool aHandlingUserInput) {
50085011
50095012 const bool oldPaused = mPaused ;
50105013 mPaused = false ;
5014+ UpdatePlaybackPseudoClasses ();
50115015 // Step 5,
50125016 // https://html.spec.whatwg.org/multipage/media.html#internal-play-steps
50135017 mCanAutoplayFlag = false ;
@@ -5100,6 +5104,18 @@ void HTMLMediaElement::UpdateWakeLock() {
51005104 }
51015105}
51025106
5107+ void HTMLMediaElement::UpdatePlaybackPseudoClasses () {
5108+ MOZ_ASSERT (NS_IsMainThread());
5109+ if (mPaused ) {
5110+ // We don’t need to update the playing state because these states are
5111+ // exclusive, and the `:playing` pseudo-class is determined by checking
5112+ // the element's PAUSED state.
5113+ AddStates (ElementState::PAUSED);
5114+ } else {
5115+ RemoveStates (ElementState::PAUSED);
5116+ }
5117+ }
5118+
51035119void HTMLMediaElement::CreateAudioWakeLockIfNeeded () {
51045120 MOZ_ASSERT (NS_IsMainThread());
51055121 if (AppShutdown::IsInOrBeyond (ShutdownPhase::AppShutdownConfirmed)) {
@@ -6725,6 +6741,8 @@ void HTMLMediaElement::CheckAutoplayDataReady() {
67256741void HTMLMediaElement::RunAutoplay () {
67266742 mAllowedToPlayPromise .ResolveIfExists (true , __func__);
67276743 mPaused = false ;
6744+ UpdatePlaybackPseudoClasses ();
6745+
67286746 // We changed mPaused which can affect AddRemoveSelfReference
67296747 AddRemoveSelfReference ();
67306748 UpdateSrcMediaStreamPlaying ();
@@ -8068,6 +8086,7 @@ void HTMLMediaElement::AsyncResolvePendingPlayPromises() {
80688086void HTMLMediaElement::AsyncRejectPendingPlayPromises (nsresult aError) {
80698087 if (!mPaused ) {
80708088 mPaused = true ;
8089+ UpdatePlaybackPseudoClasses ();
80718090 QueueEvent (u" pause" _ns);
80728091 }
80738092
0 commit comments