parent->ChildAt(index, content); nsIAtom* tag; content->GetTag(tag);
parent->ChildAt(index, &content); nsCOMPtr<nsIAtom> tag; content->GetTag(getter_AddRefs(tag));
static PRBool SelectorMatchesTree(RuleProcessorData &data,                                  nsCSSSelector* aSelector) {  nsCSSSelector* selector = aSelector;  if (selector) {    nsIContent* content = nsnull;    nsIContent* lastContent = data.mContent;    NS_ADDREF(lastContent);    RuleProcessorData* curdata = &data;    while (nsnull != selector) { // check compound selectors      // Find the appropriate content (whether parent or previous sibling)      // to check next, and if we don't already have a RuleProcessorData      // for it, create one.      // for adjacent sibling combinators, the content to test against the      // selector is the previous sibling      nsCompatibility compat = curdata->mCompatMode;      RuleProcessorData* newdata;      if (PRUnichar('+') == selector->mOperator) {        newdata = curdata->mPreviousSiblingData;        if (!newdata) {          nsIContent* parent;          PRInt32 index;          lastContent->GetParent(parent);          if (parent) {            parent->IndexOf(lastContent, index);            while (0 <= --index) {  // skip text & comment nodes              parent->ChildAt(index, content);              nsIAtom* tag;              content->GetTag(tag);              if ((tag != nsLayoutAtoms::textTagName) &&                   (tag != nsLayoutAtoms::commentTagName)) {                NS_IF_RELEASE(tag);                newdata =                    new (curdata->mPresContext) RuleProcessorData(curdata->mPresContext, content,                                                                    curdata->mRuleWalker, &compat);                curdata->mPreviousSiblingData = newdata;                    break;              }              NS_RELEASE(content);              NS_IF_RELEASE(tag);            }            NS_RELEASE(parent);          }        } else {          content = newdata->mContent;          NS_ADDREF(content);        }      }      // for descendant combinators and child combinators, the content      // to test against is the parent      else {        newdata = curdata->mParentData;        if (!newdata) {          lastContent->GetParent(content);          if (content) {            newdata = new (curdata->mPresContext) RuleProcessorData(curdata->mPresContext, content,                                                                      curdata->mRuleWalker, &compat);            curdata->mParentData = newdata;              }        } else {          content = newdata->mContent;          NS_ADDREF(content);        }      }      if (! newdata) {        NS_ASSERTION(!content, "content must be null");        break;      }      if (SelectorMatches(*newdata, selector, 0, nsnull, 0)) {        // to avoid greedy matching, we need to recurse if this is a        // descendant combinator and the next combinator is not        if ((NS_IS_GREEDY_OPERATOR(selector->mOperator)) &&            (selector->mNext) &&            (!NS_IS_GREEDY_OPERATOR(selector->mNext->mOperator))) {          // pretend the selector didn't match, and step through content          // while testing the same selector          // This approach is slightly strange is that when it recurses          // it tests from the top of the content tree, down.  This          // doesn't matter much for performance since most selectors          // don't match.  (If most did, it might be faster...)          if (SelectorMatchesTree(*newdata, selector)) {            selector = nsnull; // indicate success            break;          }        }        selector = selector->mNext;      }      else {        // for adjacent sibling and child combinators, if we didn't find        // a match, we're done        if (!NS_IS_GREEDY_OPERATOR(selector->mOperator)) {          NS_RELEASE(content);          break;  // parent was required to match        }      }      NS_IF_RELEASE(lastContent);      lastContent = content;  // take refcount      content = nsnull;      curdata = newdata;    }    NS_IF_RELEASE(lastContent);  }  return PRBool(nsnull == selector);  // matches if ran out of selectors}