nsCOMPtr<nsIDocument> parent; doc->GetParentDocument(getter_AddRefs(parent));  doc = parent;
doc = doc->GetParentDocument();
nsFrameLoader::GetPresContext(nsIPresContext **aPresContext){  *aPresContext = nsnull;  nsCOMPtr<nsIDocument> doc = mOwnerContent->GetDocument();  while (doc) {    nsIPresShell *presShell = doc->GetShellAt(0);    if (presShell) {      presShell->GetPresContext(aPresContext);      return NS_OK;    }    nsCOMPtr<nsIDocument> parent;    doc->GetParentDocument(getter_AddRefs(parent));    doc = parent;  }  return NS_OK;}