+2012-09-13 Tony Chang <tony@chromium.org>
+
+ Refactor duplicate code into RenderFlexibleBox::mainAxisContentExtent
+ https://bugs.webkit.org/show_bug.cgi?id=96676
+
+ Reviewed by Eric Seidel.
+
+ There was computeAvailableFreeSpace() and lineBreakLength() shared some very similar code.
+ Merge this code into mainAxisContentExtent().
+
+ No new tests, this is just a refactor.
+
+ * rendering/RenderFlexibleBox.cpp:
+ (WebCore::RenderFlexibleBox::mainAxisContentExtent): Take contentLogicalHeight as a parameter,
+ which is needed when determining the logical height.
+ (WebCore::RenderFlexibleBox::computeAvailableFreeSpace): Use mainAxisContentExtent() and inline.
+ (WebCore::RenderFlexibleBox::computeNextFlexLine): Use mainAxisContentExtent().
+ * rendering/RenderFlexibleBox.h:
+
2012-09-13 Glenn Hartmann <hartmanng@chromium.org>
Add new accelerated compositing for overflow scroll setting.
return isHorizontalFlow() ? contentHeight() : contentWidth();
}
-LayoutUnit RenderFlexibleBox::mainAxisContentExtent()
+LayoutUnit RenderFlexibleBox::mainAxisContentExtent(LayoutUnit contentLogicalHeight)
{
if (isColumnFlow()) {
LogicalExtentComputedValues computedValues;
- computeLogicalHeight(logicalHeight(), logicalTop(), computedValues);
+ computeLogicalHeight(contentLogicalHeight, logicalTop(), computedValues);
return std::max(LayoutUnit(0), computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight());
}
return contentLogicalWidth();
return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis));
}
-LayoutUnit RenderFlexibleBox::computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent)
-{
- LayoutUnit contentExtent = 0;
- if (!isColumnFlow())
- contentExtent = mainAxisContentExtent();
- else {
- // FIXME: Refactor to avoid similar code in mainAxisContentExtent().
- LogicalExtentComputedValues computedValues;
- computeLogicalHeight(preferredMainAxisExtent, logicalTop(), computedValues);
- contentExtent = computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight();
- }
-
- return contentExtent - preferredMainAxisExtent;
-}
-
void RenderFlexibleBox::layoutFlexItems(OrderIterator& iterator, WTF::Vector<LineContext>& lineContexts)
{
OrderedFlexItemList orderedChildren;
LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
while (computeNextFlexLine(iterator, orderedChildren, preferredMainAxisExtent, totalFlexGrow, totalWeightedFlexShrink, minMaxAppliedMainAxisExtent)) {
- LayoutUnit availableFreeSpace = computeAvailableFreeSpace(preferredMainAxisExtent);
+ LayoutUnit availableFreeSpace = mainAxisContentExtent(preferredMainAxisExtent) - preferredMainAxisExtent;
FlexSign flexSign = (minMaxAppliedMainAxisExtent < preferredMainAxisExtent + availableFreeSpace) ? PositiveFlexibility : NegativeFlexibility;
InflexibleFlexItemSize inflexibleItems;
WTF::Vector<LayoutUnit> childSizes;
}
}
-LayoutUnit RenderFlexibleBox::lineBreakLength()
-{
- if (!isColumnFlow())
- return mainAxisContentExtent();
-
- // FIXME: Refactor to avoid similar code in mainAxisContentExtent().
- LogicalExtentComputedValues computedValues;
- computeLogicalHeight(MAX_LAYOUT_UNIT, logicalTop(), computedValues);
- return computedValues.m_extent - borderAndPaddingLogicalHeight() - scrollbarLogicalHeight();
-}
-
LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox* child, LayoutUnit childSize)
{
// FIXME: Support intrinsic min/max lengths.
if (!iterator.currentChild())
return false;
- LayoutUnit lineBreak = lineBreakLength();
+ LayoutUnit lineBreakLength = mainAxisContentExtent(MAX_LAYOUT_UNIT);
for (RenderBox* child = iterator.currentChild(); child; child = iterator.next()) {
if (child->isOutOfFlowPositioned()) {
LayoutUnit childMainAxisMarginBoxExtent = mainAxisBorderAndPaddingExtentForChild(child) + childMainAxisExtent;
childMainAxisMarginBoxExtent += isHorizontalFlow() ? child->marginWidth() : child->marginHeight();
- if (isMultiline() && preferredMainAxisExtent + childMainAxisMarginBoxExtent > lineBreak && orderedChildren.size() > 0)
+ if (isMultiline() && preferredMainAxisExtent + childMainAxisMarginBoxExtent > lineBreakLength && orderedChildren.size() > 0)
break;
orderedChildren.append(child);
preferredMainAxisExtent += childMainAxisMarginBoxExtent;
LayoutUnit crossAxisExtent() const;
LayoutUnit mainAxisExtent() const;
LayoutUnit crossAxisContentExtent() const;
- LayoutUnit mainAxisContentExtent();
+ LayoutUnit mainAxisContentExtent(LayoutUnit contentLogicalHeight);
LayoutUnit computeMainAxisExtentForChild(RenderBox* child, SizeType, const Length& size);
WritingMode transformedWritingMode() const;
LayoutUnit flowAwareBorderStart() const;
LayoutUnit computeChildMarginValue(Length margin, RenderView*);
void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&);
- LayoutUnit lineBreakLength();
LayoutUnit adjustChildSizeForMinAndMax(RenderBox*, LayoutUnit childSize);
bool computeNextFlexLine(OrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalFlexGrow, float& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent);
- LayoutUnit computeAvailableFreeSpace(LayoutUnit preferredMainAxisExtent);
bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
void freezeViolations(const WTF::Vector<Violation>&, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize&);