nsCOMPtr<nsIDocumentViewer> docViewer ( do_QueryInterface(mContentViewer, &rv) );
nsCOMPtr<nsIDocumentViewer> docViewer; rv = mContentViewer->QueryInterface(kIDocumentViewerIID, getter_AddRefs(docViewer));
nsWebShell::SelectAll(void){  nsresult rv;  nsCOMPtr<nsIDocumentViewer> docViewer ( do_QueryInterface(mContentViewer, &rv) );  if (NS_FAILED(rv) || !docViewer) return rv;  nsCOMPtr<nsIPresShell> presShell;  rv = docViewer->GetPresShell(*getter_AddRefs(presShell));  if (NS_FAILED(rv) || !presShell) return rv;    nsCOMPtr<nsISelectionController> selCon = do_QueryInterface(presShell, &rv);  if (NS_FAILED(rv) || !selCon) return rv;  nsCOMPtr<nsISelection> selection;  rv = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL, getter_AddRefs(selection));  if (NS_FAILED(rv) || !selection) return rv;  // Get the document object  nsCOMPtr<nsIDocument> doc;  rv = docViewer->GetDocument(*getter_AddRefs(doc));  if (NS_FAILED(rv) || !doc) return rv;  nsCOMPtr<nsIDOMHTMLDocument> htmldoc( do_QueryInterface(doc) );  if (NS_FAILED(rv) || !htmldoc) return rv;  nsCOMPtr<nsIDOMHTMLElement>bodyElement;  rv = htmldoc->GetBody(getter_AddRefs(bodyElement));  if (NS_FAILED(rv) || !bodyElement) return rv;  nsCOMPtr<nsIDOMNode>bodyNode = do_QueryInterface(bodyElement);  if (!bodyNode) return NS_ERROR_NO_INTERFACE;#if 0  rv = selection->Collapse(bodyNode, 0);  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIDOMRange>range;  rv = selection->GetRangeAt(0, getter_AddRefs(range));  if (NS_FAILED(rv) || !range) return rv;#endif  rv = selection->RemoveAllRanges();  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIDOMRange> range;  rv = nsComponentManager::CreateInstance(kCDOMRangeCID, nsnull,                                          NS_GET_IID(nsIDOMRange),                                          getter_AddRefs(range));  rv = range->SelectNodeContents(bodyNode);  if (NS_FAILED(rv)) return rv;  rv = selection->AddRange(range);  return rv;}