Bug 1555488 - Part 1: Clear WindowProxy cache when flipping processes, r=peterv,mccr8

This is sorta-part of the work for bug 1510760. Currently if you do a process
switch, the window proxy state is completely borked, and a lot of stuff doesn't
work.

This patch aims to make it so that, while not transplanted correctly, methods
generally don't return the wrong WindowProxy object anymore after a process
swap.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-06-06 14:57:18 +00:00
Родитель 03a2f40528
Коммит 05c6ade09e
3 изменённых файлов: 28 добавлений и 3 удалений

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

@ -313,6 +313,26 @@ void BrowsingContext::Detach(bool aFromIPC) {
}
}
void BrowsingContext::PrepareForProcessChange() {
MOZ_LOG(GetLog(), LogLevel::Debug,
("%s: Preparing 0x%08" PRIx64 " for a process change",
XRE_IsParentProcess() ? "Parent" : "Child", Id()));
MOZ_ASSERT(mIsInProcess, "Must currently be an in-process frame");
MOZ_ASSERT(!mClosed, "We're already closed?");
mIsInProcess = false;
// XXX: We should transplant our WindowProxy into a Cross-Process WindowProxy
// if mWindowProxy is non-nullptr. (bug 1510760)
mWindowProxy = nullptr;
// NOTE: For now, clear our nsDocShell reference, as we're primarily in a
// different process now. This may need to change in the future with
// Cross-Process BFCache.
mDocShell = nullptr;
}
void BrowsingContext::CacheChildren(bool aFromIPC) {
MOZ_LOG(GetLog(), LogLevel::Debug,
("%s: Caching children of 0x%08" PRIx64 "",

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

@ -145,6 +145,9 @@ class BrowsingContext : public nsWrapperCache, public BrowsingContextBase {
// child and the parent process.
void Detach(bool aFromIPC = false);
// Prepare this BrowsingContext to leave the current process.
void PrepareForProcessChange();
// Remove all children from the current BrowsingContext and cache
// them to allow them to be attached again.
void CacheChildren(bool aFromIPC = false);

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

@ -5072,9 +5072,11 @@ nsDocShell::Destroy() {
mSessionHistory = nullptr;
}
// This will be skipped in cases where we want to preserve the browsing
// context between loads.
if (!mSkipBrowsingContextDetachOnDestroy) {
// Either `Detach` our BrowsingContext if this window is closing, or prepare
// the BrowsingContext for the switch to continue.
if (mSkipBrowsingContextDetachOnDestroy) {
mBrowsingContext->PrepareForProcessChange();
} else {
mBrowsingContext->Detach();
}