Bug 1069772 - Part 1: Update document to support prerender visibility state. r=smaug
authorSamael Wang <freesamael@gmail.com>
Wed, 25 May 2016 16:52:24 +0800
changeset 371076 d9b584a14402209fb9c714b193702aaba53800c8
parent 371075 3a3dcaf968523e481d7501f7e9e420c43362d3eb
child 371077 7909d0735869e171d3daef18be07afef8abb2add
push id19232
push userbmo:gps@mozilla.com
push dateWed, 25 May 2016 22:36:54 +0000
reviewerssmaug
bugs1069772
milestone49.0a1
Bug 1069772 - Part 1: Update document to support prerender visibility state. r=smaug
dom/base/nsDocument.cpp
dom/webidl/Document.webidl
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -12816,16 +12816,23 @@ nsDocument::GetVisibilityState() const
   // 1)  Are we in bfcache (!IsVisible())?  If so, nothing else matters.
   // 2)  Do we have an outer window?  If not, we're hidden.  Note that we don't
   //     want to use GetWindow here because it does weird groveling for windows
   //     in some cases.
   // 3)  Is our outer window background?  If so, we're hidden.
   // Otherwise, we're visible.
   if (!IsVisible() || !mWindow || !mWindow->GetOuterWindow() ||
       mWindow->GetOuterWindow()->IsBackground()) {
+
+    // Check if the document is in prerender state.
+    nsCOMPtr<nsIDocShell> docshell = GetDocShell();
+    if (docshell && docshell->GetIsPrerendered()) {
+      return dom::VisibilityState::Prerender;
+    }
+
     return dom::VisibilityState::Hidden;
   }
 
   return dom::VisibilityState::Visible;
 }
 
 /* virtual */ void
 nsDocument::PostVisibilityUpdateEvent()
--- a/dom/webidl/Document.webidl
+++ b/dom/webidl/Document.webidl
@@ -7,17 +7,17 @@
  */
 
 interface WindowProxy;
 interface nsISupports;
 interface URI;
 interface nsIDocShell;
 interface nsILoadGroup;
 
-enum VisibilityState { "hidden", "visible" };
+enum VisibilityState { "hidden", "visible", "prerender" };
 
 /* http://dom.spec.whatwg.org/#interface-document */
 [Constructor]
 interface Document : Node {
   [Throws]
   readonly attribute DOMImplementation implementation;
   [Pure]
   readonly attribute DOMString URL;