Move nsCSSRendering::GetBorderRadiusTwips to nsIFrame and rename it to ComputeBorderRadii. (Bug 459144, patch 1) r=roc a2.0=blocking:beta6+

This commit is contained in:
L. David Baron 2010-09-07 15:20:34 -07:00
Родитель 71f7365d9b
Коммит 999f84163c
5 изменённых файлов: 58 добавлений и 65 удалений

Просмотреть файл

@ -629,8 +629,8 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
}
nsSize frameSize = aForFrame->GetSize();
GetBorderRadiusTwips(aStyleBorder.mBorderRadius, frameSize.width,
frameSize.height, twipsRadii);
nsIFrame::ComputeBorderRadii(aStyleBorder.mBorderRadius, frameSize.width,
frameSize.height, twipsRadii);
// Turn off rendering for all of the zero sized sides
if (aSkipSides & SIDE_BIT_TOP) border.top = 0;
@ -750,8 +750,8 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
bgContext->GetVisitedDependentColor(eCSSProperty_background_color);
// get the radius for our outline
GetBorderRadiusTwips(ourOutline->mOutlineRadius, aBorderArea.width,
aBorderArea.height, twipsRadii);
nsIFrame::ComputeBorderRadii(ourOutline->mOutlineRadius, aBorderArea.width,
aBorderArea.height, twipsRadii);
// When the outline property is set on :-moz-anonymous-block or
// :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
@ -1138,40 +1138,6 @@ nsCSSRendering::DidPaint()
gInlineBGData->Reset();
}
PRBool
nsCSSRendering::GetBorderRadiusTwips(const nsStyleCorners& aBorderRadius,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8])
{
PRBool result = PR_FALSE;
// Percentages are relative to whichever side they're on.
NS_FOR_CSS_HALF_CORNERS(i) {
const nsStyleCoord c = aBorderRadius.Get(i);
nscoord axis = NS_HALF_CORNER_IS_X(i) ? aFrameWidth : aFrameHeight;
switch (c.GetUnit()) {
case eStyleUnit_Percent:
aRadii[i] = (nscoord)(c.GetPercentValue() * axis);
break;
case eStyleUnit_Coord:
aRadii[i] = c.GetCoordValue();
break;
default:
NS_NOTREACHED("GetBorderRadiusTwips: bad unit");
aRadii[i] = 0;
break;
}
if (aRadii[i])
result = PR_TRUE;
}
return result;
}
void
nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
@ -1201,11 +1167,8 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
} else {
nativeTheme = PR_FALSE;
nscoord twipsRadii[8];
hasBorderRadius =
GetBorderRadiusTwips(styleBorder->mBorderRadius,
aFrameArea.width,
aFrameArea.height,
twipsRadii);
hasBorderRadius = nsIFrame::ComputeBorderRadii(styleBorder->mBorderRadius,
aFrameArea.width, aFrameArea.height, twipsRadii);
if (hasBorderRadius) {
PRIntn sidesToSkip = aForFrame->GetSkipSides();
ComputePixelRadii(twipsRadii, aFrameArea, sidesToSkip, twipsPerPixel,
@ -1384,10 +1347,9 @@ nsCSSRendering::PaintBoxShadowInner(nsPresContext* aPresContext,
// Get any border radius, since box-shadow must also have rounded corners if the frame does
nscoord twipsRadii[8];
PRBool hasBorderRadius = GetBorderRadiusTwips(styleBorder->mBorderRadius,
aFrameArea.width,
aFrameArea.height,
twipsRadii);
PRBool hasBorderRadius = nsIFrame::ComputeBorderRadii(
styleBorder->mBorderRadius, aFrameArea.width,
aFrameArea.height, twipsRadii);
nscoord twipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
nsRect paddingRect = aFrameArea;
@ -2279,9 +2241,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
{
nscoord radii[8];
nsSize frameSize = aForFrame->GetSize();
haveRoundedCorners =
GetBorderRadiusTwips(aBorder.mBorderRadius, frameSize.width,
frameSize.height, radii);
haveRoundedCorners = nsIFrame::ComputeBorderRadii(aBorder.mBorderRadius,
frameSize.width, frameSize.height, radii);
if (haveRoundedCorners)
ComputePixelRadii(radii, aBorderArea, aForFrame->GetSkipSides(),
appUnitsPerPixel, &bgRadii);

Просмотреть файл

@ -73,16 +73,6 @@ struct nsCSSRendering {
const nsRect& aFrameArea,
const nsRect& aDirtyRect);
/**
* Get the size, in app units, of the border radii. It returns FALSE iff all
* returned radii == 0 (so no border radii), TRUE otherwise.
* For the aRadii indexes, use the NS_CORNER_* constants in nsStyleConsts.h
*/
static PRBool GetBorderRadiusTwips(const nsStyleCorners& aBorderRadius,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8]);
/**
* Render the border for an element using css rendering rules
* for borders. aSkipSides is a bitmask of the sides to skip

Просмотреть файл

@ -1009,11 +1009,9 @@ nsDisplayBoxShadowOuter::ComputeVisibility(nsDisplayListBuilder* aBuilder,
// the visible region is entirely inside the border-rect, and box shadows
// never render within the border-rect (unless there's a border radius).
nscoord twipsRadii[8];
PRBool hasBorderRadii =
nsCSSRendering::GetBorderRadiusTwips(mFrame->GetStyleBorder()->
mBorderRadius,
frameRect.width, frameRect.height,
twipsRadii);
PRBool hasBorderRadii = nsIFrame::ComputeBorderRadii(
mFrame->GetStyleBorder()->mBorderRadius,
frameRect.width, frameRect.height, twipsRadii);
if (!hasBorderRadii)
return PR_FALSE;

Просмотреть файл

@ -736,6 +736,40 @@ nsIFrame::GetContentRect() const
return r;
}
PRBool
nsIFrame::ComputeBorderRadii(const nsStyleCorners& aBorderRadius,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8])
{
PRBool result = PR_FALSE;
// Percentages are relative to whichever side they're on.
NS_FOR_CSS_HALF_CORNERS(i) {
const nsStyleCoord c = aBorderRadius.Get(i);
nscoord axis = NS_HALF_CORNER_IS_X(i) ? aFrameWidth : aFrameHeight;
switch (c.GetUnit()) {
case eStyleUnit_Percent:
aRadii[i] = (nscoord)(c.GetPercentValue() * axis);
break;
case eStyleUnit_Coord:
aRadii[i] = c.GetCoordValue();
break;
default:
NS_NOTREACHED("ComputeBorderRadii: bad unit");
aRadii[i] = 0;
break;
}
if (aRadii[i])
result = PR_TRUE;
}
return result;
}
nsStyleContext*
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
{

Просмотреть файл

@ -918,6 +918,16 @@ public:
nsRect GetPaddingRect() const;
nsRect GetContentRect() const;
/**
* Get the size, in app units, of the border radii. It returns FALSE iff all
* returned radii == 0 (so no border radii), TRUE otherwise.
* For the aRadii indexes, use the NS_CORNER_* constants in nsStyleConsts.h
*/
static PRBool ComputeBorderRadii(const nsStyleCorners& aBorderRadius,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8]);
/**
* Get the position of the frame's baseline, relative to the top of
* the frame (its top border edge). Only valid when Reflow is not