Bug 1110928, part 2 - Call PokeGC in nsDocumentViewer::PageHide before the call to OnPageHide. r=smaug
authorAndrew McCreight <continuation@gmail.com>
Mon, 23 Jan 2017 19:21:13 +0200
changeset 469638 b39457b9fe3bffc6d05a4e118273beae2a772aeb
parent 469637 551a93b7b47186cf638770337545345d8cd3b720
child 469639 a1bbc6ed667015ece98beb737f51614b220cf418
push id43793
push userdmitchell@mozilla.com
push dateThu, 02 Feb 2017 14:41:57 +0000
reviewerssmaug
bugs1110928
milestone54.0a1
Bug 1110928, part 2 - Call PokeGC in nsDocumentViewer::PageHide before the call to OnPageHide. r=smaug This ensures that the document isn't destroyed when we call PokeGC, which will be useful later.
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1332,28 +1332,30 @@ nsDocumentViewer::PageHide(bool aIsUnloa
   AutoDontWarnAboutSyncXHR disableSyncXHRWarning;
 
   mHidden = true;
 
   if (!mDocument) {
     return NS_ERROR_NULL_POINTER;
   }
 
+  if (aIsUnload) {
+    // Poke the GC. The window might be collectable garbage now.
+    nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2);
+  }
+
   mDocument->OnPageHide(!aIsUnload, nullptr);
 
   // inform the window so that the focus state is reset.
   NS_ENSURE_STATE(mDocument);
   nsPIDOMWindowOuter* window = mDocument->GetWindow();
   if (window)
     window->PageHidden();
 
   if (aIsUnload) {
-    // Poke the GC. The window might be collectable garbage now.
-    nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE, NS_GC_DELAY * 2);
-
     // if Destroy() was called during OnPageHide(), mDocument is nullptr.
     NS_ENSURE_STATE(mDocument);
 
     // First, get the window from the document...
     nsPIDOMWindowOuter* window = mDocument->GetWindow();
 
     if (!window) {
       // Fail if no window is available...