NS_RELEASE(iRule);
PRInt32 CSSStyleSheetImpl::RulesMatching(nsIPresContext* aPresContext,                                         nsIContent* aContent,                                         nsIFrame* aParentFrame,                                         nsISupportsArray* aResults){  NS_PRECONDITION(nsnull != aPresContext, "null arg");  NS_PRECONDITION(nsnull != aContent, "null arg");//  NS_PRECONDITION(nsnull != aParentFrame, "null arg");  NS_PRECONDITION(nsnull != aResults, "null arg");  PRInt32 matchCount = 0;  CSSStyleSheetImpl*  child = mFirstChild;  while (nsnull != child) {    matchCount += child->RulesMatching(aPresContext, aContent, aParentFrame, aResults);    child = child->mNext;  }  PRInt32 count = ((nsnull != mRules) ? mRules->Count() : 0);  for (PRInt32 index = 0; index < count; index++) {    nsICSSStyleRule* rule = (nsICSSStyleRule*)mRules->ElementAt(index);    nsCSSSelector* selector = rule->FirstSelector();    if (SelectorMatches(selector, aContent)) {      selector = selector->mNext;      nsIFrame* frame = aParentFrame;      while ((nsnull != selector) && (nsnull != frame)) { // check compound selectors        nsIContent* content;                 frame->GetContent(content);        if (SelectorMatches(selector, content)) {          selector = selector->mNext;        }        frame->GetGeometricParent(frame);        NS_RELEASE(content);      }      if (nsnull == selector) { // ran out, it matched        nsIStyleRule* iRule;        if (NS_OK == rule->QueryInterface(kIStyleRuleIID, (void**)&iRule)) {          aResults->AppendElement(iRule);          NS_RELEASE(iRule);          matchCount++;        }      }    }    NS_RELEASE(rule);  }  return matchCount;}