Bug 1620172 - Use GetActiveBrowsingContext for full screen auto-exit. r=NeilDeakin

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Henri Sivonen 2020-03-11 16:00:45 +00:00
Родитель 7d98d5c9e0
Коммит 6276ea07ae
6 изменённых файлов: 65 добавлений и 5 удалений

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

@ -1404,13 +1404,28 @@ void nsFocusManager::SetFocusInner(Element* aNewContent, int32_t aFlags,
if (StaticPrefs::full_screen_api_exit_on_windowRaise() &&
!isElementInActiveWindow &&
aFlags & (FLAG_RAISE | FLAG_NONSYSTEMCALLER)) {
// TODO mActiveWindow in content process
if (Document* doc = mActiveWindow ? mActiveWindow->GetDoc() : nullptr) {
if (doc->GetFullscreenElement()) {
if (XRE_IsParentProcess()) {
if (XRE_IsParentProcess()) {
if (Document* doc = mActiveWindow ? mActiveWindow->GetDoc() : nullptr) {
if (doc->GetFullscreenElement()) {
LogWarningFullscreenWindowRaise(mFocusedElement);
Document::AsyncExitFullscreen(doc);
}
}
} else {
BrowsingContext* activeBrowsingContext = GetActiveBrowsingContext();
if (activeBrowsingContext) {
nsIDocShell* shell = activeBrowsingContext->GetDocShell();
if (shell) {
Document* doc = shell->GetDocument();
if (doc && doc->GetFullscreenElement()) {
Document::AsyncExitFullscreen(doc);
}
} else {
mozilla::dom::ContentChild* contentChild =
mozilla::dom::ContentChild::GetSingleton();
MOZ_ASSERT(contentChild);
contentChild->SendMaybeExitFullscreen(activeBrowsingContext);
}
Document::AsyncExitFullscreen(doc);
}
}
}

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

@ -4192,6 +4192,27 @@ mozilla::ipc::IPCResult ContentChild::RecvSetupFocusedAndActive(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvMaybeExitFullscreen(
const MaybeDiscarded<BrowsingContext>& aContext) {
if (aContext.IsNullOrDiscarded()) {
MOZ_LOG(BrowsingContext::GetLog(), LogLevel::Debug,
("ChildIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
nsIDocShell* shell = aContext.get()->GetDocShell();
if (!shell) {
return IPC_OK();
}
Document* doc = shell->GetDocument();
if (doc && doc->GetFullscreenElement()) {
Document::AsyncExitFullscreen(doc);
}
return IPC_OK();
}
mozilla::ipc::IPCResult ContentChild::RecvWindowPostMessage(
const MaybeDiscarded<BrowsingContext>& aContext,
const ClonedMessageData& aMessage, const PostMessageData& aData) {

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

@ -771,6 +771,8 @@ class ContentChild final
mozilla::ipc::IPCResult RecvSetupFocusedAndActive(
const MaybeDiscarded<BrowsingContext>& aFocusedBrowsingContext,
const MaybeDiscarded<BrowsingContext>& aActiveBrowsingContext);
mozilla::ipc::IPCResult RecvMaybeExitFullscreen(
const MaybeDiscarded<BrowsingContext>& aContext);
mozilla::ipc::IPCResult RecvWindowPostMessage(
const MaybeDiscarded<BrowsingContext>& aContext,

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

@ -6358,6 +6358,25 @@ mozilla::ipc::IPCResult ContentParent::RecvBlurToParent(
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvMaybeExitFullscreen(
const MaybeDiscarded<BrowsingContext>& aContext) {
if (aContext.IsNullOrDiscarded()) {
MOZ_LOG(
BrowsingContext::GetLog(), LogLevel::Debug,
("ParentIPC: Trying to send a message to dead or detached context"));
return IPC_OK();
}
CanonicalBrowsingContext* context = aContext.get_canonical();
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
ContentParent* cp =
cpm->GetContentProcessById(ContentParentId(context->OwnerProcessId()));
Unused << cp->SendMaybeExitFullscreen(context);
return IPC_OK();
}
mozilla::ipc::IPCResult ContentParent::RecvWindowPostMessage(
const MaybeDiscarded<BrowsingContext>& aContext,
const ClonedMessageData& aMessage, const PostMessageData& aData) {

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

@ -670,6 +670,8 @@ class ContentParent final
bool aIsLeavingDocument, bool aAdjustWidget,
bool aBrowsingContextToClearHandled,
bool aAncestorBrowsingContextToFocusHandled);
mozilla::ipc::IPCResult RecvMaybeExitFullscreen(
const MaybeDiscarded<BrowsingContext>& aContext);
mozilla::ipc::IPCResult RecvWindowPostMessage(
const MaybeDiscarded<BrowsingContext>& aContext,

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

@ -1628,6 +1628,7 @@ child:
async SetupFocusedAndActive(MaybeDiscardedBrowsingContext aFocusedBrowsingContext,
MaybeDiscardedBrowsingContext aActiveBrowsingContext);
both:
async MaybeExitFullscreen(MaybeDiscardedBrowsingContext aContext);
async WindowPostMessage(MaybeDiscardedBrowsingContext aContext,
ClonedMessageData aMessage,
PostMessageData aData);