Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 96046b2

Browse files
committed
Remove notion of percentage intrinsic size: remove the single case that (incorrectly) sets percentage intrinsic sizes, and fix all of the tests that depend on our old incorrect behavior. (Bug 611099) r=dholbert
Needed to help CSS 2.1 meet Proposed Recommendation entrance criteria.
1 parent d268d11 commit 96046b2

24 files changed

+95
-61
lines changed

layout/reftests/svg/as-image/img-novb-height-all-1-ref.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
// elements.
1919

2020
// * FIRST TWO ROWS: has width=auto height=auto
21-
// - Each renders w/ width = 10% * body_width = .1*600 = 60px
22-
// - Synthesized viewBox has width = 10% * viewport_width = .1*60 = 6
21+
// - Each renders w/ width = 300px (default)
22+
// - Synthesized viewBox has width = 10% * viewport_width = .1*300 = 30
2323
// - & viewBox both get height=30px, from height attr
24-
svgParams.viewBox = [0, 0, 6, 30],
25-
appendSVGSubArrayWithParams(svgParams, "embed", "60px", "30px");
24+
svgParams.viewBox = [0, 0, 30, 30],
25+
appendSVGSubArrayWithParams(svgParams, "embed", "300px", "30px");
2626

2727
// * SECOND TWO ROWS: has width=auto, height=20px
2828
// Calculations are as above, except now imposes height="20px".
29-
appendSVGSubArrayWithParams(svgParams, "embed", "60px", "20px");
29+
appendSVGSubArrayWithParams(svgParams, "embed", "300px", "20px");
3030

3131
// * THIRD TWO ROWS: has width=30px height=auto
3232
// - now renders w/ width = 30px (imposed by width attr)

layout/reftests/svg/as-image/img-novb-width-all-1-ref.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
// elements.
1919

2020
// * FIRST TWO ROWS: has width=auto height=auto
21-
// - Each renders w/ height = 20% * body_height = .2*600 = 120px
22-
// - Synthesized viewBox has height = 20% * viewport_height = .2*120 = 24
21+
// - Each renders w/ height = 150px (default)
22+
// - Synthesized viewBox has height = 20% * viewport_height = .2*150 = 30
2323
// - & viewBox both get width=20px, from width attr
24-
svgParams.viewBox = [0, 0, 20, 24],
25-
appendSVGSubArrayWithParams(svgParams, "embed", "20px", "120px");
24+
svgParams.viewBox = [0, 0, 20, 30],
25+
appendSVGSubArrayWithParams(svgParams, "embed", "20px", "150px");
2626

2727
// * SECOND TWO ROWS: has width=auto, height=20px
2828
// - now renders w/ height = 20px (imposed by height attr)
@@ -34,8 +34,8 @@
3434
// * THIRD TWO ROWS: has width=30px height=auto
3535
// Calculations are as with "FIRST TWO ROWS", except now imposes
3636
// width="30px".
37-
svgParams.viewBox = [0, 0, 20, 24],
38-
appendSVGSubArrayWithParams(svgParams, "embed", "30px", "120px");
37+
svgParams.viewBox = [0, 0, 20, 30],
38+
appendSVGSubArrayWithParams(svgParams, "embed", "30px", "150px");
3939

4040
// * FOURTH TWO ROWS: has width=30px height=20px
4141
// Calculations are as with "SECOND TWO ROWS", except now imposes

