GetPresShell(*getter_AddRefs(presShell));
GetPresShell(getter_AddRefs(presShell));
NS_IMETHODIMP DocumentViewerImpl::SizeToContent(){   NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_AVAILABLE);   nsCOMPtr<nsIDocShellTreeItem> docShellAsItem(do_QueryInterface(mContainer));   NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);   nsCOMPtr<nsIDocShellTreeItem> docShellParent;   docShellAsItem->GetSameTypeParent(getter_AddRefs(docShellParent));   // It's only valid to access this from a top frame.  Doesn't work from   // sub-frames.   NS_ENSURE_TRUE(!docShellParent, NS_ERROR_FAILURE);   nsCOMPtr<nsIPresShell> presShell;   GetPresShell(*getter_AddRefs(presShell));   NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);   NS_ENSURE_SUCCESS(presShell->ResizeReflow(NS_UNCONSTRAINEDSIZE,      NS_UNCONSTRAINEDSIZE), NS_ERROR_FAILURE);   nsCOMPtr<nsIPresContext> presContext;   GetPresContext(*getter_AddRefs(presContext));   NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);   nsRect  shellArea;   PRInt32 width, height;   float   pixelScale;   // so how big is it?   presContext->GetVisibleArea(shellArea);   presContext->GetTwipsToPixels(&pixelScale);   width = PRInt32((float)shellArea.width*pixelScale);   height = PRInt32((float)shellArea.height*pixelScale);   nsCOMPtr<nsIDocShellTreeOwner> treeOwner;   docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));   NS_ENSURE_TRUE(treeOwner, NS_ERROR_FAILURE);   /* presContext's size was calculated in twips and has already been      rounded to the equivalent pixels (so the width/height calculation      we just performed was probably exact, though it was based on      values already rounded during ResizeReflow). In a surprising      number of instances, this rounding makes a window which for want      of one extra pixel's width ends up wrapping the longest line of      text during actual window layout. This makes the window too short,      generally clipping the OK/Cancel buttons. Here we add one pixel      to the calculated width, to circumvent this problem. */   NS_ENSURE_SUCCESS(treeOwner->SizeShellTo(docShellAsItem, width+1, height),      NS_ERROR_FAILURE);   return NS_OK;}