Changeset 121380 in webkit


Ignore:
Timestamp:
Jun 27, 2012 4:05:19 PM (12 years ago)
Author:
tony@chromium.org
Message:

Split flex into flex-grow/flex-shrink/flex-basis
https://bugs.webkit.org/show_bug.cgi?id=86525

Reviewed by Ojan Vafai.

Source/WebCore:

Split flex into 3 separate properties per the spec:
http://dev.w3.org/csswg/css3-flexbox/#flex-components

Tests: css3/flexbox/flex-longhand-parsing.html

css3/flexbox/flex-property-parsing.html: Updated test results.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore): -webkit-flex is no longer enumerable.
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Add new css property names and use
getCSSPropertyValuesForShorthandProperties for WebkitFlex. Also sort flex propery names.

  • css/CSSParser.cpp:

(WebCore::isValidKeywordPropertyAndValue): Fix indent.
(WebCore::CSSParser::parseValue): Add parsing for new properties and handle -webkit-flex: none.
(WebCore::CSSParser::parseFlex): Switch to new names (positive -> grow, negative -> shrink,
preferred size -> basis) and assign to longhand properties.

  • css/CSSParser.h:
  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty): Add new properties.

  • css/CSSPropertyNames.in: Add new properties.
  • css/StyleBuilder.cpp:

(WebCore::StyleBuilder::StyleBuilder): Delete special handling of applying flex and just use shorthand handlers.

  • css/StylePropertySet.cpp:

(WebCore::StylePropertySet::getPropertyValue): Add new shorthand.
(WebCore::StylePropertySet::asText):

  • css/StylePropertyShorthand.cpp:

(WebCore::webkitFlexShorthand): Add new shorthand.
(WebCore::shorthandForProperty):

  • css/StylePropertyShorthand.h:
  • css/StyleResolver.cpp:

(WebCore::StyleResolver::collectMatchingRulesForList): Add to list of properties applied by StyleBuilder.

LayoutTests:

If -webkit-flex is set to none, when the user reads the value back out, it is
now 0 0 auto. 'none' is for convenience, not an actual value.

  • css3/flexbox/flex-longhand-parsing-expected.txt:
  • css3/flexbox/flex-longhand-parsing.html: Test flex-grow, flex-shrink and flex-basis.
  • css3/flexbox/flex-property-parsing-expected.txt:
  • css3/flexbox/flex-property-parsing.html: Update results for 'none'.
  • fast/css/getComputedStyle/computed-style-expected.txt:
  • fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • fast/css/getComputedStyle/resources/property-names.js: Remove -webkit-flex since it's no longer enumerable.
  • svg/css/getComputedStyle-basic-expected.txt:
