nsresult rv = mDocument->GetDocumentURL(getter_AddRefs(docURI));
rv = mDocument->GetDocumentURL(getter_AddRefs(docURI));
CSSLoaderImpl::LoadStyleLink(nsIContent* aElement,                             nsIURI* aURL,                              const nsAString& aTitle,                              const nsAString& aMedia,                              PRInt32 aDefaultNameSpaceID,                             nsIParser* aParserToUnblock,                             PRBool& aCompleted,                             nsICSSLoaderObserver* aObserver){  LOG(("CSSLoaderImpl::LoadStyleLink"));  NS_PRECONDITION(aURL, "Must have URL to load");  NS_ASSERTION(mParsingDatas.Count() == 0, "We're in the middle of a parse?");  LOG_URI("  Link uri: '%s'", aURL);    aCompleted = PR_TRUE;  if (!mEnabled) {    LOG_WARN(("  Not enabled"));    return NS_ERROR_NOT_AVAILABLE;  }    NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_INITIALIZED);  // Check whether we should even load  nsCOMPtr<nsIURI> docURI;  nsresult rv = mDocument->GetDocumentURL(getter_AddRefs(docURI));  if (NS_FAILED(rv) || !docURI) return NS_ERROR_FAILURE;  rv = CheckLoadAllowed(docURI, aURL, aElement);  if (NS_FAILED(rv)) return rv;  LOG(("  Passed load check"));    StyleSheetState state;  nsCOMPtr<nsICSSStyleSheet> sheet;  rv = CreateSheet(aURL, aDefaultNameSpaceID, PR_FALSE, state,                   getter_AddRefs(sheet));  NS_ENSURE_SUCCESS(rv, rv);  rv = PrepareSheet(sheet, aTitle, aMedia);  NS_ENSURE_SUCCESS(rv, rv);    rv = InsertSheetInDoc(sheet, aElement, mDocument);  NS_ENSURE_SUCCESS(rv, rv);  if (state == eSheetComplete) {    LOG(("  Sheet already complete"));    // We're completely done; this sheet is fully loaded, clean, and so forth    if (aObserver) {      aObserver->StyleSheetLoaded(sheet, PR_TRUE);    }    return NS_OK;  }  nsCOMPtr<nsIStyleSheetLinkingElement> owningElement(do_QueryInterface(aElement));  // Now we need to actually load it  SheetLoadData* data = new SheetLoadData(this, aTitle, aParserToUnblock, aURL,                                          sheet, owningElement, aObserver);  if (!data) {    sheet->SetComplete();    if (aObserver) {      aObserver->StyleSheetLoaded(sheet, PR_TRUE);    }    return NS_ERROR_OUT_OF_MEMORY;  }  NS_ADDREF(data);  // Caller gets to wait for the sheet to load.  aCompleted = PR_FALSE;  // If we have to parse and it's an alternate non-inline, defer it  if (aURL && state == eSheetNeedsParser && mLoadingDatas.Count() != 0 &&      IsAlternate(aTitle)) {    LOG(("  Deferring alternate sheet load"));    URLKey key(aURL);    mPendingDatas.Put(&key, data);    return NS_OK;  }  // Load completion will free the data  return LoadSheet(data, state);}