Title: [93551] trunk
Revision
93551
Author
t...@chromium.org
Date
2011-08-22 15:20:17 -0700 (Mon, 22 Aug 2011)

Log Message

Add CSS parsing of -webkit-flex-pack
https://bugs.webkit.org/show_bug.cgi?id=66701

Reviewed by Eric Seidel.

Source/WebCore:

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EFlexPack):
* css/CSSPropertyNames.in:
* css/CSSStyleApplyProperty.cpp:
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::flexPack):
(WebCore::InheritedFlags::setFlexPack):
(WebCore::InheritedFlags::initialFlexPack):
* rendering/style/RenderStyleConstants.h:
* rendering/style/StyleFlexibleBoxData.cpp:
(WebCore::StyleFlexibleBoxData::StyleFlexibleBoxData):
(WebCore::StyleFlexibleBoxData::operator==):
* rendering/style/StyleFlexibleBoxData.h:

LayoutTests:

* css3/flexbox/css-properties-expected.txt:
* css3/flexbox/script-tests/css-properties.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (93550 => 93551)


--- trunk/LayoutTests/ChangeLog	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/LayoutTests/ChangeLog	2011-08-22 22:20:17 UTC (rev 93551)
@@ -1,3 +1,13 @@
+2011-08-22  Tony Chang  <t...@chromium.org>
+
+        Add CSS parsing of -webkit-flex-pack
+        https://bugs.webkit.org/show_bug.cgi?id=66701
+
+        Reviewed by Eric Seidel.
+
+        * css3/flexbox/css-properties-expected.txt:
+        * css3/flexbox/script-tests/css-properties.js:
+
 2011-08-22  Ryosuke Niwa  <rn...@webkit.org>
 
         Add editing/selection/caret-at-bidi-boundary.html back to the Qt's skipped list

Modified: trunk/LayoutTests/css3/flexbox/css-properties-expected.txt (93550 => 93551)


--- trunk/LayoutTests/css3/flexbox/css-properties-expected.txt	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/LayoutTests/css3/flexbox/css-properties-expected.txt	2011-08-22 22:20:17 UTC (rev 93551)
@@ -3,11 +3,11 @@
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS div.style.display is "-webkit-flexbox"
-PASS div.style.display is "inline"
-PASS div.style.display is "-webkit-inline-flexbox"
-PASS div.style.display is "-webkit-inline-flexbox"
-PASS div.style.display is "block"
+PASS flexbox.style.display is "-webkit-flexbox"
+PASS flexbox.style.display is "inline"
+PASS flexbox.style.display is "-webkit-inline-flexbox"
+PASS flexbox.style.display is "-webkit-inline-flexbox"
+PASS flexbox.style.display is "block"
 PASS flexitem.style.webkitFlexOrder is ""
 PASS flexitem.style.webkitFlexOrder is "2"
 PASS flexitem.style.webkitFlexOrder is "-1"
@@ -15,6 +15,19 @@
 PASS flexitem.style.webkitFlexOrder is "0"
 PASS flexitem.style.webkitFlexOrder is "0"
 PASS flexitem.style.webkitFlexOrder is ""
+PASS flexbox.style.webkitFlexPack is ""
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "start"
+PASS flexbox.style.webkitFlexPack is ""
+PASS flexbox.style.webkitFlexPack is "start"
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "start"
+PASS flexbox.style.webkitFlexPack is "end"
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "end"
+PASS flexbox.style.webkitFlexPack is "center"
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "center"
+PASS flexbox.style.webkitFlexPack is "justify"
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "justify"
+PASS flexbox.style.webkitFlexPack is ""
+PASS window.getComputedStyle(flexbox, null).webkitFlexPack is "start"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/css3/flexbox/script-tests/css-properties.js (93550 => 93551)


--- trunk/LayoutTests/css3/flexbox/script-tests/css-properties.js	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/LayoutTests/css3/flexbox/script-tests/css-properties.js	2011-08-22 22:20:17 UTC (rev 93551)
@@ -1,22 +1,23 @@
 description('Tests being able to set the display to -webkit-flexbox and -webkit-inline-flexbox.');
 
