Diff
Modified: trunk/LayoutTests/ChangeLog (113884 => 113885)
--- trunk/LayoutTests/ChangeLog 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/LayoutTests/ChangeLog 2012-04-11 18:35:37 UTC (rev 113885)
@@ -1,3 +1,19 @@
+2012-04-11 David Hyatt <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=83614
+
+ Improve how auto margins are handled on objects that avoid floats. Add a new test covering this
+ for tables and overflow sections and revise existing results. The CSS2.1 test in particular is
+ a progression.
+
+ Reviewed by Dan Bernstein.
+
+ * fast/block/float/avoiding-float-centered.html: Added.
+ * platform/mac/css2.1/20110323/replaced-elements-001-expected.txt:
+ * platform/mac/fast/block/float/avoiding-float-centered-expected.png: Added.
+ * platform/mac/fast/block/float/avoiding-float-centered-expected.txt: Added.
+ * platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt:
+
2012-04-11 Tom Zakrajsek <[email protected]>
Unreviewed gardening. Found EFL results.
Added: trunk/LayoutTests/fast/block/float/avoiding-float-centered.html (0 => 113885)
--- trunk/LayoutTests/fast/block/float/avoiding-float-centered.html (rev 0)
+++ trunk/LayoutTests/fast/block/float/avoiding-float-centered.html 2012-04-11 18:35:37 UTC (rev 113885)
@@ -0,0 +1,9 @@
+<!doctype html>
+<div style="float:right;width:300px;margin:10px;height:100px;background-color:green"></div>
+
+<table style="background-color:orange;margin-left:auto; margin-right:auto"><tr><td>This is a test and is demonstrating that auto width really
+should kick in here.</table>
+
+
+<div style="overflow:hidden; max-width:300px; background-color:orange;margin-left:auto; margin-right:auto">This is a test and is demonstrating that auto width really
+should kick in here.</div>
\ No newline at end of file
Modified: trunk/LayoutTests/platform/mac/css2.1/20110323/replaced-elements-001-expected.txt (113884 => 113885)
--- trunk/LayoutTests/platform/mac/css2.1/20110323/replaced-elements-001-expected.txt 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/LayoutTests/platform/mac/css2.1/20110323/replaced-elements-001-expected.txt 2012-04-11 18:35:37 UTC (rev 113885)
@@ -10,10 +10,10 @@
RenderBlock (anonymous) at (0,0) size 752x18
RenderText {#text} at (0,0) size 36x18
text run at (0,0) width 36: " "
- RenderButton {INPUT} at (0,20) size 16x22 [bgcolor=#FFA500] [border: (2px outset #C0C0C0)]
+ RenderButton {INPUT} at (368,20) size 16x22 [bgcolor=#FFA500] [border: (2px outset #C0C0C0)]
RenderBlock {FORM} at (0,92) size 784x42
RenderBlock {DIV} at (16,0) size 752x42 [bgcolor=#008000]
RenderBlock (anonymous) at (0,0) size 752x18
RenderText {#text} at (0,0) size 36x18
text run at (0,0) width 36: " "
- RenderButton {INPUT} at (0,20) size 16x22 [bgcolor=#FFA500] [border: (2px outset #C0C0C0)]
+ RenderButton {INPUT} at (368,20) size 16x22 [bgcolor=#FFA500] [border: (2px outset #C0C0C0)]
Added: trunk/LayoutTests/platform/mac/fast/block/float/avoiding-float-centered-expected.png
(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/fast/block/float/avoiding-float-centered-expected.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/LayoutTests/platform/mac/fast/block/float/avoiding-float-centered-expected.txt (0 => 113885)
--- trunk/LayoutTests/platform/mac/fast/block/float/avoiding-float-centered-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/mac/fast/block/float/avoiding-float-centered-expected.txt 2012-04-11 18:35:37 UTC (rev 113885)
@@ -0,0 +1,19 @@
+layer at (0,0) size 800x600
+ RenderView at (0,0) size 800x600
+layer at (0,0) size 800x128
+ RenderBlock {HTML} at (0,0) size 800x128
+ RenderBody {BODY} at (8,8) size 784x78
+ RenderBlock (floating) {DIV} at (474,10) size 300x100 [bgcolor=#008000]
+ RenderTable {TABLE} at (0,0) size 464x42 [bgcolor=#FFA500]
+ RenderTableSection {TBODY} at (0,0) size 464x42
+ RenderTableRow {TR} at (0,2) size 464x38
+ RenderTableCell {TD} at (2,2) size 460x38 [r=0 c=0 rs=1 cs=1]
+ RenderText {#text} at (1,1) size 442x36
+ text run at (1,1) width 353: "This is a test and is demonstrating that auto width really "
+ text run at (354,1) width 89: "should kick in"
+ text run at (1,19) width 31: "here."
+ RenderBlock {DIV} at (82,42) size 300x36 [bgcolor=#FFA500]
+ RenderText {#text} at (0,0) size 270x36
+ text run at (0,0) width 270: "This is a test and is demonstrating that auto"
+ text run at (0,18) width 79: "width really "
+ text run at (79,18) width 124: "should kick in here."
Modified: trunk/LayoutTests/platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt (113884 => 113885)
--- trunk/LayoutTests/platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/LayoutTests/platform/mac/fast/regions/overflow-not-moving-below-floats-in-variable-width-regions-expected.txt 2012-04-11 18:35:37 UTC (rev 113885)
@@ -19,28 +19,28 @@
RenderBlock {DIV} at (5,5) size 390x255 [border: (1px solid #0000FF)]
RenderBlock (floating) {DIV} at (1,1) size 30x50 [bgcolor=#00FF00]
RenderBlock (floating) {DIV} at (259,1) size 30x50 [bgcolor=#00FF00]
- layer at (53,6) size 293x253 clip at (54,7) size 291x251 scrollWidth 500
- RenderBlock {DIV} at (48,1) size 293x253 [border: (1px solid #008000)]
+ layer at (6,6) size 293x253 clip at (7,7) size 291x251 scrollWidth 500
+ RenderBlock {DIV} at (1,1) size 293x253 [border: (1px solid #008000)]
RenderBlock {DIV} at (1,1) size 500x18
- RenderText {#text} at (-12,0) size 286x18
- text run at (-12,0) width 286: "Clipped line of text that should not be visible."
+ RenderText {#text} at (35,0) size 286x18
+ text run at (35,0) width 286: "Clipped line of text that should not be visible."
RenderBlock {P} at (1,35) size 291x95
- RenderText {#text} at (-12,0) size 303x95
- text run at (-12,0) width 216: "These lines will not spill out of"
- text run at (-12,18) width 216: "the regions. These lines will not"
- text run at (-12,36) width 178: "spill out of the regions. "
- text run at (166,36) width 38: "These"
- text run at (0,59) width 291: "lines will not spill out of the regions. These"
- text run at (0,77) width 229: "lines will not spill out of the regions."
+ RenderText {#text} at (35,0) size 303x95
+ text run at (35,0) width 216: "These lines will not spill out of"
+ text run at (35,18) width 216: "the regions. These lines will not"
+ text run at (35,36) width 178: "spill out of the regions. "
+ text run at (213,36) width 38: "These"
+ text run at (47,59) width 291: "lines will not spill out of the regions. These"
+ text run at (47,77) width 229: "lines will not spill out of the regions."
RenderBlock {P} at (1,146) size 291x72
- RenderText {#text} at (0,0) size 291x72
- text run at (0,0) width 291: "These lines will not spill out of the regions."
- text run at (0,18) width 291: "These lines will not spill out of the regions."
- text run at (0,36) width 291: "These lines will not spill out of the regions."
- text run at (0,54) width 271: "These lines will not spill out of the regions."
+ RenderText {#text} at (47,0) size 291x72
+ text run at (47,0) width 291: "These lines will not spill out of the regions."
+ text run at (47,18) width 291: "These lines will not spill out of the regions."
+ text run at (47,36) width 291: "These lines will not spill out of the regions."
+ text run at (47,54) width 271: "These lines will not spill out of the regions."
RenderBlock {DIV} at (1,234) size 500x18
- RenderText {#text} at (0,0) size 286x18
- text run at (0,0) width 286: "Clipped line of text that should not be visible."
+ RenderText {#text} at (47,0) size 286x18
+ text run at (47,0) width 286: "Clipped line of text that should not be visible."
Regions for flow 'flow1'
RenderRegion {DIV} #region1
RenderRegion {DIV} #region2
Modified: trunk/Source/WebCore/ChangeLog (113884 => 113885)
--- trunk/Source/WebCore/ChangeLog 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/ChangeLog 2012-04-11 18:35:37 UTC (rev 113885)
@@ -1,3 +1,36 @@
+2012-04-11 David Hyatt <[email protected]>
+
+ https://bugs.webkit.org/show_bug.cgi?id=83614
+ <rdar://problem/11177351>
+
+ REGRESSION: Table on wikipedia overlaps float on right hand side.
+
+ Revise how auto margins are resolved so that for objects that avoid floats, the available line
+ width is always used instead of the overall containing block width. computeLogicalWidth now
+ always properly computes inline margins (based off the object's current logicalTop() position)
+ and so the code in computeStartPositionDeltaForChildAvoidingFloats that recomputes inline
+ direction margins can now be removed.
+
+ Reviewed by Dan Bernstein.
+
+ Added new test in fast/block/float.
+
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::computeStartPositionDeltaForChildAvoidingFloats):
+ (WebCore::RenderBlock::determineLogicalLeftPositionForChild):
+ * rendering/RenderBlock.h:
+ (RenderBlock):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::containingBlockAvailableLineWidthInRegion):
+ (WebCore):
+ (WebCore::RenderBox::computeLogicalWidthInRegion):
+ (WebCore::RenderBox::renderBoxRegionInfo):
+ (WebCore::RenderBox::shrinkToAvoidFloats):
+ * rendering/RenderBox.h:
+ (RenderBox):
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::computeLogicalWidth):
+
2012-04-11 Adrienne Walker <[email protected]>
Fix regression where a clip style change did not update layer sizes
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (113884 => 113885)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2012-04-11 18:35:37 UTC (rev 113885)
@@ -2019,7 +2019,7 @@
}
LayoutUnit RenderBlock::computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart,
- LayoutUnit childLogicalWidth, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
+ RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
{
LayoutUnit startPosition = startOffsetForContent(region, offsetFromLogicalTopOfFirstPage);
@@ -2036,24 +2036,9 @@
if (childMarginStart < 0)
startOff += childMarginStart;
newPosition = max(newPosition, startOff); // Let the float sit in the child's margin if it can fit.
- } else if (startOff != startPosition) {
- // The object is shifting to the "end" side of the block. The object might be centered, so we need to
- // recalculate our inline direction margins. Note that the containing block content
- // width computation will take into account the delta between |startOff| and |startPosition|
- // so that we can just pass the content width in directly to the |computeMarginsInContainingBlockInlineDirection|
- // function.
- LayoutUnit oldMarginStart = marginStartForChild(child);
- LayoutUnit oldMarginEnd = marginEndForChild(child);
- RenderBox* mutableChild = const_cast<RenderBox*>(child);
- mutableChild->computeInlineDirectionMargins(this,
- availableLogicalWidthForLine(blockOffset, false, region, offsetFromLogicalTopOfFirstPage), childLogicalWidth);
- newPosition = startOff + marginStartForChild(child);
- if (inRenderFlowThread()) {
- setMarginStartForChild(mutableChild, oldMarginStart);
- setMarginEndForChild(mutableChild, oldMarginEnd);
- }
- }
-
+ } else if (startOff != startPosition)
+ newPosition = startOff + childMarginStart;
+
return newPosition - oldPosition;
}
@@ -2071,7 +2056,7 @@
// Some objects (e.g., tables, horizontal rules, overflow:auto blocks) avoid floats. They need
// to shift over as necessary to dodge any floats that might get in the way.
if (child->avoidsFloats() && containsFloats() && !inRenderFlowThread())
- newPosition += computeStartPositionDeltaForChildAvoidingFloats(child, marginStartForChild(child), logicalWidthForChild(child));
+ newPosition += computeStartPositionDeltaForChildAvoidingFloats(child, marginStartForChild(child));
setLogicalLeftForChild(child, style()->isLeftToRightDirection() ? newPosition : totalAvailableLogicalWidth - newPosition - logicalWidthForChild(child), ApplyLayoutDelta);
}
Modified: trunk/Source/WebCore/rendering/RenderBlock.h (113884 => 113885)
--- trunk/Source/WebCore/rendering/RenderBlock.h 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/rendering/RenderBlock.h 2012-04-11 18:35:37 UTC (rev 113885)
@@ -373,8 +373,7 @@
void setStaticInlinePositionForChild(RenderBox*, LayoutUnit blockOffset, LayoutUnit inlinePosition);
- LayoutUnit computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart,
- LayoutUnit childLogicalWidth, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0);
+ LayoutUnit computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0);
#ifndef NDEBUG
void showLineTreeAndMark(const InlineBox* = 0, const char* = 0, const InlineBox* = 0, const char* = 0, const RenderObject* = 0) const;
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (113884 => 113885)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-04-11 18:35:37 UTC (rev 113885)
@@ -1381,6 +1381,20 @@
return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));
}
+LayoutUnit RenderBox::containingBlockAvailableLineWidthInRegion(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
+{
+ RenderBlock* cb = containingBlock();
+ RenderRegion* containingBlockRegion = 0;
+ LayoutUnit logicalTopPosition = logicalTop();
+ LayoutUnit adjustedPageOffsetForContainingBlock = offsetFromLogicalTopOfFirstPage - logicalTop();
+ if (region) {
+ LayoutUnit offsetFromLogicalTopOfRegion = region ? region->offsetFromLogicalTopOfFirstPage() - offsetFromLogicalTopOfFirstPage : ZERO_LAYOUT_UNIT;
+ logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offsetFromLogicalTopOfRegion);
+ containingBlockRegion = cb->clampToStartAndEndRegions(region);
+ }
+ return cb->availableLogicalWidthForLine(logicalTopPosition, false, containingBlockRegion, adjustedPageOffsetForContainingBlock);
+}
+
LayoutUnit RenderBox::perpendicularContainingBlockLogicalHeight() const
{
RenderBlock* cb = containingBlock();
@@ -1809,13 +1823,17 @@
}
// Margin calculations.
- if (logicalWidthLength.isAuto() || hasPerpendicularContainingBlock) {
+ if (hasPerpendicularContainingBlock || isFloating() || isInline()) {
RenderView* renderView = view();
setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView));
setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView));
- } else
- computeInlineDirectionMargins(cb, containerLogicalWidth, logicalWidth());
-
+ } else {
+ LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth;
+ if (avoidsFloats() && cb->containsFloats())
+ containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(region, offsetFromLogicalTopOfFirstPage);
+ computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, logicalWidth());
+ }
+
if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (logicalWidth() + marginStart() + marginEnd())
&& !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated())
cb->setMarginEndForChild(this, containerLogicalWidth - logicalWidth() - cb->marginStartForChild(this));
@@ -2019,8 +2037,7 @@
LayoutUnit logicalLeftOffset = 0;
if (!isPositioned() && avoidsFloats() && cb->containsFloats()) {
- LayoutUnit startPositionDelta = cb->computeStartPositionDeltaForChildAvoidingFloats(this, marginStartInRegion, logicalWidthInRegion,
- region, offsetFromLogicalTopOfFirstPage);
+ LayoutUnit startPositionDelta = cb->computeStartPositionDeltaForChildAvoidingFloats(this, marginStartInRegion, region, offsetFromLogicalTopOfFirstPage);
if (cb->style()->isLeftToRightDirection())
logicalLeftDelta += startPositionDelta;
else
@@ -3614,9 +3631,9 @@
// Floating objects don't shrink. Objects that don't avoid floats don't shrink. Marquees don't shrink.
if ((isInline() && !isHTMLMarquee()) || !avoidsFloats() || isFloating())
return false;
-
- // All auto-width objects that avoid floats should always use lineWidth.
- return style()->width().isAuto();
+
+ // Only auto width objects can possibly shrink to avoid floats.
+ return style()->width().isAuto();
}
bool RenderBox::avoidsFloats() const
Modified: trunk/Source/WebCore/rendering/RenderBox.h (113884 => 113885)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-04-11 18:35:37 UTC (rev 113885)
@@ -318,6 +318,7 @@
virtual LayoutUnit containingBlockLogicalWidthForContent() const;
LayoutUnit containingBlockLogicalWidthForContentInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
+ LayoutUnit containingBlockAvailableLineWidthInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
LayoutUnit perpendicularContainingBlockLogicalHeight() const;
virtual void computeLogicalWidth();
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (113884 => 113885)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2012-04-11 18:30:52 UTC (rev 113884)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2012-04-11 18:35:37 UTC (rev 113885)
@@ -254,9 +254,12 @@
// Finally, with our true width determined, compute our margins for real.
setMarginStart(0);
setMarginEnd(0);
- if (!hasPerpendicularContainingBlock)
- computeInlineDirectionMargins(cb, availableLogicalWidth, logicalWidth());
- else {
+ if (!hasPerpendicularContainingBlock) {
+ LayoutUnit containerLogicalWidthForAutoMargins = availableLogicalWidth;
+ if (avoidsFloats() && cb->containsFloats())
+ containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(0, 0); // FIXME: Work with regions someday.
+ computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, logicalWidth());
+ } else {
setMarginStart(minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView));
setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView));
}