Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (127913 => 127914)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-07 20:47:44 UTC (rev 127913)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-07 20:50:41 UTC (rev 127914)
@@ -413,7 +413,7 @@
layer()->updateTransform();
}
-LayoutUnit RenderBox::constrainLogicalWidthInRegionByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
+LayoutUnit RenderBox::constrainLogicalWidthInRegionByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
{
RenderStyle* styleToUse = style();
if (!styleToUse->logicalMaxWidth().isUndefined())
@@ -1151,7 +1151,7 @@
return clipRect;
}
-LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
+LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
{
RenderRegion* containingBlockRegion = 0;
LayoutUnit logicalTopPosition = logicalTop();
@@ -1617,20 +1617,26 @@
void RenderBox::computeLogicalWidth()
{
- computeLogicalWidthInRegion();
+ LogicalExtentComputedValues computedValues;
+ computeLogicalWidthInRegion(computedValues);
+
+ setLogicalWidth(computedValues.m_extent);
+ setLogicalLeft(computedValues.m_position);
+ setMarginStart(computedValues.m_margins.m_start);
+ setMarginEnd(computedValues.m_margins.m_end);
}
-void RenderBox::computeLogicalWidthInRegion(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
+void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& computedValues, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
{
+ computedValues.m_extent = logicalWidth();
+ computedValues.m_position = logicalLeft();
+ computedValues.m_margins.m_start = marginStart();
+ computedValues.m_margins.m_end = marginEnd();
+
if (isOutOfFlowPositioned()) {
// FIXME: This calculation is not patched for block-flow yet.
// https://bugs.webkit.org/show_bug.cgi?id=46500
- LogicalExtentComputedValues computedValues;
computePositionedLogicalWidth(computedValues, region, offsetFromLogicalTopOfFirstPage);
- setLogicalWidth(computedValues.m_extent);
- setLogicalLeft(computedValues.m_position);
- setMarginStart(computedValues.m_margins.m_start);
- setMarginEnd(computedValues.m_margins.m_end);
return;
}
@@ -1643,7 +1649,7 @@
// FIXME: Account for block-flow in flexible boxes.
// https://bugs.webkit.org/show_bug.cgi?id=46418
if (hasOverrideWidth() && parent()->isFlexibleBoxIncludingDeprecated()) {
- setLogicalWidth(overrideLogicalContentWidth() + borderAndPaddingLogicalWidth());
+ computedValues.m_extent = overrideLogicalContentWidth() + borderAndPaddingLogicalWidth();
return;
}
@@ -1654,7 +1660,7 @@
bool treatAsReplaced = shouldComputeSizeAsReplaced() && (!inVerticalBox || !stretching);
RenderStyle* styleToUse = style();
- Length logicalWidthLength = (treatAsReplaced) ? Length(computeReplacedLogicalWidth(), Fixed) : styleToUse->logicalWidth();
+ Length logicalWidthLength = treatAsReplaced ? Length(computeReplacedLogicalWidth(), Fixed) : styleToUse->logicalWidth();
RenderBlock* cb = containingBlock();
LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogicalWidthForContentInRegion(region, offsetFromLogicalTopOfFirstPage));
@@ -1666,50 +1672,53 @@
if (isInline() && !isInlineBlockOrInlineTable()) {
// just calculate margins
RenderView* renderView = view();
- setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView));
- setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView));
+ computedValues.m_margins.m_start = minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView);
+ computedValues.m_margins.m_end = minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView);
if (treatAsReplaced)
- setLogicalWidth(max<LayoutUnit>(floatValueForLength(logicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth()));
+ computedValues.m_extent = max<LayoutUnit>(floatValueForLength(logicalWidthLength, 0) + borderAndPaddingLogicalWidth(), minPreferredLogicalWidth());
return;
}
// Width calculations
if (treatAsReplaced)
- setLogicalWidth(logicalWidthLength.value() + borderAndPaddingLogicalWidth());
+ computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingLogicalWidth();
else {
LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPreferredSize, containerWidthInInlineDirection, cb, region, offsetFromLogicalTopOfFirstPage);
- setLogicalWidth(constrainLogicalWidthInRegionByMinMax(preferredWidth, containerWidthInInlineDirection, cb, region, offsetFromLogicalTopOfFirstPage));
+ computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferredWidth, containerWidthInInlineDirection, cb, region, offsetFromLogicalTopOfFirstPage);
}
// Fieldsets are currently the only objects that stretch to their minimum width.
if (stretchesToMinIntrinsicLogicalWidth())
- setLogicalWidth(max(logicalWidth(), minPreferredLogicalWidth()));
+ computedValues.m_extent = max(computedValues.m_extent, minPreferredLogicalWidth());
// Margin calculations.
if (hasPerpendicularContainingBlock || isFloating() || isInline()) {
RenderView* renderView = view();
- setMarginStart(minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView));
- setMarginEnd(minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView));
+ computedValues.m_margins.m_start = minimumValueForLength(styleToUse->marginStart(), containerLogicalWidth, renderView);
+ computedValues.m_margins.m_end = minimumValueForLength(styleToUse->marginEnd(), containerLogicalWidth, renderView);
} else {
LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth;
if (avoidsFloats() && cb->containsFloats())
containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(region, offsetFromLogicalTopOfFirstPage);
- ComputedMarginValues marginValues;
- bool hasInvertedDirection = cb->style()->isLeftToRightDirection() == style()->isLeftToRightDirection();
- computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, logicalWidth(),
- hasInvertedDirection ? marginValues.m_start : marginValues.m_end,
- hasInvertedDirection ? marginValues.m_end : marginValues.m_start);
- setMarginStart(marginValues.m_start);
- setMarginEnd(marginValues.m_end);
+ bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection();
+ computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, computedValues.m_extent,
+ hasInvertedDirection ? computedValues.m_margins.m_end : computedValues.m_margins.m_start,
+ hasInvertedDirection ? computedValues.m_margins.m_start : computedValues.m_margins.m_end);
}
- if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (logicalWidth() + marginStart() + marginEnd())
- && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated())
- cb->setMarginEndForChild(this, containerLogicalWidth - logicalWidth() - cb->marginStartForChild(this));
+ if (!hasPerpendicularContainingBlock && containerLogicalWidth && containerLogicalWidth != (computedValues.m_extent + computedValues.m_margins.m_start + computedValues.m_margins.m_end)
+ && !isFloating() && !isInline() && !cb->isFlexibleBoxIncludingDeprecated()) {
+ LayoutUnit newMargin = containerLogicalWidth - computedValues.m_extent - cb->marginStartForChild(this);
+ bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection();
+ if (hasInvertedDirection)
+ computedValues.m_margins.m_start = newMargin;
+ else
+ computedValues.m_margins.m_end = newMargin;
+ }
}
LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, LayoutUnit availableLogicalWidth,
- const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
+ const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
{
RenderStyle* styleToUse = style();
Length logicalWidth;
@@ -1875,22 +1884,13 @@
|| isTableCell() || !isBlockFlow() || isRenderFlowThread())
return 0;
- // FIXME: It's gross to cast away the const, but it would be a huge refactoring to
- // change all width computation to avoid updating any member variables, and it would be pretty lame to
- // make all the variables mutable as well.
RenderFlowThread* flowThread = enclosingRenderFlowThread();
if (flowThread->style()->writingMode() != style()->writingMode())
return 0;
- LayoutUnit oldLogicalWidth = logicalWidth();
- LayoutUnit oldLogicalLeft = logicalLeft();
- LayoutUnit oldMarginStart = marginStart();
- LayoutUnit oldMarginEnd = marginEnd();
+ LogicalExtentComputedValues computedValues;
+ computeLogicalWidthInRegion(computedValues, region, offsetFromLogicalTopOfFirstPage);
- RenderBox* mutableBox = const_cast<RenderBox*>(this);
-
- mutableBox->computeLogicalWidthInRegion(region, offsetFromLogicalTopOfFirstPage);
-
// Now determine the insets based off where this object is supposed to be positioned.
RenderBlock* cb = containingBlock();
RenderRegion* clampedContainingBlockRegion = cb->clampToStartAndEndRegions(region);
@@ -1899,22 +1899,16 @@
LayoutUnit containingBlockLogicalWidth = cb->logicalWidth();
LayoutUnit containingBlockLogicalWidthInRegion = containingBlockInfo ? containingBlockInfo->logicalWidth() : containingBlockLogicalWidth;
- LayoutUnit marginStartInRegion = marginStart();
- LayoutUnit startMarginDelta = marginStartInRegion - oldMarginStart;
- LayoutUnit logicalWidthInRegion = logicalWidth();
- LayoutUnit logicalLeftInRegion = logicalLeft();
- LayoutUnit widthDelta = logicalWidthInRegion - oldLogicalWidth;
- LayoutUnit logicalLeftDelta = isOutOfFlowPositioned() ? logicalLeftInRegion - oldLogicalLeft : startMarginDelta;
+ LayoutUnit marginStartInRegion = computedValues.m_margins.m_start;
+ LayoutUnit startMarginDelta = marginStartInRegion - marginStart();
+ LayoutUnit logicalWidthInRegion = computedValues.m_extent;
+ LayoutUnit logicalLeftInRegion = computedValues.m_position;
+ LayoutUnit widthDelta = logicalWidthInRegion - logicalWidth();
+ LayoutUnit logicalLeftDelta = isOutOfFlowPositioned() ? logicalLeftInRegion - logicalLeft() : startMarginDelta;
LayoutUnit logicalRightInRegion = containingBlockLogicalWidthInRegion - (logicalLeftInRegion + logicalWidthInRegion);
- LayoutUnit oldLogicalRight = containingBlockLogicalWidth - (oldLogicalLeft + oldLogicalWidth);
+ LayoutUnit oldLogicalRight = containingBlockLogicalWidth - (logicalLeft() + logicalWidth());
LayoutUnit logicalRightDelta = isOutOfFlowPositioned() ? logicalRightInRegion - oldLogicalRight : startMarginDelta;
- // Set our values back.
- mutableBox->setLogicalWidth(oldLogicalWidth);
- mutableBox->setLogicalLeft(oldLogicalLeft);
- mutableBox->setMarginStart(oldMarginStart);
- mutableBox->setMarginEnd(oldMarginEnd);
-
LayoutUnit logicalLeftOffset = 0;
if (!isOutOfFlowPositioned() && avoidsFloats() && cb->containsFloats()) {
Modified: trunk/Source/WebCore/rendering/RenderBox.h (127913 => 127914)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-09-07 20:47:44 UTC (rev 127913)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-09-07 20:50:41 UTC (rev 127914)
@@ -75,7 +75,7 @@
LayoutUnit logicalWidth() const { return style()->isHorizontalWritingMode() ? width() : height(); }
LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
- LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT);
+ LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT) const;
LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit) const;
int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
@@ -369,7 +369,7 @@
void computeLogicalHeight(LogicalExtentComputedValues&) const;
RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
- void computeLogicalWidthInRegion(RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT);
+ void computeLogicalWidthInRegion(LogicalExtentComputedValues&, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT) const;
bool stretchesToViewport() const
{
@@ -385,9 +385,9 @@
bool sizesLogicalWidthToFitContent(SizeType) const;
virtual bool stretchesToMinIntrinsicLogicalWidth() const { return false; }
- LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage);
+ LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
- LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage);
+ LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height) const;
LayoutUnit computeLogicalClientHeight(SizeType, const Length& height);
LayoutUnit computeContentLogicalHeightUsing(SizeType, const Length& height) const;