Bug 471643: Evaluate vertical percentages in border-radius relative to box height. r=dbaron a2.0=blocking:beta6+

This commit is contained in:
Zack Weinberg 2010-08-31 12:05:11 -04:00
Родитель 0314e7b046
Коммит 3c7d2bc0ae
12 изменённых файлов: 315 добавлений и 24 удалений

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

@ -628,8 +628,9 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext,
return;
}
GetBorderRadiusTwips(aStyleBorder.mBorderRadius, aForFrame->GetSize().width,
twipsRadii);
nsSize frameSize = aForFrame->GetSize();
GetBorderRadiusTwips(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,7 +751,7 @@ nsCSSRendering::PaintOutline(nsPresContext* aPresContext,
// get the radius for our outline
GetBorderRadiusTwips(ourOutline->mOutlineRadius, aBorderArea.width,
twipsRadii);
aBorderArea.height, twipsRadii);
// When the outline property is set on :-moz-anonymous-block or
// :-moz-anonyomus-positioned-block pseudo-elements, it inherited that
@ -1139,18 +1140,20 @@ nsCSSRendering::DidPaint()
PRBool
nsCSSRendering::GetBorderRadiusTwips(const nsStyleCorners& aBorderRadius,
const nscoord& aFrameWidth,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8])
{
PRBool result = PR_FALSE;
// Convert percentage values
// 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() * aFrameWidth);
aRadii[i] = (nscoord)(c.GetPercentValue() * axis);
break;
case eStyleUnit_Coord:
@ -1200,7 +1203,9 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext,
nscoord twipsRadii[8];
hasBorderRadius =
GetBorderRadiusTwips(styleBorder->mBorderRadius,
aFrameArea.width, twipsRadii);
aFrameArea.width,
aFrameArea.height,
twipsRadii);
if (hasBorderRadius) {
PRIntn sidesToSkip = aForFrame->GetSkipSides();
ComputePixelRadii(twipsRadii, aFrameArea, sidesToSkip, twipsPerPixel,
@ -1380,7 +1385,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, twipsRadii);
aFrameArea.width,
aFrameArea.height,
twipsRadii);
nscoord twipsPerPixel = aPresContext->DevPixelsToAppUnits(1);
nsRect paddingRect = aFrameArea;
@ -2271,9 +2278,10 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
PRBool haveRoundedCorners;
{
nscoord radii[8];
nsSize frameSize = aForFrame->GetSize();
haveRoundedCorners =
GetBorderRadiusTwips(aBorder.mBorderRadius, aForFrame->GetSize().width,
radii);
GetBorderRadiusTwips(aBorder.mBorderRadius, frameSize.width,
frameSize.height, radii);
if (haveRoundedCorners)
ComputePixelRadii(radii, aBorderArea, aForFrame->GetSkipSides(),
appUnitsPerPixel, &bgRadii);

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

@ -79,7 +79,8 @@ struct nsCSSRendering {
* For the aRadii indexes, use the NS_CORNER_* constants in nsStyleConsts.h
*/
static PRBool GetBorderRadiusTwips(const nsStyleCorners& aBorderRadius,
const nscoord& aFrameWidth,
const nscoord aFrameWidth,
const nscoord aFrameHeight,
nscoord aRadii[8]);
/**

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

@ -1002,8 +1002,9 @@ nsDisplayBoxShadowOuter::ComputeVisibility(nsDisplayListBuilder* aBuilder,
// never render within the border-rect (unless there's a border radius).
nscoord twipsRadii[8];
PRBool hasBorderRadii =
nsCSSRendering::GetBorderRadiusTwips(mFrame->GetStyleBorder()->mBorderRadius,
frameRect.width,
nsCSSRendering::GetBorderRadiusTwips(mFrame->GetStyleBorder()->
mBorderRadius,
frameRect.width, frameRect.height,
twipsRadii);
if (!hasBorderRadii)
return PR_FALSE;

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

@ -0,0 +1,55 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; reference</title>
<style>
div { background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
.r1.c1 { -moz-border-radius: 5px / 5px; }
.r1.c2 { -moz-border-radius: 10px / 5px; }
.r1.c3 { -moz-border-radius: 15px / 5px; }
.r1.c4 { -moz-border-radius: 20px / 5px; }
.r2.c1 { -moz-border-radius: 5px / 10px; }
.r2.c2 { -moz-border-radius: 10px / 10px; }
.r2.c3 { -moz-border-radius: 15px / 10px; }
.r2.c4 { -moz-border-radius: 20px / 10px; }
.r3.c1 { -moz-border-radius: 5px / 15px; }
.r3.c2 { -moz-border-radius: 10px / 15px; }
.r3.c3 { -moz-border-radius: 15px / 15px; }
.r3.c4 { -moz-border-radius: 20px / 15px; }
.r4.c1 { -moz-border-radius: 5px / 20px; }
.r4.c2 { -moz-border-radius: 10px / 20px; }
.r4.c3 { -moz-border-radius: 15px / 20px; }
.r4.c4 { -moz-border-radius: 20px / 20px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -0,0 +1,37 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; test</title>
<style>
div { -moz-border-radius: 25%; background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -0,0 +1,55 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; reference</title>
<style>
div { background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
.r1.c1 { -moz-border-radius: 5px 2px / 5px 2px; }
.r1.c2 { -moz-border-radius: 10px 4px / 5px 2px; }
.r1.c3 { -moz-border-radius: 15px 6px / 5px 2px; }
.r1.c4 { -moz-border-radius: 20px 8px / 5px 2px; }
.r2.c1 { -moz-border-radius: 5px 2px / 10px 4px; }
.r2.c2 { -moz-border-radius: 10px 4px / 10px 4px; }
.r2.c3 { -moz-border-radius: 15px 6px / 10px 4px; }
.r2.c4 { -moz-border-radius: 20px 8px / 10px 4px; }
.r3.c1 { -moz-border-radius: 5px 2px / 15px 6px; }
.r3.c2 { -moz-border-radius: 10px 4px / 15px 6px; }
.r3.c3 { -moz-border-radius: 15px 6px / 15px 6px; }
.r3.c4 { -moz-border-radius: 20px 8px / 15px 6px; }
.r4.c1 { -moz-border-radius: 5px 2px / 20px 8px; }
.r4.c2 { -moz-border-radius: 10px 4px / 20px 8px; }
.r4.c3 { -moz-border-radius: 15px 6px / 20px 8px; }
.r4.c4 { -moz-border-radius: 20px 8px / 20px 8px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -0,0 +1,37 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; test</title>
<style>
div { -moz-border-radius: 25% 10%; background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -0,0 +1,55 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; reference</title>
<style>
div { background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
.r1.c1 { -moz-border-radius: 5px / 2px; }
.r1.c2 { -moz-border-radius: 10px / 2px; }
.r1.c3 { -moz-border-radius: 15px / 2px; }
.r1.c4 { -moz-border-radius: 20px / 2px; }
.r2.c1 { -moz-border-radius: 5px / 4px; }
.r2.c2 { -moz-border-radius: 10px / 4px; }
.r2.c3 { -moz-border-radius: 15px / 4px; }
.r2.c4 { -moz-border-radius: 20px / 4px; }
.r3.c1 { -moz-border-radius: 5px / 6px; }
.r3.c2 { -moz-border-radius: 10px / 6px; }
.r3.c3 { -moz-border-radius: 15px / 6px; }
.r3.c4 { -moz-border-radius: 20px / 6px; }
.r4.c1 { -moz-border-radius: 5px / 8px; }
.r4.c2 { -moz-border-radius: 10px / 8px; }
.r4.c3 { -moz-border-radius: 15px / 8px; }
.r4.c4 { -moz-border-radius: 20px / 8px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -0,0 +1,37 @@
<!doctype html>
<html><head><title>Border radius with percent units &mdash; test</title>
<style>
div { -moz-border-radius: 25% / 10%; background: green; }
.r1 { height: 20px; } .c1 { width: 20px; }
.r2 { height: 40px; } .c2 { width: 40px; }
.r3 { height: 60px; } .c3 { width: 60px; }
.r4 { height: 80px; } .c4 { width: 80px; }
</style>
</head><body>
<table>
<tr>
<td><div class="r1 c1"></div></td>
<td><div class="r1 c2"></div></td>
<td><div class="r1 c3"></div></td>
<td><div class="r1 c4"></div></td>
</tr>
<tr>
<td><div class="r2 c1"></div></td>
<td><div class="r2 c2"></div></td>
<td><div class="r2 c3"></div></td>
<td><div class="r2 c4"></div></td>
</tr>
<tr>
<td><div class="r3 c1"></div></td>
<td><div class="r3 c2"></div></td>
<td><div class="r3 c3"></div></td>
<td><div class="r3 c4"></div></td>
</tr>
<tr>
<td><div class="r4 c1"></div></td>
<td><div class="r4 c2"></div></td>
<td><div class="r4 c3"></div></td>
<td><div class="r4 c4"></div></td>
</tr>
</table>
</body></html>

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

@ -17,6 +17,11 @@
!= curved-borders-all-styles.html about:blank # no way to generate reference for dotted/dashed/inset/outset
# ridge/groove borders
# percent units
== percent-1.html percent-1-ref.html
== percent-2.html percent-2-ref.html
== percent-3.html percent-3-ref.html
# more serious tests, using SVG reference
== border-circle-2.html border-circle-2-ref.xhtml
fails == curved-stripe-border.html curved-stripe-border-ref.svg # bug 459945

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

@ -12,16 +12,16 @@
</style>
</head>
<body>
<div style="-moz-outline-radius: 20px;"></div>
<div style="-moz-outline-radius: 40px;"></div>
<div style="-moz-outline-radius: 80px;"></div>
<div style="padding: 0 100px; -moz-outline-radius: 60px;"></div>
<div style="padding: 0 100px 0 0; -moz-outline-radius: 50px;"></div>
<div style="padding: 0 0 0 100px; -moz-outline-radius: 50px;"></div>
<div style="border-width: 0 100px; -moz-outline-radius: 60px;"></div>
<div style="border-width: 0 100px 0 0; -moz-outline-radius: 50px;"></div>
<div style="border-width: 0 0 0 100px; -moz-outline-radius: 50px;"></div>
<div style="-moz-outline-radius: 20px / 2.5px;"></div>
<div style="-moz-outline-radius: 40px / 5px;"></div>
<div style="-moz-outline-radius: 80px / 10px;"></div>
<div style="padding: 0 100px; -moz-outline-radius: 60px / 5px;"></div>
<div style="padding: 0 100px 0 0; -moz-outline-radius: 50px / 5px;"></div>
<div style="padding: 0 0 0 100px; -moz-outline-radius: 50px / 5px;"></div>
<div style="border-width: 0 100px; -moz-outline-radius: 60px / 5px;"></div>
<div style="border-width: 0 100px 0 0; -moz-outline-radius: 50px / 5px;"></div>
<div style="border-width: 0 0 0 100px; -moz-outline-radius: 50px / 5px;"></div>
<div style="border-width: 0 100px; padding: 0 100px;
-moz-outline-radius: 80px;"></div>
-moz-outline-radius: 80px / 5px;"></div>
</body>
</html>

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

@ -7,7 +7,7 @@
padding: 0;
height: 300px;
border: 100px solid rgba(255, 255, 0, 0.5);
-moz-border-radius: 240px">
-moz-border-radius: 240px / 200px">
</div>
</body>
</html>