mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-03 18:47:53 +00:00
Bug 1319771 - part2 : resume foreground window if it was still be blocked. r=baku
In previous patch, we modify the behavior of nsDocument, now it would only resume window when document has active media components. However, it causes another issue. If the tab really goes to foreground, but there is no active media component, the tab would still be blocked and it won't be resumed anymore. Therefore, we need to resume it by ourself if the tab is on the foreground but doesn't be resumed yet. MozReview-Commit-ID: EdnQ7sRkSJK --HG-- extra : rebase_source : c2ab932cc3134531e5c49581c5e63b4aabef6ca4
This commit is contained in:
parent
9e4d1c7549
commit
b55cdff3c1
@ -184,6 +184,9 @@ AudioChannelAgent::InitInternal(nsPIDOMWindowInner* aWindow,
|
|||||||
mCallback = aCallback;
|
mCallback = aCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RefPtr<AudioChannelService> service = AudioChannelService::GetOrCreate();
|
||||||
|
service->NotifyCreatedNewAgent(this);
|
||||||
|
|
||||||
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
MOZ_LOG(AudioChannelService::GetAudioChannelLog(), LogLevel::Debug,
|
||||||
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
|
("AudioChannelAgent, InitInternal, this = %p, type = %d, "
|
||||||
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
|
"owner = %p, hasCallback = %d\n", this, mAudioChannelType,
|
||||||
|
@ -293,6 +293,19 @@ AudioChannelService::~AudioChannelService()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioChannelService::NotifyCreatedNewAgent(AudioChannelAgent* aAgent)
|
||||||
|
{
|
||||||
|
MOZ_ASSERT(aAgent);
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindowOuter> window = aAgent->Window();
|
||||||
|
if (!window) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window->NotifyCreatedNewMediaComponent();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
AudioChannelService::RegisterAudioChannelAgent(AudioChannelAgent* aAgent,
|
||||||
AudibleState aAudible)
|
AudibleState aAudible)
|
||||||
|
@ -199,6 +199,8 @@ public:
|
|||||||
void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
|
void ChildStatusReceived(uint64_t aChildID, bool aTelephonyChannel,
|
||||||
bool aContentOrNormalChannel, bool aAnyChannel);
|
bool aContentOrNormalChannel, bool aAnyChannel);
|
||||||
|
|
||||||
|
void NotifyCreatedNewAgent(AudioChannelAgent* aAgent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioChannelService();
|
AudioChannelService();
|
||||||
~AudioChannelService();
|
~AudioChannelService();
|
||||||
|
@ -12085,10 +12085,7 @@ nsDocument::MaybeActiveMediaComponents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mEverInForeground = true;
|
mEverInForeground = true;
|
||||||
if (GetWindow()->GetMediaSuspend() == nsISuspendedTypes::SUSPENDED_BLOCK &&
|
GetWindow()->MaybeActiveMediaComponents();
|
||||||
AudioChannelService::IsServiceStarted()) {
|
|
||||||
GetWindow()->SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
@ -4172,6 +4172,45 @@ nsPIDOMWindowInner::IsRunningTimeout()
|
|||||||
return TimeoutManager().IsRunningTimeout();
|
return TimeoutManager().IsRunningTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsPIDOMWindowOuter::NotifyCreatedNewMediaComponent()
|
||||||
|
{
|
||||||
|
if (mMediaSuspend != nsISuspendedTypes::SUSPENDED_BLOCK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the document is already on the foreground but the suspend state is still
|
||||||
|
// suspend-block, that means the media component was created after calling
|
||||||
|
// MaybeActiveMediaComponents, so the window's suspend state doesn't be
|
||||||
|
// changed yet. Therefore, we need to call it again, because the state is only
|
||||||
|
// changed after there exists alive media within the window.
|
||||||
|
MaybeActiveMediaComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsPIDOMWindowOuter::MaybeActiveMediaComponents()
|
||||||
|
{
|
||||||
|
if (IsInnerWindow()) {
|
||||||
|
return mOuterWindow->MaybeActiveMediaComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsPIDOMWindowInner> inner = GetCurrentInnerWindow();
|
||||||
|
if (!inner) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocument> doc = inner->GetExtantDoc();
|
||||||
|
if (!doc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doc->Hidden() &&
|
||||||
|
mMediaSuspend == nsISuspendedTypes::SUSPENDED_BLOCK &&
|
||||||
|
AudioChannelService::IsServiceStarted()) {
|
||||||
|
SetMediaSuspend(nsISuspendedTypes::NONE_SUSPENDED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SuspendTypes
|
SuspendTypes
|
||||||
nsPIDOMWindowOuter::GetMediaSuspend() const
|
nsPIDOMWindowOuter::GetMediaSuspend() const
|
||||||
{
|
{
|
||||||
|
@ -963,6 +963,9 @@ public:
|
|||||||
float GetAudioVolume() const;
|
float GetAudioVolume() const;
|
||||||
nsresult SetAudioVolume(float aVolume);
|
nsresult SetAudioVolume(float aVolume);
|
||||||
|
|
||||||
|
void NotifyCreatedNewMediaComponent();
|
||||||
|
void MaybeActiveMediaComponents();
|
||||||
|
|
||||||
void SetServiceWorkersTestingEnabled(bool aEnabled);
|
void SetServiceWorkersTestingEnabled(bool aEnabled);
|
||||||
bool GetServiceWorkersTestingEnabled();
|
bool GetServiceWorkersTestingEnabled();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user