nsIFrame * pageFrame; seqFrame->FirstChild(mPresContext, nsnull, &pageFrame);
nsIFrame* pageFrame = seqFrame->GetFirstChild(nsnull);
DocumentViewerImpl::PrintPreviewNavigate(PRInt16 aType, PRInt32 aPageNum){#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)  if (GetIsPrinting()) return NS_ERROR_FAILURE;  if (!mPrintEngine) return NS_ERROR_FAILURE;  nsIScrollableView* scrollableView;  mViewManager->GetRootScrollableView(&scrollableView);  if (scrollableView == nsnull) return NS_OK;  // Check to see if we can short circut scrolling to the top  if (aType == nsIWebBrowserPrint::PRINTPREVIEW_HOME ||      (aType == nsIWebBrowserPrint::PRINTPREVIEW_GOTO_PAGENUM && aPageNum == 1)) {    scrollableView->ScrollTo(0, 0, PR_TRUE);    return NS_OK;  }  // Finds the SimplePageSequencer frame  // in PP mPrtPreview->mPrintObject->mSeqFrame is null  nsIFrame* seqFrame  = nsnull;  PRInt32   pageCount = 0;  if (NS_FAILED(mPrintEngine->GetSeqFrameAndCountPages(seqFrame, pageCount))) {    return NS_ERROR_FAILURE;  }  // Figure where we are currently scrolled to  const nsIView * clippedView;  scrollableView->GetClipView(&clippedView);  nscoord x;  nscoord y;  scrollableView->GetScrollPosition(x, y);  PRInt32    pageNum = 1;  nsIFrame * fndPageFrame  = nsnull;  nsIFrame * currentPage   = nsnull;  // If it is "End" then just do a "goto" to the last page  if (aType == nsIWebBrowserPrint::PRINTPREVIEW_END) {    aType    = nsIWebBrowserPrint::PRINTPREVIEW_GOTO_PAGENUM;    aPageNum = pageCount;  }  // Now, locate the current page we are on and  // and the page of the page number  nscoord gap = 0;  nsIFrame * pageFrame;  seqFrame->FirstChild(mPresContext, nsnull, &pageFrame);  while (pageFrame != nsnull) {    nsRect pageRect = pageFrame->GetRect();    if (pageNum == 1) {      gap = pageRect.y;    }    if (pageRect.Contains(pageRect.x, y)) {      currentPage = pageFrame;    }    if (pageNum == aPageNum) {      fndPageFrame = pageFrame;      break;    }    pageNum++;    pageFrame = pageFrame->GetNextSibling();  }  if (aType == nsIWebBrowserPrint::PRINTPREVIEW_PREV_PAGE) {    if (currentPage) {      currentPage->GetPrevInFlow(&fndPageFrame);      if (!fndPageFrame) {        return NS_OK;      }    } else {      return NS_OK;    }  } else if (aType == nsIWebBrowserPrint::PRINTPREVIEW_NEXT_PAGE) {    if (currentPage) {      currentPage->GetNextInFlow(&fndPageFrame);      if (!fndPageFrame) {        return NS_OK;      }    } else {      return NS_OK;    }  } else { // If we get here we are doing "GoTo"    if (aPageNum < 0 || aPageNum > pageCount) {      return NS_OK;    }  }  if (fndPageFrame && scrollableView) {    // find offset from view    nsPoint pnt;    nsIView * view;    fndPageFrame->GetOffsetFromView(mPresContext, pnt, &view);    nscoord deadSpaceGap = 0;    nsIPageSequenceFrame * sqf;    if (NS_SUCCEEDED(CallQueryInterface(seqFrame, &sqf))) {      sqf->GetDeadSpaceValue(&deadSpaceGap);    }    // scroll so that top of page (plus the gray area) is at the top of the scroll area    scrollableView->ScrollTo(0, fndPageFrame->GetPosition().y-deadSpaceGap, PR_TRUE);  }  return NS_OK;#else  return NS_ERROR_FAILURE;#endif // NS_PRINT_PREVIEW}