Added code to size the button appropriately when style sets the size and

make it clip for drawing.
NOTE: This is a temporary fix for bug #17474
This commit is contained in:
rods@netscape.com
1999-11-03 00:05:30 +00:00
parent 3c30b69ede
commit ec7a00a1d1
2 changed files with 86 additions and 0 deletions

View File

@@ -411,8 +411,37 @@ nsHTMLButtonControlFrame::Paint(nsIPresContext& aPresContext,
mRenderer.PaintButton(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, rect);
}
#if 0 // old way
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
#else // temporary
// XXX This is temporary
// clips to it's size minus the border and padding,
// but the real problem is the FirstChild (the AreaFrame)
// isn't being constrained properly
// Bug #17474
const nsStyleSpacing* spacing;
GetStyleData(eStyleStruct_Spacing, (const nsStyleStruct *&)spacing);
nsMargin borderPadding;
borderPadding.SizeTo(0, 0, 0, 0);
spacing->CalcBorderPaddingFor(this, borderPadding);
nsRect rect;
GetRect(rect);
rect.x = 0;
rect.y = 0;
rect.Deflate(borderPadding);
aRenderingContext.PushState();
PRBool clipEmpty;
aRenderingContext.SetClipRect(rect, nsClipCombine_kReplace, clipEmpty);
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
aRenderingContext.PopState(clipEmpty);
#endif
return NS_OK;
}
@@ -557,6 +586,7 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
nsRect rect = nsRect(focusPadding.left + aReflowState.mComputedBorderPadding.left, focusPadding.top + aReflowState.mComputedBorderPadding.top, aDesiredSize.width, aDesiredSize.height);
firstKid->SetRect(&aPresContext, rect);
#if 0 // old way
// if computed use the computed values.
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE && (aDesiredSize.width < aReflowState.mComputedWidth))
aDesiredSize.width = aReflowState.mComputedWidth;
@@ -568,6 +598,19 @@ nsHTMLButtonControlFrame::Reflow(nsIPresContext& aPresContext,
else
aDesiredSize.height += focusPadding.top + focusPadding.bottom;
#else // temporary for Bug #17474
// if computed use the computed values.
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE)
aDesiredSize.width = aReflowState.mComputedWidth;
else
aDesiredSize.width += focusPadding.left + focusPadding.right;
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE)
aDesiredSize.height = aReflowState.mComputedHeight;
else
aDesiredSize.height += focusPadding.top + focusPadding.bottom;
#endif
AddComputedBorderPaddingToDesiredSize(aDesiredSize, aReflowState);
//aDesiredSize.width += aReflowState.mComputedBorderPadding.left + aReflowState.mComputedBorderPadding.right;
//aDesiredSize.height += aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom;