Bug 1458383 - Assume tabs delay playback start of media. r=baku
Regardless of whether autoplay is enabled or not, we want to delay playback
start in tabs until the tab has been in the foreground. So initialize
nsPIDOMWindowOuter::mMediaSuspend to SUSPENDED_BLOCK if the controlling
pref for the delay-playback-start feature is enabled.
MozReview-Commit-ID: 7A8U5922AW8
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -7698,28 +7698,36 @@ nsPIDOMWindowOuter::GetDocGroup() const
namespace mozilla {
namespace dom {
extern uint64_t
NextWindowID();
} // namespace dom
} // namespace mozilla
nsPIDOMWindowOuter::nsPIDOMWindowOuter()
-: mFrameElement(nullptr), mDocShell(nullptr), mModalStateDepth(0),
- mIsActive(false), mIsBackground(false),
- mMediaSuspend(
- Preferences::GetBool("media.block-autoplay-until-in-foreground", true) &&
- Preferences::GetBool("media.autoplay.enabled", true) ?
- nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
- mAudioMuted(false), mAudioVolume(1.0),
- mDesktopModeViewport(false), mIsRootOuterWindow(false), mInnerWindow(nullptr),
+ : mFrameElement(nullptr)
+ , mDocShell(nullptr)
+ , mModalStateDepth(0)
+ , mIsActive(false)
+ , mIsBackground(false)
+ , mMediaSuspend(
+ Preferences::GetBool("media.block-autoplay-until-in-foreground", true)
+ ? nsISuspendedTypes::SUSPENDED_BLOCK
+ : nsISuspendedTypes::NONE_SUSPENDED)
+ , mAudioMuted(false)
+ , mAudioVolume(1.0)
+ , mDesktopModeViewport(false)
+ , mIsRootOuterWindow(false)
+ , mInnerWindow(nullptr)
+ ,
// Make sure no actual window ends up with mWindowID == 0
- mWindowID(NextWindowID()),
- mMarkedCCGeneration(0), mServiceWorkersTestingEnabled(false),
- mLargeAllocStatus(LargeAllocStatus::NONE)
+ mWindowID(NextWindowID())
+ , mMarkedCCGeneration(0)
+ , mServiceWorkersTestingEnabled(false)
+ , mLargeAllocStatus(LargeAllocStatus::NONE)
{
}
nsPIDOMWindowOuter::~nsPIDOMWindowOuter() {}
nsAutoPopupStatePusherInternal::nsAutoPopupStatePusherInternal(PopupControlState aState, bool aForce)
: mOldState(nsContentUtils::PushPopupControlState(aState, aForce))
{