Add CSS parsing for -webkit-flex-align
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 20:42:27 +0000 (20:42 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Aug 2011 20:42:27 +0000 (20:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=66726

Reviewed by Ojan Vafai.

Source/WebCore:

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator EFlexAlign):
* css/CSSPropertyNames.in:
* css/CSSStyleApplyProperty.cpp:
(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):
* css/CSSValueKeywords.in:
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::flexAlign):
(WebCore::InheritedFlags::setFlexAlign):
(WebCore::InheritedFlags::initialFlexAlign):
* 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:

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

15 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/flexbox/css-properties-expected.txt
LayoutTests/css3/flexbox/script-tests/css-properties.js
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleApplyProperty.cpp
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/RenderStyleConstants.h
Source/WebCore/rendering/style/StyleFlexibleBoxData.cpp
Source/WebCore/rendering/style/StyleFlexibleBoxData.h

index 6509113..3d417ef 100644 (file)
@@ -1,3 +1,13 @@
+2011-08-26  Tony Chang  <tony@chromium.org>
+
+        Add CSS parsing for -webkit-flex-align
+        https://bugs.webkit.org/show_bug.cgi?id=66726
+
+        Reviewed by Ojan Vafai.
+
+        * css3/flexbox/css-properties-expected.txt:
+        * css3/flexbox/script-tests/css-properties.js:
+
 2011-08-26  Martin Robinson  <mrobinson@igalia.com>
 
         Skip two tests on GTK+ that are failing due to known issues.
index 0b64556..acbada5 100644 (file)
@@ -28,6 +28,21 @@ 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 flexbox.style.webkitFlexAlign is ""
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "stretch"
+PASS flexbox.style.webkitFlexAlign is ""
+PASS flexbox.style.webkitFlexAlign is "before"
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "before"
+PASS flexbox.style.webkitFlexAlign is "after"
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "after"
+PASS flexbox.style.webkitFlexAlign is "middle"
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "middle"
+PASS flexbox.style.webkitFlexAlign is "stretch"
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "stretch"
+PASS flexbox.style.webkitFlexAlign is "baseline"
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "baseline"
+PASS flexbox.style.webkitFlexAlign is ""
+PASS window.getComputedStyle(flexbox, null).webkitFlexAlign is "stretch"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 7b32cbe..da73c96 100644 (file)
@@ -68,4 +68,36 @@ flexbox.style.webkitFlexPack = '';
 shouldBeEqualToString('flexbox.style.webkitFlexPack', '');
 shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexPack', 'start');
 
+
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', '');
+// The initial value is 'stretch'.
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'stretch');
+
+flexbox.style.webkitFlexAlign = 'foo';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', '');
+
+flexbox.style.webkitFlexAlign = 'before';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', 'before');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'before');
+
+flexbox.style.webkitFlexAlign = 'after';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', 'after');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'after');
+
+flexbox.style.webkitFlexAlign = 'middle';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', 'middle');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'middle');
+
+flexbox.style.webkitFlexAlign = 'stretch';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', 'stretch');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'stretch');
+
+flexbox.style.webkitFlexAlign = 'baseline';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', 'baseline');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'baseline');
+
+flexbox.style.webkitFlexAlign = '';
+shouldBeEqualToString('flexbox.style.webkitFlexAlign', '');
+shouldBeEqualToString('window.getComputedStyle(flexbox, null).webkitFlexAlign', 'stretch');
+
 successfullyParsed = true;
index d0cb829..803408b 100644 (file)
@@ -1,3 +1,33 @@
+2011-08-26  Tony Chang  <tony@chromium.org>
+
+        Add CSS parsing for -webkit-flex-align
+        https://bugs.webkit.org/show_bug.cgi?id=66726
+
+        Reviewed by Ojan Vafai.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator EFlexAlign):
+        * css/CSSPropertyNames.in:
+        * css/CSSStyleApplyProperty.cpp:
+        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+        * css/CSSValueKeywords.in:
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::flexAlign):
+        (WebCore::InheritedFlags::setFlexAlign):
+        (WebCore::InheritedFlags::initialFlexAlign):
+        * rendering/style/RenderStyleConstants.h:
+        * rendering/style/StyleFlexibleBoxData.cpp:
+        (WebCore::StyleFlexibleBoxData::StyleFlexibleBoxData):
+        (WebCore::StyleFlexibleBoxData::operator==):
+        * rendering/style/StyleFlexibleBoxData.h:
+
 2011-08-26  Nate Chapin  <japhet@chromium.org>
 
         Fix http/tests/misc/willCacheResponse-delegate-callback.html
