res = InitStaticMenu(rdfServ, ccMan, pref, decs, kNC_BrowserCharsetMenuRoot, kBrowserStaticPrefKey, &mBrowserMenu); NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser static charset menu");
res = container->GetCount(&mBrowserMenuRDFPosition); if (NS_FAILED(res)) return res;   mBrowserMenuRDFPosition -= mBrowserCacheStart - 1;
nsresult nsCharsetMenu::InitBrowserMenu() {  nsresult res = NS_OK;  NS_WITH_SERVICE(nsIRDFService, rdfServ, kRDFServiceCID, &res);  if (NS_FAILED(res)) return res;  NS_WITH_SERVICE(nsICharsetConverterManager2, ccMan, kCharsetConverterManagerCID, &res);  if (NS_FAILED(res)) return res;  nsCOMPtr<nsISupportsArray> decs;  res = ccMan->GetDecoderList(getter_AddRefs(decs));  if (NS_FAILED(res)) return res;  NS_WITH_SERVICE(nsIPref, pref, NS_PREF_PROGID, &res);  if (NS_FAILED(res)) return res;  nsCOMPtr<nsIRDFContainer> container;  res = NewRDFContainer(mInner, kNC_BrowserCharsetMenuRoot, getter_AddRefs(container));  if (NS_FAILED(res)) return res;  // even if we fail, the show must go on  res = InitStaticMenu(rdfServ, ccMan, pref, decs, kNC_BrowserCharsetMenuRoot,     kBrowserStaticPrefKey, &mBrowserMenu);  NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser static charset menu");  // mark the end of the static area, the rest is cache  mBrowserCacheStart = mBrowserMenu.Count();  pref->GetIntPref(kBrowserCacheSizePrefKey, &mBrowserCacheSize);  // compute the position of the menu in the RDF container  res = container->GetCount(&mBrowserMenuRDFPosition);  if (NS_FAILED(res)) return res;  // this "1" here is a correction necessary because the RDF container   // elements are numbered from 1 (why god, WHY?!?!?!)  mBrowserMenuRDFPosition -= mBrowserCacheStart - 1;  res = InitCacheMenu(rdfServ, ccMan, pref, decs, kNC_BrowserCharsetMenuRoot,     kBrowserCachePrefKey, &mBrowserMenu);  NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser cache charset menu");  res = InitBrowserMoreSubmenus(rdfServ, ccMan, pref, decs);  NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser static X charset menu");  res = InitMoreMenu(rdfServ, ccMan, decs, kNC_BrowserMoreCharsetMenuRoot, ".notForBrowser");  NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser more charset menu");  // register prefs callback  pref->RegisterCallback(kBrowserStaticPrefKey, BrowserStaticChanged, this);  return res;}