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-27 10:08:31 +00:00
Родитель 77294951e7
Коммит cb5aed4e04
1 изменённых файлов: 32 добавлений и 15 удалений

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

@ -13376,28 +13376,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) {