Bug 1047603 - Make TabParent::AnswerCreateWindow force the initial browser to be remote in a new window. r=smaug.
authorMike Conley <mconley@mozilla.com>
Tue, 13 Jan 2015 17:24:52 -0500
changeset 255633 73e42f528ee6fe304357312b5e922567f4799dd3
parent 255632 2d57d1d460071e691fa054a60d4cd75a7945fdab
child 255634 fc4dbee3da2bad065f28c74b931e4258b56a9d53
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1047603
milestone38.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 1047603 - Make TabParent::AnswerCreateWindow force the initial browser to be remote in a new window. r=smaug.
browser/base/content/browser.js
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsIDocShell.idl
dom/base/nsFrameLoader.cpp
dom/ipc/TabParent.cpp
xpfe/appshell/nsIXULBrowserWindow.idl
xpfe/appshell/nsXULWindow.cpp
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -935,18 +935,16 @@ var gBrowserInit = {
     window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow =
       new nsBrowserAccess();
 
     if (!gMultiProcessBrowser) {
       // There is a Content:Click message manually sent from content.
       Cc["@mozilla.org/eventlistenerservice;1"]
         .getService(Ci.nsIEventListenerService)
         .addSystemEventListener(gBrowser, "click", contentAreaClick, true);
-    } else {
-      gBrowser.updateBrowserRemoteness(gBrowser.selectedBrowser, true);
     }
 
     // hook up UI through progress listener
     gBrowser.addProgressListener(window.XULBrowserWindow);
     gBrowser.addTabsProgressListener(window.TabsProgressListener);
 
     // setup simple gestures support
     gGestureSupport.init(true);
@@ -4093,16 +4091,23 @@ var XULBrowserWindow = {
     var securityUI = gBrowser.securityUI;
     this.onSecurityChange(null, null, securityUI.state);
   },
 
   setJSStatus: function () {
     // unsupported
   },
 
+  forceInitialBrowserRemote: function() {
+    let initBrowser =
+      document.getAnonymousElementByAttribute(gBrowser, "anonid", "initialBrowser");
+    gBrowser.updateBrowserRemoteness(initBrowser, true);
+    return initBrowser.frameLoader.tabParent;
+  },
+
   setDefaultStatus: function (status) {
     this.defaultStatus = status;
     this.updateStatusField();
   },
 
   setOverLink: function (url, anchorElt) {
     // Encode bidirectional formatting characters.
     // (RFC 3987 sections 3.2 and 4.1 paragraph 6)
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -13749,29 +13749,16 @@ nsDocShell::SetOpener(nsITabParent* aOpe
 
 nsITabParent*
 nsDocShell::GetOpener()
 {
   nsCOMPtr<nsITabParent> opener(do_QueryReferent(mOpener));
   return opener;
 }
 
-void
-nsDocShell::SetOpenedRemote(nsITabParent* aOpenedRemote)
-{
-  mOpenedRemote = do_GetWeakReference(aOpenedRemote);
-}
-
-nsITabParent*
-nsDocShell::GetOpenedRemote()
-{
-  nsCOMPtr<nsITabParent> openedRemote(do_QueryReferent(mOpenedRemote));
-  return openedRemote;
-}
-
 URLSearchParams*
 nsDocShell::GetURLSearchParams()
 {
   return mURLSearchParams;
 }
 
 void
 nsDocShell::NotifyJSRunToCompletionStart()
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -958,17 +958,16 @@ private:
     nsCString         mParentCharset;
     int32_t           mParentCharsetSource;
     nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
     nsTObserverArray<nsWeakPtr> mPrivacyObservers;
     nsTObserverArray<nsWeakPtr> mReflowObservers;
     nsTObserverArray<nsWeakPtr> mScrollObservers;
     nsCString         mOriginalUriString;
     nsWeakPtr mOpener;
-    nsWeakPtr mOpenedRemote;
 
     // A depth count of how many times NotifyRunToCompletionStart
     // has been called without a matching NotifyRunToCompletionStop.
     uint32_t          mJSRunToCompletionDepth;
 
     // True if recording profiles.
     bool mProfileTimelineRecording;
 
--- a/docshell/base/nsIDocShell.idl
+++ b/docshell/base/nsIDocShell.idl
@@ -49,17 +49,17 @@ interface nsIWebBrowserPrint;
 interface nsIVariant;
 interface nsIPrivacyTransitionObserver;
 interface nsIReflowObserver;
 interface nsIScrollObserver;
 interface nsITabParent;
  
 typedef unsigned long nsLoadFlags;
 
-[scriptable, builtinclass, uuid(888fcf04-a69b-11e4-8d33-6fbb72d2eb03)]
+[scriptable, builtinclass, uuid(f84b1ae4-2f78-4bad-b36a-6a8516ee6e40)]
 interface nsIDocShell : nsIDocShellTreeItem
 {
   /**
    * Loads a given URI.  This will give priority to loading the requested URI
    * in the object implementing	this interface.  If it can't be loaded here
    * however, the URL dispatcher will go through its normal process of content
    * loading.
    *
@@ -1020,23 +1020,16 @@ interface nsIDocShell : nsIDocShellTreeI
    * Regarding setOpener / getOpener - We can't use XPIDL's "attribute"
    * for notxpcom, so we're relegated to using explicit gets / sets. This
    * should be fine, considering that these methods should only ever be
    * called from native code.
    */
   [noscript,notxpcom,nostdcall] void setOpener(in nsITabParent aOpener);
   [noscript,notxpcom,nostdcall] nsITabParent getOpener();
 
-  /**
-   * See the documentation for setOpener and getOpener about why we
-   * don't use attribute here instead.
-   */
-  [noscript,notxpcom,nostdcall] void setOpenedRemote(in nsITabParent aOpenedRemote);
-  [noscript,notxpcom,nostdcall] nsITabParent getOpenedRemote();
-
   // URLSearchParams for the window.location is owned by the docShell.
   [noscript,notxpcom] URLSearchParams getURLSearchParams();
 
   /**
    * Notify DocShell when the browser is about to start executing JS, and after
    * that execution has stopped.  This only occurs when the Timeline devtool
    * is collecting information.
    */
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2200,17 +2200,16 @@ nsFrameLoader::TryRemoteBrowser()
     mContentParent = mRemoteBrowser->Manager();
 
     if (mOwnerContent->AttrValueIs(kNameSpaceID_None,
                                    nsGkAtoms::mozpasspointerevents,
                                    nsGkAtoms::_true,
                                    eCaseMatters)) {
       unused << mRemoteBrowser->SendSetUpdateHitRegion(true);
     }
-    parentDocShell->SetOpenedRemote(mRemoteBrowser);
   }
   return true;
 }
 
 mozilla::dom::PBrowserParent*
 nsFrameLoader::GetRemoteBrowser()
 {
   return mRemoteBrowser;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -642,21 +642,32 @@ TabParent::RecvCreateWindow(PBrowserPare
                             NS_ConvertUTF16toUTF8(aName).get(),
                             NS_ConvertUTF16toUTF8(aFeatures).get(), aCalledFromJS,
                             false, false, this, nullptr, getter_AddRefs(window));
   NS_ENSURE_SUCCESS(rv, false);
 
   nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(window);
   NS_ENSURE_TRUE(pwindow, false);
 
-  nsRefPtr<nsIDocShell> newDocShell = pwindow->GetDocShell();
-  NS_ENSURE_TRUE(newDocShell, false);
-
-  nsCOMPtr<nsITabParent> newRemoteTab = newDocShell->GetOpenedRemote();
-  NS_ENSURE_TRUE(newRemoteTab, false);
+  nsCOMPtr<nsIDocShell> windowDocShell = pwindow->GetDocShell();
+  NS_ENSURE_TRUE(windowDocShell, false);
+
+  nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
+  windowDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
+
+  nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(treeOwner);
+  NS_ENSURE_TRUE(xulWin, false);
+
+  nsCOMPtr<nsIXULBrowserWindow> xulBrowserWin;
+  xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin));
+  NS_ENSURE_TRUE(xulBrowserWin, false);
+
+  nsCOMPtr<nsITabParent> newRemoteTab;
+  rv = xulBrowserWin->ForceInitialBrowserRemote(getter_AddRefs(newRemoteTab));
+  NS_ENSURE_SUCCESS(rv, false);
 
   MOZ_ASSERT(TabParent::GetFrom(newRemoteTab) == newTab);
 
   aFrameScripts->SwapElements(newTab->mDelayedFrameScripts);
   return true;
 }
 
 TabParent* TabParent::sNextTabParent;