index 81c68c7..4c1b6f0 100644 (file)
@@ -202,6 +202,7 @@ static const int computedProperties[] = {
 #if ENABLE(CSS3_FLEXBOX)
     CSSPropertyWebkitFlexOrder,
     CSSPropertyWebkitFlexPack,
+    CSSPropertyWebkitFlexAlign,
 #endif
     CSSPropertyWebkitFontSmoothing,
     CSSPropertyWebkitHighlight,
@@ -1108,6 +1109,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return primitiveValueCache->createValue(style->flexOrder(), CSSPrimitiveValue::CSS_NUMBER);
         case CSSPropertyWebkitFlexPack:
             return primitiveValueCache->createValue(style->flexPack());
+        case CSSPropertyWebkitFlexAlign:
+            return primitiveValueCache->createValue(style->flexAlign());
 #endif
         case CSSPropertyFloat:
             return primitiveValueCache->createValue(style->floating());
index d6f4277..2b72054 100644 (file)
@@ -1543,6 +1543,9 @@ bool CSSParser::parseValue(int propId, bool important)
     case CSSPropertyWebkitFlexPack:
         validPrimitive = id == CSSValueStart || id == CSSValueEnd || id == CSSValueCenter || id == CSSValueJustify;
         break;
+    case CSSPropertyWebkitFlexAlign:
+        validPrimitive = id == CSSValueBefore || id == CSSValueAfter || id == CSSValueMiddle || id == CSSValueBaseline || id == CSSValueStretch;
+        break;
 #endif
     case CSSPropertyWebkitMarquee: {
         const int properties[5] = { CSSPropertyWebkitMarqueeDirection, CSSPropertyWebkitMarqueeIncrement,
index 23241d9..43b4b00 100644 (file)
@@ -1063,6 +1063,48 @@ template<> inline CSSPrimitiveValue::operator EEmptyCell() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexAlign e)
+    : m_type(CSS_IDENT)
+    , m_hasCachedCSSText(false)
+{
+    switch (e) {
+    case AlignBefore:
+        m_value.ident = CSSValueBefore;
+        break;
+    case AlignAfter:
+        m_value.ident = CSSValueAfter;
+        break;
+    case AlignMiddle:
+        m_value.ident = CSSValueMiddle;
+        break;
+    case AlignStretch:
+        m_value.ident = CSSValueStretch;
+        break;
+    case AlignBaseline:
+        m_value.ident = CSSValueBaseline;
+        break;
+    }
+}
+
+template<> inline CSSPrimitiveValue::operator EFlexAlign() const
+{
+    switch (m_value.ident) {
+    case CSSValueBefore:
+        return AlignBefore;
+    case CSSValueAfter:
+        return AlignAfter;
+    case CSSValueMiddle:
+        return AlignMiddle;
+    case CSSValueStretch:
+        return AlignStretch;
+    case CSSValueBaseline:
+        return AlignBaseline;
+    default:
+        ASSERT_NOT_REACHED();
+        return AlignBefore;
+    }
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EFlexPack e)
     : m_type(CSS_IDENT)
     , m_hasCachedCSSText(false)
index eedbc0d..353a307 100644 (file)
@@ -243,6 +243,7 @@ z-index
 -webkit-column-width
 -webkit-columns
 #if defined(ENABLE_CSS3_FLEXBOX) && ENABLE_CSS3_FLEXBOX
+-webkit-flex-align
 -webkit-flex-order
 -webkit-flex-pack
 #endif
index b3b7237..8278363 100644 (file)
@@ -987,6 +987,7 @@ CSSStyleApplyProperty::CSSStyleApplyProperty()
 #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));
+    setPropertyHandler(CSSPropertyWebkitFlexAlign, new ApplyPropertyDefault<EFlexAlign>(&RenderStyle::flexAlign, &RenderStyle::setFlexAlign, &RenderStyle::initialFlexAlign));
 #endif
 
     setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));
