refactor RenderFlexibleBox to use flex-flow aware methods
authorojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 20:32:18 +0000 (20:32 +0000)
committerojan@chromium.org <ojan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Sep 2011 20:32:18 +0000 (20:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68665

Reviewed by Tony Chang.

This is just a refactor. Just move the all the code that needs to
be flow aware into helper functions. Actually making them flow-aware
can be done in a followup patch.

* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
Moved setLogicalLocationForChild into RenderFlexibleBox since that was the only caller.
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::hasOrthogonalFlow):
(WebCore::RenderFlexibleBox::isHorizontalFlow):
(WebCore::RenderFlexibleBox::isLeftToRightFlow):
(WebCore::RenderFlexibleBox::setFlowAwareLogicalHeight):
(WebCore::RenderFlexibleBox::flowAwareLogicalHeightForChild):
(WebCore::RenderFlexibleBox::flowAwareLogicalWidthForChild):
(WebCore::RenderFlexibleBox::flowAwareLogicalHeight):
(WebCore::RenderFlexibleBox::flowAwareContentLogicalWidth):
(WebCore::RenderFlexibleBox::flowAwareAvailableLogicalWidth):
(WebCore::RenderFlexibleBox::flowAwareBorderStart):
(WebCore::RenderFlexibleBox::flowAwareBorderBefore):
(WebCore::RenderFlexibleBox::flowAwareBorderAfter):
(WebCore::RenderFlexibleBox::flowAwarePaddingStart):
(WebCore::RenderFlexibleBox::flowAwarePaddingBefore):
(WebCore::RenderFlexibleBox::flowAwarePaddingAfter):
(WebCore::RenderFlexibleBox::flowAwareMarginStartForChild):
(WebCore::RenderFlexibleBox::flowAwareMarginBeforeForChild):
(WebCore::RenderFlexibleBox::flowAwareMarginAfterForChild):
(WebCore::RenderFlexibleBox::setFlowAwareMarginStartForChild):
(WebCore::RenderFlexibleBox::setFlowAwareMarginEndForChild):
(WebCore::RenderFlexibleBox::setFlowAwareLogicalLocationForChild):
(WebCore::RenderFlexibleBox::logicalBorderAndPaddingWidthForChild):
(WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
(WebCore::RenderFlexibleBox::marginStartStyleForChild):
(WebCore::RenderFlexibleBox::marginEndStyleForChild):
(WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
(WebCore::RenderFlexibleBox::layoutInlineDirection):
(WebCore::RenderFlexibleBox::logicalPositiveFlexForChild):
(WebCore::RenderFlexibleBox::logicalNegativeFlexForChild):
(WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
(WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
(WebCore::RenderFlexibleBox::setLogicalOverrideSize):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
* rendering/RenderFlexibleBox.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@95856 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderFlexibleBox.h

index b6c6dac..d66af6b 100644 (file)
@@ -1,3 +1,53 @@
+2011-09-22  Ojan Vafai  <ojan@chromium.org>
+
+        refactor RenderFlexibleBox to use flex-flow aware methods
+        https://bugs.webkit.org/show_bug.cgi?id=68665
+
+        Reviewed by Tony Chang.
+
+        This is just a refactor. Just move the all the code that needs to
+        be flow aware into helper functions. Actually making them flow-aware
+        can be done in a followup patch.
+
+        * rendering/RenderBlock.cpp:
+        * rendering/RenderBlock.h:
+        Moved setLogicalLocationForChild into RenderFlexibleBox since that was the only caller.
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::hasOrthogonalFlow):
+        (WebCore::RenderFlexibleBox::isHorizontalFlow):
+        (WebCore::RenderFlexibleBox::isLeftToRightFlow):
+        (WebCore::RenderFlexibleBox::setFlowAwareLogicalHeight):
+        (WebCore::RenderFlexibleBox::flowAwareLogicalHeightForChild):
+        (WebCore::RenderFlexibleBox::flowAwareLogicalWidthForChild):
+        (WebCore::RenderFlexibleBox::flowAwareLogicalHeight):
+        (WebCore::RenderFlexibleBox::flowAwareContentLogicalWidth):
+        (WebCore::RenderFlexibleBox::flowAwareAvailableLogicalWidth):
+        (WebCore::RenderFlexibleBox::flowAwareBorderStart):
+        (WebCore::RenderFlexibleBox::flowAwareBorderBefore):
+        (WebCore::RenderFlexibleBox::flowAwareBorderAfter):
+        (WebCore::RenderFlexibleBox::flowAwarePaddingStart):
+        (WebCore::RenderFlexibleBox::flowAwarePaddingBefore):
+        (WebCore::RenderFlexibleBox::flowAwarePaddingAfter):
+        (WebCore::RenderFlexibleBox::flowAwareMarginStartForChild):
+        (WebCore::RenderFlexibleBox::flowAwareMarginBeforeForChild):
+        (WebCore::RenderFlexibleBox::flowAwareMarginAfterForChild):
+        (WebCore::RenderFlexibleBox::setFlowAwareMarginStartForChild):
+        (WebCore::RenderFlexibleBox::setFlowAwareMarginEndForChild):
+        (WebCore::RenderFlexibleBox::setFlowAwareLogicalLocationForChild):
+        (WebCore::RenderFlexibleBox::logicalBorderAndPaddingWidthForChild):
+        (WebCore::RenderFlexibleBox::logicalScrollbarHeightForChild):
+        (WebCore::RenderFlexibleBox::marginStartStyleForChild):
+        (WebCore::RenderFlexibleBox::marginEndStyleForChild):
+        (WebCore::RenderFlexibleBox::preferredLogicalContentWidthForFlexItem):
+        (WebCore::RenderFlexibleBox::layoutInlineDirection):
+        (WebCore::RenderFlexibleBox::logicalPositiveFlexForChild):
+        (WebCore::RenderFlexibleBox::logicalNegativeFlexForChild):
+        (WebCore::RenderFlexibleBox::computePreferredLogicalWidth):
+        (WebCore::RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection):
+        (WebCore::RenderFlexibleBox::setLogicalOverrideSize):
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection):
+        * rendering/RenderFlexibleBox.h:
+
 2011-09-23  David Hyatt  <hyatt@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=68719
index a3597dd..00f3f3d 100644 (file)
@@ -1863,14 +1863,6 @@ void RenderBlock::handleAfterSideOfBlock(LayoutUnit beforeSide, LayoutUnit after
     setCollapsedBottomMargin(marginInfo);
 }
 
-void RenderBlock::setLogicalLocationForChild(RenderBox* child, const LayoutPoint& location)
-{
-    if (style()->isHorizontalWritingMode())
-        child->setLocation(location);
-    else
-        child->setLocation(location.transposedPoint());
-}
-
 void RenderBlock::setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode applyDelta)
 {
     if (isHorizontalWritingMode()) {
index e44e991..725b23d 100644 (file)
@@ -209,8 +209,6 @@ public:
     LayoutUnit logicalHeightForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->height() : child->width(); }
     LayoutUnit logicalTopForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->y() : child->x(); }
     LayoutUnit logicalLeftForChild(RenderBox* child) { return isHorizontalWritingMode() ? child->x() : child->y(); }
-    // FIXME: Supporting layout deltas.
-    void setLogicalLocationForChild(RenderBox* child, const LayoutPoint&);
     void setLogicalLeftForChild(RenderBox* child, LayoutUnit logicalLeft, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
     void setLogicalTopForChild(RenderBox* child, LayoutUnit logicalTop, ApplyLayoutDeltaMode = DoNotApplyLayoutDelta);
     LayoutUnit marginBeforeForChild(RenderBoxModelObject* child) const;
index c995a23..f0d74ce 100644 (file)
@@ -187,38 +187,153 @@ void RenderFlexibleBox::layoutBlock(bool relayoutChildren, int, BlockLayoutPass)
     setNeedsLayout(false);
 }
 
-LayoutUnit RenderFlexibleBox::logicalBorderAndPaddingWidthForChild(RenderBox* child)
+bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox* child) const
 {
-    return isHorizontalWritingMode() ? child->borderAndPaddingWidth() : child->borderAndPaddingHeight();
+    // FIXME: Is the child->isHorizontalWritingMode() check correct if the child is a flexbox?
+    // Should it be using child->isHorizontalFlow in that case?
+    // Or do we only care about the parent's writing mode?
+    return isHorizontalFlow() != child->isHorizontalWritingMode();
 }
 
