Bug 1519546, part 5 - Add mIsTopLevel flag for tracking the root PBrowser actor in a remote browser. r=farre
☠☠ backed out by 8a7d9dfad47e ☠ ☠
authorRyan Hunt <rhunt@eqrion.net>
Wed, 29 May 2019 11:35:37 -0500
changeset 476410 49e4d0e4fc7ccfa7b2c58bb9b64534c2d569a881
parent 476409 d31b7d33efc711fb8115663f4cfc5bc98fd58d73
child 476411 3cb9ddccccf320b19f0deae88cd990982b703022
push id113278
push userrhunt@eqrion.net
push dateFri, 31 May 2019 19:03:34 +0000
treeherdermozilla-inbound@bbcfdcc12774 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1519546
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
dom/ipc/BrowserBridgeParent.cpp
dom/ipc/BrowserChild.cpp
dom/ipc/BrowserChild.h
dom/ipc/ContentChild.cpp
dom/ipc/ContentChild.h
dom/ipc/ContentParent.cpp
dom/ipc/PContent.ipdl
--- a/dom/ipc/BrowserBridgeParent.cpp
+++ b/dom/ipc/BrowserBridgeParent.cpp
@@ -82,17 +82,17 @@ nsresult BrowserBridgeParent::Init(const
     MOZ_ASSERT(false, "Browser Open Endpoint Failed");
     return NS_ERROR_FAILURE;
   }
 
   // Tell the content process to set up its PBrowserChild.
   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;
   }
 
   // Set our BrowserParent object to the newly created browser.
   mBrowserParent = browserParent.forget();
   mBrowserParent->SetOwnerElement(Manager()->GetOwnerElement());
--- a/dom/ipc/BrowserChild.cpp
+++ b/dom/ipc/BrowserChild.cpp
@@ -353,28 +353,29 @@ already_AddRefed<BrowserChild> BrowserCh
   RefPtr<BrowserChild> browserChild = iter->second;
   return browserChild.forget();
 }
 
 /*static*/
 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),
       mBrowsingContext(aBrowsingContext),
       mChromeFlags(aChromeFlags),
       mMaxTouchPoints(0),
       mLayersId{0},
       mBeforeUnloadListeners(0),
@@ -382,16 +383,17 @@ BrowserChild::BrowserChild(ContentChild*
       mDidFakeShow(false),
       mNotified(false),
       mTriedBrowserInit(false),
       mOrientation(hal::eScreenOrientation_PortraitPrimary),
       mIgnoreKeyPressEvent(false),
       mHasValidInnerSize(false),
       mDestroyed(false),
       mUniqueId(aTabId),
+      mIsTopLevel(aIsTopLevel),
       mHasSiblings(false),
       mIsTransparent(false),
       mIPCOpen(false),
       mParentIsActive(false),
       mDidSetRealShowInfo(false),
       mDidLoadURLInit(false),
       mAwaitingLA(false),
       mSkipKeyPress(false),
--- a/dom/ipc/BrowserChild.h
+++ b/dom/ipc/BrowserChild.h
@@ -237,25 +237,25 @@ class BrowserChild final : public Browse
   static nsTArray<RefPtr<BrowserChild>> GetAll();
 
  public:
   /**
    * Create a new BrowserChild object.
    */
   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);
 
   /** Return a BrowserChild with the given attributes. */
   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; }
 
   const TabId GetTabId() const {
     MOZ_ASSERT(mUniqueId != 0);
     return mUniqueId;
   }
@@ -858,16 +858,20 @@ class BrowserChild final : public Browse
   bool mDestroyed;
 
   // Position of client area relative to the outer window
   LayoutDeviceIntPoint mClientOffset;
   // Position of tab, relative to parent widget (typically the window)
   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.
   bool mHasSiblings;
 
   // Holds the compositor options for the compositor rendering this tab,
   // once we find out which compositor that is.
   Maybe<mozilla::layers::CompositorOptions> mCompositorOptions;
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -957,18 +957,19 @@ nsresult ContentChild::ProvideWindowComm
 
   RefPtr<BrowsingContext> openerBC =
       aParent ? nsPIDOMWindowOuter::From(aParent)->GetBrowsingContext()
               : nullptr;
   RefPtr<BrowsingContext> browsingContext = BrowsingContext::Create(
       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);
     ipcContext->get_PopupIPCTabContext().opener() = aTabOpener;
   }
 
   nsCOMPtr<nsIEventTarget> target =
       tabGroup->EventTargetFor(TaskCategory::Other);
@@ -1787,17 +1788,18 @@ bool ContentChild::DeallocPJavaScriptChi
   ReleaseJavaScriptChild(aChild);
   return true;
 }
 
 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;
   if (!hasRunOnce) {
     hasRunOnce = true;
     MOZ_ASSERT(!gFirstIdleTask);
     RefPtr<CancelableRunnable> firstIdleTask =
         NewCancelableRunnableFunction("FirstIdleRunnable", FirstIdle);
@@ -1818,17 +1820,17 @@ mozilla::ipc::IPCResult ContentChild::Re
                              "the parent process. (%s)  Crashing...",
                              tc.GetInvalidReason())
                  .get());
     MOZ_CRASH("Invalid TabContext received from the parent process.");
   }
 
   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.
   if (NS_WARN_IF(!BindPBrowserEndpoint(std::move(aBrowserEp),
                                        do_AddRef(browserChild).take()))) {
     return IPC_FAIL(this, "BindPBrowserEndpoint failed");
   }
 
--- a/dom/ipc/ContentChild.h
+++ b/dom/ipc/ContentChild.h
@@ -518,17 +518,18 @@ class ContentChild final : public PConte
   PFileDescriptorSetChild* AllocPFileDescriptorSetChild(const FileDescriptor&);
 
   bool DeallocPFileDescriptorSetChild(PFileDescriptorSetChild*);
 
   mozilla::ipc::IPCResult 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);
 
   FORWARD_SHMEM_ALLOCATOR_TO(PContentChild)
 
   void GetAvailableDictionaries(InfallibleTArray<nsString>& aDictionaries);
 
   PBrowserOrId GetBrowserOrId(BrowserChild* aBrowserChild);
 
   POfflineCacheUpdateChild* AllocPOfflineCacheUpdateChild(
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1198,17 +1198,18 @@ already_AddRefed<RemoteBrowser> ContentP
       return nullptr;
     }
 
     // Tell the content process to set up its PBrowserChild.
     bool ok = constructorSender->SendConstructBrowser(
         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;
     }
 
     if (remoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) {
       // Tell the BrowserChild object that it was created due to a
       // Large-Allocation request.
       Unused << browserParent->SendAwaitLargeAlloc();
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -387,17 +387,17 @@ parent:
                                 uint32_t chromeFlags);
 
 child:
     async ConstructBrowser(ManagedEndpoint<PBrowserChild> browserEp,
                            TabId tabId, TabId sameTabGroupAs,
                            IPCTabContext context,
                            BrowsingContext browsingContext,
                            uint32_t chromeFlags, ContentParentId cpId,
-                           bool isForBrowser);
+                           bool isForBrowser, bool isTopLevel);
 
 both:
     async PFileDescriptorSet(FileDescriptor fd);
 
     // For parent->child, aBrowser must be non-null; aOuterWindowID can
     // be 0 to indicate the browser's current root document, or nonzero
     // to persist a subdocument.  For child->parent, arguments are
     // ignored and should be null/zero.