layout/reftests/svg/dynamic-rect-04.xhtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ function m() {
1414
svg.style.position = 'absolute';
1515
svg.style.left = '0px';
1616
svg.style.top = '0px';
17+
svg.style.width = '100%';
18+
svg.style.height = '100%';
1719
document.body.appendChild(svg);
1820

1921
var rect = document.createElementNS(SVG_NS, "rect");

layout/reftests/svg/sizing/dynamic--inline-resize-cb-height.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ html, body, div {
2222
margin: 0;
2323
width: 100%;
2424
height: 100%; /* inline style override on the div below */
25-
background: red;
25+
background: white;
2626
overflow: hidden;
2727
}
2828

@@ -44,7 +44,7 @@ document.addEventListener("MozReftestInvalidate", resize_div, false);
4444

4545
<div style="height:50%;">
4646
<svg xmlns="http://www.w3.org/2000/svg" width="5000" height="100%">
47-
<rect width="100%" height="100%" fill="lime"/>
47+
<rect width="100%" height="100%" fill="blue"/>
4848
svg>
4949
div>
5050

layout/reftests/svg/sizing/dynamic--inline-resize-cb-width.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ html, body, div {
2222
margin: 0;
2323
width: 100%; /* inline style override on the div below */
2424
height: 100%;
25-
background: red;
25+
background: white;
2626
overflow: hidden;
2727
}
2828

@@ -44,7 +44,7 @@ document.addEventListener("MozReftestInvalidate", resize_div, false);
4444

4545
<div style="width:50%;">
4646
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="5000">
47-
<rect width="100%" height="100%" fill="lime"/>
47+
<rect width="100%" height="100%" fill="blue"/>
4848
svg>
4949
div>
5050

layout/reftests/svg/sizing/dynamic--object--auto-auto--pct-px.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
<title>Test: width:auto; height:auto; width="49%" height="70px"title>
1111

1212
1819

1920
<style type="text/css">

layout/reftests/svg/sizing/inline--position-absolute--02.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ html, body {
3535
3636
<div style="height:20px; background:red;"/>
3737

38-
42-
<svg xmlns="http://www.w3.org/2000/svg" style="position:absolute; top:0;">
42+
<svg xmlns="http://www.w3.org/2000/svg" style="position:absolute; top:0; width: 100%; height: 100%">
4343
<rect width="100%" height="100%" fill="red"/>
4444
<rect width="100%" height="20px" fill="lime"/>
4545
svg>

layout/reftests/svg/sizing/object--auto-auto--0-pct--ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
border: 1px solid blue;
2727
margin: 50px;
2828
width: 0;
29-
height: 49%;
29+
height: 150px;
3030
}
3131

3232
style>

layout/reftests/svg/sizing/object--auto-auto--0-pct.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@
1010
<title>Test: width:auto; height:auto; width="0" height="49%"title>
1111

1212
1819

1920
<style type="text/css">

layout/reftests/svg/sizing/object--auto-auto--pct-0--ref.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
padding: 0;
2626
border: 1px solid blue;
2727
margin: 50px;
28-
width: 49%;
28+
width: 300px;
2929
height: 0;
3030
}
3131

layout/reftests/svg/sizing/object--auto-auto--pct-0.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<title>Test: width:auto; height:auto; width="49%" height="0"title>
1111

1212
1919

2020
<style type="text/css">

layout/reftests/svg/sizing/reftest.list

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,10 @@ random-if(Android) == object--auto-auto--px-px.html object--auto-auto--px
303303

304304
== dynamic--inline-css-height.xhtml pass.svg
305305
== dynamic--inline-css-width.xhtml pass.svg
306-
== dynamic--inline-resize-cb-height.xhtml pass.svg
307-
== dynamic--inline-resize-cb-width.xhtml pass.svg
306+
# These two don't have a whole lot of point anymore now that the meaning
307+
# of percentages has changed.
308+
== dynamic--inline-resize-cb-height.xhtml standalone-sanity-height-150px.svg
309+
== dynamic--inline-resize-cb-width.xhtml standalone-sanity-width-300px.svg
308310
skip == dynamic--inline-resize-window-height.xhtml pass.svg # XXX breaks the reftest run as the window height somehow is not restored
309311
skip == dynamic--inline-resize-window-width.xhtml pass.svg # Fails way too much
310312
fails == dynamic--object-svg-unloaded.xhtml pass.svg

layout/reftests/svg/svg-in-foreignObject-01.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<title>Test percentages dimensions for SVG inside a foreignObjecttitle>
1010

1111
<foreignObject width="50%" height="50%">
12-
<svg xmlns="http://www.w3.org/2000/svg" width="50%" height="50%">
12+
<svg xmlns="http://www.w3.org/2000/svg" style="width: 50%; height: 50%">
1313
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
1414
svg>
1515
foreignObject>

