if (NS_SUCCEEDED(rv)) { PRBool complete;  if (!cssLoader) return NS_ERROR_NULL_POINTER;
document->SetStyleSheetDisabledState(styleSheet, PR_FALSE); } else { rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete, this); if (NS_FAILED(rv)) return rv; if (complete) ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);
nsHTMLEditor::ApplyDocumentOrOverrideStyleSheet(const nsString& aURL, PRBool aOverride){  nsresult rv   = NS_OK;  nsCOMPtr<nsIURI> uaURL;  rv = NS_NewURI(getter_AddRefs(uaURL), aURL);  if (NS_SUCCEEDED(rv)) {    nsCOMPtr<nsIDocument> document;    if (!mPresShellWeak) return NS_ERROR_NOT_INITIALIZED;    nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);    if (!ps) return NS_ERROR_NOT_INITIALIZED;    rv = ps->GetDocument(getter_AddRefs(document));    if (NS_SUCCEEDED(rv)) {      if (!document)        return NS_ERROR_NULL_POINTER;      nsCOMPtr<nsIHTMLContentContainer> container = do_QueryInterface(document);      if (!container)        return NS_ERROR_NULL_POINTER;              nsCOMPtr<nsICSSLoader> cssLoader;      nsCOMPtr<nsICSSStyleSheet> cssStyleSheet;      rv = container->GetCSSLoader(*getter_AddRefs(cssLoader));      if (NS_SUCCEEDED(rv)) {        PRBool complete;                if (!cssLoader)          return NS_ERROR_NULL_POINTER;        if (aOverride) {          // We use null for the callback and data pointer because          //  we MUST ONLY load synchronous local files (no @import)          rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,                                         nsnull);          // Synchronous loads should ALWAYS return completed          if (!complete || !cssStyleSheet)            return NS_ERROR_NULL_POINTER;          nsCOMPtr<nsIStyleSheet> styleSheet = do_QueryInterface(cssStyleSheet);          nsCOMPtr<nsIStyleSet> styleSet;          rv = ps->GetStyleSet(getter_AddRefs(styleSet));          if (NS_SUCCEEDED(rv)) {            if (!styleSet)              return NS_ERROR_NULL_POINTER;            // Add the override style sheet            // (This checks if already exists            //  If yes, it and reads it does)            styleSet->AppendOverrideStyleSheet(styleSheet);            // This notifies document observers to rebuild all frames            // (this doesn't affect style sheet because it is not a doc sheet)            document->SetStyleSheetDisabledState(styleSheet, PR_FALSE);          }        }        else {          rv = cssLoader->LoadAgentSheet(uaURL, *getter_AddRefs(cssStyleSheet), complete,                                         this);          if (NS_SUCCEEDED(rv)) {            if (complete) {              if (cssStyleSheet) {                ApplyStyleSheetToPresShellDocument(cssStyleSheet,this);              }              else                rv = NS_ERROR_NULL_POINTER;            }            //            // If not complete, we will be notified later            // with a call to ApplyStyleSheetToPresShellDocument().            //          }        }      }    }  }  return rv;}