Commit a10ca744 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:

If a float has a self-collapsing ancestor with clearance then it needs to respect
that clearance when placing itself on the line.

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

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::marginOffsetForSelfCollapsingBlock):
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace):
* rendering/RenderBox.h:
(WebCore::RenderBox::previousInFlowSiblingBox):

LayoutTests:

* fast/block/margin-collapse/self-collapsing-block-with-float-descendant-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-descendant.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 0cab07ec
2013-08-21 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/margin-collapse/self-collapsing-block-with-float-descendant-expected.html: Added.
* fast/block/margin-collapse/self-collapsing-block-with-float-descendant.html: Added.
2013-08-21 Brent Fulgham <bfulgham@apple.com> 2013-08-21 Brent Fulgham <bfulgham@apple.com>
   
[Windows] Unreviewed gardening. One more CSS_IMAGE_SET test can be activated. [Windows] Unreviewed gardening. One more CSS_IMAGE_SET test can be activated.
<!doctype html>
<html>
<body>
<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>
</body>
</html>
<!doctype html>
<html>
<body>
<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>
</body>
</html>
2013-08-21 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.
If a float has a self-collapsing ancestor with clearance then it needs to respect
that clearance when placing itself on the line.
Test: fast/block/margin-collapse/self-collapsing-block-with-float-descendant.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::marginOffsetForSelfCollapsingBlock):
* rendering/RenderBlock.h:
* rendering/RenderBlockLineLayout.cpp:
(WebCore::RenderBlock::LineBreaker::skipLeadingWhitespace):
* rendering/RenderBox.h:
(WebCore::RenderBox::previousInFlowSiblingBox):
2013-08-21 Brent Fulgham <bfulgham@apple.com> 2013-08-21 Brent Fulgham <bfulgham@apple.com>
   
<https://webkit.org/b/120113> [Windows] Enable CSS_IMAGE_SET <https://webkit.org/b/120113> [Windows] Enable CSS_IMAGE_SET
...@@ -2300,6 +2300,19 @@ LayoutUnit RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& margin ...@@ -2300,6 +2300,19 @@ LayoutUnit RenderBlock::clearFloatsIfNeeded(RenderBox* child, MarginInfo& margin
return logicalTop; return logicalTop;
} }
LayoutUnit RenderBlock::marginOffsetForSelfCollapsingBlock()
{
RenderBlock* current = this;
while (current) {
if (current->isSelfCollapsingBlock() && current->style()->clear() && current->getClearDelta(current, LayoutUnit()))
return current->collapsedMarginBeforeForChild(current);
if (current->previousInFlowSiblingBox() || !current->parent() || !current->parent()->isRenderBlock())
return LayoutUnit();
current = toRenderBlock(current->parent());
}
return LayoutUnit();
}
void RenderBlock::marginBeforeEstimateForChild(RenderBox* child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefore) const void RenderBlock::marginBeforeEstimateForChild(RenderBox* child, LayoutUnit& positiveMarginBefore, LayoutUnit& negativeMarginBefore, bool& discardMarginBefore) const
{ {
// Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky. // Give up if in quirks mode and we're a body/table cell and the top margin of the child box is quirky.
......
...@@ -1110,6 +1110,7 @@ private: ...@@ -1110,6 +1110,7 @@ private:
void marginBeforeEstimateForChild(RenderBox*, LayoutUnit&, LayoutUnit&, bool&) const; void marginBeforeEstimateForChild(RenderBox*, LayoutUnit&, LayoutUnit&, bool&) const;
void handleAfterSideOfBlock(LayoutUnit top, LayoutUnit bottom, MarginInfo&); void handleAfterSideOfBlock(LayoutUnit top, LayoutUnit bottom, MarginInfo&);
void setCollapsedBottomMargin(const MarginInfo&); void setCollapsedBottomMargin(const MarginInfo&);
LayoutUnit marginOffsetForSelfCollapsingBlock();
// End helper functions and structs used by layoutBlockChildren. // End helper functions and structs used by layoutBlockChildren.
// Helper function for layoutInlineChildren() // Helper function for layoutInlineChildren()
......
...@@ -2596,7 +2596,7 @@ void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve ...@@ -2596,7 +2596,7 @@ void RenderBlock::LineBreaker::skipLeadingWhitespace(InlineBidiResolver& resolve
} else if (object->isFloating()) { } else if (object->isFloating()) {
// The top margin edge of a self-collapsing block that clears a float intrudes up into it by the height of the margin, // The top margin edge of a self-collapsing block that clears a float intrudes up into it by the height of the margin,
// so in order to place this first child float at the top content edge of the self-collapsing block add the margin back in before placement. // so in order to place this first child float at the top content edge of the self-collapsing block add the margin back in before placement.
LayoutUnit marginOffset = (!object->previousSibling() && m_block->isSelfCollapsingBlock() && m_block->style()->clear() && m_block->getClearDelta(m_block, LayoutUnit())) ? m_block->collapsedMarginBeforeForChild(m_block) : LayoutUnit(); LayoutUnit marginOffset = !object->previousSibling() ? m_block->marginOffsetForSelfCollapsingBlock() : LayoutUnit();
LayoutUnit oldLogicalHeight = m_block->logicalHeight(); LayoutUnit oldLogicalHeight = m_block->logicalHeight();
m_block->setLogicalHeight(oldLogicalHeight + marginOffset); m_block->setLogicalHeight(oldLogicalHeight + marginOffset);
m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width); m_block->positionNewFloatOnLine(m_block->insertFloatingObject(toRenderBox(object)), lastFloatFromPreviousLine, lineInfo, width);
......
...@@ -178,6 +178,13 @@ public: ...@@ -178,6 +178,13 @@ public:
RenderBox* previousSiblingBox() const; RenderBox* previousSiblingBox() const;
RenderBox* nextSiblingBox() const; RenderBox* nextSiblingBox() const;
RenderBox* parentBox() const; RenderBox* parentBox() const;
RenderBox* previousInFlowSiblingBox() const
{
RenderBox* current = previousSiblingBox();
while (current && current->isFloatingOrOutOfFlowPositioned())
current = current->previousSiblingBox();
return current;
}
// Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions. // Visual and layout overflow are in the coordinate space of the box. This means that they aren't purely physical directions.
// For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right // For horizontal-tb and vertical-lr they will match physical directions, but for horizontal-bt and vertical-rl, the top/bottom and left/right
......
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