nsCOMPtr<nsIWebShell> top(this); nsCOMPtr<nsIWebShell> parent; for(top = this; top; top = parent) { top->GetParentEvenIfChrome(*getter_AddRefs(parent)); if(!parent) break; } *aResult = top;
nsCOMPtr<nsIDocShellTreeItem> top; GetRootTreeItem(getter_AddRefs(top)); nsCOMPtr<nsIWebShell> topAsWebShell(do_QueryInterface(top)); *aResult = topAsWebShell;
nsWebShell::GetRootWebShellEvenIfChrome(nsIWebShell** aResult){   nsCOMPtr<nsIWebShell> top(this);   nsCOMPtr<nsIWebShell> parent;   for(top = this; top; top = parent)      {      top->GetParentEvenIfChrome(*getter_AddRefs(parent));      if(!parent)         break;      }   *aResult = top;   NS_IF_ADDREF(*aResult);}