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