--- a/xpfe/appshell/nsIXULBrowserWindow.idl
+++ b/xpfe/appshell/nsIXULBrowserWindow.idl
@@ -7,23 +7,24 @@
 #include "nsISupports.idl"
 #include "nsIURI.idl"
 #include "nsIDOMNode.idl"
 
 interface nsIRequest;
 interface nsIDOMElement;
 interface nsIInputStream;
 interface nsIDocShell;
+interface nsITabParent;
 
 /**
  * The nsIXULBrowserWindow supplies the methods that may be called from the
  * internals of the browser area to tell the containing xul window to update
  * its ui. 
  */
-[scriptable, uuid(162d3378-a7d5-410c-8635-fe80e32020fc)]
+[scriptable, uuid(db89f748-9736-40b2-a172-3928aa1194b2)]
 interface nsIXULBrowserWindow : nsISupports
 {
   /**
    * Sets the status according to JS' version of status.
    */
   void setJSStatus(in AString status);
 
   /**
@@ -36,16 +37,24 @@ interface nsIXULBrowserWindow : nsISuppo
    * Determines the appropriate target for a link.
    */
   AString onBeforeLinkTraversal(in AString originalTarget,
                                 in nsIURI linkURI,
                                 in nsIDOMNode linkNode,
                                 in boolean isAppTab);
 
   /**
+   * Find the initial browser of the window and set its remote attribute.
+   * This can be used to ensure that there is a remote browser in a new
+   * window when it first spawns.
+   *
+   */
+  nsITabParent forceInitialBrowserRemote();
+
+  /**
    * Determines whether a load should continue.
    *
    * @param aDocShell
    *        The docshell performing the load.
    * @param aURI
    *        The URI being loaded.
    * @param aReferrer
    *        The referrer of the load.
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -29,16 +29,17 @@
 #include "nsIDOMElement.h"
 #include "nsIDOMXULElement.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMScreen.h"
 #include "nsIEmbeddingSiteWindow.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIIOService.h"
+#include "nsILoadContext.h"
 #include "nsIObserverService.h"
 #include "nsIWindowMediator.h"
 #include "nsIScreenManager.h"
 #include "nsIScreen.h"
 #include "nsIScrollable.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIWindowWatcher.h"
 #include "nsIURI.h"
@@ -1793,28 +1794,19 @@ NS_IMETHODIMP nsXULWindow::CreateNewCont
 
   {
     AutoNoJSAPI nojsapi;
     nsIThread *thread = NS_GetCurrentThread();
     while (xulWin->IsLocked()) {
       if (!NS_ProcessNextEvent(thread))
         break;
     }
- }
+  }
 
-  // If aOpeningTab is not null, it means that we're creating a new window
-  // with a remote browser, which doesn't have a primary docshell. In that
-  // case, we check for the chrome window docshell and make sure that a new
-  // remote tab was opened and stashed in that docshell.
-  if (aOpeningTab) {
-    NS_ENSURE_STATE(xulWin->mDocShell);
-    NS_ENSURE_STATE(xulWin->mDocShell->GetOpenedRemote());
-  } else {
-    NS_ENSURE_STATE(xulWin->mPrimaryContentShell);
-  }
+  NS_ENSURE_STATE(xulWin->mPrimaryContentShell);
 
   *_retval = newWindow;
   NS_ADDREF(*_retval);
 
   return NS_OK;
 }
 
 void nsXULWindow::EnableParent(bool aEnable)