Location:
trunk
Files:
2 added
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r121376 r121380  
     12012-06-27  Tony Chang  <tony@chromium.org>
     2
     3        Split flex into flex-grow/flex-shrink/flex-basis
     4        https://bugs.webkit.org/show_bug.cgi?id=86525
     5
     6        Reviewed by Ojan Vafai.
     7
     8        If -webkit-flex is set to none, when the user reads the value back out, it is
     9        now 0 0 auto. 'none' is for convenience, not an actual value.
     10
     11        * css3/flexbox/flex-longhand-parsing-expected.txt:
     12        * css3/flexbox/flex-longhand-parsing.html: Test flex-grow, flex-shrink and flex-basis.
     13        * css3/flexbox/flex-property-parsing-expected.txt:
     14        * css3/flexbox/flex-property-parsing.html: Update results for 'none'.
     15        * fast/css/getComputedStyle/computed-style-expected.txt:
     16        * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     17        * fast/css/getComputedStyle/resources/property-names.js: Remove -webkit-flex since it's no longer enumerable.
     18        * svg/css/getComputedStyle-basic-expected.txt:
     19
    1202012-06-27  Erik Arvidsson  <arv@chromium.org>
    221
  • trunk/LayoutTests/css3/flexbox/flex-property-parsing-expected.txt

    r120100 r121380  
    2424PASS flexitem.style.webkitFlex is "0 1 0px"
    2525PASS getComputedStyle(flexitem).webkitFlex is "0 1 0px"
    26 PASS flexitem.style.webkitFlex is "none"
     26PASS flexitem.style.webkitFlex is "0 0 auto"
    2727PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    2828PASS flexitem.style.webkitFlex is "0 0 0px"
     
    4444PASS flexitem.style.webkitFlex is "0 1 0px"
    4545PASS getComputedStyle(flexitem).webkitFlex is "0 1 0px"
    46 PASS flexitem.style.webkitFlex is "none"
     46PASS flexitem.style.webkitFlex is "0 0 auto"
    4747PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    48 PASS flexitem.style.webkitFlex is "none"
     48PASS flexitem.style.webkitFlex is "0 0 auto"
    4949PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    50 PASS flexitem.style.webkitFlex is "none"
     50PASS flexitem.style.webkitFlex is "0 0 auto"
    5151PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    52 PASS flexitem.style.webkitFlex is "none"
     52PASS flexitem.style.webkitFlex is "0 0 auto"
    5353PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    54 PASS flexitem.style.webkitFlex is "none"
     54PASS flexitem.style.webkitFlex is "0 0 auto"
    5555PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    56 PASS flexitem.style.webkitFlex is "none"
     56PASS flexitem.style.webkitFlex is "0 0 auto"
    5757PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    5858PASS flexitem.style.webkitFlex is "1 2 0px"
     
    7878PASS flexitem.style.webkitFlex is "0 0 0px"
    7979PASS getComputedStyle(flexitem).webkitFlex is "0 0 0px"
    80 PASS flexitem.style.webkitFlex is "none"
     80PASS flexitem.style.webkitFlex is "0 0 auto"
    8181PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    82 PASS flexitem.style.webkitFlex is "none"
     82PASS flexitem.style.webkitFlex is "0 0 auto"
    8383PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    84 PASS flexitem.style.webkitFlex is "none"
     84PASS flexitem.style.webkitFlex is "0 0 auto"
    8585PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    86 PASS flexitem.style.webkitFlex is "none"
     86PASS flexitem.style.webkitFlex is "0 0 auto"
    8787PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    88 PASS flexitem.style.webkitFlex is "none"
     88PASS flexitem.style.webkitFlex is "0 0 auto"
    8989PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    90 PASS flexitem.style.webkitFlex is "none"
     90PASS flexitem.style.webkitFlex is "0 0 auto"
    9191PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    92 PASS flexitem.style.webkitFlex is "none"
     92PASS flexitem.style.webkitFlex is "0 0 auto"
    9393PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    94 PASS flexitem.style.webkitFlex is "none"
     94PASS flexitem.style.webkitFlex is "0 0 auto"
    9595PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    96 PASS flexitem.style.webkitFlex is "none"
     96PASS flexitem.style.webkitFlex is "0 0 auto"
    9797PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    98 PASS flexitem.style.webkitFlex is "none"
     98PASS flexitem.style.webkitFlex is "0 0 auto"
    9999PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    100 PASS flexitem.style.webkitFlex is "none"
     100PASS flexitem.style.webkitFlex is "0 0 auto"
    101101PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    102 PASS flexitem.style.webkitFlex is "none"
     102PASS flexitem.style.webkitFlex is "0 0 auto"
    103103PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    104 PASS flexitem.style.webkitFlex is "none"
     104PASS flexitem.style.webkitFlex is "0 0 auto"
    105105PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    106 PASS flexitem.style.webkitFlex is "none"
     106PASS flexitem.style.webkitFlex is "0 0 auto"
    107107PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    108108PASS flexitem.style.webkitFlex is "initial"
    109109PASS getComputedStyle(flexitem).webkitFlex is "0 1 auto"
    110 PASS flexitem.style.webkitFlex is "none"
     110FAIL flexitem.style.webkitFlex should be 0 0 auto. Was initial.
    111111PASS getComputedStyle(flexitem).webkitFlex is "0 0 auto"
    112112PASS successfullyParsed is true
  • trunk/LayoutTests/css3/flexbox/flex-property-parsing.html

    r120100 r121380  
    5858flexitem.style.webkitFlex = 'none';
    5959flexitem.style.webkitFlex = '-2'; // Invalid, return previous value.
    60 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     60shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    6161shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    6262
     
    9999flexitem.style.webkitFlex = 'none';
    100100flexitem.style.webkitFlex = '-1 5'; // Invalid, return previous value.
    101 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     101shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    102102shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    103103
    104104flexitem.style.webkitFlex = '1 -1'; // Invalid, return previous value.
    105 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     105shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    106106shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    107107
    108108flexitem.style.webkitFlex = '-1 -1'; // Invalid, return previous value.
    109 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     109shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    110110shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    111111
    112112flexitem.style.webkitFlex = 'auto 2em'; // Invalid, return previous value.
    113 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     113shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    114114shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    115115
    116116flexitem.style.webkitFlex = '2px 4px'; // Invalid, return previous value.
    117 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     117shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    118118shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    119119
    120120flexitem.style.webkitFlex = '0px 0px'; // Invalid, return previous value.
    121 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     121shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    122122shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    123123
     
    168168flexitem.style.webkitFlex = 'none';
    169169flexitem.style.webkitFlex = '1 2 3'; // Invalid, return previous value.
    170 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     170shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    171171shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    172172
    173173flexitem.style.webkitFlex = '0 2 3'; // Invalid, return previous value.
    174 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     174shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    175175shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    176176
    177177flexitem.style.webkitFlex = '1 0 3'; // Invalid, return previous value.
    178 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     178shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    179179shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    180180
    181181flexitem.style.webkitFlex = '0 0 1';  // Invalid, return previous value.
    182 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     182shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    183183shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    184184
    185185flexitem.style.webkitFlex = '1 -2 3px';  // Invalid, return previous value.
    186 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     186shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    187187shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    188188
    189189flexitem.style.webkitFlex = '1 2px 3px';  // Invalid, return previous value.
    190 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     190shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    191191shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    192192
    193193flexitem.style.webkitFlex = '1 2px auto';  // Invalid, return previous value.
    194 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     194shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    195195shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    196196
    197197flexitem.style.webkitFlex = '0px 0px 0';  // Invalid, return previous value.
    198 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     198shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    199199shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    200200
    201201flexitem.style.webkitFlex = '0 0 0 0';  // Invalid, return previous value.
    202 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     202shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    203203shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    204204
    205205flexitem.style.webkitFlex = '0 0 0px 0';  // Invalid, return previous value.
    206 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     206shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    207207shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    208208
    209209flexitem.style.webkitFlex = '0 0 0px 0px';  // Invalid, return previous value.
    210 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     210shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    211211shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    212212
    213213flexitem.style.webkitFlex = '0 0 0px 0';  // Invalid, return previous value.
    214 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     214shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    215215shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    216216
    217217flexitem.style.webkitFlex = '1, 2, 3px';  // Invalid, return previous value.
    218 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     218shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    219219shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    220220
    221221flexitem.style.webkitFlex = '1,';  // Invalid, return previous value.
    222 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     222shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    223223shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    224224
     
    228228
    229229flexitem.style.webkitFlex = 'none';
    230 shouldBeEqualToString('flexitem.style.webkitFlex', 'none');
     230// FIXME: This test case is failing. https://bugs.webkit.org/show_bug.cgi?id=90020
     231shouldBeEqualToString('flexitem.style.webkitFlex', '0 0 auto');
    231232shouldBeEqualToString('getComputedStyle(flexitem).webkitFlex', '0 0 auto');
    232233</script>
  • trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt

    r121026 r121380  
    147147-webkit-align-items: stretch;
    148148-webkit-align-self: stretch;
    149 -webkit-flex: 0 1 auto;
    150149-webkit-flex-direction: row;
    151150-webkit-flex-wrap: none;
  • trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r121026 r121380  
    146146-webkit-align-items: stretch
    147147-webkit-align-self: stretch
    148 -webkit-flex: 0 1 auto
    149148-webkit-flex-direction: row
    150149-webkit-flex-wrap: none
  • trunk/LayoutTests/fast/css/getComputedStyle/resources/property-names.js

    r121026 r121380  
    4545    "-webkit-column-span": true,
    4646    "-webkit-column-width": true,
    47     "-webkit-flex": true,
    4847    "-webkit-flex-direction": true,
    4948    "-webkit-flex-wrap": true,
  • trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt

    r121026 r121380  
    291291rect: style.getPropertyValue(-webkit-align-self) : stretch
    292292rect: style.getPropertyCSSValue(-webkit-align-self) : [object CSSPrimitiveValue]
    293 rect: style.getPropertyValue(-webkit-flex) : 0 1 auto
    294 rect: style.getPropertyCSSValue(-webkit-flex) : [object CSSValueList]
    295293rect: style.getPropertyValue(-webkit-flex-direction) : row
    296294rect: style.getPropertyCSSValue(-webkit-flex-direction) : [object CSSPrimitiveValue]
     
    795793g: style.getPropertyValue(-webkit-align-self) : stretch
    796794g: style.getPropertyCSSValue(-webkit-align-self) : [object CSSPrimitiveValue]
    797 g: style.getPropertyValue(-webkit-flex) : 0 1 auto
    798 g: style.getPropertyCSSValue(-webkit-flex) : [object CSSValueList]
    799795g: style.getPropertyValue(-webkit-flex-direction) : row
    800796g: style.getPropertyCSSValue(-webkit-flex-direction) : [object CSSPrimitiveValue]
  • trunk/Source/WebCore/ChangeLog

    r121379 r121380  
     12012-06-27  Tony Chang  <tony@chromium.org>
     2
     3        Split flex into flex-grow/flex-shrink/flex-basis
     4        https://bugs.webkit.org/show_bug.cgi?id=86525
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Split flex into 3 separate properties per the spec:
     9        http://dev.w3.org/csswg/css3-flexbox/#flex-components
     10
     11        Tests: css3/flexbox/flex-longhand-parsing.html
     12               css3/flexbox/flex-property-parsing.html: Updated test results.
     13
     14        * css/CSSComputedStyleDeclaration.cpp:
     15        (WebCore): -webkit-flex is no longer enumerable.
     16        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Add new css property names and use
     17        getCSSPropertyValuesForShorthandProperties for WebkitFlex. Also sort flex propery names.
     18        * css/CSSParser.cpp:
     19        (WebCore::isValidKeywordPropertyAndValue): Fix indent.
     20        (WebCore::CSSParser::parseValue): Add parsing for new properties and handle -webkit-flex: none.
     21        (WebCore::CSSParser::parseFlex): Switch to new names (positive -> grow, negative -> shrink,
     22        preferred size -> basis) and assign to longhand properties.
     23        * css/CSSParser.h:
     24        * css/CSSProperty.cpp:
     25        (WebCore::CSSProperty::isInheritedProperty): Add new properties.
     26        * css/CSSPropertyNames.in: Add new properties.
     27        * css/StyleBuilder.cpp:
     28        (WebCore::StyleBuilder::StyleBuilder): Delete special handling of applying flex and just use shorthand handlers.
     29        * css/StylePropertySet.cpp:
     30        (WebCore::StylePropertySet::getPropertyValue): Add new shorthand.
     31        (WebCore::StylePropertySet::asText):
     32        * css/StylePropertyShorthand.cpp:
     33        (WebCore::webkitFlexShorthand): Add new shorthand.
     34        (WebCore::shorthandForProperty):
     35        * css/StylePropertyShorthand.h:
     36        * css/StyleResolver.cpp:
     37        (WebCore::StyleResolver::collectMatchingRulesForList): Add to list of properties applied by StyleBuilder.
     38
    1392012-06-27  Kentaro Hara  <haraken@chromium.org>
    240
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r121123 r121380  
    238238    CSSPropertyWebkitAlignItems,
    239239    CSSPropertyWebkitAlignSelf,
    240     CSSPropertyWebkitFlex,
     240    CSSPropertyWebkitFlexBasis,
     241    CSSPropertyWebkitFlexGrow,
     242    CSSPropertyWebkitFlexShrink,
    241243    CSSPropertyWebkitFlexDirection,
    242244    CSSPropertyWebkitFlexWrap,
     
    16511653            return cssValuePool().createValue(style->emptyCells());
    16521654#if ENABLE(CSS3_FLEXBOX)
    1653         case CSSPropertyWebkitFlex: {
    1654             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    1655             list->append(cssValuePool().createValue(style->flexGrow()));
    1656             list->append(cssValuePool().createValue(style->flexShrink()));
    1657 
    1658             Length flexBasis = style->flexBasis();
    1659             if (flexBasis.isAuto())
    1660                 list->append(cssValuePool().createIdentifierValue(CSSValueAuto));
    1661             else if (flexBasis.isPercent())
    1662                 list->append(cssValuePool().createValue(flexBasis.value(), CSSPrimitiveValue::CSS_PERCENTAGE));
    1663             else
    1664                 list->append(cssValuePool().createValue(flexBasis.value(), CSSPrimitiveValue::CSS_PX));
    1665 
    1666             return list.release();
    1667         }
    1668         case CSSPropertyWebkitOrder:
    1669             return cssValuePool().createValue(style->order());
    1670         case CSSPropertyWebkitJustifyContent:
    1671             return cssValuePool().createValue(style->justifyContent());
     1655        case CSSPropertyWebkitAlignContent:
     1656            return cssValuePool().createValue(style->alignContent());
    16721657        case CSSPropertyWebkitAlignItems:
    16731658            return cssValuePool().createValue(style->alignItems());
     
    16791664            }
    16801665            return cssValuePool().createValue(style->alignSelf());
     1666        case CSSPropertyWebkitFlex:
     1667            return getCSSPropertyValuesForShorthandProperties(webkitFlexShorthand());
     1668        case CSSPropertyWebkitFlexBasis:
     1669            return cssValuePool().createValue(style->flexBasis());
    16811670        case CSSPropertyWebkitFlexDirection:
    16821671            return cssValuePool().createValue(style->flexDirection());
     1672        case CSSPropertyWebkitFlexFlow:
     1673            return getCSSPropertyValuesForShorthandProperties(webkitFlexFlowShorthand());
     1674        case CSSPropertyWebkitFlexGrow:
     1675            return cssValuePool().createValue(style->flexGrow());
     1676        case CSSPropertyWebkitFlexShrink:
     1677            return cssValuePool().createValue(style->flexShrink());
    16831678        case CSSPropertyWebkitFlexWrap:
    16841679            return cssValuePool().createValue(style->flexWrap());
    1685         case CSSPropertyWebkitAlignContent:
    1686             return cssValuePool().createValue(style->alignContent());
    1687         case CSSPropertyWebkitFlexFlow: {
    1688             RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
    1689             list->append(cssValuePool().createValue(style->flexDirection()));
    1690             list->append(cssValuePool().createValue(style->flexWrap()));
    1691             return list.release();
    1692         }
     1680        case CSSPropertyWebkitJustifyContent:
     1681            return cssValuePool().createValue(style->justifyContent());
     1682        case CSSPropertyWebkitOrder:
     1683            return cssValuePool().createValue(style->order());
    16931684#endif
    16941685        case CSSPropertyFloat:
  • trunk/Source/WebCore/css/CSSParser.cpp

    r121311 r121380  
    717717    case CSSPropertyWebkitFlexDirection:
    718718        if (valueID == CSSValueRow || valueID == CSSValueRowReverse || valueID == CSSValueColumn || valueID == CSSValueColumnReverse)
    719                 return true;
     719            return true;
    720720        break;
    721721    case CSSPropertyWebkitFlexWrap:
     
    22762276#endif
    22772277#if ENABLE(CSS3_FLEXBOX)
    2278     case CSSPropertyWebkitFlex:
    2279         if (id == CSSValueNone)
     2278    case CSSPropertyWebkitFlex: {
     2279        ShorthandScope scope(this, propId);
     2280        if (id == CSSValueNone) {
     2281            addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important);
     2282            addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(0, CSSPrimitiveValue::CSS_NUMBER), important);
     2283            addProperty(CSSPropertyWebkitFlexBasis, cssValuePool().createIdentifierValue(CSSValueAuto), important);
     2284            return true;
     2285        }
     2286        return parseFlex(m_valueList.get(), important);
     2287    }
     2288    case CSSPropertyWebkitFlexBasis:
     2289        // FIXME: Support intrinsic dimensions too.
     2290        if (id == CSSValueAuto)
    22802291            validPrimitive = true;
    22812292        else
    2282             parsedValue = parseFlex(m_valueList.get());
     2293            validPrimitive = (!id && validUnit(value, FLength | FPercent | FNonNeg));
     2294        break;
     2295    case CSSPropertyWebkitFlexGrow:
     2296    case CSSPropertyWebkitFlexShrink:
     2297        validPrimitive = validUnit(value, FNumber | FNonNeg);
    22832298        break;
    22842299    case CSSPropertyWebkitOrder:
     
    57815796#if ENABLE(CSS3_FLEXBOX)
    57825797
    5783 PassRefPtr<CSSValue> CSSParser::parseFlex(CSSParserValueList* args)
     5798bool CSSParser::parseFlex(CSSParserValueList* args, bool important)
    57845799{
    57855800    if (!args || !args->size() || args->size() > 3)
    5786         return 0;
     5801        return false;
    57875802    static const double unsetValue = -1;
    5788     double positiveFlex = unsetValue;
    5789     double negativeFlex = unsetValue;
    5790     RefPtr<CSSPrimitiveValue> preferredSize;
     5803    double flexGrow = unsetValue;
     5804    double flexShrink = unsetValue;
     5805    RefPtr<CSSPrimitiveValue> flexBasis;
    57915806
    57925807    while (CSSParserValue* arg = args->current()) {
    57935808        if (validUnit(arg, FNumber | FNonNeg)) {
    5794             if (positiveFlex == unsetValue)
    5795                 positiveFlex = arg->fValue;
    5796             else if (negativeFlex == unsetValue)
    5797                 negativeFlex = arg->fValue;
     5809            if (flexGrow == unsetValue)
     5810                flexGrow = arg->fValue;
     5811            else if (flexShrink == unsetValue)
     5812                flexShrink = arg->fValue;
    57985813            else if (!arg->fValue) {
    5799                 // flex() only allows a preferred size of 0 (sans units) if the positive and negative flex values have already been set.
    5800                 preferredSize = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
     5814                // flex only allows a basis of 0 (sans units) if flex-grow and flex-shrink values have already been set.
     5815                flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
    58015816            } else {
    5802                 // We only allow 3 numbers without units if the last value is 0. E.g., flex(1 1 1) is invalid.
    5803                 return 0;
     5817                // We only allow 3 numbers without units if the last value is 0. E.g., flex:1 1 1 is invalid.
     5818                return false;
    58045819            }
    5805         } else if (!preferredSize && (arg->id == CSSValueAuto || validUnit(arg, FLength | FPercent | FNonNeg)))
    5806             preferredSize = parseValidPrimitive(arg->id, arg);
     5820        } else if (!flexBasis && (arg->id == CSSValueAuto || validUnit(arg, FLength | FPercent | FNonNeg)))
     5821            flexBasis = parseValidPrimitive(arg->id, arg);
    58075822        else {
    5808             // Not a valid arg for flex().
    5809             return 0;
     5823            // Not a valid arg for flex.
     5824            return false;
    58105825        }
    58115826        args->next();
    58125827    }
    58135828
    5814     if (positiveFlex == unsetValue)
    5815         positiveFlex = 0;
    5816     if (negativeFlex == unsetValue)
    5817         negativeFlex = 1;
    5818     if (!preferredSize)
    5819         preferredSize = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
    5820 
    5821     RefPtr<CSSValueList> flex = CSSValueList::createSpaceSeparated();
    5822     flex->append(cssValuePool().createValue(clampToFloat(positiveFlex), CSSPrimitiveValue::CSS_NUMBER));
    5823     flex->append(cssValuePool().createValue(clampToFloat(negativeFlex), CSSPrimitiveValue::CSS_NUMBER));
    5824     flex->append(preferredSize);
    5825     return flex;
     5829    if (flexGrow == unsetValue)
     5830        flexGrow = 0;
     5831    if (flexShrink == unsetValue)
     5832        flexShrink = 1;
     5833    if (!flexBasis)
     5834        flexBasis = cssValuePool().createValue(0, CSSPrimitiveValue::CSS_PX);
     5835
     5836    addProperty(CSSPropertyWebkitFlexGrow, cssValuePool().createValue(clampToFloat(flexGrow), CSSPrimitiveValue::CSS_NUMBER), important);
     5837    addProperty(CSSPropertyWebkitFlexShrink, cssValuePool().createValue(clampToFloat(flexShrink), CSSPrimitiveValue::CSS_NUMBER), important);
     5838    addProperty(CSSPropertyWebkitFlexBasis, flexBasis, important);
     5839    return true;
    58265840}
    58275841
  • trunk/Source/WebCore/css/CSSParser.h

    r121229 r121380  
    190190    bool parseReflect(CSSPropertyID, bool important);
    191191
    192     PassRefPtr<CSSValue> parseFlex(CSSParserValueList* args);
     192    bool parseFlex(CSSParserValueList* args, bool important);
    193193
    194194    // Image generators
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r120735 r121380  
    553553    case CSSPropertyWebkitAlignSelf:
    554554    case CSSPropertyWebkitFlex:
     555    case CSSPropertyWebkitFlexBasis:
    555556    case CSSPropertyWebkitFlexDirection:
    556557    case CSSPropertyWebkitFlexFlow:
     558    case CSSPropertyWebkitFlexGrow:
     559    case CSSPropertyWebkitFlexShrink:
    557560    case CSSPropertyWebkitFlexWrap:
    558561    case CSSPropertyWebkitJustifyContent:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r120735 r121380  
    269269-webkit-align-self
    270270-webkit-flex
     271-webkit-flex-basis
    271272-webkit-flex-direction
    272273-webkit-flex-flow
     274-webkit-flex-grow
     275-webkit-flex-shrink
    273276-webkit-flex-wrap
    274277-webkit-justify-content
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r121349 r121380  
    17151715        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
    17161716    }
    1717 };
    1718 
    1719 class ApplyPropertyFlex {
    1720 public:
    1721     static void applyInheritValue(StyleResolver* styleResolver)
    1722     {
    1723         ApplyPropertyDefaultBase<float, &RenderStyle::flexGrow, float, &RenderStyle::setFlexGrow, float, &RenderStyle::initialFlexGrow>::applyInheritValue(styleResolver);
    1724         ApplyPropertyDefaultBase<float, &RenderStyle::flexShrink, float, &RenderStyle::setFlexShrink, float, &RenderStyle::initialFlexShrink>::applyInheritValue(styleResolver);
    1725         ApplyPropertyDefaultBase<Length, &RenderStyle::flexBasis, Length, &RenderStyle::setFlexBasis, Length, &RenderStyle::initialFlexBasis>::applyInheritValue(styleResolver);
    1726     }
    1727 
    1728     static void applyInitialValue(StyleResolver* styleResolver)
    1729     {
    1730         styleResolver->style()->setFlexGrow(RenderStyle::initialFlexGrow());
    1731         styleResolver->style()->setFlexShrink(RenderStyle::initialFlexShrink());
    1732         styleResolver->style()->setFlexBasis(RenderStyle::initialFlexBasis());
    1733     }
    1734 
    1735     static void applyValue(StyleResolver* styleResolver, CSSValue* value)
    1736     {
    1737         if (value->isPrimitiveValue()) {
    1738             CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    1739             if (primitiveValue->getIdent() == CSSValueNone) {
    1740                 styleResolver->style()->setFlexGrow(0);
    1741                 styleResolver->style()->setFlexShrink(0);
    1742                 styleResolver->style()->setFlexBasis(Length(Auto));
    1743             }
    1744             return;
    1745         }
    1746 
    1747         if (!value->isValueList())
    1748             return;
    1749         CSSValueList* valueList = static_cast<CSSValueList*>(value);
    1750         if (valueList->length() != 3)
    1751             return;
    1752 
    1753         float flexValue = 0;
    1754         if (!getFlexValue(valueList->itemWithoutBoundsCheck(0), flexValue))
    1755             return;
    1756         styleResolver->style()->setFlexGrow(flexValue);
    1757 
    1758         if (!getFlexValue(valueList->itemWithoutBoundsCheck(1), flexValue))
    1759             return;
    1760         styleResolver->style()->setFlexShrink(flexValue);
    1761 
    1762         ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::applyValue(styleResolver, valueList->itemWithoutBoundsCheck(2));
    1763     }
    1764 
    1765     static PropertyHandler createHandler()
    1766     {
    1767         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
    1768     }
    1769 private:
    1770     static bool getFlexValue(CSSValue* value, float& flexValue)
    1771     {
    1772         if (!value->isPrimitiveValue())
    1773             return false;
    1774         CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
    1775         if (!primitiveValue->isNumber())
    1776             return false;
    1777         flexValue = primitiveValue->getFloatValue();
    1778         return true;
    1779     }
    1780 
    17811717};
    17821718
     
    20311967    setPropertyHandler(CSSPropertyWebkitAlignItems, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignItems, EAlignItems, &RenderStyle::setAlignItems, EAlignItems, &RenderStyle::initialAlignItems>::createHandler());
    20321968    setPropertyHandler(CSSPropertyWebkitAlignSelf, ApplyPropertyDefault<EAlignItems, &RenderStyle::alignSelf, EAlignItems, &RenderStyle::setAlignSelf, EAlignItems, &RenderStyle::initialAlignSelf>::createHandler());
    2033     setPropertyHandler(CSSPropertyWebkitFlex, ApplyPropertyFlex::createHandler());
     1969    setPropertyHandler(CSSPropertyWebkitFlexBasis, ApplyPropertyLength<&RenderStyle::flexBasis, &RenderStyle::setFlexBasis, &RenderStyle::initialFlexBasis, AutoEnabled>::createHandler());
    20341970    setPropertyHandler(CSSPropertyWebkitFlexDirection, ApplyPropertyDefault<EFlexDirection, &RenderStyle::flexDirection, EFlexDirection, &RenderStyle::setFlexDirection, EFlexDirection, &RenderStyle::initialFlexDirection>::createHandler());
    2035     setPropertyHandler(CSSPropertyWebkitFlexFlow, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitFlexDirection, CSSPropertyWebkitFlexWrap>::createHandler());
     1971    setPropertyHandler(CSSPropertyWebkitFlexGrow, ApplyPropertyDefault<float, &RenderStyle::flexGrow, float, &RenderStyle::setFlexGrow, float, &RenderStyle::initialFlexGrow>::createHandler());
     1972    setPropertyHandler(CSSPropertyWebkitFlexShrink, ApplyPropertyDefault<float, &RenderStyle::flexShrink, float, &RenderStyle::setFlexShrink, float, &RenderStyle::initialFlexShrink>::createHandler());
    20361973    setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
    20371974    setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler());
  • trunk/Source/WebCore/css/StylePropertySet.cpp

    r120696 r121380  
    163163        return get4Values(borderStyleShorthand());
    164164#if ENABLE(CSS3_FLEXBOX)
     165    case CSSPropertyWebkitFlex:
     166        return getShorthandValue(webkitFlexShorthand());
    165167    case CSSPropertyWebkitFlexFlow:
    166168        return getShorthandValue(webkitFlexFlowShorthand());
     
    756758            shorthandPropertyID = CSSPropertyWebkitFlexFlow;
    757759            break;
     760        case CSSPropertyWebkitFlexBasis:
     761        case CSSPropertyWebkitFlexGrow:
     762        case CSSPropertyWebkitFlexShrink:
     763            shorthandPropertyID = CSSPropertyWebkitFlex;
     764            break;
    758765#endif
    759766        case CSSPropertyWebkitMaskPositionX:
  • trunk/Source/WebCore/css/StylePropertyShorthand.cpp

    r118583 r121380  
    314314    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexFlowLonghands, (flexFlowProperties, WTF_ARRAY_LENGTH(flexFlowProperties)));
    315315    return webkitFlexFlowLonghands;
     316}
     317
     318const StylePropertyShorthand& webkitFlexShorthand()
     319{
     320    static const CSSPropertyID flexProperties[] = { CSSPropertyWebkitFlexGrow, CSSPropertyWebkitFlexShrink, CSSPropertyWebkitFlexBasis };
     321    DEFINE_STATIC_LOCAL(StylePropertyShorthand, webkitFlexLonghands, (flexProperties, WTF_ARRAY_LENGTH(flexProperties)));
     322    return webkitFlexLonghands;
    316323}
    317324#endif
     
    481488        return webkitColumnRuleShorthand();
    482489#if ENABLE(CSS3_FLEXBOX)
     490    case CSSPropertyWebkitFlex:
     491        return webkitFlexShorthand();
    483492    case CSSPropertyWebkitFlexFlow:
    484493        return webkitFlexFlowShorthand();
  • trunk/Source/WebCore/css/StylePropertyShorthand.h

    r118583 r121380  
    8989#if ENABLE(CSS3_FLEXBOX)
    9090const StylePropertyShorthand& webkitFlexFlowShorthand();
     91const StylePropertyShorthand& webkitFlexShorthand();
    9192#endif
    9293const StylePropertyShorthand& webkitMarginCollapseShorthand();
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r121349 r121380  
    43144314    case CSSPropertyWebkitAlignSelf:
    43154315    case CSSPropertyWebkitFlex:
     4316    case CSSPropertyWebkitFlexBasis:
    43164317    case CSSPropertyWebkitFlexDirection:
    43174318    case CSSPropertyWebkitFlexFlow:
     4319    case CSSPropertyWebkitFlexGrow:
     4320    case CSSPropertyWebkitFlexShrink:
    43184321    case CSSPropertyWebkitFlexWrap:
    43194322    case CSSPropertyWebkitJustifyContent:
Note: See TracChangeset for help on using the changeset viewer.