Bug 1618102 - Use BrowsingContext for Full screen API "is caller in focused tab?" check. r=farre

Differential Revision: https://phabricator.services.mozilla.com/D64288

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2020-02-26 16:05:12 +00:00
Родитель 7727d63396
Коммит cb9b1d9bb4
1 изменённых файлов: 32 добавлений и 15 удалений

Просмотреть файл

@ -13429,28 +13429,45 @@ static bool IsInActiveTab(Document* aDoc) {
return false;
}
nsCOMPtr<nsIDocShellTreeItem> rootItem;
docshell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
if (!rootItem) {
return false;
}
nsCOMPtr<nsPIDOMWindowOuter> rootWin = rootItem->GetWindow();
if (!rootWin) {
return false;
}
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm) {
return false;
}
nsCOMPtr<mozIDOMWindowProxy> activeWindow;
fm->GetActiveWindow(getter_AddRefs(activeWindow));
if (!activeWindow) {
if (XRE_IsParentProcess()) {
// Keep dom/tests/mochitest/chrome/test_MozDomFullscreen_event.xhtml happy
// by retaining the old code path for the parent process.
nsCOMPtr<nsIDocShellTreeItem> rootItem;
docshell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
if (!rootItem) {
return false;
}
nsCOMPtr<nsPIDOMWindowOuter> rootWin = rootItem->GetWindow();
if (!rootWin) {
return false;
}
nsCOMPtr<nsPIDOMWindowOuter> activeWindow;
activeWindow = fm->GetActiveWindow();
if (!activeWindow) {
return false;
}
return activeWindow == rootWin;
}
BrowsingContext* bc = aDoc->GetBrowsingContext();
if (!bc) {
return false;
}
return activeWindow == rootWin;
BrowsingContext* activeBrowsingContext = fm->GetActiveBrowsingContext();
if (!activeBrowsingContext) {
return false;
}
return activeBrowsingContext == bc->Top();
}
void Document::RemoteFrameFullscreenChanged(Element* aFrameElement) {