their top margins do not get added in when they clear the float because of having a large width.
Reviewed by kocienda
* khtml/rendering/render_block.cpp:
(khtml::RenderBlock::layoutBlockChildren):
* layout-tests/fast/block/margin-collapse/101-expected.txt: Added.
* layout-tests/fast/block/margin-collapse/101.html: Added.
* layout-tests/fast/block/margin-collapse/102-expected.txt: Added.
* layout-tests/fast/block/margin-collapse/102.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@6078
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x363
+ RenderBlock {HTML} at (0,0) size 800x363
+ RenderBody {BODY} at (8,8) size 784x347
+ RenderBlock {DIV} at (0,0) size 385x347
+ RenderBlock {P} at (0,0) size 385x40 [border: (2px solid #0000FF)]
+ RenderText {TEXT} at (2,2) size 365x36
+ text run at (2,2) width 146: "There should be only 2"
+ text run at (148,2) width 219: "em between this paragraph and the"
+ text run at (2,20) width 85: "image below."
+ RenderImage {IMG} at (0,72) size 395x275
--- /dev/null
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+ <title>Jeffrey Zeldman Presents: The Daily Report</title>
+
+<style>
+
+#bravefourhundred {
+ width: 385px;
+}
+
+img {
+ display: block;
+ margin-top: 1em;
+}
+
+p { border: 2px solid blue; margin-bottom: 2em; }
+</style>
+
+
+
+ </head>
+
+<body>
+<div id="bravefourhundred">
+
+<p>There should be only 2em between this paragraph and the
+image below.</p>
+
+<img width="395" height="275" border="0"></div>
+</body>
+</html>
--- /dev/null
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x427
+ RenderBlock {HTML} at (0,0) size 800x427
+ RenderBody {BODY} at (8,8) size 784x411
+ RenderBlock {DIV} at (0,0) size 385x411
+ RenderBlock {DIV} at (0,0) size 385x36
+ RenderText {TEXT} at (0,0) size 364x36
+ text run at (0,0) width 364: "There should be no vertical space between the two blocks"
+ text run at (0,18) width 43: "below."
+ RenderBlock (floating) {DIV} at (0,36) size 100x100 [bgcolor=#008000]
+ RenderImage {IMG} at (0,136) size 395x275 [bgcolor=#FFFF00]
--- /dev/null
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+
+ <title>Jeffrey Zeldman Presents: The Daily Report</title>
+
+<style>
+
+#bravefourhundred {
+ width: 385px;
+}
+
+img {
+ margin-top:1em;
+ display: block;
+ background-color:yellow;
+}
+
+.foo { float:left;width:100px; height:100px;background-color:green }
+
+</style>
+
+
+
+ </head>
+
+<body>
+<div id="bravefourhundred">
+<div>There should be no vertical space between the two blocks below.</div>
+<div class="foo"></div><img width="395" height="275" border="0">
+</div>
+</body>
+</html>
+2004-02-11 David Hyatt <hyatt@apple.com>
+
+ Add some more polish to ensure the ypos estimate is right. Correct the clearing of images so that
+ their top margins do not get added in when they clear the float because of having a large width.
+
+ Reviewed by kocienda
+
+ * khtml/rendering/render_block.cpp:
+ (khtml::RenderBlock::layoutBlockChildren):
+ * layout-tests/fast/block/margin-collapse/101-expected.txt: Added.
+ * layout-tests/fast/block/margin-collapse/101.html: Added.
+ * layout-tests/fast/block/margin-collapse/102-expected.txt: Added.
+ * layout-tests/fast/block/margin-collapse/102.html: Added.
+
2004-02-11 David Hyatt <hyatt@apple.com>
Fix for 3556702, margin collapsing gets disabled when images spill out of the containing block.
}
}
- // Note this occurs after the test for positioning and floating above, since
- // we want to ensure that we don't artificially increase our height because of
- // a positioned or floating child.
- if (child->avoidsFloats() && style()->width().isFixed() && child->minWidth() > lineWidth(m_height)) {
- m_height = kMax(m_height, floatBottom());
- shouldCollapseChild = false;
- clearOccurred = true;
- }
-
- // take care in case we inherited floats
- if (child && floatBottom() > m_height)
- child->setChildNeedsLayout(true);
-
child->calcVerticalMargins();
- //kdDebug(0) << "margin = " << margin << " yPos = " << m_height << endl;
-
- int oldChildX = child->xPos();
- int oldChildY = child->yPos();
-
// Try to guess our correct y position. In most cases this guess will
// be correct. Only if we're wrong (when we compute the real y position)
// will we have to relayout.
}
else if (!canCollapseTopWithChildren || !topMarginContributor)
yPosEstimate += child->marginTop();
+
+ // Note this occurs after the test for positioning and floating above, since
+ // we want to ensure that we don't artificially increase our height because of
+ // a positioned or floating child.
+ int fb = floatBottom();
+ if (child->avoidsFloats() && style()->width().isFixed() && child->minWidth() > lineWidth(m_height)) {
+ if (fb > m_height) {
+ m_height = yPosEstimate = fb;
+ shouldCollapseChild = false;
+ clearOccurred = true;
+ prevFlow = 0;
+ prevBlock = 0;
+ }
+ }
+ // take care in case we inherited floats
+ if (fb > m_height)
+ child->setChildNeedsLayout(true);
+
+ //kdDebug(0) << "margin = " << margin << " yPos = " << m_height << endl;
+
+ int oldChildX = child->xPos();
+ int oldChildY = child->yPos();
+
// Go ahead and position the child as though it didn't collapse with the top.
child->setPos(child->xPos(), yPosEstimate);
child->layoutIfNeeded();