Commit 3d0dad09 authored by tony@chromium.org's avatar tony@chromium.org

Add CSS parsing for -webkit-flex-align

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: http://svn.webkit.org/repository/webkit/trunk@93908 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5b5a87fa
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.
......@@ -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
......
......@@ -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;
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
......@@ -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());
......
......@@ -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,
......
......@@ -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)
......
......@@ -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
......
......@@ -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));
......
......@@ -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:
......
......@@ -471,6 +471,13 @@ block-axis
single
multiple
// CSS_PROP_FLEX_ALIGN
before
after
// middle
// stretch
// baseline
// CSS_PROP_MARQUEE_DIRECTION
forwards
backwards
......
......@@ -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); }
......
......@@ -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
......
......@@ -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;
}
}
......
......@@ -52,6 +52,7 @@ public:
int m_flexOrder;
unsigned m_flexPack : 2; // EFlexPack
unsigned m_flexAlign : 3; // EFlexAlign
private:
StyleFlexibleBoxData();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment