зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
71f7365d9b
Коммит
999f84163c
|
@ -629,8 +629,8 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
nsSize frameSize = aForFrame->GetSize();
|
nsSize frameSize = aForFrame->GetSize();
|
||||||
GetBorderRadiusTwips(aStyleBorder.mBorderRadius, frameSize.width,
|
nsIFrame::ComputeBorderRadii(aStyleBorder.mBorderRadius, frameSize.width,
|
||||||
frameSize.height, twipsRadii);
|
frameSize.height, twipsRadii);
|
||||||
|
|
||||||
// Turn off rendering for all of the zero sized sides
|
// Turn off rendering for all of the zero sized sides
|
||||||
if (aSkipSides & SIDE_BIT_TOP) border.top = 0;
|
if (aSkipSides & SIDE_BIT_TOP) border.top = 0;
|
||||||
|
@ -750,8 +750,8 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
|
||||||
bgContext->GetVisitedDependentColor(eCSSProperty_background_color);
|
bgContext->GetVisitedDependentColor(eCSSProperty_background_color);
|
||||||
|
|
||||||
// get the radius for our outline
|
// get the radius for our outline
|
||||||
GetBorderRadiusTwips(ourOutline->mOutlineRadius, aBorderArea.width,
|
nsIFrame::ComputeBorderRadii(ourOutline->mOutlineRadius, aBorderArea.width,
|
||||||
aBorderArea.height, twipsRadii);
|
aBorderArea.height, twipsRadii);
|
||||||
|
|
||||||
// When the outline property is set on :-moz-anonymous-block or
|
// When the outline property is set on :-moz-anonymous-block or
|
||||||
// :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
|
// :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
|
||||||
|
@ -1138,40 +1138,6 @@ nsCSSRendering::DidPaint()
|
||||||
gInlineBGData->Reset();
|
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
|
void
|
||||||
nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
|
nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
|
||||||
nsIRenderingContext& aRenderingContext,
|
nsIRenderingContext& aRenderingContext,
|
||||||
|
@ -1201,11 +1167,8 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
nativeTheme = PR_FALSE;
|
nativeTheme = PR_FALSE;
|
||||||
nscoord twipsRadii[8];
|
nscoord twipsRadii[8];
|
||||||
hasBorderRadius =
|
hasBorderRadius = nsIFrame::ComputeBorderRadii(styleBorder->mBorderRadius,
|
||||||
GetBorderRadiusTwips(styleBorder->mBorderRadius,
|
aFrameArea.width, aFrameArea.height, twipsRadii);
|
||||||
aFrameArea.width,
|
|
||||||
aFrameArea.height,
|
|
||||||
twipsRadii);
|
|
||||||
if (hasBorderRadius) {
|
if (hasBorderRadius) {
|
||||||
PRIntn sidesToSkip = aForFrame->GetSkipSides();
|
PRIntn sidesToSkip = aForFrame->GetSkipSides();
|
||||||
ComputePixelRadii(twipsRadii, aFrameArea, sidesToSkip, twipsPerPixel,
|
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
|
// Get any border radius, since box-shadow must also have rounded corners if the frame does
|
||||||
nscoord twipsRadii[8];
|
nscoord twipsRadii[8];
|
||||||
PRBool hasBorderRadius = GetBorderRadiusTwips(styleBorder->mBorderRadius,
|
PRBool hasBorderRadius = nsIFrame::ComputeBorderRadii(
|
||||||
aFrameArea.width,
|
styleBorder->mBorderRadius, aFrameArea.width,
|
||||||
aFrameArea.height,
|
aFrameArea.height, twipsRadii);
|
||||||
twipsRadii);
|
|
||||||
nscoord twipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
nscoord twipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
|
||||||
|
|
||||||
nsRect paddingRect = aFrameArea;
|
nsRect paddingRect = aFrameArea;
|
||||||
|
@ -2279,9 +2241,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
|
||||||
{
|
{
|
||||||
nscoord radii[8];
|
nscoord radii[8];
|
||||||
nsSize frameSize = aForFrame->GetSize();
|
nsSize frameSize = aForFrame->GetSize();
|
||||||
haveRoundedCorners =
|
haveRoundedCorners = nsIFrame::ComputeBorderRadii(aBorder.mBorderRadius,
|
||||||
GetBorderRadiusTwips(aBorder.mBorderRadius, frameSize.width,
|
frameSize.width, frameSize.height, radii);
|
||||||
frameSize.height, radii);
|
|
||||||
if (haveRoundedCorners)
|
if (haveRoundedCorners)
|
||||||
ComputePixelRadii(radii, aBorderArea, aForFrame->GetSkipSides(),
|
ComputePixelRadii(radii, aBorderArea, aForFrame->GetSkipSides(),
|
||||||
appUnitsPerPixel, &bgRadii);
|
appUnitsPerPixel, &bgRadii);
|
||||||
|
|
|
@ -73,16 +73,6 @@ struct nsCSSRendering {
|
||||||
const nsRect& aFrameArea,
|
const nsRect& aFrameArea,
|
||||||
const nsRect& aDirtyRect);
|
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
|
* Render the border for an element using css rendering rules
|
||||||
* for borders. aSkipSides is a bitmask of the sides to skip
|
* 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
|
// the visible region is entirely inside the border-rect, and box shadows
|
||||||
// never render within the border-rect (unless there's a border radius).
|
// never render within the border-rect (unless there's a border radius).
|
||||||
nscoord twipsRadii[8];
|
nscoord twipsRadii[8];
|
||||||
PRBool hasBorderRadii =
|
PRBool hasBorderRadii = nsIFrame::ComputeBorderRadii(
|
||||||
nsCSSRendering::GetBorderRadiusTwips(mFrame->GetStyleBorder()->
|
mFrame->GetStyleBorder()->mBorderRadius,
|
||||||
mBorderRadius,
|
frameRect.width, frameRect.height, twipsRadii);
|
||||||
frameRect.width, frameRect.height,
|
|
||||||
twipsRadii);
|
|
||||||
if (!hasBorderRadii)
|
if (!hasBorderRadii)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
|
|
|
@ -736,6 +736,40 @@ nsIFrame::GetContentRect() const
|
||||||
return r;
|
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*
|
nsStyleContext*
|
||||||
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
|
nsFrame::GetAdditionalStyleContext(PRInt32 aIndex) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -918,6 +918,16 @@ public:
|
||||||
nsRect GetPaddingRect() const;
|
nsRect GetPaddingRect() const;
|
||||||
nsRect GetContentRect() 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
|
* 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
|
* the frame (its top border edge). Only valid when Reflow is not
|
||||||
|
|
Загрузка…
Ссылка в новой задаче