PRInt32 sheetDocIndex = 0; aDocument->GetIndexOfStyleSheet(sheet, &sheetDocIndex);
PRInt32 sheetDocIndex = aDocument->GetIndexOfStyleSheet(sheet);
void StyleSetImpl::AddDocStyleSheet(nsIStyleSheet* aSheet, nsIDocument* aDocument){  NS_PRECONDITION((nsnull != aSheet) && (nsnull != aDocument), "null arg");#ifdef DEBUG  PRBool applicable = PR_TRUE;  aSheet->GetApplicable(applicable);  NS_ASSERTION(applicable, "Inapplicable sheet being placed in style set");#endif  if (EnsureArray(mDocSheets)) {    mDocSheets->RemoveElement(aSheet);    // lowest index last    PRInt32 newDocIndex = 0;    aDocument->GetIndexOfStyleSheet(aSheet, &newDocIndex);    PRUint32 count;    nsresult rv = mDocSheets->Count(&count);    if (NS_FAILED(rv)) return;  // XXX error?    PRUint32 index;    for (index = 0; index < count; index++) {      nsIStyleSheet* sheet = (nsIStyleSheet*)mDocSheets->ElementAt(index);      PRInt32 sheetDocIndex = 0;      aDocument->GetIndexOfStyleSheet(sheet, &sheetDocIndex);      if (sheetDocIndex < newDocIndex) {        mDocSheets->InsertElementAt(aSheet, index);        index = count; // break loop      }      NS_RELEASE(sheet);    }    PRUint32 cnt;    rv = mDocSheets->Count(&cnt);    if (NS_FAILED(rv)) return;  // XXX error?    if (cnt == count) {  // didn't insert it      mDocSheets->AppendElement(aSheet);    }    if (nsnull == mFrameConstructor) {      CallQueryInterface(aSheet, &mFrameConstructor);    }    ClearDocRuleProcessors();  }}