case nsIReflowCommand::ReflowDirty:
case eReflowType_ReflowDirty:
CanvasFrame::Reflow(nsIPresContext*          aPresContext,                    nsHTMLReflowMetrics&     aDesiredSize,                    const nsHTMLReflowState& aReflowState,                    nsReflowStatus&          aStatus){  DO_GLOBAL_REFLOW_COUNT("CanvasFrame", aReflowState.reason);  NS_FRAME_TRACE_REFLOW_IN("CanvasFrame::Reflow");  //NS_PRECONDITION(nsnull == aDesiredSize.maxElementSize, "unexpected request");  // Initialize OUT parameter  aStatus = NS_FRAME_COMPLETE;  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");    }  }  // Reflow our one and only child frame  nsHTMLReflowMetrics kidDesiredSize(nsnull);  if (mFrames.IsEmpty()) {    // We have no child frame, so return an empty size    aDesiredSize.width = aDesiredSize.height = 0;    aDesiredSize.ascent = aDesiredSize.descent = 0;  } else {    nsIFrame* kidFrame = mFrames.FirstChild();    // We must specify an unconstrained available height, because constrained    // is only for when we're paginated...    nsHTMLReflowState kidReflowState(aPresContext, aReflowState, kidFrame,                                     nsSize(aReflowState.availableWidth,                                            NS_UNCONSTRAINEDSIZE));    if (isDirtyChildReflow) {      // Note: the only reason the frame would be dirty would be if it had      // just been inserted or appended      kidReflowState.reason = eReflowReason_Initial;      kidReflowState.reflowCommand = nsnull;    } else if (isStyleChange) {      kidReflowState.reason = eReflowReason_StyleChange;      kidReflowState.reflowCommand = nsnull;    }    // Reflow the frame    ReflowChild(kidFrame, aPresContext, kidDesiredSize, kidReflowState,                kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,                0, aStatus);    // The document element's background should cover the entire canvas, so    // take into account the combined area and any space taken up by    // absolutely positioned elements    nsMargin      border;    nsFrameState  kidState;    if (!kidReflowState.mStyleBorder->GetBorder(border)) {      NS_NOTYETIMPLEMENTED("percentage border");    }    kidFrame->GetFrameState(&kidState);    // First check the combined area    if (NS_FRAME_OUTSIDE_CHILDREN & kidState) {      // The background covers the content area and padding area, so check      // for children sticking outside the child frame's padding edge      nscoord paddingEdgeX = kidDesiredSize.width - border.right;      nscoord paddingEdgeY = kidDesiredSize.height - border.bottom;      if (kidDesiredSize.mOverflowArea.XMost() > paddingEdgeX) {        kidDesiredSize.width = kidDesiredSize.mOverflowArea.XMost() +                               border.right;      }      if (kidDesiredSize.mOverflowArea.YMost() > paddingEdgeY) {        kidDesiredSize.height = kidDesiredSize.mOverflowArea.YMost() +                                border.bottom;      }    }    // If our height is fixed, then make sure the child frame plus its top and    // bottom margin is at least that high as well...    if (NS_AUTOHEIGHT != aReflowState.mComputedHeight) {      nscoord totalHeight = kidDesiredSize.height + kidReflowState.mComputedMargin.top +        kidReflowState.mComputedMargin.bottom;      if (totalHeight < aReflowState.mComputedHeight) {        kidDesiredSize.height += aReflowState.mComputedHeight - totalHeight;      }    }    // Complete the reflow and position and size the child frame    nsRect  rect(kidReflowState.mComputedMargin.left, kidReflowState.mComputedMargin.top,                 kidDesiredSize.width, kidDesiredSize.height);    FinishReflowChild(kidFrame, aPresContext, &kidReflowState, kidDesiredSize, rect.x, rect.y, 0);    // If the child frame was just inserted, then we're responsible for making sure    // it repaints    if (isDirtyChildReflow) {      // Damage the area occupied by the deleted frame      Invalidate(aPresContext, rect, PR_FALSE);    }    // Return our desired size    aDesiredSize.width = kidDesiredSize.width + kidReflowState.mComputedMargin.left +      kidReflowState.mComputedMargin.right;    aDesiredSize.height = kidDesiredSize.height + kidReflowState.mComputedMargin.top +      kidReflowState.mComputedMargin.bottom;    aDesiredSize.ascent = aDesiredSize.height;    aDesiredSize.descent = 0;    // XXX Don't completely ignore NS_FRAME_OUTSIDE_CHILDREN for child frames    // that stick out on the left or top edges...  }  NS_FRAME_TRACE_REFLOW_OUT("CanvasFrame::Reflow", aStatus);  return NS_OK;}