Backed out changeset 178fa7e29bb6 (bug 1585070) for Browser-chrome failures in general/browser_windowactivation.js. CLOSED TREE

This commit is contained in:
Dorel Luca
2020-08-12 20:10:46 +03:00
parent bb5c52efa7
commit 282e4df17e
6 changed files with 48 additions and 35 deletions

View File

@@ -6616,15 +6616,33 @@ void nsGlobalWindowOuter::ActivateOrDeactivate(bool aActivate) {
}
}
static CallState NotifyDocumentTree(Document& aDocument) {
aDocument.EnumerateSubDocuments(NotifyDocumentTree);
aDocument.UpdateDocumentStates(NS_DOCUMENT_STATE_WINDOW_INACTIVE, true);
return CallState::Continue;
}
void nsGlobalWindowOuter::SetActive(bool aActive) {
if (mBrowsingContext) {
Unused << mBrowsingContext->Top()->SetIsActiveBrowserWindow(aActive);
nsPIDOMWindowOuter::SetActive(aActive);
if (mDoc) {
NotifyDocumentTree(*mDoc);
}
}
bool nsGlobalWindowOuter::IsTopLevelWindowActive() {
BrowsingContext* bc = GetBrowsingContext();
return bc ? bc->Top()->GetIsActiveBrowserWindow() : false;
nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShell());
if (!treeItem) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> rootItem;
treeItem->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
if (!rootItem) {
return false;
}
nsCOMPtr<nsPIDOMWindowOuter> domWindow = rootItem->GetWindow();
return domWindow && domWindow->IsActive();
}
void nsGlobalWindowOuter::SetIsBackground(bool aIsBackground) {
@@ -7524,6 +7542,7 @@ mozilla::dom::DocGroup* nsPIDOMWindowOuter::GetDocGroup() const {
nsPIDOMWindowOuter::nsPIDOMWindowOuter(uint64_t aWindowID)
: mFrameElement(nullptr),
mModalStateDepth(0),
mIsActive(false),
mIsBackground(false),
mMediaSuspend(StaticPrefs::media_block_autoplay_until_in_foreground()
? nsISuspendedTypes::SUSPENDED_BLOCK