Commit 97037ef5 authored by robert@webkit.org's avatar robert@webkit.org
Browse files

REGRESSION(r127163): Respect clearance set on ancestors when placing floats

https://bugs.webkit.org/show_bug.cgi?id=119979

Reviewed by David Hyatt.

Source/WebCore:

Refactor the way self-collapsing blocks with clearance are positioned so that they
get the correct logical-top position during margin-collapsing.

Test: fast/block/margin-collapse/self-collapsing-block-with-float-descendants.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::clearFloats):
(WebCore::RenderBlockFlow::marginOffsetForSelfCollapsingBlock):
(WebCore::RenderBlockFlow::collapseMargins):
(WebCore::RenderBlockFlow::clearFloatsIfNeeded):
(WebCore::RenderBlockFlow::handleAfterSideOfBlock):
* rendering/RenderBlockFlow.h:

LayoutTests:

* fast/block/float/clear-negative-margin-top-expected.html:
* fast/block/float/clear-negative-margin-top.html:
* fast/block/margin-collapse/self-collapsing-block-with-float-descendants-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-descendants.html: Added.
* platform/mac/fast/block/float/024-expected.txt:
* platform/mac/fast/block/margin-collapse/025-expected.txt:
* platform/mac/fast/block/margin-collapse/block-inside-inline/025-expected.txt:
* platform/mac/fast/block/margin-collapse/empty-clear-blocks-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159575 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d7004194
2013-11-20 Robert Hogan <robert@webkit.org>
REGRESSION(r127163): Respect clearance set on ancestors when placing floats
https://bugs.webkit.org/show_bug.cgi?id=119979
Reviewed by David Hyatt.
* fast/block/float/clear-negative-margin-top-expected.html:
* fast/block/float/clear-negative-margin-top.html:
* fast/block/margin-collapse/self-collapsing-block-with-float-descendants-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-descendants.html: Added.
* platform/mac/fast/block/float/024-expected.txt:
* platform/mac/fast/block/margin-collapse/025-expected.txt:
* platform/mac/fast/block/margin-collapse/block-inside-inline/025-expected.txt:
* platform/mac/fast/block/margin-collapse/empty-clear-blocks-expected.txt:
2013-11-20 Dean Jackson <dino@apple.com>
 
