Modified: trunk/Source/WebCore/ChangeLog (127548 => 127549)
--- trunk/Source/WebCore/ChangeLog 2012-09-05 03:57:56 UTC (rev 127548)
+++ trunk/Source/WebCore/ChangeLog 2012-09-05 04:14:44 UTC (rev 127549)
@@ -1,3 +1,26 @@
+2012-09-04 Tony Chang <t...@chromium.org>
+
+ Add a const version of RenderBox::computeLogicalHeight
+ https://bugs.webkit.org/show_bug.cgi?id=95787
+
+ Reviewed by Ojan Vafai.
+
+ After this, we can rename the old computeLogicalHeight to computeAndSetLogicalHeight
+ to make it clear that it is modifying values.
+
+ No new tests, this should just be a refactor.
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::constrainLogicalHeightByMinMax): Make const.
+ (WebCore::RenderBox::computeLogicalHeight): Add a const version that takes a LogicalExtentComputedValues struct for out values.
+ (WebCore::RenderBox::computeLogicalHeightUsing): Make const.
+ (WebCore::RenderBox::computeContentLogicalHeightUsing): Make const.
+ (WebCore::RenderBox::computePercentageLogicalHeight): Add a const cast. I tried to
+ convert everything below to const, but that's not a simple task. Also, computeReplacedLogicalHeightUsing
+ is already using a const_cast.
+ * rendering/RenderBox.h:
+ (RenderBox): Add const to method signatures.
+
2012-09-04 Dirk Schulze <k...@webkit.org>
-webkit-clip-path does not apply origin for polygon()
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (127548 => 127549)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-05 03:57:56 UTC (rev 127548)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2012-09-05 04:14:44 UTC (rev 127549)
@@ -421,7 +421,7 @@
return max(logicalWidth, computeLogicalWidthInRegionUsing(MinSize, availableWidth, cb, region, offsetFromLogicalTopOfFirstPage));
}
-LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight)
+LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight) const
{
RenderStyle* styleToUse = style();
if (!styleToUse->logicalMaxHeight().isUndefined()) {
@@ -1967,43 +1967,45 @@
void RenderBox::computeLogicalHeight()
{
+ LogicalExtentComputedValues computedValues;
+ computeLogicalHeight(computedValues);
+
+ setLogicalHeight(computedValues.m_extent);
+ setLogicalTop(computedValues.m_position);
+ setMarginBefore(computedValues.m_margins.m_before);
+ setMarginAfter(computedValues.m_margins.m_after);
+}
+
+void RenderBox::computeLogicalHeight(LogicalExtentComputedValues& computedValues) const
+{
+ computedValues.m_extent = logicalHeight();
+ computedValues.m_position = logicalTop();
+
// Cell height is managed by the table and inline non-replaced elements do not support a height property.
if (isTableCell() || (isInline() && !isReplaced()))
return;
Length h;
- if (isOutOfFlowPositioned()) {
- LogicalExtentComputedValues computedValues;
+ if (isOutOfFlowPositioned())
computePositionedLogicalHeight(computedValues);
-
- setLogicalHeight(computedValues.m_extent);
- setLogicalTop(computedValues.m_position);
- setMarginBefore(computedValues.m_margins.m_before);
- setMarginAfter(computedValues.m_margins.m_after);
- } else {
+ else {
RenderBlock* cb = containingBlock();
bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHorizontalWritingMode();
if (!hasPerpendicularContainingBlock) {
- ComputedMarginValues marginValues;
bool shouldFlipBeforeAfter = cb->style()->writingMode() != style()->writingMode();
computeBlockDirectionMargins(cb,
- shouldFlipBeforeAfter ? marginValues.m_after : marginValues.m_before,
- shouldFlipBeforeAfter ? marginValues.m_before : marginValues.m_after);
- setMarginBefore(marginValues.m_before);
- setMarginAfter(marginValues.m_after);
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_after : computedValues.m_margins.m_before,
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after);
}
// For tables, calculate margins only.
if (isTable()) {
if (hasPerpendicularContainingBlock) {
- ComputedMarginValues marginValues;
bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style(), style());
computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), logicalHeight(),
- shouldFlipBeforeAfter ? marginValues.m_after : marginValues.m_before,
- shouldFlipBeforeAfter ? marginValues.m_before : marginValues.m_after);
- setMarginBefore(marginValues.m_before);
- setMarginAfter(marginValues.m_after);
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_after : computedValues.m_margins.m_before,
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after);
}
return;
}
@@ -2050,16 +2052,13 @@
heightResult = h.value() + borderAndPaddingLogicalHeight();
}
- setLogicalHeight(heightResult);
+ computedValues.m_extent = heightResult;
if (hasPerpendicularContainingBlock) {
- ComputedMarginValues marginValues;
bool shouldFlipBeforeAfter = shouldFlipBeforeAfterMargins(cb->style(), style());
computeInlineDirectionMargins(cb, containingBlockLogicalWidthForContent(), heightResult,
- shouldFlipBeforeAfter ? marginValues.m_after : marginValues.m_before,
- shouldFlipBeforeAfter ? marginValues.m_before : marginValues.m_after);
- setMarginBefore(marginValues.m_before);
- setMarginAfter(marginValues.m_after);
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_after : computedValues.m_margins.m_before,
+ shouldFlipBeforeAfter ? computedValues.m_margins.m_before : computedValues.m_margins.m_after);
}
}
@@ -2084,15 +2083,15 @@
visHeight = view()->viewWidth();
}
if (isRoot())
- setLogicalHeight(max(logicalHeight(), visHeight - margins));
+ computedValues.m_extent = max(computedValues.m_extent, visHeight - margins);
else {
LayoutUnit marginsBordersPadding = margins + parentBox()->marginBefore() + parentBox()->marginAfter() + parentBox()->borderAndPaddingLogicalHeight();
- setLogicalHeight(max(logicalHeight(), visHeight - marginsBordersPadding));
+ computedValues.m_extent = max(computedValues.m_extent, visHeight - marginsBordersPadding);
}
}
}
-LayoutUnit RenderBox::computeLogicalHeightUsing(SizeType heightType, const Length& height)
+LayoutUnit RenderBox::computeLogicalHeightUsing(SizeType heightType, const Length& height) const
{
LayoutUnit logicalHeight = computeContentLogicalHeightUsing(heightType, height);
if (logicalHeight != -1)
@@ -2108,7 +2107,7 @@
return std::max(LayoutUnit(0), computeContentBoxLogicalHeight(heightIncludingScrollbar) - scrollbarLogicalHeight());
}
-LayoutUnit RenderBox::computeContentLogicalHeightUsing(SizeType heightType, const Length& height)
+LayoutUnit RenderBox::computeContentLogicalHeightUsing(SizeType heightType, const Length& height) const
{
if (height.isAuto())
return heightType == MinSize ? 0 : -1;
@@ -2121,7 +2120,7 @@
return -1;
}
-LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height)
+LayoutUnit RenderBox::computePercentageLogicalHeight(const Length& height) const
{
LayoutUnit result = -1;
@@ -2137,7 +2136,7 @@
break;
skippedAutoHeightContainingBlock = true;
cb = cb->containingBlock();
- cb->addPercentHeightDescendant(this);
+ cb->addPercentHeightDescendant(const_cast<RenderBox*>(this));
}
RenderStyle* cbstyle = cb->style();
Modified: trunk/Source/WebCore/rendering/RenderBox.h (127548 => 127549)
--- trunk/Source/WebCore/rendering/RenderBox.h 2012-09-05 03:57:56 UTC (rev 127548)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2012-09-05 04:14:44 UTC (rev 127549)
@@ -76,7 +76,7 @@
LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT);
- LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit);
+ LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit) const;
int pixelSnappedLogicalHeight() const { return style()->isHorizontalWritingMode() ? pixelSnappedHeight() : pixelSnappedWidth(); }
int pixelSnappedLogicalWidth() const { return style()->isHorizontalWritingMode() ? pixelSnappedWidth() : pixelSnappedHeight(); }
@@ -366,6 +366,7 @@
virtual void computeLogicalWidth();
virtual void computeLogicalHeight();
+ void computeLogicalHeight(LogicalExtentComputedValues&) const;
RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
void computeLogicalWidthInRegion(RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = ZERO_LAYOUT_UNIT);
@@ -387,9 +388,9 @@
LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage);
LayoutUnit computeLogicalWidthInRegionUsing(SizeType, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage);
- LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height);
+ LayoutUnit computeLogicalHeightUsing(SizeType, const Length& height) const;
LayoutUnit computeLogicalClientHeight(SizeType, const Length& height);
- LayoutUnit computeContentLogicalHeightUsing(SizeType, const Length& height);
+ LayoutUnit computeContentLogicalHeightUsing(SizeType, const Length& height) const;
LayoutUnit computeReplacedLogicalWidthUsing(SizeType, Length width) const;
LayoutUnit computeReplacedLogicalWidthRespectingMinMaxWidth(LayoutUnit logicalWidth, bool includeMaxWidth = true) const;
LayoutUnit computeReplacedLogicalHeightUsing(SizeType, Length height) const;
@@ -398,7 +399,7 @@
virtual LayoutUnit computeReplacedLogicalWidth(bool includeMaxWidth = true) const;
virtual LayoutUnit computeReplacedLogicalHeight() const;
- LayoutUnit computePercentageLogicalHeight(const Length& height);
+ LayoutUnit computePercentageLogicalHeight(const Length& height) const;
// Block flows subclass availableWidth/Height to handle multi column layout (shrinking the width/height available to children when laying out.)
virtual LayoutUnit availableLogicalWidth() const { return contentLogicalWidth(); }