nsCAutoString features; if (height != NS_SIZETOCONTENT) { features.Append("height="); features.AppendInt(height); } if (width != NS_SIZETOCONTENT) { if (!features.IsEmpty()) features.Append(','); features.Append("width="); features.AppendInt(width); }
if (!urlToLoad.IsEmpty()) {
static nsresult OpenBrowserWindow(PRInt32 height, PRInt32 width){    nsresult rv;    nsCOMPtr<nsICmdLineHandler> handler(do_GetService(NS_BROWSERSTARTUPHANDLER_CONTRACTID, &rv));    if (NS_FAILED(rv)) return rv;    nsXPIDLCString chromeUrlForTask;    rv = handler->GetChromeUrlForTask(getter_Copies(chromeUrlForTask));    if (NS_FAILED(rv)) return rv;    nsCOMPtr <nsICmdLineService> cmdLine = do_GetService("@mozilla.org/appshell/commandLineService;1", &rv);    if (NS_FAILED(rv)) return rv;    nsXPIDLCString urlToLoad;    rv = cmdLine->GetURLToLoad(getter_Copies(urlToLoad));    if (NS_FAILED(rv)) return rv;    nsCAutoString features;    if (height != NS_SIZETOCONTENT) {      features.Append("height=");      features.AppendInt(height);    }    if (width != NS_SIZETOCONTENT) {      if (!features.IsEmpty())        features.Append(',');      features.Append("width=");      features.AppendInt(width);    }    if (!urlToLoad.IsEmpty()) {#ifdef DEBUG_CMD_LINE      printf("url to load: %s\n", urlToLoad.get());#endif /* DEBUG_CMD_LINE */      NS_ConvertUTF8toUCS2 url(urlToLoad);      rv = OpenWindow(chromeUrlForTask, url.get(), features.get());    } else {      nsXPIDLString defaultArgs;      rv = handler->GetDefaultArgs(getter_Copies(defaultArgs));      if (NS_FAILED(rv)) return rv;#ifdef DEBUG_CMD_LINE      printf("default args: %s\n", NS_ConvertUCS2toUTF8(defaultArgs).get());#endif /* DEBUG_CMD_LINE */      rv = OpenWindow(chromeUrlForTask, defaultArgs.get(), features.get());    }    return rv;}