https://bugs.webkit.org/show_bug.cgi?id=124637
......
<style>
div.negativemargintop { position: absolute; top: 20px; font: 14px/0 Ahem; color: green;}
h2 { float:left; background-color: green;}
img { height: 20px; width: 40px; }
#visible { background-color: blue; }
#transparent { background-color: white; }
#float { float:left; background-color: green; margin-top: 17px; font-size: 1.5em; }
#visible { height: 20px; width:40px; float:left; background-color: blue; }
</style>
The green box should be below the blue box.<br>
- .negativemargintop gets 30px clearance thanks to its negative margin-top of -10px.
- .negativemargintop then collapses its margins to -10px which pulls it up 10px to the bottom edge of the float.
- #float positions itself 17px below the top-border edge of .negativemargintop
https://bugs.webkit.org/show_bug.cgi?id=14664<br>
<div style="position:relative">
<img id="visible" align="left">
<img id="transparent">
<div style="position:relative;">
<div id="visible"></div>
<div class="negativemargintop">
<h2>xx</h2>
<div id="float">xx</div>
</div>
</div>
<style>
div.negativemargintop { clear:both; margin-top:-10px; font: 14px/0 Ahem; color: green;}
h2 { float:left; background-color: green;}
img { height: 20px; width: 40px; }
#visible { background-color: blue; }
#transparent { background-color: white; }
#float { float:left; background-color: green; margin-top: 17px; font-size: 1.5em; }
#visible { height: 20px; width:40px; float:left; background-color: blue; }
</style>
The green box should be below the blue box.<br>
- .negativemargintop gets 30px clearance thanks to its negative margin-top of -10px.
- .negativemargintop then collapses its margins to -10px which pulls it up 10px to the bottom edge of the float.
- #float positions itself 17px below the top-border edge of .negativemargintop
https://bugs.webkit.org/show_bug.cgi?id=14664<br>
<div style="position:relative; line-height: 20px;">
<img id="visible" align="left">
<img id="transparent">
<div class="negativemargintop">
<h2>xx</h2>
</div>
<div id="visible"></div>
<div class="negativemargintop">
<div id="float">xx</div>
</div>
<!doctype html>
<html>
<body>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue;">
Text1
</div>
<div style="height:20px; width: 50px; background-color: green;">
Text2
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue;">
Text1
</div>
<div style="height:20px; width: 50px; background-color: green;">
Text2
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue;">
Text1
</div>
<div style="height:20px; width: 50px; background-color: green;">
Text2
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div style="height: 20px; width: 50px; background-color: blue;">
Text1
</div>
<div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div>
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div style="height: 20px; width: 50px; background-color: blue;">
Text1
</div>
<div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div>
</div>
</div>
</div>
</body>
</html>
<!doctype html>
<html>
<body>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue; float:left;">
Text1
</div>
<div style="margin-top:10px;clear:both;">
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div>
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue; float:left;">
Text1
</div>
<div style="margin-top:10px;clear:both;">
<div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The green box should be under the blue box. </p>
<div style="height: 20px; width: 50px; background-color: blue; float:left;">
Text1
</div>
<div style="margin-top:10px;clear:both;">
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div style="margin-top:10px;clear:both;">
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div style="height: 20px; width: 50px; background-color: blue; float:left;">
Text1
</div>
<div style="margin-top:10px;clear:both;">
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div>
</div>
</div>
</div>
<div style="overflow: hidden;">
<p> webkit.org/b/119979: The three green boxes should be in a row. </p>
<div style="height: 20px; width: 50px; background-color: blue; float:left;">
Text1
</div>
<div style="margin-top:10px;clear:both;">
<div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div style="height:20px; width: 50px; float: left; background-color: green;">
Text2
</div>
<div>
</div>
</div>
</div>
</div>
</body>
</html>
......@@ -12,7 +12,7 @@ layer at (0,0) size 800x600
text run at (2,2) width 451: "There should be a gap between this float and the green rectangle above."
RenderBlock {DIV} at (0,221) size 800x54 [bgcolor=#DDDDDD] [border: (2px solid #000000)]
RenderBlock (floating) {DIV} at (2,2) size 32x32 [bgcolor=#FFFFFF]
RenderBlock {DIV} at (2,18) size 796x0
RenderBlock {DIV} at (2,34) size 796x0
RenderBlock (anonymous) at (2,34) size 796x18
RenderText {#text} at (0,0) size 483x18
text run at (0,0) width 483: "This text should be inside a black rectangle and below the 2em white square."
......
......@@ -12,7 +12,7 @@ layer at (0,0) size 800x224
RenderTableCell {TD} at (16,16) size 134x134 [bgcolor=#FF0000] [border: (3px solid #000000)] [r=0 c=0 rs=1 cs=1]
RenderBlock {DIV} at (3,3) size 128x128 [bgcolor=#00FF00]
RenderBlock (floating) {DIV} at (0,0) size 64x64 [bgcolor=#00FFFF]
RenderBlock {DIV} at (0,48) size 128x0 [bgcolor=#FF0000]
RenderBlock {DIV} at (0,64) size 128x0 [bgcolor=#FF0000]
RenderBlock {DIV} at (0,64) size 128x64 [border: (32px solid #FFFF00)]
RenderTableCell {TD} at (166,16) size 134x134 [bgcolor=#FF0000] [border: (3px solid #000000)] [r=0 c=1 rs=1 cs=1]
RenderTable {TABLE} at (3,3) size 128x128
......
......@@ -15,7 +15,7 @@ layer at (0,0) size 800x224
RenderBlock (floating) {DIV} at (0,0) size 64x64 [bgcolor=#00FFFF]
RenderInline {SPAN} at (0,0) size 0x0
RenderBlock (anonymous) at (0,0) size 128x128
RenderBlock {DIV} at (0,48) size 128x0 [bgcolor=#FF0000]
RenderBlock {DIV} at (0,64) size 128x0 [bgcolor=#FF0000]
RenderBlock {DIV} at (0,64) size 128x64 [border: (32px solid #FFFF00)]
RenderBlock (anonymous) at (0,128) size 128x0
RenderInline {SPAN} at (0,0) size 0x0
......
......@@ -11,7 +11,7 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (0,75) size 769x0
RenderBlock {SPAN} at (0,100) size 769x0
RenderBlock {SPAN} at (0,105) size 769x18
RenderText {#text} at (0,0) size 300x18
text run at (0,0) width 300: "This text should be immediately under the float."
......@@ -24,7 +24,7 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (0,216) size 769x0
RenderBlock {SPAN} at (0,241) size 769x0
RenderBlock {SPAN} at (0,256) size 769x18
RenderText {#text} at (0,0) size 255x18
text run at (0,0) width 255: "This text should be 10px under the float."
......@@ -37,10 +37,10 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (0,362) size 769x0
RenderBlock {SPAN} at (0,392) size 769x0
RenderBlock {SPAN} at (0,362) size 769x18
RenderText {#text} at (100,0) size 268x18
text run at (100,0) width 268: "This text should be to the right of the float."
RenderText {#text} at (0,0) size 268x18
text run at (0,0) width 268: "This text should be to the right of the float."
RenderBlock {HR} at (100,388) size 669x2 [border: (1px inset #000000)]
RenderBlock {SPAN} at (0,398) size 769x18
RenderBlock (floating) {DIV} at (0,0) size 100x100 [bgcolor=#00FF00]
......@@ -50,7 +50,7 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (0,473) size 769x0
RenderBlock {SPAN} at (0,498) size 769x0
RenderBlock {SPAN} at (0,503) size 769x18
RenderText {#text} at (0,0) size 300x18
text run at (0,0) width 300: "This text should be immediately under the float."
......@@ -63,7 +63,7 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (0,609) size 769x0
RenderBlock {SPAN} at (0,639) size 769x0
RenderBlock {SPAN} at (0,649) size 769x18
RenderText {#text} at (0,0) size 255x18
text run at (0,0) width 255: "This text should be 10px under the float."
......@@ -90,7 +90,7 @@ layer at (0,0) size 785x1130
text run at (0,36) width 32: "high."
RenderText {#text} at (100,0) size 284x18
text run at (100,0) width 284: "This paragraph has a bottom margin of 50px."
RenderBlock {SPAN} at (10,85) size 749x0
RenderBlock {SPAN} at (10,110) size 749x0
RenderBlock {HR} at (0,984) size 769x2 [border: (1px inset #000000)]
RenderBlock {SPAN} at (0,994) size 769x120 [border: (10px dotted #000000)]
RenderBlock {SPAN} at (10,10) size 749x18
......
2013-11-20 Robert Hogan <robert@webkit.org>
REGRESSION(r127163): Respect clearance set on ancestors when placing floats
https://bugs.webkit.org/show_bug.cgi?id=119979
Reviewed by David Hyatt.
Refactor the way self-collapsing blocks with clearance are positioned so that they
get the correct logical-top position during margin-collapsing.
Test: fast/block/margin-collapse/self-collapsing-block-with-float-descendants.html
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::clearFloats):
(WebCore::RenderBlockFlow::marginOffsetForSelfCollapsingBlock):
(WebCore::RenderBlockFlow::collapseMargins):
(WebCore::RenderBlockFlow::clearFloatsIfNeeded):
(WebCore::RenderBlockFlow::handleAfterSideOfBlock):
* rendering/RenderBlockFlow.h:
2013-11-20 Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
 
[GTK] Remove Chromium as user agent and claim to be Safari in OS X
......
......@@ -215,9 +215,10 @@ void RenderBlockFlow::clearFloats()
prev = prev->previousSibling();
}
// First add in floats from the parent.
// First add in floats from the parent. Self-collapsing blocks let their parent track any floats that intrude into
// them (as opposed to floats they contain themselves) so check for those here too.
LayoutUnit logicalTopOffset = logicalTop();
if (parentHasFloats)
if (parentHasFloats || (parentBlock->lowestFloatLogicalBottom() > logicalTopOffset && prev && toRenderBlockFlow(prev)->isSelfCollapsingBlock()))
addIntrudingFloats(parentBlock, parentBlock->logicalLeftOffsetForContent(), logicalTopOffset);
LayoutUnit logicalLeftOffset = 0;
......@@ -708,6 +709,16 @@ void RenderBlockFlow::adjustPositionedBlock(RenderBox& child, const MarginInfo&
}
}
LayoutUnit RenderBlockFlow::marginOffsetForSelfCollapsingBlock()
{
ASSERT(isSelfCollapsingBlock());
RenderBlockFlow* parentBlock = toRenderBlockFlow(parent());
if (parentBlock && style().clear() && parentBlock->getClearDelta(*this, logicalHeight()))
return marginValuesForChild(*this).positiveMarginBefore();
return LayoutUnit();
}
void RenderBlockFlow::adjustFloatingBlock(const MarginInfo& marginInfo)
{
// The float should be positioned taking into account the bottom margin
......@@ -873,6 +884,17 @@ LayoutUnit RenderBlockFlow::collapseMargins(RenderBox& child, MarginInfo& margin
LayoutUnit beforeCollapseLogicalTop = logicalHeight();
LayoutUnit logicalTop = beforeCollapseLogicalTop;
LayoutUnit clearanceForSelfCollapsingBlock;
RenderObject* prev = child.previousSibling();
// If the child's previous sibling is a self-collapsing block that cleared a float then its top border edge has been set at the bottom border edge
// of the float. Since we want to collapse the child's top margin with the self-collapsing block's top and bottom margins we need to adjust our parent's height to match the
// margin top of the self-collapsing block. If the resulting collapsed margin leaves the child still intruding into the float then we will want to clear it.
if (!marginInfo.canCollapseWithMarginBefore() && prev && prev->isRenderBlockFlow() && toRenderBlockFlow(prev)->isSelfCollapsingBlock()) {
clearanceForSelfCollapsingBlock = toRenderBlockFlow(prev)->marginOffsetForSelfCollapsingBlock();
setLogicalHeight(logicalHeight() - clearanceForSelfCollapsingBlock);
}
if (childIsSelfCollapsing) {
// For a self collapsing block both the before and after margins get discarded. The block doesn't contribute anything to the height of the block.
// Also, the child's top position equals the logical height of the container.
......@@ -936,18 +958,23 @@ LayoutUnit RenderBlockFlow::collapseMargins(RenderBox& child, MarginInfo& margin
setLogicalHeight(logicalHeight() + (logicalTop - oldLogicalTop));
}
// If we have collapsed into a previous sibling and so reduced the height of the parent, ensure any floats that now
// overhang from the previous sibling are added to our parent. If the child's previous sibling itself is a float the child will avoid
// or clear it anyway, so don't worry about any floating children it may contain.
LayoutUnit oldLogicalHeight = logicalHeight();
setLogicalHeight(logicalTop);
RenderObject* prev = child.previousSibling();
if (prev && prev->isRenderBlockFlow() && !prev->isFloatingOrOutOfFlowPositioned()) {
// If |child| is a self-collapsing block it may have collapsed into a previous sibling and although it hasn't reduced the height of the parent yet
// any floats from the parent will now overhang.
RenderBlockFlow& block = toRenderBlockFlow(*prev);
LayoutUnit oldLogicalHeight = logicalHeight();
setLogicalHeight(logicalTop);
if (block.containsFloats() && !block.avoidsFloats() && (block.logicalTop() + block.lowestFloatLogicalBottom()) > logicalTop)
addOverhangingFloats(block, false);
setLogicalHeight(oldLogicalHeight);
// If |child|'s previous sibling is a self-collapsing block that cleared a float and margin collapsing resulted in |child| moving up
// into the margin area of the self-collapsing block then the float it clears is now intruding into |child|. Layout again so that we can look for
// floats in the parent that overhang |child|'s new logical top.
bool logicalTopIntrudesIntoFloat = clearanceForSelfCollapsingBlock > 0 && logicalTop < beforeCollapseLogicalTop;
if (logicalTopIntrudesIntoFloat && containsFloats() && !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop)
child.setNeedsLayout();
}
setLogicalHeight(oldLogicalHeight);
return logicalTop;
}
......@@ -965,8 +992,8 @@ LayoutUnit RenderBlockFlow::clearFloatsIfNeeded(RenderBox& child, MarginInfo& ma
// margins with following siblings. Reset the current margins to represent
// the self-collapsing block's margins only.
// If DISCARD is specified for -webkit-margin-collapse, reset the margin values.
MarginValues childMargins = marginValuesForChild(child);
if (!childDiscardMargin) {
MarginValues childMargins = marginValuesForChild(child);
marginInfo.setPositiveMargin(std::max(childMargins.positiveMarginBefore(), childMargins.positiveMarginAfter()));
marginInfo.setNegativeMargin(std::max(childMargins.negativeMarginBefore(), childMargins.negativeMarginAfter()));
} else
......@@ -986,12 +1013,14 @@ LayoutUnit RenderBlockFlow::clearFloatsIfNeeded(RenderBox& child, MarginInfo& ma
if (wouldCollapseMarginsWithParent)
marginInfo.setCanCollapseMarginAfterWithChildren(false);
// CSS2.1: "the amount of clearance is set so that clearance + margin-top = [height of float], i.e., clearance = [height of float] - margin-top"
// Move the top of the child box to the bottom of the float ignoring the child's top margin.
LayoutUnit collapsedMargin = collapsedMarginBeforeForChild(child);
setLogicalHeight(child.logicalTop() - collapsedMargin);
// A negative collapsed margin-top value cancels itself out as it has already been factored into |yPos| above.
heightIncrease -= std::max(LayoutUnit(), collapsedMargin);
// For now set the border-top of |child| flush with the bottom border-edge of the float so it can layout any floating or positioned children of
// its own at the correct vertical position. If subsequent siblings attempt to collapse with |child|'s margins in |collapseMargins| we will
// adjust the height of the parent to |child|'s margin top (which if it is positive sits up 'inside' the float it's clearing) so that all three
// margins can collapse at the correct vertical position.
// Per CSS2.1 we need to ensure that any negative margin-top clears |child| beyond the bottom border-edge of the float so that the top border edge of the child
// (i.e. its clearance) is at a position that satisfies the equation: "the amount of clearance is set so that clearance + margin-top = [height of float],
// i.e., clearance = [height of float] - margin-top".
setLogicalHeight(child.logicalTop() + childMargins.negativeMarginBefore());
} else
// Increase our height by the amount we had to clear.
setLogicalHeight(logicalHeight() + heightIncrease);
......@@ -1009,13 +1038,7 @@ LayoutUnit RenderBlockFlow::clearFloatsIfNeeded(RenderBox& child, MarginInfo& ma
setMustDiscardMarginBefore(style().marginBeforeCollapse() == MDISCARD);
}
LayoutUnit logicalTop = yPos + heightIncrease;
// After margin collapsing, one of our floats may now intrude into the child. If the child doesn't contain floats of its own it
// won't get picked up for relayout even though the logical top estimate was wrong - so add the newly intruding float now.
if (containsFloats() && child.isRenderBlockFlow() && !toRenderBlockFlow(child).containsFloats() && !child.avoidsFloats() && lowestFloatLogicalBottom() > logicalTop)
toRenderBlockFlow(child).addIntrudingFloats(this, logicalLeftOffsetForContent(), logicalTop);
return logicalTop;
return yPos + heightIncrease;
}
void RenderBlockFlow::marginBeforeEstimateForChild(RenderBox& child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefore) const
......@@ -1154,6 +1177,13 @@ void RenderBlockFlow::handleAfterSideOfBlock(LayoutUnit beforeSide, LayoutUnit a
{
marginInfo.setAtAfterSideOfBlock(true);
// If our last child was a self-collapsing block with clearance then our logical height is flush with the
// bottom edge of the float that the child clears. The correct vertical position for the margin-collapsing we want
// to perform now is at the child's margin-top - so adjust our height to that position.
RenderObject* lastBlock = lastChild();
if (lastBlock && lastBlock->isRenderBlockFlow() && toRenderBlockFlow(lastBlock)->isSelfCollapsingBlock())
setLogicalHeight(logicalHeight() - toRenderBlockFlow(lastBlock)->marginOffsetForSelfCollapsingBlock());
// If we can't collapse with children then go ahead and add in the bottom margin.
if (!marginInfo.discardMargin() && (!marginInfo.canCollapseWithMarginAfter() && !marginInfo.canCollapseWithMarginBefore()
&& (!document().inQuirksMode() || !marginInfo.quirkContainer() || !marginInfo.hasMarginAfterQuirk())))
......
......@@ -216,6 +216,7 @@ public:
bool discardMargin() const { return m_discardMargin; }
LayoutUnit margin() const { return m_positiveMargin - m_negativeMargin; }
};
LayoutUnit marginOffsetForSelfCollapsingBlock();
void layoutBlockChild(RenderBox& child, MarginInfo&, LayoutUnit& previousFloatLogicalBottom, LayoutUnit& maxFloatLogicalBottom);
void adjustPositionedBlock(RenderBox& child, const MarginInfo&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment