NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE); mChildren.AppendElement(aChild); NS_ADDREF(aChild);  nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild)); if(!childAsDocShell) return NS_OK;   nsXPIDLString defaultCharset; nsXPIDLString forceCharset; NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);  nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(mContentViewer); if(muDV) { NS_ENSURE_SUCCESS(muDV->GetDefaultCharacterSet(getter_Copies(defaultCharset)), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(muDV->GetForceCharacterSet(getter_Copies(forceCharset)), NS_ERROR_FAILURE); } nsCOMPtr<nsIContentViewer> childCV; NS_ENSURE_SUCCESS(childAsDocShell->GetContentViewer(getter_AddRefs(childCV)), NS_ERROR_FAILURE); if(childCV) { nsCOMPtr<nsIMarkupDocumentViewer> childmuDV = do_QueryInterface(childCV); if(childmuDV) { NS_ENSURE_SUCCESS(childmuDV->SetDefaultCharacterSet(defaultCharset), NS_ERROR_FAILURE); NS_ENSURE_SUCCESS(childmuDV->SetForceCharacterSet(forceCharset), NS_ERROR_FAILURE); } }  return NS_OK;
nsCOMPtr<nsIDocShellTreeItem> treeItemChild(do_QueryInterface(aChild)); return nsDocShell::AddChild(treeItemChild);
NS_IMETHODIMP nsWebShell::AddChild(nsIDocShellTreeItem *aChild){   NS_ENSURE_ARG_POINTER(aChild);   NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);   mChildren.AppendElement(aChild);   NS_ADDREF(aChild);   nsCOMPtr<nsIDocShell> childAsDocShell(do_QueryInterface(aChild));   if(!childAsDocShell)      return NS_OK;   // Do some docShell Specific stuff.   nsXPIDLString defaultCharset;   nsXPIDLString forceCharset;   NS_ENSURE_TRUE(mContentViewer, NS_ERROR_FAILURE);   nsCOMPtr<nsIMarkupDocumentViewer> muDV = do_QueryInterface(mContentViewer);   if(muDV)      {      NS_ENSURE_SUCCESS(muDV->GetDefaultCharacterSet(getter_Copies(defaultCharset)),         NS_ERROR_FAILURE);      NS_ENSURE_SUCCESS(muDV->GetForceCharacterSet(getter_Copies(forceCharset)),         NS_ERROR_FAILURE);      }   nsCOMPtr<nsIContentViewer> childCV;   NS_ENSURE_SUCCESS(childAsDocShell->GetContentViewer(getter_AddRefs(childCV)),      NS_ERROR_FAILURE);   if(childCV)      {      nsCOMPtr<nsIMarkupDocumentViewer> childmuDV = do_QueryInterface(childCV);      if(childmuDV)         {         NS_ENSURE_SUCCESS(childmuDV->SetDefaultCharacterSet(defaultCharset),             NS_ERROR_FAILURE);         NS_ENSURE_SUCCESS(childmuDV->SetForceCharacterSet(forceCharset),             NS_ERROR_FAILURE);         }      }  return NS_OK;}