layout/reftests/svg/svg-in-foreignObject-02.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<foreignObject width="50%" height="50%">
1212
<div xmlns="http://www.w3.org/1999/xhtml" style="width:100%;height:100%;">
13-
<svg xmlns="http://www.w3.org/2000/svg" width="50%" height="50%">
13+
<svg xmlns="http://www.w3.org/2000/svg" style="width: 50%; height: 50%">
1414
<ellipse cx="50%" cy="50%" rx="50%" ry="50%" fill="blue"/>
1515
svg>
1616
div>

layout/reftests/svg/svg-integration/clipPath-html-06-extref.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<div style="height:200px; width:100px;"/>
1717
<span class="unit" style="background:lime;">span>
1818
span>
19-
<svg:svg height="0">
19+
<svg:svg height="0" style="display: block">
2020
2121
<svg:use xlink:href="clipPath-html-06.xhtml#empty" />
2222
svg:svg>

layout/reftests/svg/svg-integration/clipPath-html-06.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<span class="unit" style="background:lime;">span>
1818
span>
1919

20-
<svg:svg height="0">
20+
<svg:svg height="0" style="display: block">
2121
2323
<svg:g id="empty" />

layout/reftests/svg/svg-integration/conditions-outer-svg-01.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<head>
88
<title>Test that conditional processing attributes on outer 'svg' elements are honoredtitle>
99
10-
<style>svg { position: absolute; top: 0; left: 0 }style>
10+
<style>svg { position: absolute; top: 0; left: 0; height: 100%; width: 100% }style>
1111
head>
1212
<body>
1313

layout/reftests/svg/svg-integration/conditions-outer-svg-02.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<head>
99
<title>Test that using elements from conditional-failing outer 'svg' elements workstitle>
1010
11-
<style>svg { position: absolute; top: 0; left: 0 }style>
11+
<style>svg { position: absolute; top: 0; left: 0; height: 100%; width: 100% }style>
1212
head>
1313
<body>
1414

layout/reftests/svg/svg-integration/dynamic-conditions-outer-svg-01.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<head>
88
<title>Test that conditional processing attributes on outer 'svg' elements are honoredtitle>
99
10-
<style>svg { position: absolute; top: 0; left: 0 }style>
10+
<style>svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }style>
1111
head>
1212
<body onload="document.getElementById('a').setAttribute('requiredExtensions', 'x')">
1313

layout/reftests/svg/svg-integration/dynamic-conditions-outer-svg-02.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<head>
88
<title>Test that conditional processing attributes on outer 'svg' elements are honoredtitle>
99
10-
<style>svg { position: absolute; top: 0; left: 0 }style>
10+
<style>svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }style>
1111
head>
1212
<body onload="document.getElementById('a').removeAttribute('requiredExtensions')">
1313

layout/reftests/svg/svg-integration/dynamic-conditions-outer-svg-03.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<head>
88
<title>Test that conditional processing attributes on outer 'svg' elements are honoredtitle>
99
10-
<style>svg { position: absolute; top: 0; left: 0 }style>
10+
<style>svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }style>
1111
head>
1212
<body onload="document.getElementById('a').setAttribute('requiredFeatures', 'x')">
1313

layout/reftests/svg/svg-integration/dynamic-conditions-outer-svg-04.xhtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<head>
88
<title>Test that conditional processing attributes on outer 'svg' elements are honoredtitle>
99
10-
<style>svg { position: absolute; top: 0; left: 0 }style>
10+
<style>svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }style>
1111
head>
1212
<body onload="document.getElementById('a').setAttribute('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Gradient')">
1313

layout/svg/base/src/nsSVGOuterSVGFrame.cpp

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -248,21 +248,13 @@ nsSVGOuterSVGFrame::GetIntrinsicSize()
248248
nsSVGLength2 &width = content->mLengthAttributes[nsSVGSVGElement::WIDTH];
249249
nsSVGLength2 &height = content->mLengthAttributes[nsSVGSVGElement::HEIGHT];
250250

251-
if (width.IsPercentage()) {
252-
float val = width.GetAnimValInSpecifiedUnits() / 100.0f;
253-
if (val < 0.0f) val = 0.0f;
254-
intrinsicSize.width.SetPercentValue(val);
255-
} else {
251+
if (!width.IsPercentage()) {
256252
nscoord val = nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(content));
257253
if (val < 0) val = 0;
258254
intrinsicSize.width.SetCoordValue(val);
259255
}
260256

