nsresult result = NS_ERROR_NULL_POINTER; if (aIn) { nsIURI* docURL; mDocument->GetBaseURL(docURL); SheetLoadData* data = new SheetLoadData(this, docURL, aTitle, aMedia, aDefaultNameSpaceID, aElement, aDocIndex, aParserToUnblock, PR_TRUE, aObserver); if (data == nsnull) { result = NS_ERROR_OUT_OF_MEMORY; } else { NS_ADDREF(data); nsICSSStyleSheet* sheet; result = ParseSheet(aIn, data, aCompleted, sheet); NS_IF_RELEASE(sheet); if ((! aCompleted) && (aParserToUnblock)) { data->mDidBlockParser = PR_TRUE; } } NS_RELEASE(docURL);
NS_ENSURE_TRUE(mDocument, NS_ERROR_NOT_INITIALIZED);  nsCOMPtr<nsIStyleSheetLinkingElement> owningElement(do_QueryInterface(aElement)); NS_ASSERTION(owningElement, "Element is not a style linking element!");  StyleSheetState state; nsCOMPtr<nsICSSStyleSheet> sheet; nsresult rv = CreateSheet(nsnull, aElement, PR_FALSE, state, getter_AddRefs(sheet)); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(state == eSheetNeedsParser, "Inline sheets should not be cached");  rv = PrepareSheet(sheet, aTitle, aMedia); NS_ENSURE_SUCCESS(rv, rv);  rv = InsertSheetInDoc(sheet, aElement, mDocument); NS_ENSURE_SUCCESS(rv, rv);  SheetLoadData* data = new SheetLoadData(this, aTitle, aParserToUnblock, nsnull, sheet, owningElement, aObserver);  if (!data) { sheet->SetComplete(); return NS_ERROR_OUT_OF_MEMORY;
CSSLoaderImpl::LoadInlineStyle(nsIContent* aElement,                               nsIUnicharInputStream* aIn,                                const nsString& aTitle,                                const nsString& aMedia,                                PRInt32 aDefaultNameSpaceID,                               PRInt32 aDocIndex,                               nsIParser* aParserToUnblock,                               PRBool& aCompleted,                               nsICSSLoaderObserver* aObserver){  NS_ASSERTION(mDocument, "not initialized");  if (! mDocument) {    return NS_ERROR_NOT_INITIALIZED;  }  // XXX need to add code to cancel any pending sheets for element  nsresult result = NS_ERROR_NULL_POINTER;  if (aIn) {    nsIURI* docURL;    mDocument->GetBaseURL(docURL);    SheetLoadData* data = new SheetLoadData(this, docURL, aTitle, aMedia, aDefaultNameSpaceID,                                            aElement,                                            aDocIndex, aParserToUnblock,                                            PR_TRUE, aObserver);    if (data == nsnull) {      result = NS_ERROR_OUT_OF_MEMORY;    }    else {      NS_ADDREF(data);      nsICSSStyleSheet* sheet;      result = ParseSheet(aIn, data, aCompleted, sheet);      NS_IF_RELEASE(sheet);      if ((! aCompleted) && (aParserToUnblock)) {        data->mDidBlockParser = PR_TRUE;      }    }    NS_RELEASE(docURL);  }  return result;}