Bug 1519546, part 5 - Add mIsTopLevel flag for tracking the root PBrowser actor in a remote browser. r=farre

The root PBrowser actor needs special case visibility behavior to satisfy the async tab
switcher. This commit adds a flag to track whether a BrowserChild is part of the root
actor.

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

--HG--
extra : rebase_source : 5f7cb11f77d41f3265d211e99713a1dad6ae2579
extra : intermediate-source : 49e4d0e4fc7ccfa7b2c58bb9b64534c2d569a881
extra : source : adcc870662770a99962e721bd3c5ff4c2616c21d
This commit is contained in:
Ryan Hunt 2019-05-29 11:35:37 -05:00
Родитель ea567d2cec
Коммит c382491672
7 изменённых файлов: 24 добавлений и 14 удалений

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

@ -87,7 +87,7 @@ nsresult BrowserBridgeParent::Init(const nsString& aPresentationURL,
bool ok = constructorSender->SendConstructBrowser(
std::move(childEp), tabId, TabId(0), tabContext.AsIPCTabContext(),
aBrowsingContext, aChromeFlags, constructorSender->ChildID(),
constructorSender->IsForBrowser());
constructorSender->IsForBrowser(), /* aIsTopLevel */ false);
if (NS_WARN_IF(!ok)) {
MOZ_ASSERT(false, "Browser Constructor Failed");
return NS_ERROR_FAILURE;

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

@ -358,18 +358,19 @@ already_AddRefed<BrowserChild> BrowserChild::FindBrowserChild(
already_AddRefed<BrowserChild> BrowserChild::Create(
ContentChild* aManager, const TabId& aTabId, const TabId& aSameTabGroupAs,
const TabContext& aContext, BrowsingContext* aBrowsingContext,
uint32_t aChromeFlags) {
uint32_t aChromeFlags, bool aIsTopLevel) {
RefPtr<BrowserChild> groupChild = FindBrowserChild(aSameTabGroupAs);
dom::TabGroup* group = groupChild ? groupChild->TabGroup() : nullptr;
RefPtr<BrowserChild> iframe = new BrowserChild(
aManager, aTabId, group, aContext, aBrowsingContext, aChromeFlags);
RefPtr<BrowserChild> iframe =
new BrowserChild(aManager, aTabId, group, aContext, aBrowsingContext,
aChromeFlags, aIsTopLevel);
return iframe.forget();
}
BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId,
dom::TabGroup* aTabGroup, const TabContext& aContext,
BrowsingContext* aBrowsingContext,
uint32_t aChromeFlags)
uint32_t aChromeFlags, bool aIsTopLevel)
: TabContext(aContext),
mTabGroup(aTabGroup),
mManager(aManager),
@ -387,6 +388,7 @@ BrowserChild::BrowserChild(ContentChild* aManager, const TabId& aTabId,
mHasValidInnerSize(false),
mDestroyed(false),
mUniqueId(aTabId),
mIsTopLevel(aIsTopLevel),
mHasSiblings(false),
mIsTransparent(false),
mIPCOpen(false),

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

@ -242,7 +242,7 @@ class BrowserChild final : public BrowserChildBase,
*/
BrowserChild(ContentChild* aManager, const TabId& aTabId, TabGroup* aTabGroup,
const TabContext& aContext, BrowsingContext* aBrowsingContext,
uint32_t aChromeFlags);
uint32_t aChromeFlags, bool aIsTopLevel);
nsresult Init(mozIDOMWindowProxy* aParent);
@ -250,7 +250,7 @@ class BrowserChild final : public BrowserChildBase,
static already_AddRefed<BrowserChild> Create(
ContentChild* aManager, const TabId& aTabId, const TabId& aSameTabGroupAs,
const TabContext& aContext, BrowsingContext* aBrowsingContext,
uint32_t aChromeFlags);
uint32_t aChromeFlags, bool aIsTopLevel);
// Let managees query if it is safe to send messages.
bool IsDestroyed() const { return mDestroyed; }
@ -863,6 +863,10 @@ class BrowserChild final : public BrowserChildBase,
LayoutDeviceIntPoint mChromeOffset;
TabId mUniqueId;
// Whether or not this browser is the child part of the top level PBrowser
// actor in a remote browser.
bool mIsTopLevel;
// Whether or not this tab has siblings (other tabs in the same window).
// This is one factor used when choosing to allow or deny a non-system
// script's attempt to resize the window.

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

@ -966,8 +966,9 @@ nsresult ContentChild::ProvideWindowCommon(
nullptr, openerBC, aName, BrowsingContext::Type::Content);
TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext();
RefPtr<BrowserChild> newChild = new BrowserChild(
this, tabId, tabGroup, newTabContext, browsingContext, aChromeFlags);
RefPtr<BrowserChild> newChild =
new BrowserChild(this, tabId, tabGroup, newTabContext, browsingContext,
aChromeFlags, /* aIsTopLevel */ true);
if (aTabOpener) {
MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext);
@ -1796,7 +1797,8 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
ManagedEndpoint<PBrowserChild>&& aBrowserEp, const TabId& aTabId,
const TabId& aSameTabGroupAs, const IPCTabContext& aContext,
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
const ContentParentId& aCpID, const bool& aIsForBrowser) {
const ContentParentId& aCpID, const bool& aIsForBrowser,
const bool& aIsTopLevel) {
MOZ_ASSERT(!IsShuttingDown());
static bool hasRunOnce = false;
@ -1827,7 +1829,7 @@ mozilla::ipc::IPCResult ContentChild::RecvConstructBrowser(
RefPtr<BrowserChild> browserChild =
BrowserChild::Create(this, aTabId, aSameTabGroupAs, tc.GetTabContext(),
aBrowsingContext, aChromeFlags);
aBrowsingContext, aChromeFlags, aIsTopLevel);
// Bind the created BrowserChild to IPC to actually link the actor. The ref
// here is released in DeallocPBrowserChild.

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

@ -523,7 +523,8 @@ class ContentChild final : public PContentChild,
ManagedEndpoint<PBrowserChild>&& aBrowserEp, const TabId& aTabId,
const TabId& aSameTabGroupAs, const IPCTabContext& aContext,
BrowsingContext* aBrowsingContext, const uint32_t& aChromeFlags,
const ContentParentId& aCpID, const bool& aIsForBrowser);
const ContentParentId& aCpID, const bool& aIsForBrowser,
const bool& aIsTopLevel);
FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)

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

@ -1206,7 +1206,8 @@ already_AddRefed<RemoteBrowser> ContentParent::CreateBrowser(
std::move(childEp), tabId,
aSameTabGroupAs ? aSameTabGroupAs->GetTabId() : TabId(0),
aContext.AsIPCTabContext(), aBrowsingContext, chromeFlags,
constructorSender->ChildID(), constructorSender->IsForBrowser());
constructorSender->ChildID(), constructorSender->IsForBrowser(),
/* aIsTopLevel */ true);
if (NS_WARN_IF(!ok)) {
return nullptr;
}

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

@ -393,7 +393,7 @@ child:
IPCTabContext context,
BrowsingContext browsingContext,
uint32_t chromeFlags, ContentParentId cpId,
bool isForBrowser);
bool isForBrowser, bool isTopLevel);
both:
async PFileDescriptorSet(FileDescriptor fd);