Title: [102090] trunk/Source/WebCore
Revision
102090
Author
t...@chromium.org
Date
2011-12-05 20:59:11 -0800 (Mon, 05 Dec 2011)

Log Message

small refactor of RenderFlexibleBox
https://bugs.webkit.org/show_bug.cgi?id=73854

Reviewed by Darin Adler.

No new tests, just a refactor.

* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::isLeftToRightFlow): Inline isReverseFlow since it's only used in one place.
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren): Rename startEdge
to mainAxisOffset.  Rename logicalTop to crossAxisOffset.  Get rid of
logicalLeft local variable since it's confusing.  Move shouldFlipMainAxis
out of the for loop to avoid computing it each iteration.
* rendering/RenderFlexibleBox.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102089 => 102090)


--- trunk/Source/WebCore/ChangeLog	2011-12-06 04:46:01 UTC (rev 102089)
+++ trunk/Source/WebCore/ChangeLog	2011-12-06 04:59:11 UTC (rev 102090)
@@ -1,3 +1,20 @@
+2011-12-05  Tony Chang  <t...@chromium.org>
+
+        small refactor of RenderFlexibleBox
+        https://bugs.webkit.org/show_bug.cgi?id=73854
+
+        Reviewed by Darin Adler.
+
+        No new tests, just a refactor.
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::RenderFlexibleBox::isLeftToRightFlow): Inline isReverseFlow since it's only used in one place.
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren): Rename startEdge
+        to mainAxisOffset.  Rename logicalTop to crossAxisOffset.  Get rid of
+        logicalLeft local variable since it's confusing.  Move shouldFlipMainAxis
+        out of the for loop to avoid computing it each iteration.
+        * rendering/RenderFlexibleBox.h:
+
 2011-12-05  Florin Malita  <fmal...@google.com>
 
         Heap-buffer-overflow in WebCore::HTMLTreeBuilder::processEndTag

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (102089 => 102090)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2011-12-06 04:46:01 UTC (rev 102089)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2011-12-06 04:59:11 UTC (rev 102090)
@@ -206,11 +206,6 @@
     return style()->isColumnFlexFlow();
 }
 
-bool RenderFlexibleBox::isReverseFlow() const
-{
-    return style()->flexFlow() == FlowColumnReverse || style()->flexFlow() == FlowRowReverse;
-}
-
 bool RenderFlexibleBox::isHorizontalFlow() const
 {
     if (isHorizontalWritingMode())
@@ -222,7 +217,7 @@
 {
     if (isColumnFlow())
         return style()->writingMode() == TopToBottomWritingMode || style()->writingMode() == LeftToRightWritingMode;
-    return style()->isLeftToRightDirection() ^ isReverseFlow();
+    return style()->isLeftToRightDirection() ^ (style()->flexFlow() == FlowRowReverse);
 }
 
 Length RenderFlexibleBox::mainAxisLengthForChild(RenderBox* child) const
@@ -598,12 +593,13 @@
 
 void RenderFlexibleBox::layoutAndPlaceChildren(FlexOrderIterator& iterator, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
 {
-    LayoutUnit startEdge = flowAwareBorderStart() + flowAwarePaddingStart();
-    startEdge += initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack());
+    LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart();
+    mainAxisOffset += initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack());
 
-    LayoutUnit logicalTop = flowAwareBorderBefore() + flowAwarePaddingBefore();
+    LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
     LayoutUnit totalMainExtent = mainAxisExtent();
     LayoutUnit maxAscent = 0, maxDescent = 0; // Used when flex-align: baseline.
+    bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow();
     size_t i = 0;
     for (RenderBox* child = iterator.first(); child; child = iterator.next(), ++i) {
         LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPaddingExtentForChild(child);
@@ -624,20 +620,20 @@
         } else if (crossAxisLength().isAuto())
             setCrossAxisExtent(std::max(crossAxisExtent(), crossAxisBorderAndPaddingExtent() + crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child) + scrollbarLogicalHeight()));
 
-        startEdge += flowAwareMarginStartForChild(child);
+        mainAxisOffset += flowAwareMarginStartForChild(child);
 
         LayoutUnit childMainExtent = mainAxisExtentForChild(child);
-        bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow();
-        LayoutUnit logicalLeft = shouldFlipMainAxis ? totalMainExtent - startEdge - childMainExtent : startEdge;
+        IntPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxisOffset - childMainExtent : mainAxisOffset,
+            crossAxisOffset + flowAwareMarginBeforeForChild(child));
 
         // FIXME: Supporting layout deltas.
-        setFlowAwareLocationForChild(child, IntPoint(logicalLeft, logicalTop + flowAwareMarginBeforeForChild(child)));
-        startEdge += childMainExtent + flowAwareMarginEndForChild(child);
+        setFlowAwareLocationForChild(child, childLocation);
+        mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(child);
 
-        startEdge += packingSpaceBetweenChildren(availableFreeSpace, totalPositiveFlexibility, style()->flexPack(), childSizes.size());
+        mainAxisOffset += packingSpaceBetweenChildren(availableFreeSpace, totalPositiveFlexibility, style()->flexPack(), childSizes.size());
 
         if (isColumnFlow())
-            setLogicalHeight(startEdge);
+            setLogicalHeight(mainAxisOffset);
     }
 
     if (style()->flexFlow() == FlowColumnReverse) {

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (102089 => 102090)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2011-12-06 04:46:01 UTC (rev 102089)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2011-12-06 04:59:11 UTC (rev 102090)
@@ -53,7 +53,6 @@
 
     bool hasOrthogonalFlow(RenderBox* child) const;
     bool isColumnFlow() const;
-    bool isReverseFlow() const;
     bool isHorizontalFlow() const;
     bool isLeftToRightFlow() const;
     Length crossAxisLength() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to