Fix tests to match what they should have been testing, and fix nsFloatManager behavior to match what the old code actually did as far as considering floats at the side that did not protrude into the containing block. (
Bug 472252) r+sr=roc
--- a/layout/generic/nsFloatManager.cpp
+++ b/layout/generic/nsFloatManager.cpp
@@ -195,35 +195,41 @@ nsFloatManager::GetBand(nscoord aYOffset
nscoord floatTop = fi.mRect.y, floatBottom = fi.mRect.YMost();
if (floatTop > top) {
// This float is below our band. Shrink our band's height if needed.
if (floatTop < bottom) {
bottom = floatTop;
}
} else if (floatBottom > top) {
// This float is in our band.
- haveFloats = PR_TRUE;
// Shrink our band's height if needed.
if (floatBottom < bottom) {
bottom = floatBottom;
}
// Shrink our band's width if needed.
if (fi.mFrame->GetStyleDisplay()->mFloats == NS_STYLE_FLOAT_LEFT) {
// A left float.
nscoord rightEdge = fi.mRect.XMost();
if (rightEdge > left) {
left = rightEdge;
+ // Only set haveFloats to true if the float is inside our
+ // containing block. This matches the spec for what some
+ // callers want and disagrees for other callers, so we should
+ // probably provide better information at some point.
+ haveFloats = PR_TRUE;
}
} else {
// A right float.
nscoord leftEdge = fi.mRect.x;
if (leftEdge < right) {
right = leftEdge;
+ // See above.
+ haveFloats = PR_TRUE;
}
}
}
}
*aHasFloats = haveFloats;
nscoord height = (bottom == nscoord_MAX) ? nscoord_MAX : (bottom - top);
return nsRect(left - mX, top - mY, right - left, height);
new file mode 100644
--- /dev/null
+++ b/layout/reftests/floats/float-outside-block-push-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<html lang="en">
+<head>
+<title>Testcase, bug 472252</title>
+
+<style type="text/css">
+#wrap {width:600px; border:1px solid;position:relative}
+.a {background:lime; color:#fff; width:80%;}
+.b {position:absolute; right:0; width:18%; background: cyan; color: #000; height:10em;}
+textarea {width: 100%; height:10em;}
+</style>
+
+<title>test</title>
+</head>
+<body>
+<div id="wrap">
+ <div class="b"></div>
+ <div class="a"><textarea></textarea></div>
+</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/floats/float-outside-block-push.html
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML>
+<html lang="en">
+<head>
+<title>Testcase, bug 472252</title>
+
+<style type="text/css">
+#wrap {width:600px; border:1px solid;}
+.a {background:lime; color:#fff; width:80%;}
+.b {float:right; width:18%; background: cyan; color: #000; height:10em;}
+textarea {width: 100%; height:10em;}
+</style>
+
+<title>test</title>
+</head>
+<body>
+<div id="wrap">
+ <div class="b"></div>
+ <div class="a"><textarea></textarea></div>
+</div>
+</body>
+</html>
--- a/layout/reftests/floats/other-float-outside-rule-3-left-ref.html
+++ b/layout/reftests/floats/other-float-outside-rule-3-left-ref.html
@@ -1,6 +1,6 @@
<!DOCTYPE HTML>
<title>Test for float placement around other float in BFC but outside containing block</title>
<div style="float: left; width: 500px; height: 500px">
- <div style="height: 10px; background: blue"></div>
+ <div style="width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/other-float-outside-rule-3-left.html
+++ b/layout/reftests/floats/other-float-outside-rule-3-left.html
@@ -8,17 +8,17 @@
of the left outer edge of any right-floating box that is to the
right of it. Analogous rules hold for right-floating elements.
-->
<!-- the block formatting context inside which we're testing -->
<div style="float: left; width: 500px; height: 500px">
- <div style="float: right: width: 50px; height: 300px"></div>
+ <div style="float: right; width: 50px; height: 300px"></div>
<div style="margin-right: 100px"> <!-- 400px wide -->
<!-- we're testing the position of this float -->
<div style="float: left; width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/other-float-outside-rule-3-right-ref.html
+++ b/layout/reftests/floats/other-float-outside-rule-3-right-ref.html
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<title>Test for float placement around other float in BFC but outside containing block</title>
<div style="float: left; width: 500px; height: 500px">
- <div style="margin-left: 75px; width: 425px; height: 10px; background: blue"></div>
+ <div style="margin-left: 75px; width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/other-float-outside-rule-3-right.html
+++ b/layout/reftests/floats/other-float-outside-rule-3-right.html
@@ -8,17 +8,17 @@
of the left outer edge of any right-floating box that is to the
right of it. Analogous rules hold for right-floating elements.
-->
<!-- the block formatting context inside which we're testing -->
<div style="float: left; width: 500px; height: 500px">
- <div style="float: left: width: 50px; height: 300px"></div>
+ <div style="float: left; width: 50px; height: 300px"></div>
<div style="margin-left: 100px"> <!-- 400px wide -->
<!-- we're testing the position of this float -->
<div style="float: right; width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/other-float-outside-rule-7-left.html
+++ b/layout/reftests/floats/other-float-outside-rule-7-left.html
@@ -10,17 +10,17 @@
right edge, unless it is already as far to the left as possible.) An
analogous rule holds for right-floating elements.
-->
<!-- the block formatting context inside which we're testing -->
<div style="float: left; width: 500px; height: 500px">
- <div style="float: left: width: 50px; height: 300px"></div>
+ <div style="float: left; width: 50px; height: 300px"></div>
<div style="margin-left: 100px"> <!-- 400px wide -->
<!-- we're testing the position of this float -->
<div style="float: left; width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/other-float-outside-rule-7-right.html
+++ b/layout/reftests/floats/other-float-outside-rule-7-right.html
@@ -10,17 +10,17 @@
right edge, unless it is already as far to the left as possible.) An
analogous rule holds for right-floating elements.
-->
<!-- the block formatting context inside which we're testing -->
<div style="float: left; width: 500px; height: 500px">
- <div style="float: right: width: 50px; height: 300px"></div>
+ <div style="float: right; width: 50px; height: 300px"></div>
<div style="margin-right: 100px"> <!-- 400px wide -->
<!-- we're testing the position of this float -->
<div style="float: right; width: 425px; height: 10px; background: blue"></div>
</div>
--- a/layout/reftests/floats/reftest.list
+++ b/layout/reftests/floats/reftest.list
@@ -1,7 +1,8 @@
-# It's possible the spec should change here...
-fails == other-float-outside-rule-3-left.html other-float-outside-rule-3-left-ref.html
-fails == other-float-outside-rule-3-right.html other-float-outside-rule-3-right-ref.html
-== other-float-outside-rule-7-left.html other-float-outside-rule-7-left-ref.html
-== other-float-outside-rule-7-right.html other-float-outside-rule-7-right-ref.html
+== other-float-outside-rule-3-left.html other-float-outside-rule-3-left-ref.html
+== other-float-outside-rule-3-right.html other-float-outside-rule-3-right-ref.html
+# It's possible the spec should change here to match rule 3...
+fails == other-float-outside-rule-7-left.html other-float-outside-rule-7-left-ref.html
+fails == other-float-outside-rule-7-right.html other-float-outside-rule-7-right-ref.html
+== float-outside-block-push.html float-outside-block-push-ref.html
fails == zero-height-float-base.html zero-height-float-ref.html
fails == zero-height-float.html zero-height-float-ref.html