зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1262053 - part1 : unblock window's media when the page was first visited. r=baku
MozReview-Commit-ID: 5g5cYdgC8sg --HG-- extra : rebase_source : 5af18ff846f464b1d3d195d7dc2634e03601cfcc
This commit is contained in:
Родитель
4460ee8698
Коммит
b194d26e61
|
@ -1498,6 +1498,8 @@ nsDocument::nsDocument(const char* aContentType)
|
||||||
// Add the base queue sentinel to the processing stack.
|
// Add the base queue sentinel to the processing stack.
|
||||||
sProcessingStack->AppendElement((CustomElementData*) nullptr);
|
sProcessingStack->AppendElement((CustomElementData*) nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEverInForeground = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -12603,6 +12605,10 @@ nsDocument::UpdateVisibilityState()
|
||||||
|
|
||||||
EnumerateActivityObservers(NotifyActivityChanged, nullptr);
|
EnumerateActivityObservers(NotifyActivityChanged, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mVisibilityState == dom::VisibilityState::Visible) {
|
||||||
|
MaybeActiveMediaComponents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VisibilityState
|
VisibilityState
|
||||||
|
@ -12638,6 +12644,23 @@ nsDocument::PostVisibilityUpdateEvent()
|
||||||
NS_DispatchToMainThread(event);
|
NS_DispatchToMainThread(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDocument::MaybeActiveMediaComponents()
|
||||||
|
{
|
||||||
|
if (mEverInForeground) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mWindow) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mEverInForeground = true;
|
||||||
|
if (GetWindow()->GetMediaSuspend() == nsISuspendedTypes::SUSPENDED_BLOCK) {
|
||||||
|
GetWindow()->SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDocument::GetMozHidden(bool* aHidden)
|
nsDocument::GetMozHidden(bool* aHidden)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1209,6 +1209,10 @@ public:
|
||||||
// Posts an event to call UpdateVisibilityState
|
// Posts an event to call UpdateVisibilityState
|
||||||
virtual void PostVisibilityUpdateEvent() override;
|
virtual void PostVisibilityUpdateEvent() override;
|
||||||
|
|
||||||
|
// Since we wouldn't automatically play media from non-visited page, we need
|
||||||
|
// to notify window when the page was first visited.
|
||||||
|
void MaybeActiveMediaComponents();
|
||||||
|
|
||||||
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
|
virtual void DocAddSizeOfExcludingThis(nsWindowSizes* aWindowSizes) const override;
|
||||||
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
|
// DocAddSizeOfIncludingThis is inherited from nsIDocument.
|
||||||
|
|
||||||
|
|
|
@ -618,7 +618,8 @@ nsPIDOMWindow<T>::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow)
|
||||||
mInnerObjectsFreed(false),
|
mInnerObjectsFreed(false),
|
||||||
mIsModalContentWindow(false),
|
mIsModalContentWindow(false),
|
||||||
mIsActive(false), mIsBackground(false),
|
mIsActive(false), mIsBackground(false),
|
||||||
mMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED),
|
mMediaSuspend(Preferences::GetBool("media.block-autoplay-until-in-foreground", true) ?
|
||||||
|
nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED),
|
||||||
mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
|
mAudioMuted(false), mAudioVolume(1.0), mAudioCaptured(false),
|
||||||
mDesktopModeViewport(false), mInnerWindow(nullptr),
|
mDesktopModeViewport(false), mInnerWindow(nullptr),
|
||||||
mOuterWindow(aOuterWindow),
|
mOuterWindow(aOuterWindow),
|
||||||
|
|
|
@ -3069,6 +3069,9 @@ protected:
|
||||||
// Do we currently have an event posted to call FlushUserFontSet?
|
// Do we currently have an event posted to call FlushUserFontSet?
|
||||||
bool mPostedFlushUserFontSet : 1;
|
bool mPostedFlushUserFontSet : 1;
|
||||||
|
|
||||||
|
// True is document has ever been in a foreground window.
|
||||||
|
bool mEverInForeground : 1;
|
||||||
|
|
||||||
enum Type {
|
enum Type {
|
||||||
eUnknown, // should never be used
|
eUnknown, // should never be used
|
||||||
eHTML,
|
eHTML,
|
||||||
|
|
|
@ -5532,6 +5532,7 @@ pref("dom.webkitBlink.dirPicker.enabled", true);
|
||||||
pref("dom.webkitBlink.filesystem.enabled", true);
|
pref("dom.webkitBlink.filesystem.enabled", true);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
pref("media.block-autoplay-until-in-foreground", true);
|
||||||
#ifdef MOZ_STYLO
|
#ifdef MOZ_STYLO
|
||||||
// Is the Servo-backed style system enabled?
|
// Is the Servo-backed style system enabled?
|
||||||
pref("layout.css.servo.enabled", true);
|
pref("layout.css.servo.enabled", true);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче