}
} else if (eReflowReason_Initial == aReflowState.reason) { mPresContext = aPresContext; nsFormControlFrame::RegUnRegAccessKey(aPresContext, NS_STATIC_CAST(nsIFrame*, this), PR_TRUE); }
nsLabelFrame::Reflow(nsIPresContext*          aPresContext,                     nsHTMLReflowMetrics&     aDesiredSize,                     const nsHTMLReflowState& aReflowState,                     nsReflowStatus&          aStatus){  PRBool     isStyleChange      = PR_FALSE;  PRBool     isDirtyChildReflow = PR_FALSE;  // Check for an incremental reflow  if (eReflowReason_Incremental == aReflowState.reason) {    // See if we're the target frame    nsIFrame* targetFrame;    aReflowState.reflowCommand->GetTarget(targetFrame);    if (this == targetFrame) {      // Get the reflow type      nsIReflowCommand::ReflowType  reflowType;      aReflowState.reflowCommand->GetType(reflowType);      switch (reflowType) {      case nsIReflowCommand::ReflowDirty:        isDirtyChildReflow = PR_TRUE;        break;      case nsIReflowCommand::StyleChanged:        // Remember it's a style change so we can set the reflow reason below        isStyleChange = PR_TRUE;        break;      default:        NS_ASSERTION(PR_FALSE, "unexpected reflow command type");      }    } else {      nsIFrame* nextFrame;      // Get the next frame in the reflow chain      aReflowState.reflowCommand->GetNext(nextFrame);      NS_ASSERTION(nextFrame == mFrames.FirstChild(), "unexpected next reflow command frame");    }  }  // XXX remove the following when the reflow state is fixed  LabelHack((nsHTMLReflowState&)aReflowState, "BUG - label");  if (nsnull == mControlFrame) {    // check to see if a form control is referenced via the "for" attribute    if (FindForControl(mControlFrame)) {      mControlIsInside = PR_FALSE;    } else {      // find the 1st (and should be only) form control contained within if there is no "for"      mControlIsInside = FindFirstControl(aPresContext, this, mControlFrame);    }  }  nsSize availSize(aReflowState.mComputedWidth, aReflowState.mComputedHeight);  // get border and padding  const nsStyleSpacing* spacing =    (const nsStyleSpacing*)mStyleContext->GetStyleData(eStyleStruct_Spacing);  nsMargin borderPadding;  spacing->CalcBorderPaddingFor(this, borderPadding);  if (NS_INTRINSICSIZE != availSize.width) {    availSize.width -= borderPadding.left + borderPadding.right;    availSize.width = PR_MAX(availSize.width,0);  }  if (NS_AUTOHEIGHT != availSize.height) {    availSize.height -= borderPadding.top + borderPadding.bottom;    availSize.height = PR_MAX(availSize.height,0);  }  // reflow the child  nsIFrame* firstKid = mFrames.FirstChild();  nsHTMLReflowState reflowState(aPresContext, aReflowState, firstKid, availSize);  if (isDirtyChildReflow) {    // Note: the only reason the frame would be dirty would be if it had    // just been inserted or appended    reflowState.reason = eReflowReason_Initial;    reflowState.reflowCommand = nsnull;  } else if (isStyleChange) {    reflowState.reason = eReflowReason_StyleChange;    reflowState.reflowCommand = nsnull;  }  // XXX remove when reflow state is fixed  LabelHack(reflowState, "label's area");  ReflowChild(firstKid, aPresContext, aDesiredSize, reflowState,              borderPadding.left, borderPadding.top, 0, aStatus);  // Place the child  FinishReflowChild(firstKid, aPresContext, aDesiredSize,                    borderPadding.left, borderPadding.top, 0);  // If the child frame was just inserted, then   // we're responsible for making sure it repaints  // XXX Although in this case I don't think the areaFrame can be delete#if 1  if (isDirtyChildReflow) {    // Complete the reflow and position and size the child frame    nsRect  rect(reflowState.mComputedMargin.left, reflowState.mComputedMargin.top,                 aDesiredSize.width, aDesiredSize.height);    // Damage the area occupied by the deleted frame    Invalidate(aPresContext, rect, PR_FALSE);  }#endif  // add in our border and padding to the size of the child  aDesiredSize.width  += borderPadding.left + borderPadding.right;  aDesiredSize.height += borderPadding.top + borderPadding.bottom;  // adjust our max element size, if necessary  if (aDesiredSize.maxElementSize) {    aDesiredSize.AddBorderPaddingToMaxElementSize(borderPadding);  }  aDesiredSize.ascent  = aDesiredSize.height;  aDesiredSize.descent = 0;  aStatus = NS_FRAME_COMPLETE;  return NS_OK;}