Bug 1179894, part 1 - Split out MarkDocument for easier reuse. draft
authorAndrew McCreight <continuation@gmail.com>
Tue, 09 Jan 2018 15:49:35 -0800
changeset 718275 25f811bf5877e2fc96a6d39913601391552ea809
parent 717183 ca379fcca95b1f4a3744242ea8647004b99b3507
child 718276 8ee459b0e33c447e3b558e94fc75b7579075315f
push id94856
push userbmo:continuation@gmail.com
push dateWed, 10 Jan 2018 00:12:35 +0000
bugs1179894
milestone59.0a1
Bug 1179894, part 1 - Split out MarkDocument for easier reuse. MozReview-Commit-ID: 3ReA6wVkU5Y
dom/base/nsCCUncollectableMarker.cpp
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -185,58 +185,65 @@ MarkMessageManagers()
     }
   }
   if (nsFrameMessageManager::sSameProcessParentManager) {
     nsFrameMessageManager::sSameProcessParentManager->MarkForCC();
   }
 }
 
 void
-MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
-                  bool aPrepareForCC)
+MarkDocument(nsIDocument* aDoc, bool aCleanupJS, bool aPrepareForCC)
 {
-  if (!aViewer) {
+  if (!aDoc) {
     return;
   }
 
-  nsIDocument *doc = aViewer->GetDocument();
-  if (doc &&
-      doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
-    doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
+  if (aDoc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) {
+    aDoc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
     if (aCleanupJS) {
-      EventListenerManager* elm = doc->GetExistingListenerManager();
+      EventListenerManager* elm = aDoc->GetExistingListenerManager();
       if (elm) {
         elm->MarkForCC();
       }
-      nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow());
+      nsCOMPtr<EventTarget> win = do_QueryInterface(aDoc->GetInnerWindow());
       if (win) {
         elm = win->GetExistingListenerManager();
         if (elm) {
           elm->MarkForCC();
         }
         static_cast<nsGlobalWindowInner*>(win.get())->AsInner()->
           TimeoutManager().UnmarkGrayTimers();
       }
     } else if (aPrepareForCC) {
       // Unfortunately we need to still mark user data just before running CC so
       // that it has the right generation.
-      doc->PropertyTable(DOM_USER_DATA)->
+      aDoc->PropertyTable(DOM_USER_DATA)->
         EnumerateAll(MarkUserData, &nsCCUncollectableMarker::sGeneration);
     }
   }
-  if (doc) {
-    if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) {
-      inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
-    }
-    if (nsPIDOMWindowOuter* outer = doc->GetWindow()) {
-      outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
-    }
+
+  if (nsPIDOMWindowInner* inner = aDoc->GetInnerWindow()) {
+    inner->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
+  }
+  if (nsPIDOMWindowOuter* outer = aDoc->GetWindow()) {
+    outer->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration);
   }
 }
 
+void
+MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS,
+                  bool aPrepareForCC)
+{
+  if (!aViewer) {
+    return;
+  }
+
+  MarkDocument(aViewer->GetDocument(), aCleanupJS, aPrepareForCC);
+}
+
 void MarkDocShell(nsIDocShellTreeItem* aNode, bool aCleanupJS,
                   bool aPrepareForCC);
 
 void
 MarkSHEntry(nsISHEntry* aSHEntry, bool aCleanupJS, bool aPrepareForCC)
 {
   if (!aSHEntry) {
     return;