void MarkContentViewer(nsIContentViewer* aViewer, bool aCleanupJS) { if (!aViewer) { return; } Document* doc = aViewer->GetDocument(); if (doc && doc->GetMarkedCCGeneration() != nsCCUncollectableMarker::sGeneration) { doc->MarkUncollectableForCCGeneration(nsCCUncollectableMarker::sGeneration); if (aCleanupJS) { EventListenerManager* elm = doc->GetExistingListenerManager(); if (elm) { elm->MarkForCC(); } nsCOMPtr<EventTarget> win = do_QueryInterface(doc->GetInnerWindow()); if (win) { elm = win->GetExistingListenerManager(); if (elm) { elm->MarkForCC(); } static_cast<nsGlobalWindowInner*>(win.get()) ->AsInner() ->TimeoutManager() .UnmarkGrayTimers(); } } } if (doc) { if (nsPIDOMWindowInner* inner = doc->GetInnerWindow()) { inner->MarkUncollectableForCCGeneration( nsCCUncollectableMarker::sGeneration); } if (nsPIDOMWindowOuter* outer = doc->GetWindow()) { outer->MarkUncollectableForCCGeneration( nsCCUncollectableMarker::sGeneration); } } }