Title: [105694] trunk
Revision
105694
Author
[email protected]
Date
2012-01-23 22:26:54 -0800 (Mon, 23 Jan 2012)

Log Message

Implement flex-pack:distribute
https://bugs.webkit.org/show_bug.cgi?id=76864

Reviewed by Tony Chang.

Source/WebCore:

See http://dev.w3.org/csswg/css3-flexbox/#flex-pack.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EFlexPack):
* css/CSSValueKeywords.in:
* rendering/RenderFlexibleBox.cpp:
(WebCore::initialPackingOffset):
(WebCore::packingSpaceBetweenChildren):
(WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
(WebCore::RenderFlexibleBox::layoutColumnReverse):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleFlexibleBoxData.h:

LayoutTests:

* css3/flexbox/004-expected.txt:
* css3/flexbox/004.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (105693 => 105694)


--- trunk/LayoutTests/ChangeLog	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/LayoutTests/ChangeLog	2012-01-24 06:26:54 UTC (rev 105694)
@@ -1,3 +1,13 @@
+2012-01-23  Ojan Vafai  <[email protected]>
+
+        Implement flex-pack:distribute
+        https://bugs.webkit.org/show_bug.cgi?id=76864
+
+        Reviewed by Tony Chang.
+
+        * css3/flexbox/004-expected.txt:
+        * css3/flexbox/004.html:
+
 2012-01-23  Tom Sepez  <[email protected]>
 
         decodeEscapeSequences() not correct for some encodings (GBK, Big5, ...).

Modified: trunk/LayoutTests/css3/flexbox/004-expected.txt (105693 => 105694)


--- trunk/LayoutTests/css3/flexbox/004-expected.txt	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/LayoutTests/css3/flexbox/004-expected.txt	2012-01-24 06:26:54 UTC (rev 105694)
@@ -5,3 +5,6 @@
 PASS
 PASS
 PASS
+PASS
+PASS
+PASS

Modified: trunk/LayoutTests/css3/flexbox/004.html (105693 => 105694)


--- trunk/LayoutTests/css3/flexbox/004.html	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/LayoutTests/css3/flexbox/004.html	2012-01-24 06:26:54 UTC (rev 105694)
@@ -60,6 +60,20 @@
   <div data-expected-width="100" data-offset-x="0" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
 </div>
 
+<div class="flexbox" style="-webkit-flex-pack: distribute">
+  <div data-expected-width="100" data-offset-x="50" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
+  <div data-expected-width="100" data-offset-x="250" style="width: 100px;"></div>
+  <div data-expected-width="100" data-offset-x="450" style="width: 100px;"></div>
+</div>
+
+<!-- If there's only one child, we pack center. -->
+<div class="flexbox" style="-webkit-flex-pack: distribute">
+  <div data-expected-width="100" data-offset-x="250" style="width: -webkit-flex(1 0 0); max-width: 100px;"></div>
+</div>
+
+<!-- Make sure we don't crash with no children. -->
+<div class="flexbox" style="-webkit-flex-pack: distribute"></div>
+
 <!-- margin:auto does nothing here. -->
 <div class="flexbox" style="-webkit-flex-pack: end">
   <div data-expected-width="100" data-offset-x="300" style="width: 100px;"></div>

Modified: trunk/Source/WebCore/ChangeLog (105693 => 105694)


--- trunk/Source/WebCore/ChangeLog	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/ChangeLog	2012-01-24 06:26:54 UTC (rev 105694)
@@ -1,3 +1,26 @@
+2012-01-23  Ojan Vafai  <[email protected]>
+
+        Implement flex-pack:distribute
+        https://bugs.webkit.org/show_bug.cgi?id=76864
+
+        Reviewed by Tony Chang.
+
+        See http://dev.w3.org/csswg/css3-flexbox/#flex-pack.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EFlexPack):
+        * css/CSSValueKeywords.in:
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::initialPackingOffset):
+        (WebCore::packingSpaceBetweenChildren):
+        (WebCore::RenderFlexibleBox::layoutAndPlaceChildren):
+        (WebCore::RenderFlexibleBox::layoutColumnReverse):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleFlexibleBoxData.h:
+
 2012-01-23  Luke Macpherson   <[email protected]>
 
         Implement CSS clip property in CSSStyleApplyProperty.

Modified: trunk/Source/WebCore/css/CSSParser.cpp (105693 => 105694)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-01-24 06:26:54 UTC (rev 105694)
@@ -1636,7 +1636,7 @@
         }
         break;
     case CSSPropertyWebkitFlexPack:
-        validPrimitive = id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || id == CSSValueJustify;
+        validPrimitive = id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || id == CSSValueJustify || id == CSSValueDistribute;
         break;
     case CSSPropertyWebkitFlexAlign:
         validPrimitive = id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || id == CSSValueBaseline || id == CSSValueStretch;

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (105693 => 105694)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2012-01-24 06:26:54 UTC (rev 105694)
@@ -1218,6 +1218,9 @@
     case PackJustify:
         m_value.ident = CSSValueJustify;
         break;