-var div = document.getElementById("flexbox");
+var flexbox = document.getElementById("flexbox");
 
-div.style.display = '-webkit-flexbox';
-shouldBeEqualToString('div.style.display', '-webkit-flexbox');
+flexbox.style.display = '-webkit-flexbox';
+shouldBeEqualToString('flexbox.style.display', '-webkit-flexbox');
 
-div.style.display = 'inline';
-shouldBeEqualToString('div.style.display', 'inline');
+flexbox.style.display = 'inline';
+shouldBeEqualToString('flexbox.style.display', 'inline');
 
-div.style.display = '-webkit-inline-flexbox';
-shouldBeEqualToString('div.style.display', '-webkit-inline-flexbox');
+flexbox.style.display = '-webkit-inline-flexbox';
+shouldBeEqualToString('flexbox.style.display', '-webkit-inline-flexbox');
 
-div.style.display = 'junk';
-shouldBeEqualToString('div.style.display', '-webkit-inline-flexbox');
+flexbox.style.display = 'junk';
+shouldBeEqualToString('flexbox.style.display', '-webkit-inline-flexbox');
 
-div.style.display = 'block';
-shouldBeEqualToString('div.style.display', 'block');
+flexbox.style.display = 'block';
+shouldBeEqualToString('flexbox.style.display', 'block');
 
+
 var flexitem = document.getElementById("flexitem");
 shouldBeEqualToString('flexitem.style.webkitFlexOrder', '');
 
@@ -39,4 +40,32 @@
 flexitem.style.webkitFlexOrder = '';
 shouldBeEqualToString('flexitem.style.webkitFlexOrder', '');
 
+
+shouldBeEqualToString('flexbox.style.webkitFlexPack', '');
+// The initial value is 'start'.
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'start');
+
+flexbox.style.webkitFlexPack = 'foo';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', '');
+
+flexbox.style.webkitFlexPack = 'start';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', 'start');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'start');
+
+flexbox.style.webkitFlexPack = 'end';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', 'end');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'end');
+
+flexbox.style.webkitFlexPack = 'center';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', 'center');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'center');
+
+flexbox.style.webkitFlexPack = 'justify';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', 'justify');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'justify');
+
+flexbox.style.webkitFlexPack = '';
+shouldBeEqualToString('flexbox.style.webkitFlexPack', '');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'start');
+
 successfullyParsed = true;

Modified: trunk/Source/WebCore/ChangeLog (93550 => 93551)


--- trunk/Source/WebCore/ChangeLog	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/ChangeLog	2011-08-22 22:20:17 UTC (rev 93551)
@@ -1,5 +1,34 @@
 2011-08-22  Tony Chang  <t...@chromium.org>
 
+        Add CSS parsing of -webkit-flex-pack
+        https://bugs.webkit.org/show_bug.cgi?id=66701
+
+        Reviewed by Eric Seidel.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EFlexPack):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::flexPack):
+        (WebCore::InheritedFlags::setFlexPack):
+        (WebCore::InheritedFlags::initialFlexPack):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleFlexibleBoxData.cpp:
+        (WebCore::StyleFlexibleBoxData::StyleFlexibleBoxData):
+        (WebCore::StyleFlexibleBoxData::operator==):
+        * rendering/style/StyleFlexibleBoxData.h:
+
+2011-08-22  Tony Chang  <t...@chromium.org>
+
         handle child margin values when flexing
         https://bugs.webkit.org/show_bug.cgi?id=65887
 

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (93550 => 93551)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2011-08-22 22:20:17 UTC (rev 93551)
@@ -201,6 +201,7 @@
 #endif
 #if ENABLE(CSS3_FLEXBOX)
     CSSPropertyWebkitFlexOrder,
+    CSSPropertyWebkitFlexPack,
 #endif
     CSSPropertyWebkitFontSmoothing,
     CSSPropertyWebkitHighlight,
@@ -1105,6 +1106,8 @@
 #if ENABLE(CSS3_FLEXBOX)
         case CSSPropertyWebkitFlexOrder:
             return primitiveValueCache->createValue(style->flexOrder(), CSSPrimitiveValue::CSS_NUMBER);
