if (nsnull != aObserver) { aObserver->StyleSheetLoaded(aSheet, aNotify); }
CSSLoaderImpl::InsertSheetInDoc(nsICSSStyleSheet* aSheet, PRInt32 aDocIndex,                                 nsIContent* aElement, PRBool aNotify){  if ((! mDocument) || (! aSheet)) {    return NS_ERROR_NULL_POINTER;  }  if (nsnull != aElement) {    nsIDOMNode* domNode = nsnull;    if (NS_SUCCEEDED(aElement->QueryInterface(kIDOMNodeIID, (void**)&domNode))) {      aSheet->SetOwningNode(domNode);      NS_RELEASE(domNode);    }    nsIStyleSheetLinkingElement* element;    if (NS_SUCCEEDED(aElement->QueryInterface(kIStyleSheetLinkingElementIID,                                              (void**)&element))) {      element->SetStyleSheet(aSheet);      NS_RELEASE(element);    }  }  nsAutoString  title;  aSheet->GetTitle(title);  aSheet->SetEnabled(! IsAlternate(title));  SupportsKey key(mDocument);  nsVoidArray*  sheetMap = (nsVoidArray*)mSheetMapTable.Get(&key);  if (! sheetMap) {    sheetMap = new nsVoidArray();    if (sheetMap) {      mSheetMapTable.Put(&key, sheetMap);    }  }  if (sheetMap) {    PRInt32 insertIndex = sheetMap->Count();    while (0 <= --insertIndex) {      PRInt32 targetIndex = (PRInt32)sheetMap->ElementAt(insertIndex);      if (targetIndex < aDocIndex) {        mDocument->InsertStyleSheetAt(aSheet, insertIndex + 1, aNotify);        sheetMap->InsertElementAt((void*)aDocIndex, insertIndex + 1);        aSheet = nsnull;        break;      }    }    if (nsnull != aSheet) { // didn't insert yet      mDocument->InsertStyleSheetAt(aSheet, 0, aNotify);      sheetMap->InsertElementAt((void*)aDocIndex, 0);    }    return NS_OK;  }  return NS_ERROR_OUT_OF_MEMORY;}