Bug 1297996 - Add preference to show background colour between pageloads for non-e10s. r?tnikkel draft
authorMike Conley <mconley@mozilla.com>
Wed, 17 Aug 2016 17:55:49 -0400
changeset 413177 16c2b025822ba3f73526c7cb5d2461d0c30dbe76
parent 411657 938ce16be25f9c551c19ef8938e8717ed3d41ff5
child 531172 3f8c953a11fdf8e0e7d4d856530be20088f5d7c1
push id29372
push usermconley@mozilla.com
push dateTue, 13 Sep 2016 19:52:39 +0000
reviewerstnikkel
bugs1297996
milestone51.0a1
Bug 1297996 - Add preference to show background colour between pageloads for non-e10s. r?tnikkel Adds a hidden layout.show_previous_page pref for non-e10s that, when set to false, will blank out the content area in between page loads instead of showing the previous page. MozReview-Commit-ID: 1EyDk4IabeK
layout/generic/nsSubDocumentFrame.cpp
--- a/layout/generic/nsSubDocumentFrame.cpp
+++ b/layout/generic/nsSubDocumentFrame.cpp
@@ -36,20 +36,23 @@
 #include "nsIObjectLoadingContent.h"
 #include "nsLayoutUtils.h"
 #include "FrameLayerBuilder.h"
 #include "nsPluginFrame.h"
 #include "nsContentUtils.h"
 #include "nsIPermissionManager.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIDOMMutationEvent.h"
+#include "mozilla/Preferences.h"
 
 using namespace mozilla;
 using mozilla::layout::RenderFrameParent;
 
+static bool sShowPreviousPage = true;
+
 static nsIDocument*
 GetDocumentFromView(nsView* aView)
 {
   NS_PRECONDITION(aView, "");
 
   nsViewManager* vm = aView->GetViewManager();
   nsIPresShell* ps =  vm ? vm->GetPresShell() : nullptr;
   return ps ? ps->GetDocument() : nullptr;
@@ -102,16 +105,22 @@ void
 nsSubDocumentFrame::Init(nsIContent*       aContent,
                          nsContainerFrame* aParent,
                          nsIFrame*         aPrevInFlow)
 {
   // determine if we are a <frame> or <iframe>
   nsCOMPtr<nsIDOMHTMLFrameElement> frameElem = do_QueryInterface(aContent);
   mIsInline = frameElem ? false : true;
 
+  static bool addedShowPreviousPage = false;
+  if (!addedShowPreviousPage) {
+    Preferences::AddBoolVarCache(&sShowPreviousPage, "layout.show_previous_page", true);
+    addedShowPreviousPage = true;
+  }
+
   nsAtomicContainerFrame::Init(aContent, aParent, aPrevInFlow);
 
   // We are going to create an inner view.  If we need a view for the
   // OuterFrame but we wait for the normal view creation path in
   // nsCSSFrameConstructor, then we will lose because the inner view's
   // parent will already have been set to some outer view (e.g., the
   // canvas) when it really needs to have this frame's view as its
   // parent. So, create this frame's view right away, whether we
@@ -222,17 +231,17 @@ nsSubDocumentFrame::GetSubdocumentPresSh
     // being the old page that will probably have a frame.
     nsView* nextView = subdocView->GetNextSibling();
     nsIFrame* frame = nullptr;
     if (nextView) {
       frame = nextView->GetFrame();
     }
     if (frame) {
       nsIPresShell* ps = frame->PresContext()->PresShell();
-      if (!presShell || (ps && !ps->IsPaintingSuppressed())) {
+      if (!presShell || (ps && !ps->IsPaintingSuppressed() && sShowPreviousPage)) {
         subdocView = nextView;
         subdocRootFrame = frame;
         presShell = ps;
       }
     }
     if (!presShell) {
       // If we don't have a frame we use this roundabout way to get the pres shell.
       if (!mFrameLoader)