-LayoutUnit RenderFlexibleBox::logicalScrollbarHeightForChild(RenderBox* child)
+bool RenderFlexibleBox::isHorizontalFlow() const
 {
-    return isHorizontalWritingMode() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight();
+    // FIXME: Take flex-flow value into account.
+    return isHorizontalWritingMode();
 }
 
-Length RenderFlexibleBox::marginStartStyleForChild(RenderBox* child)
+bool RenderFlexibleBox::isLeftToRightFlow() const
 {
-    if (isHorizontalWritingMode())
-        return style()->isLeftToRightDirection() ? child->style()->marginLeft() : child->style()->marginRight();
-    return style()->isLeftToRightDirection() ? child->style()->marginTop() : child->style()->marginBottom();
+    // FIXME: Take flex-flow value into account.
+    return style()->isLeftToRightDirection();
 }
 
-Length RenderFlexibleBox::marginEndStyleForChild(RenderBox* child)
+// FIXME: Make all these flow aware methods actually be flow aware.
+
+void RenderFlexibleBox::setFlowAwareLogicalHeight(LayoutUnit size)
+{
+    setLogicalHeight(size);
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareLogicalHeightForChild(RenderBox* child)
+{
+    return logicalHeightForChild(child);
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareLogicalWidthForChild(RenderBox* child)
+{
+    return logicalWidthForChild(child);
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareLogicalHeight() const
+{
+    return logicalHeight();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareContentLogicalWidth() const
+{
+    return contentLogicalWidth();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareAvailableLogicalWidth() const
+{
+    return availableLogicalWidth();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareBorderStart() const
+{
+    return borderStart();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareBorderBefore() const
+{
+    return borderBefore();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareBorderAfter() const
+{
+    return borderAfter();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwarePaddingStart() const
+{
+    return paddingStart();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwarePaddingBefore() const
+{
+    return paddingBefore();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwarePaddingAfter() const
+{
+    return paddingAfter();
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox* child) const
+{
+    return marginStartForChild(child);
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox* child) const
+{
+    return marginBeforeForChild(child);
+}
+
+LayoutUnit RenderFlexibleBox::flowAwareMarginAfterForChild(RenderBox* child) const
+{
+    return marginAfterForChild(child);
+}
+
+void RenderFlexibleBox::setFlowAwareMarginStartForChild(RenderBox* child, LayoutUnit margin)
+{
+    setMarginStartForChild(child, margin);
+}
+
+void RenderFlexibleBox::setFlowAwareMarginEndForChild(RenderBox* child, LayoutUnit margin)
+{
+    setMarginEndForChild(child, margin);
+}
+
+void RenderFlexibleBox::setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint& location)
+{
+    if (isHorizontalFlow())
+        child->setLocation(location);
+    else
+        child->setLocation(location.transposedPoint());
+}
+
+LayoutUnit RenderFlexibleBox::logicalBorderAndPaddingWidthForChild(RenderBox* child) const
+{
+    return isHorizontalFlow() ? child->borderAndPaddingWidth() : child->borderAndPaddingHeight();
+}
+
+LayoutUnit RenderFlexibleBox::logicalScrollbarHeightForChild(RenderBox* child) const
+{
+    return isHorizontalFlow() ? child->verticalScrollbarWidth() : child->horizontalScrollbarHeight();
+}
+
+Length RenderFlexibleBox::marginStartStyleForChild(RenderBox* child) const
+{
+    if (isHorizontalFlow())
+        return isLeftToRightFlow() ? child->style()->marginLeft() : child->style()->marginRight();
+    return isLeftToRightFlow() ? child->style()->marginTop() : child->style()->marginBottom();
+}
+
+Length RenderFlexibleBox::marginEndStyleForChild(RenderBox* child) const
 {
-    if (isHorizontalWritingMode())
-        return style()->isLeftToRightDirection() ? child->style()->marginRight() : child->style()->marginLeft();
-    return style()->isLeftToRightDirection() ? child->style()->marginBottom() : child->style()->marginTop();
+    if (isHorizontalFlow())
+        return isLeftToRightFlow() ? child->style()->marginRight() : child->style()->marginLeft();
+    return isLeftToRightFlow() ? child->style()->marginBottom() : child->style()->marginTop();
 }
 
-LayoutUnit RenderFlexibleBox::preferredLogicalContentWidthForFlexItem(RenderBox* child)
+LayoutUnit RenderFlexibleBox::preferredLogicalContentWidthForFlexItem(RenderBox* child) const
 {
-    Length width = isHorizontalWritingMode() ? child->style()->width() : child->style()->height();
+    Length width = isHorizontalFlow() ? child->style()->width() : child->style()->height();
     if (width.isAuto()) {
-        LayoutUnit logicalWidth = isHorizontalWritingMode() == child->isHorizontalWritingMode() ? child->maxPreferredLogicalWidth() : child->logicalHeight();
+        LayoutUnit logicalWidth = hasOrthogonalFlow(child) ? child->logicalHeight() : child->maxPreferredLogicalWidth();
         return logicalWidth - logicalBorderAndPaddingWidthForChild(child) - logicalScrollbarHeightForChild(child);
     }
-    return isHorizontalWritingMode() ? child->contentWidth() : child->contentHeight();
+    return isHorizontalFlow() ? child->contentWidth() : child->contentHeight();
 }
 
 void RenderFlexibleBox::layoutInlineDirection(bool relayoutChildren)
@@ -229,7 +344,7 @@ void RenderFlexibleBox::layoutInlineDirection(bool relayoutChildren)
     TreeOrderIterator treeIterator(this);
 
     computePreferredLogicalWidth(relayoutChildren, treeIterator, preferredLogicalWidth, totalPositiveFlexibility, totalNegativeFlexibility);
-    LayoutUnit availableFreeSpace = contentLogicalWidth() - preferredLogicalWidth;
+    LayoutUnit availableFreeSpace = flowAwareContentLogicalWidth() - preferredLogicalWidth;
 
     FlexOrderIterator flexIterator(this, treeIterator.flexOrderValues());
     InflexibleFlexItemSize inflexibleItems;
@@ -244,14 +359,14 @@ void RenderFlexibleBox::layoutInlineDirection(bool relayoutChildren)
     // FIXME: Handle distribution of cross-axis space (third distribution round).
 }
 
-float RenderFlexibleBox::logicalPositiveFlexForChild(RenderBox* child)
+float RenderFlexibleBox::logicalPositiveFlexForChild(RenderBox* child) const
 {
-    return isHorizontalWritingMode() ? child->style()->flexboxWidthPositiveFlex() : child->style()->flexboxHeightPositiveFlex();
+    return isHorizontalFlow() ? child->style()->flexboxWidthPositiveFlex() : child->style()->flexboxHeightPositiveFlex();
 }
 
-float RenderFlexibleBox::logicalNegativeFlexForChild(RenderBox* child)
+float RenderFlexibleBox::logicalNegativeFlexForChild(RenderBox* child) const
 {
-    return isHorizontalWritingMode() ? child->style()->flexboxWidthNegativeFlex() : child->style()->flexboxHeightNegativeFlex();
+    return isHorizontalFlow() ? child->style()->flexboxWidthNegativeFlex() : child->style()->flexboxHeightNegativeFlex();
 }
 
 void RenderFlexibleBox::computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator& iterator, LayoutUnit& preferredLogicalWidth, float& totalPositiveFlexibility, float& totalNegativeFlexibility)
@@ -259,7 +374,7 @@ void RenderFlexibleBox::computePreferredLogicalWidth(bool relayoutChildren, Tree
     preferredLogicalWidth = 0;
     totalPositiveFlexibility = totalNegativeFlexibility = 0;
 
-    LayoutUnit flexboxAvailableLogicalWidth = availableLogicalWidth();
+    LayoutUnit flexboxAvailableLogicalWidth = flowAwareAvailableLogicalWidth();
     for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
         // We always have to lay out flexible objects again, since the flex distribution
         // may have changed, and we need to reallocate space.
@@ -269,7 +384,7 @@ void RenderFlexibleBox::computePreferredLogicalWidth(bool relayoutChildren, Tree
         child->layoutIfNeeded();
 
         // We can't just use marginStartForChild, et. al. because "auto" needs to be treated as 0.
-        if (isHorizontalWritingMode()) {
+        if (isHorizontalFlow()) {
             preferredLogicalWidth += child->style()->marginLeft().calcMinValue(flexboxAvailableLogicalWidth);
             preferredLogicalWidth += child->style()->marginRight().calcMinValue(flexboxAvailableLogicalWidth);
         } else {
@@ -295,7 +410,7 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrder
 {
     childSizes.clear();
 
-    LayoutUnit flexboxAvailableLogicalWidth = availableLogicalWidth();
+    LayoutUnit flexboxAvailableLogicalWidth = flowAwareAvailableLogicalWidth();
     for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
         LayoutUnit childPreferredSize;
         if (inflexibleItems.contains(child))
@@ -305,7 +420,7 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrder
             if (availableFreeSpace > 0 && totalPositiveFlexibility > 0) {
                 childPreferredSize += lroundf(availableFreeSpace * logicalPositiveFlexForChild(child) / totalPositiveFlexibility);
 
-                Length childLogicalMaxWidth = isHorizontalWritingMode() ? child->style()->maxWidth() : child->style()->maxHeight();
+                Length childLogicalMaxWidth = isHorizontalFlow() ? child->style()->maxWidth() : child->style()->maxHeight();
                 if (!childLogicalMaxWidth.isUndefined() && childLogicalMaxWidth.isSpecified() && childPreferredSize > childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth)) {
                     childPreferredSize = childLogicalMaxWidth.calcValue(flexboxAvailableLogicalWidth);
                     availableFreeSpace -= childPreferredSize - preferredLogicalContentWidthForFlexItem(child);
@@ -317,7 +432,7 @@ bool RenderFlexibleBox::runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrder
             } else if (availableFreeSpace < 0 && totalNegativeFlexibility > 0) {
                 childPreferredSize += lroundf(availableFreeSpace * logicalNegativeFlexForChild(child) / totalNegativeFlexibility);
 
-                Length childLogicalMinWidth = isHorizontalWritingMode() ? child->style()->minWidth() : child->style()->minHeight();
+                Length childLogicalMinWidth = isHorizontalFlow() ? child->style()->minWidth() : child->style()->minHeight();
                 if (!childLogicalMinWidth.isUndefined() && childLogicalMinWidth.isSpecified() && childPreferredSize < childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth)) {
                     childPreferredSize = childLogicalMinWidth.calcValue(flexboxAvailableLogicalWidth);
                     availableFreeSpace += preferredLogicalContentWidthForFlexItem(child) - childPreferredSize;
@@ -341,15 +456,15 @@ static bool hasPackingSpace(LayoutUnit availableFreeSpace, float totalPositiveFl
 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize)
 {
     // FIXME: Rename setOverrideWidth/setOverrideHeight to setOverrideLogicalWidth/setOverrideLogicalHeight.
-    if (isHorizontalWritingMode())
-        child->isHorizontalWritingMode() ? child->setOverrideWidth(childPreferredSize) : child->setOverrideHeight(childPreferredSize);
+    if (hasOrthogonalFlow(child))
+        child->setOverrideHeight(childPreferredSize);
     else
-        child->isHorizontalWritingMode() ? child->setOverrideHeight(childPreferredSize) : child->setOverrideWidth(childPreferredSize);
+        child->setOverrideWidth(childPreferredSize);
 }
 
 void RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection(FlexOrderIterator& iterator, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
 {
-    LayoutUnit startEdge = borderStart() + paddingStart();
+    LayoutUnit startEdge = flowAwareBorderStart() + flowAwarePaddingStart();
 
     if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) {
         if (style()->flexPack() == PackEnd)
@@ -358,9 +473,9 @@ void RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection(FlexOrderIterator&
             startEdge += availableFreeSpace / 2;
     }
 
-    LayoutUnit logicalTop = borderBefore() + paddingBefore();
-    LayoutUnit totalAvailableLogicalWidth = availableLogicalWidth();
-    setLogicalHeight(0);
+    LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore();
+    LayoutUnit totalAvailableLogicalWidth = flowAwareAvailableLogicalWidth();
+    setFlowAwareLogicalHeight(0);
     size_t i = 0;
     for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) {
         // FIXME: Does this need to take the scrollbar width into account?
@@ -369,20 +484,20 @@ void RenderFlexibleBox::layoutAndPlaceChildrenInlineDirection(FlexOrderIterator&
         child->setChildNeedsLayout(true);
         child->layoutIfNeeded();
 
-        setLogicalHeight(std::max(logicalHeight(), borderBefore() + paddingBefore() + marginBeforeForChild(child) + logicalHeightForChild(child) + marginAfterForChild(child) + paddingAfter() + borderAfter() + scrollbarLogicalHeight()));
+        setFlowAwareLogicalHeight(std::max(flowAwareLogicalHeight(), flowAwareBorderBefore() + flowAwarePaddingBefore() + flowAwareMarginBeforeForChild(child) + flowAwareLogicalHeightForChild(child) + flowAwareMarginAfterForChild(child) + flowAwarePaddingAfter() + flowAwareBorderAfter() + scrollbarLogicalHeight()));
 
         if (marginStartStyleForChild(child).isAuto())
-            setMarginStartForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
+            setFlowAwareMarginStartForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
         if (marginEndStyleForChild(child).isAuto())
-            setMarginEndForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
+            setFlowAwareMarginEndForChild(child, availableFreeSpace > 0 ? lroundf(availableFreeSpace / totalPositiveFlexibility) : 0);
 
-        startEdge += marginStartForChild(child);
+        startEdge += flowAwareMarginStartForChild(child);
 
-        LayoutUnit childLogicalWidth = logicalWidthForChild(child);
-        LayoutUnit logicalLeft = style()->isLeftToRightDirection() ? startEdge : totalAvailableLogicalWidth - startEdge - childLogicalWidth;
+        LayoutUnit childLogicalWidth = flowAwareLogicalWidthForChild(child);
+        LayoutUnit logicalLeft = isLeftToRightFlow() ? startEdge : totalAvailableLogicalWidth - startEdge - childLogicalWidth;
         // FIXME: Do repaintDuringLayoutIfMoved.
         // FIXME: Supporting layout deltas.
-        setLogicalLocationForChild(child, IntPoint(logicalLeft, logicalTop));
+        setFlowAwareLogicalLocationForChild(child, IntPoint(logicalLeft, logicalTop));
         startEdge += childLogicalWidth + marginEndForChild(child);
 
         if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && style()->flexPack() == PackJustify && childSizes.size() > 1)
index 8b7e6b4..96ff3a9 100644 (file)
@@ -53,16 +53,38 @@ private:
     class FlexOrderIterator;
     typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;
 
-    LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child);
-    LayoutUnit logicalScrollbarHeightForChild(RenderBox* child);
-    Length marginStartStyleForChild(RenderBox* child);
-    Length marginEndStyleForChild(RenderBox* child);
-    LayoutUnit preferredLogicalContentWidthForFlexItem(RenderBox* child);
+    bool hasOrthogonalFlow(RenderBox* child) const;
+    bool isHorizontalFlow() const;
+    bool isLeftToRightFlow() const;
+    void setFlowAwareLogicalHeight(LayoutUnit);
+    LayoutUnit flowAwareLogicalHeightForChild(RenderBox* child);
+    LayoutUnit flowAwareLogicalWidthForChild(RenderBox* child);
+    LayoutUnit flowAwareLogicalHeight() const;
+    LayoutUnit flowAwareContentLogicalWidth() const;
+    LayoutUnit flowAwareAvailableLogicalWidth() const;
+    LayoutUnit flowAwareBorderStart() const;
+    LayoutUnit flowAwareBorderBefore() const;
+    LayoutUnit flowAwareBorderAfter() const;
+    LayoutUnit flowAwarePaddingStart() const;
+    LayoutUnit flowAwarePaddingBefore() const;
+    LayoutUnit flowAwarePaddingAfter() const;
+    LayoutUnit flowAwareMarginStartForChild(RenderBox* child) const;
+    LayoutUnit flowAwareMarginBeforeForChild(RenderBox* child) const;
+    LayoutUnit flowAwareMarginAfterForChild(RenderBox* child) const;
+    void setFlowAwareMarginStartForChild(RenderBox* child, LayoutUnit);
+    void setFlowAwareMarginEndForChild(RenderBox* child, LayoutUnit);
+    // FIXME: Supporting layout deltas.
+    void setFlowAwareLogicalLocationForChild(RenderBox* child, const LayoutPoint&);
+    LayoutUnit logicalBorderAndPaddingWidthForChild(RenderBox* child) const;
+    LayoutUnit logicalScrollbarHeightForChild(RenderBox* child) const;
+    Length marginStartStyleForChild(RenderBox* child) const;
+    Length marginEndStyleForChild(RenderBox* child) const;
+    LayoutUnit preferredLogicalContentWidthForFlexItem(RenderBox* child) const;
 
     void layoutInlineDirection(bool relayoutChildren);
 
-    float logicalPositiveFlexForChild(RenderBox* child);
-    float logicalNegativeFlexForChild(RenderBox* child);
+    float logicalPositiveFlexForChild(RenderBox* child) const;
+    float logicalNegativeFlexForChild(RenderBox* child) const;
 
     void computePreferredLogicalWidth(bool relayoutChildren, TreeOrderIterator&, LayoutUnit&, float& totalPositiveFlexibility, float& totalNegativeFlexibility);
     bool runFreeSpaceAllocationAlgorithmInlineDirection(FlexOrderIterator&, LayoutUnit& availableFreeSpace, float& totalPositiveFlexibility, float& totalNegativeFlexibility, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);