+        case CSSPropertyWebkitFlexPack:
+            return primitiveValueCache->createValue(style->flexPack());
 #endif
         case CSSPropertyFloat:
             return primitiveValueCache->createValue(style->floating());

Modified: trunk/Source/WebCore/css/CSSParser.cpp (93550 => 93551)


--- trunk/Source/WebCore/css/CSSParser.cpp	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2011-08-22 22:20:17 UTC (rev 93551)
@@ -1540,6 +1540,9 @@
     case CSSPropertyWebkitFlexOrder:
         validPrimitive = validUnit(value, FInteger, true);
         break;
+    case CSSPropertyWebkitFlexPack:
+        validPrimitive = id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || id == CSSValueJustify;
+        break;
 #endif
     case CSSPropertyWebkitMarquee: {
         const int properties[5] = { CSSPropertyWebkitMarqueeDirection, CSSPropertyWebkitMarqueeIncrement,

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (93550 => 93551)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2011-08-22 22:20:17 UTC (rev 93551)
@@ -1035,6 +1035,43 @@
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexPack e)
+    : m_type(CSS_IDENT)
+    , m_hasCachedCSSText(false)
+{
+    switch (e) {
+    case PackStart:
+        m_value.ident = CSSValueStart;
+        break;
+    case PackEnd:
+        m_value.ident = CSSValueEnd;
+        break;
+    case PackCenter:
+        m_value.ident = CSSValueCenter;
+        break;
+    case PackJustify:
+        m_value.ident = CSSValueJustify;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EFlexPack() const
+{
+    switch (m_value.ident) {
+    case CSSValueStart:
+        return PackStart;
+    case CSSValueEnd:
+        return PackEnd;
+    case CSSValueCenter:
+        return PackCenter;
+    case CSSValueJustify:
+        return PackJustify;
+    default:
+        ASSERT_NOT_REACHED();
+        return PackStart;
+    }
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFloat e)
     : m_type(CSS_IDENT)
     , m_hasCachedCSSText(false)

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (93550 => 93551)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2011-08-22 22:20:17 UTC (rev 93551)
@@ -244,6 +244,7 @@
 -webkit-columns
 #if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX
 -webkit-flex-order
+-webkit-flex-pack
 #endif
 -webkit-font-size-delta
 -webkit-highlight

Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (93550 => 93551)


--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp	2011-08-22 22:20:17 UTC (rev 93551)
@@ -891,6 +891,7 @@
 
 #if ENABLE(CSS3_FLEXBOX)
     setPropertyHandler(CSSPropertyWebkitFlexOrder, new ApplyPropertyDefault<int>(&RenderStyle::flexOrder, &RenderStyle::setFlexOrder, &RenderStyle::initialFlexOrder));
+    setPropertyHandler(CSSPropertyWebkitFlexPack, new ApplyPropertyDefault<EFlexPack>(&RenderStyle::flexPack, &RenderStyle::setFlexPack, &RenderStyle::initialFlexPack));
 #endif
 
     setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));

Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (93550 => 93551)


--- trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp	2011-08-22 22:20:17 UTC (rev 93551)
@@ -5112,6 +5112,7 @@
     case CSSPropertyWordSpacing:
 #if ENABLE(CSS3_FLEXBOX)
     case CSSPropertyWebkitFlexOrder:
+    case CSSPropertyWebkitFlexPack:
 #endif
     case CSSPropertyFontStyle:
     case CSSPropertyFontVariant:

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (93550 => 93551)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2011-08-22 22:20:17 UTC (rev 93551)
@@ -677,6 +677,7 @@
     float flexboxHeightPositiveFlex() const { return rareNonInheritedData->m_flexibleBox->m_heightPositiveFlex; }
     float flexboxHeightNegativeFlex() const { return rareNonInheritedData->m_flexibleBox->m_heightNegativeFlex; }
     int flexOrder() const { return rareNonInheritedData->m_flexibleBox->m_flexOrder; }
+    EFlexPack flexPack() const { return static_cast<EFlexPack>(rareNonInheritedData->m_flexibleBox->m_flexPack); }
 #endif
 
     const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
@@ -1062,6 +1063,7 @@
     void setFlexboxHeightPositiveFlex(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_heightPositiveFlex, f); }
     void setFlexboxHeightNegativeFlex(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_heightNegativeFlex, f); }
     void setFlexOrder(int o) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexOrder, o); }