index dcbfeb6..0845b7a 100644 (file)
@@ -4977,6 +4977,7 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
 #if ENABLE(CSS3_FLEXBOX)
     case CSSPropertyWebkitFlexOrder:
     case CSSPropertyWebkitFlexPack:
+    case CSSPropertyWebkitFlexAlign:
 #endif
     case CSSPropertyFontStyle:
     case CSSPropertyFontVariant:
index 637eefd..0889adb 100644 (file)
@@ -471,6 +471,13 @@ block-axis
 single
 multiple
 
+// CSS_PROP_FLEX_ALIGN
+before
+after
+// middle
+// stretch
+// baseline
+
 // CSS_PROP_MARQUEE_DIRECTION
 forwards
 backwards
index 6bae685..4c8ab7f 100644 (file)
@@ -679,6 +679,7 @@ public:
     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); }
+    EFlexAlign flexAlign() const { return static_cast<EFlexAlign>(rareNonInheritedData->m_flexibleBox->m_flexAlign); }
 #endif
 
     const ShadowData* boxShadow() const { return rareNonInheritedData->m_boxShadow.get(); }
@@ -1065,6 +1066,7 @@ public:
     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); }
+    void setFlexAlign(EFlexAlign a) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexAlign, a); }
 #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); }
@@ -1345,6 +1347,7 @@ public:
     static float initialFlexboxHeightNegativeFlex() { return 0; }
     static int initialFlexOrder() { return 1; }
     static EFlexPack initialFlexPack() { return PackStart; }
+    static EFlexAlign initialFlexAlign() { return AlignStretch; }
     static int initialMarqueeLoopCount() { return -1; }
     static int initialMarqueeSpeed() { return 85; }
     static Length initialMarqueeIncrement() { return Length(6, Fixed); }
index 4c98f01..e041944 100644 (file)
@@ -169,6 +169,7 @@ enum EBoxDirection { BNORMAL, BREVERSE };
 // CSS3 Flexbox Properties
 
 enum EFlexPack { PackStart, PackEnd, PackCenter, PackJustify };
+enum EFlexAlign { AlignBefore, AlignAfter, AlignMiddle, AlignStretch, AlignBaseline };
 
 enum ETextSecurity {
     TSNONE, TSDISC, TSCIRCLE, TSSQUARE
index 4bbb06f..416934f 100644 (file)
@@ -39,6 +39,7 @@ StyleFlexibleBoxData::StyleFlexibleBoxData()
     , m_heightNegativeFlex(RenderStyle::initialFlexboxHeightNegativeFlex())
     , m_flexOrder(RenderStyle::initialFlexOrder())
     , m_flexPack(RenderStyle::initialFlexPack())
+    , m_flexAlign(RenderStyle::initialFlexAlign())
 {
 }
 
@@ -50,6 +51,7 @@ StyleFlexibleBoxData::StyleFlexibleBoxData(const StyleFlexibleBoxData& o)
     , m_heightNegativeFlex(o.m_heightNegativeFlex)
     , m_flexOrder(o.m_flexOrder)
     , m_flexPack(o.m_flexPack)
+    , m_flexAlign(o.m_flexAlign)
 {
 }
 
@@ -57,7 +59,7 @@ bool StyleFlexibleBoxData::operator==(const StyleFlexibleBoxData& o) const
 {
     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_flexPack == o.m_flexPack;
+        && m_flexOrder == o.m_flexOrder && m_flexPack == o.m_flexPack && m_flexAlign == o.m_flexAlign;
 }
 
 }
index 5271cc4..cf97658 100644 (file)
@@ -52,6 +52,7 @@ public:
     int m_flexOrder;
 
     unsigned m_flexPack : 2; // EFlexPack
+    unsigned m_flexAlign : 3; // EFlexAlign
 
 private:
     StyleFlexibleBoxData();