if (nsnull != mDocument) { PRUint32 count = 0; PRInt32 i, imax = mDocument->GetNumberOfStyleSheets();   for (i = 0; (i < imax) && (nsnull == *aReturn); i++) { nsCOMPtr<nsIStyleSheet> sheet(dont_AddRef(mDocument->GetStyleSheetAt(i))); if (!sheet) continue; nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));  if (domss) { if (count++ == aIndex) { *aReturn = domss; NS_IF_ADDREF(*aReturn); } }
if (mDocument) { PRInt32 count = mDocument->GetNumberOfStyleSheets(PR_FALSE); if (aIndex < (PRUint32)count) { nsIStyleSheet *sheet = mDocument->GetStyleSheetAt(aIndex, PR_FALSE); NS_ASSERTION(sheet, "Must have a sheet"); return CallQueryInterface(sheet, aReturn);
nsDOMStyleSheetList::Item(PRUint32 aIndex, nsIDOMStyleSheet** aReturn){  *aReturn = nsnull;  if (nsnull != mDocument) {    PRUint32 count = 0;    PRInt32 i, imax = mDocument->GetNumberOfStyleSheets();      // XXX Not particularly efficient, but does anyone care?    for (i = 0; (i < imax) && (nsnull == *aReturn); i++) {      nsCOMPtr<nsIStyleSheet> sheet(dont_AddRef(mDocument->GetStyleSheetAt(i)));      if (!sheet)        continue;      nsCOMPtr<nsIDOMStyleSheet> domss(do_QueryInterface(sheet));      if (domss) {        if (count++ == aIndex) {          *aReturn = domss;          NS_IF_ADDREF(*aReturn);        }      }    }  }  return NS_OK;}