+    void setFlexPack(EFlexPack p) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexPack, p); }
 #endif
     void setMarqueeIncrement(const Length& f) { SET_VAR(rareNonInheritedData.access()->m_marquee, increment, f); }
     void setMarqueeSpeed(int f) { SET_VAR(rareNonInheritedData.access()->m_marquee, speed, f); }
@@ -1317,6 +1319,7 @@
     static float initialFlexboxHeightPositiveFlex() { return 0; }
     static float initialFlexboxHeightNegativeFlex() { return 0; }
     static int initialFlexOrder() { return 1; }
+    static EFlexPack initialFlexPack() { return PackStart; }
     static int initialMarqueeLoopCount() { return -1; }
     static int initialMarqueeSpeed() { return 85; }
     static Length initialMarqueeIncrement() { return Length(6, Fixed); }

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (93550 => 93551)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2011-08-22 22:20:17 UTC (rev 93551)
@@ -159,13 +159,17 @@
 enum EMarqueeBehavior { MNONE, MSCROLL, MSLIDE, MALTERNATE };
 enum EMarqueeDirection { MAUTO = 0, MLEFT = 1, MRIGHT = -1, MUP = 2, MDOWN = -2, MFORWARD = 3, MBACKWARD = -3 };
 
-// CSS3 Flexible Box Properties
+// Deprecated Flexible Box Properties
 
 enum EBoxAlignment { BSTRETCH, BSTART, BCENTER, BEND, BJUSTIFY, BBASELINE };
 enum EBoxOrient { HORIZONTAL, VERTICAL };
 enum EBoxLines { SINGLE, MULTIPLE };
 enum EBoxDirection { BNORMAL, BREVERSE };
 
+// CSS3 Flexbox Properties
+
+enum EFlexPack { PackStart, PackEnd, PackCenter, PackJustify };
+
 enum ETextSecurity {
     TSNONE, TSDISC, TSCIRCLE, TSSQUARE
 };

Modified: trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp (93550 => 93551)


--- trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp	2011-08-22 22:20:17 UTC (rev 93551)
@@ -38,6 +38,7 @@
     , m_heightPositiveFlex(RenderStyle::initialFlexboxHeightPositiveFlex())
     , m_heightNegativeFlex(RenderStyle::initialFlexboxHeightNegativeFlex())
     , m_flexOrder(RenderStyle::initialFlexOrder())
+    , m_flexPack(RenderStyle::initialFlexPack())
 {
 }
 
@@ -48,6 +49,7 @@
     , m_heightPositiveFlex(o.m_heightPositiveFlex)
     , m_heightNegativeFlex(o.m_heightNegativeFlex)
     , m_flexOrder(o.m_flexOrder)
+    , m_flexPack(o.m_flexPack)
 {
 }
 
@@ -55,7 +57,7 @@
 {
     return m_widthPositiveFlex == o.m_widthPositiveFlex && m_widthNegativeFlex == o.m_widthNegativeFlex
         && m_heightPositiveFlex == o.m_heightPositiveFlex && m_heightNegativeFlex == o.m_heightNegativeFlex
-        && m_flexOrder == o.m_flexOrder;
+        && m_flexOrder == o.m_flexOrder && m_flexPack == o.m_flexPack;
 }
 
 }

Modified: trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h (93550 => 93551)


--- trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h	2011-08-22 22:08:33 UTC (rev 93550)
+++ trunk/Source/WebCore/rendering/style/StyleFlexibleBoxData.h	2011-08-22 22:20:17 UTC (rev 93551)
@@ -51,6 +51,8 @@
 
     int m_flexOrder;
 
+    unsigned m_flexPack : 2; // EFlexPack
+
 private:
     StyleFlexibleBoxData();
     StyleFlexibleBoxData(const StyleFlexibleBoxData&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to