Rollup of bug 819000: Preload about:blank. r=cjones,jlebar a=cjones
authorVivien Nicolas <21@vingtetun.org> and Chris Jones <jones.chris.g@gmail.com>
Thu, 24 Jan 2013 10:39:18 -0800
changeset 118338 893e68b73efd5d9f564016c34b9c8e10c774bb28
parent 118337 94a2d6fcdfde1e1b27324b5caea4c54012fb6fdd
child 118339 694c52fd8d8e9dc17e141b8b85b47551a959126a
push id361
push userjosh@joshmatthews.net
push dateFri, 25 Jan 2013 15:42:14 +0000
reviewerscjones, jlebar, cjones
bugs819000
milestone18.0
Rollup of bug 819000: Preload about:blank. r=cjones,jlebar a=cjones Includes the following patches Bug 819000: Bail out of PresShell::Paint if not active. r=roc Bug 819000: Make sure preloaded docshells are reset to active. r=jlebar Bug 819000: Preload about:blank. r=cjones a=cjones
b2g/app/b2g.js
dom/browser-element/BrowserElementChild.js
dom/ipc/ContentChild.cpp
dom/ipc/preload.js
layout/base/nsPresShell.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -572,17 +572,17 @@ pref("hal.processPriorityManager.gonk.ma
 pref("hal.processPriorityManager.gonk.foregroundNice", 0);
 pref("hal.processPriorityManager.gonk.backgroundNice", 10);
 
 #ifndef DEBUG
 // Enable pre-launching content processes for improved startup time
 // (hiding latency).
 pref("dom.ipc.processPrelaunch.enabled", true);
 // Wait this long before pre-launching a new subprocess.
-pref("dom.ipc.processPrelaunch.delayMs", 1000);
+pref("dom.ipc.processPrelaunch.delayMs", 5000);
 #endif
 
 // Ignore the "dialog=1" feature in window.open.
 pref("dom.disable_window_open_dialog_feature", true);
 
 // Screen reader support
 pref("accessibility.accessfu.activate", 2);
 
--- a/dom/browser-element/BrowserElementChild.js
+++ b/dom/browser-element/BrowserElementChild.js
@@ -65,16 +65,21 @@ function BrowserElementChild() {
 
 BrowserElementChild.prototype = {
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
                                          Ci.nsISupportsWeakReference]),
 
   _init: function() {
     debug("Starting up.");
+
+    // NB: this must happen before we process any messages from
+    // mozbrowser API clients.
+    docShell.isActive = true;
+
     sendAsyncMsg("hello");
 
     // Set the docshell's name according to our <iframe>'s name attribute.
     docShell.QueryInterface(Ci.nsIDocShellTreeItem).name =
       sendSyncMsg('get-name')[0];
 
     docShell.setFullscreenAllowed(sendSyncMsg('get-fullscreen-allowed')[0]);
 
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -1146,18 +1146,25 @@ PreloadSlowThings()
     TabChild::PreloadSlowThings();
 }
 
 bool
 ContentChild::RecvAppInfo(const nsCString& version, const nsCString& buildID)
 {
     mAppInfo.version.Assign(version);
     mAppInfo.buildID.Assign(buildID);
-
-    PreloadSlowThings();
+    // If we're part of the mozbrowser machinery, go ahead and start
+    // preloading things.  We can only do this for mozbrowser because
+    // PreloadSlowThings() may set the docshell of the first TabChild
+    // inactive, and we can only safely restore it to active from
+    // BrowserElementChild.js.
+    if ((mIsForApp || mIsForBrowser) &&
+        Preferences::GetBool("dom.ipc.processPrelaunch.enabled", false)) {
+        PreloadSlowThings();
+    }
     return true;
 }
 
 bool
 ContentChild::RecvLastPrivateDocShellDestroyed()
 {
     nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
     obs->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
--- a/dom/ipc/preload.js
+++ b/dom/ipc/preload.js
@@ -64,9 +64,16 @@
   Cc["@mozilla.org/permissionmanager;1"].getService(Ci["nsIPermissionManager"]);
   Cc["@mozilla.org/preferences-service;1"].getService(Ci["nsIPrefBranch"]);
   Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci["nsIScriptSecurityManager"]);
   Cc["@mozilla.org/storage/service;1"].getService(Ci["mozIStorageService"]);
   Cc["@mozilla.org/system-info;1"].getService(Ci["nsIPropertyBag2"]);
   Cc["@mozilla.org/thread-manager;1"].getService(Ci["nsIThreadManager"]);
   Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci["nsIAppStartup"]);
   Cc["@mozilla.org/uriloader;1"].getService(Ci["nsIURILoader"]);
+
+  docShell.isActive = false;
+  docShell.QueryInterface(Ci.nsIWebNavigation)
+          .loadURI("about:blank",
+                   Ci.nsIWebNavigation.LOAD_FLAGS_NONE,
+                   null, null, null);
+
 })();
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5241,16 +5241,20 @@ PresShell::Paint(nsIView*           aVie
                  const nsRegion&    aDirtyRegion,
                  PaintType          aType,
                  bool               aWillSendDidPaint)
 {
   SAMPLE_LABEL("Paint", "PresShell::Paint");
   NS_ASSERTION(!mIsDestroying, "painting a destroyed PresShell");
   NS_ASSERTION(aViewToPaint, "null view");
 
+  if (!mIsActive) {
+    return;
+  }
+
   nsAutoNotifyDidPaint notifyDidPaint(aWillSendDidPaint);
 
   nsPresContext* presContext = GetPresContext();
   AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint);
 
   nsIFrame* frame = aViewToPaint->GetFrame();
 
   bool isRetainingManager;