nsIDocument*  doc = mDocument; CSSStyleSheetImpl* parent = (CSSStyleSheetImpl*)mParent; while ((nsnull == doc) && (nsnull != parent)) { doc = parent->mDocument; parent = (CSSStyleSheetImpl*)(parent->mParent); }  NS_IF_ADDREF(doc); aDocument = doc;
aDocument = mDocument; NS_IF_ADDREF(aDocument);
CSSStyleSheetImpl::GetOwningDocument(nsIDocument*& aDocument) const{  nsIDocument*  doc = mDocument;  CSSStyleSheetImpl* parent = (CSSStyleSheetImpl*)mParent;  while ((nsnull == doc) && (nsnull != parent)) {    doc = parent->mDocument;    parent = (CSSStyleSheetImpl*)(parent->mParent);  }  NS_IF_ADDREF(doc);  aDocument = doc;  return NS_OK;}