sheet->mDocument = mDocument;
CSSStyleSheetImpl::InsertStyleSheetAt(nsICSSStyleSheet* aSheet, PRInt32 aIndex){  NS_PRECONDITION(nsnull != aSheet, "null arg");  nsresult result = WillDirty();  if (NS_SUCCEEDED(result)) {    NS_ADDREF(aSheet);    CSSStyleSheetImpl* sheet = (CSSStyleSheetImpl*)aSheet;    CSSStyleSheetImpl* child = mFirstChild;    if (aIndex && child) {      while ((0 < --aIndex) && child->mNext) {        child = child->mNext;      }      sheet->mNext = child->mNext;      child->mNext = sheet;    }    else {      sheet->mNext = mFirstChild;      mFirstChild = sheet;     }    // This is not reference counted. Our parent tells us when    // it's going away.    sheet->mParent = this;    DidDirty();  }  return result;}