aMetrics.height = bbox.height + aReflowState.mComputedBorderPadding.top +
const nsStyleFont* font; GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font); aReflowState.rendContext->SetFont(font->mFont); nsIFontMetrics* fm; aReflowState.rendContext->GetFontMetrics(fm); fm->GetMaxAscent(aMetrics.ascent); fm->GetMaxDescent(aMetrics.descent); fm->GetHeight(aMetrics.height); aMetrics.ascent += aReflowState.mComputedBorderPadding.top; aMetrics.descent += aReflowState.mComputedBorderPadding.bottom; aMetrics.height += aReflowState.mComputedBorderPadding.top +
nsInlineFrame::ReflowInlineFrames(nsIPresContext& aPresContext,                                  const nsHTMLReflowState& aReflowState,                                  InlineReflowState& irs,                                  nsHTMLReflowMetrics& aMetrics,                                  nsReflowStatus& aStatus){  nsresult rv = NS_OK;  aStatus = NS_FRAME_COMPLETE;  nsInlineReflow ir(*aReflowState.lineLayout, aReflowState, this, PR_FALSE,                    nsnull != aMetrics.maxElementSize);  irs.mInlineReflow = &ir;  ir.SetNextRCFrame(irs.mNextRCFrame);  aReflowState.lineLayout->PushInline(&ir);  // Compute available area  nscoord x = aReflowState.mComputedBorderPadding.left;  nscoord availableWidth = aReflowState.availableWidth;  if (NS_UNCONSTRAINEDSIZE != availableWidth) {    if (nsnull != mPrevInFlow) {      x = 0;      availableWidth -= aReflowState.mComputedBorderPadding.right +        aReflowState.computedMargin.right;    }    else {      availableWidth -= aReflowState.mComputedBorderPadding.left +        aReflowState.computedMargin.left +        aReflowState.mComputedBorderPadding.right +        aReflowState.computedMargin.right;    }  }  nscoord y = aReflowState.mComputedBorderPadding.top;  nscoord availableHeight = aReflowState.availableHeight;  if (NS_UNCONSTRAINEDSIZE != aReflowState.availableHeight) {    availableHeight -= aReflowState.mComputedBorderPadding.top +      aReflowState.mComputedBorderPadding.right;  }  ir.Init(x, y, availableWidth, availableHeight);  // First reflow our current children  nsIFrame* frame = mFrames.FirstChild();  PRBool done = PR_FALSE;  while (nsnull != frame) {    rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);    if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) {      done = PR_TRUE;      break;    }    irs.mPrevFrame = frame;    frame->GetNextSibling(&frame);  }  // Attempt to pull frames from our next-in-flow until we can't  if (!done && (nsnull != mNextInFlow)) {    while (!done) {      PRBool isComplete;      frame = PullInlineFrame(irs, &isComplete);      if (nsnull == frame) {        if (!isComplete) {          aStatus = NS_FRAME_NOT_COMPLETE;        }        break;      }      rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus);      if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) {        done = PR_TRUE;        break;      }      irs.mPrevFrame = frame;    }  }  // Compute final metrics  if (NS_SUCCEEDED(rv)) {#ifdef NS_DEBUG    if (NS_FRAME_COMPLETE == aStatus) {      // We can't be complete AND have overflow frames!      NS_ASSERTION(mOverflowFrames.IsEmpty(), "whoops");    }#endif    nsInlineReflow* ir = irs.mInlineReflow;    nsRect bbox;    ir->VerticalAlignFrames(bbox, aMetrics.ascent, aMetrics.descent);    ir->RelativePositionFrames(aMetrics.mCombinedArea);    aMetrics.width = bbox.XMost();    if (NS_FRAME_IS_COMPLETE(aStatus)) {      aMetrics.width += aReflowState.mComputedBorderPadding.right;    }    aMetrics.height = bbox.height + aReflowState.mComputedBorderPadding.top +      aReflowState.mComputedBorderPadding.bottom;#ifdef NOISY_FINAL_SIZE    ListTag(stdout);    printf(": metrics=%d,%d ascent=%d descent=%d\n",           aMetrics.width, aMetrics.height, aMetrics.ascent, aMetrics.descent);#endif    aMetrics.mCarriedOutTopMargin = 0;    aMetrics.mCarriedOutBottomMargin = 0;    if (nsnull != aMetrics.maxElementSize) {      *aMetrics.maxElementSize = ir->GetMaxElementSize();    }  }  aReflowState.lineLayout->PopInline();  return rv;}