Fix border-radius computed style code to reflect that percentage Y values are percentages of the box height. (Bug 595650) r=bzbarsky a2.0=blocking2.0:betaN

This commit is contained in:
L. David Baron 2010-10-06 21:25:47 -07:00
Родитель 54958ef33a
Коммит a3bce24717
5 изменённых файлов: 118 добавлений и 10 удалений

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

@ -2327,18 +2327,33 @@ nsComputedDOMStyle::GetEllipseRadii(const nsStyleCorners& aRadius,
PRUint8 aFullCorner,
nsIDOMCSSValue** aValue)
{
const nsStyleCoord& radiusX
nsStyleCoord radiusX
= aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, PR_FALSE));
const nsStyleCoord& radiusY
nsStyleCoord radiusY
= aRadius.Get(NS_FULL_TO_HALF_CORNER(aFullCorner, PR_TRUE));
if (mInnerFrame) {
// We need to convert to absolute coordinates before doing the
// equality check below.
nscoord v;
v = StyleCoordToNSCoord(radiusX,
&nsComputedDOMStyle::GetFrameBorderRectWidth,
0, PR_TRUE);
radiusX.SetCoordValue(v);
v = StyleCoordToNSCoord(radiusY,
&nsComputedDOMStyle::GetFrameBorderRectHeight,
0, PR_TRUE);
radiusY.SetCoordValue(v);
}
// for compatibility, return a single value if X and Y are equal
if (radiusX == radiusY) {
nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue();
NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY);
SetValueToCoord(val, radiusX, PR_TRUE,
&nsComputedDOMStyle::GetFrameBorderRectWidth);
SetValueToCoord(val, radiusX, PR_TRUE);
NS_ADDREF(*aValue = val);
return NS_OK;
@ -2361,10 +2376,8 @@ nsComputedDOMStyle::GetEllipseRadii(const nsStyleCorners& aRadius,
return NS_ERROR_OUT_OF_MEMORY;
}
SetValueToCoord(valX, radiusX, PR_TRUE,
&nsComputedDOMStyle::GetFrameBorderRectWidth);
SetValueToCoord(valY, radiusY, PR_TRUE,
&nsComputedDOMStyle::GetFrameBorderRectWidth);
SetValueToCoord(valX, radiusX, PR_TRUE);
SetValueToCoord(valY, radiusY, PR_TRUE);
NS_ADDREF(*aValue = valueList);
return NS_OK;
@ -4044,6 +4057,19 @@ nsComputedDOMStyle::GetFrameBorderRectWidth(nscoord& aWidth)
return PR_TRUE;
}
PRBool
nsComputedDOMStyle::GetFrameBorderRectHeight(nscoord& aHeight)
{
if (!mInnerFrame) {
return PR_FALSE;
}
AssertFlushedPendingReflows();
aHeight = mInnerFrame->GetSize().height;
return PR_TRUE;
}
PRBool
nsComputedDOMStyle::GetFrameBoundsWidthForTransform(nscoord& aWidth)
{

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

@ -450,6 +450,7 @@ private:
PRBool GetFrameBoundsWidthForTransform(nscoord &aWidth);
PRBool GetFrameBoundsHeightForTransform(nscoord &aHeight);
PRBool GetFrameBorderRectWidth(nscoord& aWidth);
PRBool GetFrameBorderRectHeight(nscoord& aHeight);
struct ComputedStyleMapEntry
{

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

@ -137,6 +137,7 @@ _TEST_FILES = test_acid3_test46.html \
test_bug580685.html \
test_cascade.html \
test_compute_data_with_start_struct.html \
test_computed_style.html \
test_computed_style_no_pseudo.html \
test_css_cross_domain.html \
test_css_eof_handling.html \

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

@ -147,9 +147,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=365932
style="min-height: 75%; max-height: 40%"></div>
<div id="radius1" style="border-radius: 80px"></div>
<div id="radius2" style="border-radius: 10%"></div>
<div id="radius2" style="border-radius: 10% / 20%"></div>
<div id="outlineradius1" style="-moz-outline-radius: 160px"></div>
<div id="outlineradius2" style="-moz-outline-radius: 20%"></div>
<div id="outlineradius2" style="-moz-outline-radius: 20% / 40%"></div>
</div>
<div id="content2" style="display: none">
<div id="indent3" style="text-indent: 400px"></div>

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

@ -0,0 +1,80 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Test for miscellaneous computed style issues</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for miscellaneous computed style issues **/
var frame_container = document.getElementById("display");
var noframe_container = document.getElementById("content");
(function test_bug_595650() {
// Test handling of horizontal and vertical percentages for border-radius
// and -moz-outline-radius.
var p = document.createElement("p");
p.setAttribute("style", "width: 256px; height: 128px");
p.style.borderTopLeftRadius = "1.5625%"; /* 1/64 == 4px 2px */
p.style.borderTopRightRadius = "5px";
p.style.borderBottomRightRadius = "5px 3px";
p.style.borderBottomLeftRadius = "1.5625% 3.125%" /* 1/64 1/32 == 4px 4px */
p.style.MozOutlineRadiusTopleft = "1.5625%"; /* 1/64 == 4px 2px */
p.style.MozOutlineRadiusTopright = "5px";
p.style.MozOutlineRadiusBottomright = "5px 3px";
p.style.MozOutlineRadiusBottomleft = "1.5625% 3.125%" /* 1/64 1/32 == 4px 4px */
var cs = getComputedStyle(p, "");
frame_container.appendChild(p);
is(cs.borderTopLeftRadius, "4px 2px",
"computed value of % border-radius, with frame");
is(cs.borderTopRightRadius, "5px",
"computed value of px border-radius, with frame");
is(cs.borderBottomRightRadius, "5px 3px",
"computed value of px border-radius, with frame");
is(cs.borderBottomLeftRadius, "4px",
"computed value of % border-radius, with frame");
is(cs.MozOutlineRadiusTopleft, "4px 2px",
"computed value of % outline-radius, with frame");
is(cs.MozOutlineRadiusTopright, "5px",
"computed value of px outline-radius, with frame");
is(cs.MozOutlineRadiusBottomright, "5px 3px",
"computed value of px outline-radius, with frame");
is(cs.MozOutlineRadiusBottomleft, "4px",
"computed value of % outline-radius, with frame");
noframe_container.appendChild(p);
is(cs.borderTopLeftRadius, "1.5625%",
"computed value of % border-radius, without frame");
is(cs.borderTopRightRadius, "5px",
"computed value of px border-radius, without frame");
is(cs.borderBottomRightRadius, "5px 3px",
"computed value of px border-radius, without frame");
is(cs.borderBottomLeftRadius, "1.5625% 3.125%",
"computed value of % border-radius, without frame");
is(cs.MozOutlineRadiusTopleft, "1.5625%",
"computed value of % outline-radius, without frame");
is(cs.MozOutlineRadiusTopright, "5px",
"computed value of px outline-radius, without frame");
is(cs.MozOutlineRadiusBottomright, "5px 3px",
"computed value of px outline-radius, without frame");
is(cs.MozOutlineRadiusBottomleft, "1.5625% 3.125%",
"computed value of % outline-radius, without frame");
p.parentNode.removeChild(p);
})();
</script>
</pre>
</body>
</html>