nsCOMPtr<nsIStyleContext> higherContext = aContext->GetParent();
nsStyleContext* higherContext = aContext->GetParent();
SetGenericFont(nsIPresContext* aPresContext, nsIStyleContext* aContext,               const nsRuleDataFont& aFontData, PRUint8 aGenericFontID,               nscoord aMinFontSize, PRBool aUseDocumentFonts,               PRBool aChromeOverride, nsStyleFont* aFont){  // walk up the contexts until a context with the desired generic font  nsAutoVoidArray contextPath;  nsCOMPtr<nsIStyleContext> higherContext = aContext->GetParent();  while (higherContext) {    contextPath.AppendElement(higherContext);    const nsStyleFont* higherFont = (const nsStyleFont*)higherContext->GetStyleData(eStyleStruct_Font);    if (higherFont && higherFont->mFlags & aGenericFontID) {      // done walking up the higher contexts      break;    }    higherContext = higherContext->GetParent();  }  // re-apply the cascading rules, starting from the higher context  // If we stopped earlier because we reached the root of the style tree,  // we will start with the default generic font from the presentation  // context. Otherwise we start with the higher context.  const nsFont* defaultFont;  aPresContext->GetDefaultFont(aGenericFontID, &defaultFont);  nsStyleFont parentFont(*defaultFont);  PRInt32 i = contextPath.Count() - 1;  PRBool zoom = PR_TRUE;  if (higherContext) {    nsIStyleContext* context = (nsIStyleContext*)contextPath[i];    nsStyleFont* tmpFont = (nsStyleFont*)context->GetStyleData(eStyleStruct_Font);    parentFont.mFlags = tmpFont->mFlags;    parentFont.mFont = tmpFont->mFont;    parentFont.mSize = tmpFont->mSize;    --i;    zoom = PR_FALSE;  }  aFont->mFlags = parentFont.mFlags;  aFont->mFont = parentFont.mFont;  aFont->mSize = parentFont.mSize;  PRBool dummy;  PRUint32 noneBits;  PRUint32 fontBit = nsCachedStyleData::GetBitForSID(eStyleStruct_Font);  nsRuleNode* ruleNode = nsnull;    nsCOMPtr<nsIStyleRule> rule;  for (; i >= 0; --i) {    nsIStyleContext* context = (nsIStyleContext*)contextPath[i];    nsRuleDataFont fontData; // Declare a struct with null CSS values.    nsRuleData ruleData(eStyleStruct_Font, aPresContext, context);    ruleData.mFontData = &fontData;    // Trimmed down version of ::WalkRuleTree() to re-apply the style rules    context->GetRuleNode(&ruleNode);    while (ruleNode) {      ruleNode->GetBits(nsRuleNode::eNoneBits, &noneBits);      if (noneBits & fontBit) // no more font rules on this branch, get out        break;      ruleNode->GetRule(getter_AddRefs(rule));      if (rule)        rule->MapRuleInfoInto(&ruleData);      ruleNode = ruleNode->GetParent();    }    // Compute the delta from the information that the rules specified    fontData.mFamily.Reset(); // avoid unnecessary operations in SetFont()    SetFont(aPresContext, context, aMinFontSize,            aUseDocumentFonts, aChromeOverride, PR_TRUE,            fontData, *defaultFont, &parentFont, aFont, zoom, dummy);    // XXX Not sure if we need to do this here    // If we have a post-resolve callback, handle that now.    if (ruleData.mPostResolveCallback)      (ruleData.mPostResolveCallback)((nsStyleStruct*)aFont, &ruleData);    parentFont.mFlags = aFont->mFlags;    parentFont.mFont = aFont->mFont;    parentFont.mSize = aFont->mSize;    zoom = PR_FALSE;  }  // Finish off by applying our own rules. In this case, aFontData  // already has the current cascading information that we want. We  // can just compute the delta from the parent.  SetFont(aPresContext, aContext, aMinFontSize,          aUseDocumentFonts, aChromeOverride, PR_TRUE,          aFontData, *defaultFont, &parentFont, aFont, zoom, dummy);}