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,6 +13429,15 @@ static bool IsInActiveTab(Document* aDoc) {
return false;
}
nsFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm) {
return false;
}
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) {
@ -13439,13 +13448,8 @@ static bool IsInActiveTab(Document* aDoc) {
return false;
}
nsIFocusManager* fm = nsFocusManager::GetFocusManager();
if (!fm) {
return false;
}
nsCOMPtr<mozIDOMWindowProxy> activeWindow;
fm->GetActiveWindow(getter_AddRefs(activeWindow));
nsCOMPtr<nsPIDOMWindowOuter> activeWindow;
activeWindow = fm->GetActiveWindow();
if (!activeWindow) {
return false;
}
@ -13453,6 +13457,19 @@ static bool IsInActiveTab(Document* aDoc) {
return activeWindow == rootWin;
}
BrowsingContext* bc = aDoc->GetBrowsingContext();
if (!bc) {
return false;
}
BrowsingContext* activeBrowsingContext = fm->GetActiveBrowsingContext();
if (!activeBrowsingContext) {
return false;
}
return activeBrowsingContext == bc->Top();
}
void Document::RemoteFrameFullscreenChanged(Element* aFrameElement) {
// Ensure the frame element is the fullscreen element in this document.
// If the frame element is already the fullscreen element in this document,