nsCOMPtr<nsISupports> supps; aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps)); if (supps) { nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(supps)); if (webShell) {
nsCOMPtr<nsIDocument> doc; aContent->GetDocument(*getter_AddRefs(doc));  if (!doc) { NS_ERROR("No document!");  return; }  nsCOMPtr<nsIDocument> subDoc; doc->GetSubDocumentFor(aContent, getter_AddRefs(subDoc));  if (subDoc) { nsCOMPtr<nsISupports> container; subDoc->GetContainer(getter_AddRefs(container));  nsCOMPtr<nsIPresShell> presShell; subDoc->GetShellAt(0, getter_AddRefs(presShell));  nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(container));  if (presShell && webShell) {
DocumentViewerImpl::MapContentForPO(PrintObject*   aRootObject,                                    nsIPresShell*  aPresShell,                                    nsIContent*    aContent){  NS_ASSERTION(aRootObject, "Pointer is null!");  NS_ASSERTION(aPresShell, "Pointer is null!");  NS_ASSERTION(aContent, "Pointer is null!");  nsCOMPtr<nsISupports> supps;  aPresShell->GetSubShellFor(aContent, getter_AddRefs(supps));  if (supps) {    nsCOMPtr<nsIWebShell> webShell(do_QueryInterface(supps));    if (webShell) {      PrintObject * po = FindPrintObjectByWS(aRootObject, webShell);      NS_ASSERTION(po, "PO can't be null!");      if (po != nsnull) {        po->mContent  = aContent;        // Now, "type" the PO         nsCOMPtr<nsIDOMHTMLFrameSetElement> frameSet(do_QueryInterface(aContent));        if (frameSet) {          po->mFrameType = eFrameSet;        } else {          nsCOMPtr<nsIDOMHTMLFrameElement> frame(do_QueryInterface(aContent));          if (frame) {            po->mFrameType = eFrame;          } else {            nsCOMPtr<nsIDOMHTMLObjectElement> objElement(do_QueryInterface(aContent));            nsCOMPtr<nsIDOMHTMLIFrameElement> iFrame(do_QueryInterface(aContent));            if (iFrame || objElement) {              po->mFrameType = eIFrame;              po->mPrintAsIs = PR_TRUE;              if (po->mParent) {                po->mParent->mPrintAsIs = PR_TRUE;              }            }          }        }      }    }  }  // walk children content  PRInt32 count;  aContent->ChildCount(count);  for (PRInt32 i=0;i<count;i++) {    nsIContent* child;    aContent->ChildAt(i, child);    MapContentForPO(aRootObject, aPresShell, child);  }}