+    case PackDistribute:
+        m_value.ident = CSSValueDistribute;
+        break;
     }
 }
 
@@ -1232,6 +1235,8 @@
         return PackCenter;
     case CSSValueJustify:
         return PackJustify;
+    case CSSValueDistribute:
+        return PackDistribute;
     default:
         ASSERT_NOT_REACHED();
         return PackStart;

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (105693 => 105694)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2012-01-24 06:26:54 UTC (rev 105694)
@@ -492,6 +492,13 @@
 // baseline
 // stretch
 
+// CSS_PROP_FLEX_PACK
+// start
+// end
+// center
+// justify
+distribute
+
 // CSS_PROP_FLEX_FLOW
 row
 row-reverse

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (105693 => 105694)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-01-24 06:26:54 UTC (rev 105694)
@@ -573,21 +573,27 @@
     return availableFreeSpace > 0 && !totalPositiveFlexibility;
 }
 
-static LayoutUnit initialPackingOffset(LayoutUnit availableFreeSpace, float totalPositiveFlexibility, EFlexPack flexPack)
+static LayoutUnit initialPackingOffset(LayoutUnit availableFreeSpace, float totalPositiveFlexibility, EFlexPack flexPack, size_t numberOfChildren)
 {
     if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility)) {
         if (flexPack == PackEnd)
             return availableFreeSpace;
         if (flexPack == PackCenter)
             return availableFreeSpace / 2;
+        if (flexPack == PackDistribute && numberOfChildren)
+            return availableFreeSpace / (2 * numberOfChildren);
     }
     return 0;
 }
 
 static LayoutUnit packingSpaceBetweenChildren(LayoutUnit availableFreeSpace, float totalPositiveFlexibility, EFlexPack flexPack, size_t numberOfChildren)
 {
-    if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && flexPack == PackJustify && numberOfChildren > 1)
-        return availableFreeSpace / (numberOfChildren - 1);
+    if (hasPackingSpace(availableFreeSpace, totalPositiveFlexibility) && numberOfChildren > 1) {
+        if (flexPack == PackJustify)
+            return availableFreeSpace / (numberOfChildren - 1);
+        if (flexPack == PackDistribute)
+            return availableFreeSpace / numberOfChildren;
+    }
     return 0;
 }
 
@@ -629,7 +635,7 @@
 void RenderFlexibleBox::layoutAndPlaceChildren(FlexOrderIterator& iterator, const WTF::Vector<LayoutUnit>& childSizes, LayoutUnit availableFreeSpace, float totalPositiveFlexibility)
 {
     LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart();
-    mainAxisOffset += initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack());
+    mainAxisOffset += initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack(), childSizes.size());
 
     LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
     LayoutUnit totalMainExtent = mainAxisExtent();
@@ -692,7 +698,7 @@
     // starting from the end of the flexbox. We also don't need to layout anything since we're
     // just moving the children to a new position.
     LayoutUnit mainAxisOffset = logicalHeight() - flowAwareBorderEnd() - flowAwarePaddingEnd();
-    mainAxisOffset -= initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack());
+    mainAxisOffset -= initialPackingOffset(availableFreeSpace, totalPositiveFlexibility, style()->flexPack(), childSizes.size());
 
     LayoutUnit crossAxisOffset = flowAwareBorderBefore() + flowAwarePaddingBefore();
     size_t i = 0;

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (105693 => 105694)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2012-01-24 06:26:54 UTC (rev 105694)
@@ -176,7 +176,7 @@
 
 // CSS3 Flexbox Properties
 
-enum EFlexPack { PackStart, PackEnd, PackCenter, PackJustify };
+enum EFlexPack { PackStart, PackEnd, PackCenter, PackJustify, PackDistribute };
 enum EFlexAlign { AlignAuto, AlignStart, AlignEnd, AlignCenter, AlignStretch, AlignBaseline };
 enum EFlexDirection { FlowRow, FlowRowReverse, FlowColumn, FlowColumnReverse };
 enum EFlexWrap { FlexNoWrap, FlexWrap, FlexWrapReverse };

Modified: trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h (105693 => 105694)


--- trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h	2012-01-24 05:44:22 UTC (rev 105693)
+++ trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h	2012-01-24 06:26:54 UTC (rev 105694)
@@ -49,7 +49,7 @@
 
     int m_flexOrder;
 
-    unsigned m_flexPack : 2; // EFlexPack
+    unsigned m_flexPack : 3; // EFlexPack
     unsigned m_flexAlign : 3; // EFlexAlign
     unsigned m_flexItemAlign : 3; // EFlexAlign
     unsigned m_flexDirection : 2; // EFlexDirection
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to