261-
if (height.IsPercentage()) {
262-
float val = height.GetAnimValInSpecifiedUnits() / 100.0f;
263-
if (val < 0.0f) val = 0.0f;
264-
intrinsicSize.height.SetPercentValue(val);
265-
} else {
257+
if (!height.IsPercentage()) {
266258
nscoord val = nsPresContext::CSSPixelsToAppUnits(height.GetAnimValue(content));
267259
if (val < 0) val = 0;
268260
intrinsicSize.height.SetCoordValue(val);
@@ -318,16 +310,52 @@ nsSVGOuterSVGFrame::ComputeSize(nsRenderingContext *aRenderingContext,
318310
{
319311
nsSVGSVGElement* content = static_cast(mContent);
320312

321-
if ((content->HasValidViewbox() || content->ShouldSynthesizeViewBox()) &&
322-
(IsRootOfImage() || IsRootOfReplacedElementSubDoc())) {
323-
// The embedding element has done the replaced element sizing, using our
324-
// intrinsic dimensions as necessary. We just need to fill the viewport.
325-
return aCBSize;
313+
IntrinsicSize intrinsicSize = GetIntrinsicSize();
314+
315+
if (!mContent->GetParent()) {
316+
if (IsRootOfImage() || IsRootOfReplacedElementSubDoc()) {
317+
// The embedding element has done the replaced element sizing,
318+
// using our intrinsic dimensions as necessary. We just need to
319+
// fill the viewport.
320+
return aCBSize;
321+
} else {
322+
// We're the root of a browsing context, so we need to honor
323+
// widths and heights in percentages. (GetIntrinsicSize() doesn't
324+
// report these since there's no such thing as a percentage
325+
// intrinsic size.)
326+
nsSVGLength2 &width =
327+
content->mLengthAttributes[nsSVGSVGElement::WIDTH];
328+
if (width.IsPercentage()) {
329+
NS_ABORT_IF_FALSE(intrinsicSize.width.GetUnit() == eStyleUnit_None,
330+
"GetIntrinsicSize should have reported no "
331+
"intrinsic width");
332+
float val = width.GetAnimValInSpecifiedUnits() / 100.0f;
333+
if (val < 0.0f) val = 0.0f;
334+
intrinsicSize.width.SetCoordValue(val * aCBSize.width);
335+
}
336+
337+
nsSVGLength2 &height =
338+
content->mLengthAttributes[nsSVGSVGElement::HEIGHT];
339+
NS_ABORT_IF_FALSE(aCBSize.height != NS_AUTOHEIGHT,
340+
"root should not have auto-height containing block");
341+
if (height.IsPercentage()) {
342+
NS_ABORT_IF_FALSE(intrinsicSize.height.GetUnit() == eStyleUnit_None,
343+
"GetIntrinsicSize should have reported no "
344+
"intrinsic height");
345+
float val = height.GetAnimValInSpecifiedUnits() / 100.0f;
346+
if (val < 0.0f) val = 0.0f;
347+
intrinsicSize.height.SetCoordValue(val * aCBSize.height);
348+
}
349+
NS_ABORT_IF_FALSE(intrinsicSize.height.GetUnit() == eStyleUnit_Coord &&
350+
intrinsicSize.width.GetUnit() == eStyleUnit_Coord,
351+
"We should have just handled the only situation where"
352+
"we lack an intrinsic height or width.");
353+
}
326354
}
327355

328356
return nsLayoutUtils::ComputeSizeWithIntrinsicDimensions(
329357
aRenderingContext, this,
330-
GetIntrinsicSize(), GetIntrinsicRatio(), aCBSize,
358+
intrinsicSize, GetIntrinsicRatio(), aCBSize,
331359
aMargin, aBorder, aPadding);
332360
}
333361

parser/htmlparser/tests/reftest/bug577418-1.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
>
22
<html style="width:100%;height:100%;margin:0;border:0;overflow:hidden">
33
<body style="width:100%;height:100%;margin:0;border:0;overflow:hidden">
4-
<svg>
4+
<svg style="width:100%;height:100%">
55
<rect height="100%" width="100%" fill="red"/>
66
<foreignObject>
77
<html>

0 commit comments

Comments
 (0)