Title: [108876] trunk/Source/WebCore
Revision
108876
Author
[email protected]
Date
2012-02-24 17:46:27 -0800 (Fri, 24 Feb 2012)

Log Message

More refactoring in RenderFlexibleBox
https://bugs.webkit.org/show_bug.cgi?id=79533

Reviewed by Ojan Vafai.

No new tests, just refactoring.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::layoutFlexItems): Move the flipping of RTL+column positions to its own method.
This might be a tiny bit slower, but it's clearer since it's not related to alignment.
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren): Move the logical height calculation out of the loop.  We only need the final height.
(WebCore::RenderFlexibleBox::alignChildren):
(WebCore::RenderFlexibleBox::flipForRightToLeftColumn):
* rendering/RenderFlexibleBox.h:
(RenderFlexibleBox):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (108875 => 108876)


--- trunk/Source/WebCore/ChangeLog	2012-02-25 01:31:27 UTC (rev 108875)
+++ trunk/Source/WebCore/ChangeLog	2012-02-25 01:46:27 UTC (rev 108876)
@@ -1,3 +1,21 @@
+2012-02-24  Tony Chang  <[email protected]>
+
+        More refactoring in RenderFlexibleBox
+        https://bugs.webkit.org/show_bug.cgi?id=79533
+
+        Reviewed by Ojan Vafai.
+
+        No new tests, just refactoring.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::layoutFlexItems): Move the flipping of RTL+column positions to its own method.
+        This might be a tiny bit slower, but it's clearer since it's not related to alignment.
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): Move the logical height calculation out of the loop.  We only need the final height.
+        (WebCore::RenderFlexibleBox::alignChildren):
+        (WebCore::RenderFlexibleBox::flipForRightToLeftColumn):
+        * rendering/RenderFlexibleBox.h:
+        (RenderFlexibleBox):
+
 2012-02-24  Abhishek Arya  <[email protected]>
 
         Positioned objects not cleared when moving children

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (108875 => 108876)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-02-25 01:31:27 UTC (rev 108875)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-02-25 01:46:27 UTC (rev 108876)
@@ -520,6 +520,9 @@
     }
 
     layoutAndPlaceChildren(orderedChildren, childSizes, availableFreeSpace);
+
+    // direction:rtl + flex-direction:column means the cross-axis direction is flipped.
+    flipForRightToLeftColumn(flexIterator);
 }
 
 float RenderFlexibleBox::positiveFlexForChild(RenderBox* child) const
@@ -759,11 +762,11 @@
         mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(child);
 
         mainAxisOffset += packingSpaceBetweenChildren(availableFreeSpace, style()->flexPack(), childSizes.size());
-
-        if (isColumnFlow())
-            setLogicalHeight(mainAxisOffset + flowAwareBorderEnd() + flowAwarePaddingEnd() + scrollbarLogicalHeight());
     }
 
+    if (isColumnFlow())
+        setLogicalHeight(mainAxisOffset + flowAwareBorderEnd() + flowAwarePaddingEnd() + scrollbarLogicalHeight());
+
     if (style()->flexDirection() == FlowColumnReverse) {
         // We have to do an extra pass for column-reverse to reposition the flex items since the start depends
         // on the height of the flexbox, which we only know after we've positioned all the flex items.
@@ -818,8 +821,6 @@
 
 void RenderFlexibleBox::alignChildren(const OrderedFlexItemList& children, LayoutUnit maxAscent)
 {
-    LayoutUnit crossExtent = crossAxisExtent();
-
     for (size_t i = 0; i < children.size(); ++i) {
         RenderBox* child = children[i];
         switch (flexAlignForChild(child)) {
@@ -856,14 +857,19 @@
             break;
         }
         }
+    }
+}
 
-        // direction:rtl + flex-direction:column means the cross-axis direction is flipped.
-        if (!style()->isLeftToRightDirection() && isColumnFlow()) {
-            LayoutPoint location = flowAwareLocationForChild(child);
-            location.setY(crossExtent - crossAxisExtentForChild(child) - location.y());
-            setFlowAwareLocationForChild(child, location);
-        }
+void RenderFlexibleBox::flipForRightToLeftColumn(FlexOrderIterator& iterator)
+{
+    if (style()->isLeftToRightDirection() || !isColumnFlow())
+        return;
 
+    LayoutUnit crossExtent = crossAxisExtent();
+    for (RenderBox* child = iterator.first(); child; child = iterator.next()) {
+        LayoutPoint location = flowAwareLocationForChild(child);
+        location.setY(crossExtent - crossAxisExtentForChild(child) - location.y());
+        setFlowAwareLocationForChild(child, location);
     }
 }
 

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (108875 => 108876)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-02-25 01:31:27 UTC (rev 108875)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-02-25 01:46:27 UTC (rev 108876)
@@ -106,6 +106,7 @@
     void layoutAndPlaceChildren(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace);
     void layoutColumnReverse(const OrderedFlexItemList&, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace);
     void alignChildren(const OrderedFlexItemList&, LayoutUnit maxAscent);
+    void flipForRightToLeftColumn(FlexOrderIterator&);
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to