aDirtyRect, rect, *borderStyle, 0, 0);
aDirtyRect, rect, *borderStyle, *paddingStyle, 0, 0);
nsFieldSetFrame::Paint(nsIPresContext*      aPresContext,                       nsIRenderingContext& aRenderingContext,                       const nsRect&        aDirtyRect,                       nsFramePaintLayer    aWhichLayer,                       PRUint32             aFlags){  if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {    // Paint our background and border    PRBool isVisible;    if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) &&                      isVisible && mRect.width && mRect.height) {      PRIntn skipSides = GetSkipSides();      const nsStyleBorder* borderStyle =         (const nsStyleBorder*)mStyleContext->GetStyleData(eStyleStruct_Border);               nsMargin border;        if (!borderStyle->GetBorder(border)) {          NS_NOTYETIMPLEMENTED("percentage border");        }        nscoord yoff = 0;                // if the border is smaller than the legend. Move the border down        // to be centered on the legend.         if (border.top < mLegendRect.height)            yoff = (mLegendRect.height - border.top)/2;               nsRect rect(0, yoff, mRect.width, mRect.height - yoff);        nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,                                        aDirtyRect, rect, *borderStyle, 0, 0);        if (mLegendFrame) {          // we should probably use PaintBorderEdges to do this but for now just use clipping          // to achieve the same effect.          PRBool clipState;          // draw left side          nsRect clipRect(rect);          clipRect.width = mLegendRect.x - rect.x;          clipRect.height = border.top;          aRenderingContext.PushState();          aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);          nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,                                      aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);            aRenderingContext.PopState(clipState);          // draw right side          clipRect = rect;          clipRect.x = mLegendRect.x + mLegendRect.width;          clipRect.width -= (mLegendRect.x + mLegendRect.width);          clipRect.height = border.top;          aRenderingContext.PushState();          aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);          nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,                                      aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);            aRenderingContext.PopState(clipState);                  // draw bottom          clipRect = rect;          clipRect.y += border.top;          clipRect.height = mRect.height - (yoff + border.top);                  aRenderingContext.PushState();          aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect, clipState);          nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,                                      aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);            aRenderingContext.PopState(clipState);        } else {          nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,                                      aDirtyRect,                                      nsRect(0,0,mRect.width, mRect.height),                                      *borderStyle, mStyleContext, skipSides);        }    }  }  PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);#ifdef DEBUG  if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {    nsIView* view;    GetView(aPresContext, &view);    if (nsnull != view) {      aRenderingContext.SetColor(NS_RGB(0,0,255));    }    else {      aRenderingContext.SetColor(NS_RGB(255,0,0));    }    aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);  }#endif  DO_GLOBAL_REFLOW_COUNT_DSP("nsFieldSetFrame", &aRenderingContext);  return NS_OK;}