nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(mContainer)); nsCOMPtr<nsIContentViewer> viewer;  if (item) { nsCOMPtr<nsIDocShellTreeItem> parent; item->GetParent(getter_AddRefs(parent));  nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(parent));  if (docShell) { docShell->GetContentViewer(getter_AddRefs(viewer)); } }  nsCOMPtr<nsIWebBrowserPrint> wbp(do_QueryInterface(viewer));
nsCOMPtr<nsIWebBrowserPrint> wbp; GetParentWebBrowserPrint(mContainer, getter_AddRefs(wbp));
DocumentViewerImpl::GetDoingPrintPreview(PRBool *aDoingPrintPreview){  NS_ENSURE_ARG_POINTER(aDoingPrintPreview);  *aDoingPrintPreview = mIsDoingPrintPreview;  if (!*aDoingPrintPreview) {    nsCOMPtr<nsIDocShellTreeItem> item(do_QueryInterface(mContainer));    nsCOMPtr<nsIContentViewer> viewer;    if (item) {      nsCOMPtr<nsIDocShellTreeItem> parent;      item->GetParent(getter_AddRefs(parent));      nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(parent));      if (docShell) {        docShell->GetContentViewer(getter_AddRefs(viewer));      }    }    nsCOMPtr<nsIWebBrowserPrint> wbp(do_QueryInterface(viewer));    if (wbp) {      return wbp->GetDoingPrintPreview(aDoingPrintPreview);    }  }  return NS_OK;}