diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-09 14:16:12 +0100 |
commit | 03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (patch) | |
tree | 52599cd0ab782b1768e23ad176f7618f98333cb6 /Source/WebCore/rendering/RenderFlexibleBox.cpp | |
parent | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (diff) | |
download | qtwebkit-03e12282df9aa1e1fb05a8b90f1cfc2e08764cec.tar.gz |
Imported WebKit commit e09a82039aa4273ab318b71122e92d8e5f233525 (http://svn.webkit.org/repository/webkit/trunk@107223)
Diffstat (limited to 'Source/WebCore/rendering/RenderFlexibleBox.cpp')
-rw-r--r-- | Source/WebCore/rendering/RenderFlexibleBox.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/Source/WebCore/rendering/RenderFlexibleBox.cpp b/Source/WebCore/rendering/RenderFlexibleBox.cpp index 45543fe90..b025cd317 100644 --- a/Source/WebCore/rendering/RenderFlexibleBox.cpp +++ b/Source/WebCore/rendering/RenderFlexibleBox.cpp @@ -166,6 +166,13 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int, BlockLayoutPass) LayoutRepainter repainter(*this, checkForRepaintDuringLayout()); LayoutStateMaintainer statePusher(view(), this, IntSize(x(), y()), hasTransform() || hasReflection() || style()->isFlippedBlocksWritingMode()); + if (inRenderFlowThread()) { + // Regions changing widths can force us to relayout our children. + if (logicalWidthChangedInRegions()) + relayoutChildren = true; + } + computeInitialRegionRangeForBlock(); + IntSize previousSize = size(); setLogicalHeight(0); @@ -193,6 +200,8 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int, BlockLayoutPass) layoutPositionedObjects(relayoutChildren || isRoot()); + computeRegionRangeForBlock(); + // FIXME: css3/flexbox/repaint-rtl-column.html seems to repaint more overflow than it needs to. computeOverflow(oldClientAfterEdge); statePusher.pop(); @@ -444,7 +453,7 @@ LayoutUnit RenderFlexibleBox::mainAxisScrollbarExtentForChild(RenderBox* child) return isHorizontalFlow() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight(); } -LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem(RenderBox* child) const +LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox* child) const { Length mainAxisLength = mainAxisLengthForChild(child); if (mainAxisLength.isAuto()) { @@ -456,12 +465,15 @@ LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForFlexItem(RenderBo void RenderFlexibleBox::layoutFlexItems(bool relayoutChildren) { - LayoutUnit preferredMainAxisExtent; float totalPositiveFlexibility; float totalNegativeFlexibility; TreeOrderIterator treeIterator(this); - computePreferredMainAxisExtent(relayoutChildren, treeIterator, preferredMainAxisExtent, totalPositiveFlexibility, totalNegativeFlexibility); + WTF::Vector<LayoutUnit> preferredSizes; + computeMainAxisPreferredSizes(relayoutChildren, treeIterator, preferredSizes, totalPositiveFlexibility, totalNegativeFlexibility); + LayoutUnit preferredMainAxisExtent = 0; + for (size_t i = 0; i < preferredSizes.size(); ++i) + preferredMainAxisExtent += preferredSizes[i]; LayoutUnit availableFreeSpace = mainAxisContentExtent() - preferredMainAxisExtent; FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues()); @@ -500,15 +512,16 @@ LayoutUnit RenderFlexibleBox::marginBoxAscent(RenderBox* child) return ascent + flowAwareMarginBeforeForChild(child); } -void RenderFlexibleBox::computePreferredMainAxisExtent(bool relayoutChildren, TreeOrderIterator& iterator, LayoutUnit& preferredMainAxisExtent, float& totalPositiveFlexibility, float& totalNegativeFlexibility) +void RenderFlexibleBox::computeMainAxisPreferredSizes(bool relayoutChildren, TreeOrderIterator& iterator, WTF::Vector<LayoutUnit>& preferredSizes, float& totalPositiveFlexibility, float& totalNegativeFlexibility) { - preferredMainAxisExtent = 0; totalPositiveFlexibility = totalNegativeFlexibility = 0; LayoutUnit flexboxAvailableContentExtent = mainAxisContentExtent(); for (RenderBox* child = iterator.first(); child; child = iterator.next()) { - if (child->isPositioned()) + if (child->isPositioned()) { + preferredSizes.append(0); continue; + } child->clearOverrideSize(); if (mainAxisLengthForChild(child).isAuto()) { @@ -517,21 +530,22 @@ void RenderFlexibleBox::computePreferredMainAxisExtent(bool relayoutChildren, Tr child->layoutIfNeeded(); } + LayoutUnit preferredSize = mainAxisBorderAndPaddingExtentForChild(child) + preferredMainAxisContentExtentForChild(child); + // We set the margins because we want to make sure 'auto' has a margin // of 0 and because if we're not auto sizing, we don't do a layout that // computes the start/end margins. if (isHorizontalFlow()) { child->setMarginLeft(child->style()->marginLeft().calcMinValue(flexboxAvailableContentExtent)); child->setMarginRight(child->style()->marginRight().calcMinValue(flexboxAvailableContentExtent)); - preferredMainAxisExtent += child->marginLeft() + child->marginRight(); + preferredSize += child->marginLeft() + child->marginRight(); } else { child->setMarginTop(child->style()->marginTop().calcMinValue(flexboxAvailableContentExtent)); child->setMarginBottom(child->style()->marginBottom().calcMinValue(flexboxAvailableContentExtent)); - preferredMainAxisExtent += child->marginTop() + child->marginBottom(); + preferredSize += child->marginTop() + child->marginBottom(); } - preferredMainAxisExtent += mainAxisBorderAndPaddingExtentForChild(child); - preferredMainAxisExtent += preferredMainAxisContentExtentForFlexItem(child); + preferredSizes.append(preferredSize); totalPositiveFlexibility += positiveFlexForChild(child); totalNegativeFlexibility += negativeFlexForChild(child); @@ -554,14 +568,14 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithm(FlexOrderIterator& itera if (inflexibleItems.contains(child)) childPreferredSize = inflexibleItems.get(child); else { - childPreferredSize = preferredMainAxisContentExtentForFlexItem(child); + childPreferredSize = preferredMainAxisContentExtentForChild(child); if (availableFreeSpace > 0 && totalPositiveFlexibility > 0) { childPreferredSize += lroundf(availableFreeSpace * positiveFlexForChild(child) / totalPositiveFlexibility); Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight(); if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent)) { childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableContentExtent); - availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForFlexItem(child); + availableFreeSpace -= childPreferredSize - preferredMainAxisContentExtentForChild(child); totalPositiveFlexibility -= positiveFlexForChild(child); inflexibleItems.set(child, childPreferredSize); @@ -573,7 +587,7 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithm(FlexOrderIterator& itera Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight(); if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableContentExtent)) { childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableContentExtent); - availableFreeSpace += preferredMainAxisContentExtentForFlexItem(child) - childPreferredSize; + availableFreeSpace += preferredMainAxisContentExtentForChild(child) - childPreferredSize; totalNegativeFlexibility -= negativeFlexForChild(child); inflexibleItems.set(child, childPreferredSize); |