Changeset 119455 in webkit


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

CSS property 'order' should be a number rather than an int
https://bugs.webkit.org/show_bug.cgi?id=88111

Reviewed by Ojan Vafai.

Source/WebCore:

This changed in the spec:
http://dev.w3.org/csswg/css3-flexbox/#order

I also fixed the compile with CSS3_FLEXBOX disabled.

No new tests, covered by existing tests.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue):

  • css/CSSProperty.cpp: Parse as float, remove clamping for HashMap<int>.

(WebCore::CSSProperty::isInheritedProperty):

  • css/StyleBuilder.cpp:

(WebCore::StyleBuilder::StyleBuilder):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::collectMatchingRulesForList):

  • rendering/RenderFlexibleBox.cpp: Remove traits for HashMap<int>.

(RenderFlexibleBox::OrderIterator):

  • rendering/RenderFlexibleBox.h:
  • rendering/style/RenderStyle.h:
  • rendering/style/StyleRareNonInheritedData.h:

(StyleRareNonInheritedData):

LayoutTests:

  • css3/flexbox/css-properties-expected.txt:
  • css3/flexbox/css-properties.html: Allow decimal values.
  • css3/flexbox/flex-order.html: Fix tests based on float limits.
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r119454 r119455  
     12012-06-04  Tony Chang  <tony@chromium.org>
     2
     3        CSS property 'order' should be a number rather than an int
     4        https://bugs.webkit.org/show_bug.cgi?id=88111
     5
     6        Reviewed by Ojan Vafai.
     7
     8        * css3/flexbox/css-properties-expected.txt:
     9        * css3/flexbox/css-properties.html: Allow decimal values.
     10        * css3/flexbox/flex-order.html: Fix tests based on float limits.
     11
    1122012-06-04  Leo Yang  <leo.yang@torchmobile.com.cn>
    213
  • trunk/LayoutTests/css3/flexbox/css-properties-expected.txt

    r119316 r119455  
    1414PASS flexitem.style.webkitOrder is "0"
    1515PASS flexitem.style.webkitOrder is "0"
    16 PASS flexitem.style.webkitOrder is "0"
     16PASS flexitem.style.webkitOrder is "1.5"
    1717PASS flexitem.style.webkitOrder is ""
    1818PASS flexbox.style.webkitJustifyContent is ""
  • trunk/LayoutTests/css3/flexbox/css-properties.html

    r119316 r119455  
    4141shouldBeEqualToString('flexitem.style.webkitOrder', '0');
    4242
    43 // -webkit-order must be an integer.
    44 flexitem.style.webkitOrder = 1.5;
    45 shouldBeEqualToString('flexitem.style.webkitOrder', '0');
    46 
    4743flexitem.style.webkitOrder = "test";
    4844shouldBeEqualToString('flexitem.style.webkitOrder', '0');
     45
     46flexitem.style.webkitOrder = 1.5;
     47shouldBeEqualToString('flexitem.style.webkitOrder', '1.5');
    4948
    5049flexitem.style.webkitOrder = '';
  • trunk/LayoutTests/css3/flexbox/flex-order.html

    r119255 r119455  
    3434
    3535<div style="display: -webkit-flex" class="horizontal-box">
    36   <div class="first"  style="-webkit-flex: 1; -webkit-order: 0"></div>
    37   <div class="second" style="-webkit-flex: 1;"></div>
    38   <div class="third"  style="-webkit-flex: 1; -webkit-order: 3"></div>
    39   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 20"></div>
     36  <div class="first"  style="-webkit-order: 0"></div>
     37  <div class="second" style=""></div>
     38  <div class="third"  style="-webkit-order: 3"></div>
     39  <div class="fourth" style="-webkit-order: 20"></div>
    4040</div>
    4141
    4242<div style="display: -webkit-flex" class="horizontal-box">
    43   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 4"></div>
    44   <div class="third"  style="-webkit-flex: 1; -webkit-order: 3"></div>
    45   <div class="second" style="-webkit-flex: 1; -webkit-order: 2"></div>
    46   <div class="first"  style="-webkit-flex: 1; -webkit-order: 1"></div>
     43  <div class="fourth" style="-webkit-order: 4"></div>
     44  <div class="third"  style="-webkit-order: 3"></div>
     45  <div class="second" style="-webkit-order: 2"></div>
     46  <div class="first"  style="-webkit-order: 1"></div>
    4747</div>
    4848
    4949<!-- The example from the spec. -->
    5050<div style="display: -webkit-flex" class="horizontal-box">
    51   <div class="third"  style="-webkit-flex: 1; -webkit-order: 1"></div>
    52   <div class="first"  style="-webkit-flex: 1"></div>
    53   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 1"></div>
    54   <div class="second" style="-webkit-flex: 1; -webkit-order: 0"></div>
     51  <div class="third"  style="-webkit-order: 1"></div>
     52  <div class="first"  style=""></div>
     53  <div class="fourth" style="-webkit-order: 1"></div>
     54  <div class="second" style="-webkit-order: 0"></div>
    5555</div>
    5656
    5757<div style="display: -webkit-flex" class="horizontal-box">
    58   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 2"></div>
    59   <div class="second" style="-webkit-flex: 1"></div>
    60   <div class="third"  style="-webkit-flex: 1"></div>
    61   <div class="first"  style="-webkit-flex: 1; -webkit-order: -10"></div>
     58  <div class="fourth" style="-webkit-order: 2"></div>
     59  <div class="second" style=""></div>
     60  <div class="third"  style=""></div>
     61  <div class="first"  style="-webkit-order: -10"></div>
    6262</div>
    6363
    6464<div style="display: -webkit-flex" class="horizontal-box">
    65   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 2000000000"></div>
    66   <div class="second" style="-webkit-flex: 1; -webkit-order: 1000000000"></div>
    67   <div class="third"  style="-webkit-flex: 1; -webkit-order: 1000000000"></div>
    68   <div class="first"  style="-webkit-flex: 1; -webkit-order: -1000000000"></div>
     65  <div class="fourth" style="-webkit-order: 2000000000"></div>
     66  <div class="second" style="-webkit-order: 1000000000"></div>
     67  <div class="third"  style="-webkit-order: 1000000000"></div>
     68  <div class="first"  style="-webkit-order: -1000000000"></div>
    6969</div>
    7070
    71 <!-- Floating numbers are ignored and we use the default of 1 instead. -->
     71<!-- Decimal numbers are OK. -->
    7272<div style="display: -webkit-flex" class="horizontal-box">
    73   <div class="second" style="-webkit-flex: 1; -webkit-order: 2.5"></div>
    74   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 2"></div>
    75   <div class="first"  style="-webkit-flex: 1; -webkit-order: -1"></div>
    76   <div class="third"  style="-webkit-flex: 1"></div>
     73  <div class="fourth" style="-webkit-order: 2.5"></div>
     74  <div class="third"  style="-webkit-order: 1.1"></div>
     75  <div class="first"  style="-webkit-order: -1.7"></div>
     76  <div class="second" style=""></div>
    7777</div>
    7878
    7979<div style="display: -webkit-flex" class="horizontal-box">
    80   <div class="second" style="-webkit-flex: 1; -webkit-order: 0"></div>
    81   <div class="first" style="-webkit-flex: 1; -webkit-order: -1"></div>
    82   <div class="fourth"  style="-webkit-flex: 1; -webkit-order: 1"></div>
    83   <div class="third"  style="-webkit-flex: 1"></div>
     80  <div class="second" style="-webkit-order: 0"></div>
     81  <div class="first"  style="-webkit-order: -1"></div>
     82  <div class="fourth" style="-webkit-order: 1"></div>
     83  <div class="third"  style=""></div>
    8484</div>
    8585
    86 <!-- Values greater than what can be stored in an int are clamped from
    87      -2,147,483,646 (int min + 2) to 2,147,483,647. -->
     86<!-- Values greater than what can be stored in a float are clamped. -->
    8887<div style="display: -webkit-flex" class="horizontal-box">
    89   <div class="third"  style="-webkit-flex: 1; -webkit-order: 4000000000"></div>
    90   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 3000000000"></div>
    91   <div class="first"  style="-webkit-flex: 1;"></div>
    92   <div class="second" style="-webkit-flex: 1; -webkit-order: 2147483646"></div>
     88  <div class="third"  style="-webkit-order: 99999999999999999999999999999999999999999"></div>
     89  <div class="fourth" style="-webkit-order: 88888888888888888888888888888888888888888"></div>
     90  <div class="first"  style=""></div>
     91  <div class="second" style="-webkit-order: 2147483646"></div>
    9392</div>
    9493
    9594<div style="display: -webkit-flex" class="horizontal-box">
    96   <div class="second" style="-webkit-flex: 1; -webkit-order: 4000000000"></div>
    97   <div class="third"  style="-webkit-flex: 1; -webkit-order: 3000000000"></div>
    98   <div class="first"  style="-webkit-flex: 1;"></div>
    99   <div class="fourth" style="-webkit-flex: 1; -webkit-order: 2147483647"></div>
     95  <div class="fourth" style="-webkit-order: 4000000000"></div>
     96  <div class="third"  style="-webkit-order: 3000000000"></div>
     97  <div class="first"  style=""></div>
     98  <div class="second" style="-webkit-order: 2147483647"></div>
    10099</div>
    101100
    102101<div style="display: -webkit-flex" class="horizontal-box">
    103   <div class="third"  style="-webkit-flex: 1; -webkit-order: -2147483645"></div>
    104   <div class="first"  style="-webkit-flex: 1; -webkit-order: -2147483646"></div>
    105   <div class="second" style="-webkit-flex: 1; -webkit-order: -2147483647"></div>
    106   <div class="fourth" style="-webkit-flex: 1;"></div>
     102  <div class="first"  style="-webkit-order: -99999999999999999999999999999999999999999"></div>
     103  <div class="second" style="-webkit-order: -88888888888888888888888888888888888888888"></div>
     104  <div class="third"  style="-webkit-order: -77777777777777777777777777777777777777777"></div>
     105  <div class="fourth" style=""></div>
    107106</div>
    108107
  • trunk/Source/WebCore/ChangeLog

    r119452 r119455  
     12012-06-04  Tony Chang  <tony@chromium.org>
     2
     3        CSS property 'order' should be a number rather than an int
     4        https://bugs.webkit.org/show_bug.cgi?id=88111
     5
     6        Reviewed by Ojan Vafai.
     7
     8        This changed in the spec:
     9        http://dev.w3.org/csswg/css3-flexbox/#order
     10
     11        I also fixed the compile with CSS3_FLEXBOX disabled.
     12
     13        No new tests, covered by existing tests.
     14
     15        * css/CSSComputedStyleDeclaration.cpp:
     16        (WebCore):
     17        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     18        * css/CSSParser.cpp:
     19        (WebCore::CSSParser::parseValue):
     20        * css/CSSProperty.cpp: Parse as float, remove clamping for HashMap<int>.
     21        (WebCore::CSSProperty::isInheritedProperty):
     22        * css/StyleBuilder.cpp:
     23        (WebCore::StyleBuilder::StyleBuilder):
     24        * css/StyleResolver.cpp:
     25        (WebCore::StyleResolver::collectMatchingRulesForList):
     26        * rendering/RenderFlexibleBox.cpp: Remove traits for HashMap<int>.
     27        (RenderFlexibleBox::OrderIterator):
     28        * rendering/RenderFlexibleBox.h:
     29        * rendering/style/RenderStyle.h:
     30        * rendering/style/StyleRareNonInheritedData.h:
     31        (StyleRareNonInheritedData):
     32
    1332012-06-04  Hugo Parente Lima  <hugo.lima@openbossa.org>
    234
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r119298 r119455  
    279279    CSSPropertyWebkitMaskSize,
    280280    CSSPropertyWebkitNbspMode,
     281#if ENABLE(CSS3_FLEXBOX)
    281282    CSSPropertyWebkitOrder,
     283#endif
    282284#if ENABLE(OVERFLOW_SCROLLING)
    283285    CSSPropertyWebkitOverflowScrolling,
     
    16521654        }
    16531655        case CSSPropertyWebkitOrder:
    1654             return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
     1656            return cssValuePool().createValue(style->order());
    16551657        case CSSPropertyWebkitJustifyContent:
    16561658            return cssValuePool().createValue(style->justifyContent());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r119316 r119455  
    20972097        break;
    20982098    case CSSPropertyWebkitOrder:
    2099         if (validUnit(value, FInteger, CSSStrictMode)) {
    2100             // We restrict the smallest value to int min + 2 because we use int min and int min + 1 as special values in a hash set.
    2101             parsedValue = cssValuePool().createValue(max(static_cast<double>(std::numeric_limits<int>::min() + 2), value->fValue),
    2102                                                              static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
    2103             m_valueList->next();
    2104         }
     2099        validPrimitive = validUnit(value, FNumber);
    21052100        break;
    21062101#endif
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r119298 r119455  
    548548    case CSSPropertyWebkitFlexWrap:
    549549    case CSSPropertyWebkitJustifyContent:
     550    case CSSPropertyWebkitOrder:
    550551#endif
    551552    case CSSPropertyWebkitFontSizeDelta:
     
    596597    case CSSPropertyWebkitMinLogicalWidth:
    597598    case CSSPropertyWebkitMinLogicalHeight:
    598     case CSSPropertyWebkitOrder:
    599599    case CSSPropertyWebkitPaddingAfter:
    600600    case CSSPropertyWebkitPaddingBefore:
  • trunk/Source/WebCore/css/StyleBuilder.cpp

    r119298 r119455  
    19451945    setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
    19461946    setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler());
     1947    setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<float, &RenderStyle::order, float, &RenderStyle::setOrder, float, &RenderStyle::initialOrder>::createHandler());
    19471948#endif
    19481949#if ENABLE(CSS_REGIONS)
     
    19901991    setPropertyHandler(CSSPropertyWebkitMatchNearestMailBlockquoteColor, ApplyPropertyDefault<EMatchNearestMailBlockquoteColor, &RenderStyle::matchNearestMailBlockquoteColor, EMatchNearestMailBlockquoteColor, &RenderStyle::setMatchNearestMailBlockquoteColor, EMatchNearestMailBlockquoteColor, &RenderStyle::initialMatchNearestMailBlockquoteColor>::createHandler());
    19911992    setPropertyHandler(CSSPropertyWebkitNbspMode, ApplyPropertyDefault<ENBSPMode, &RenderStyle::nbspMode, ENBSPMode, &RenderStyle::setNBSPMode, ENBSPMode, &RenderStyle::initialNBSPMode>::createHandler());
    1992     setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<int, &RenderStyle::order, int, &RenderStyle::setOrder, int, &RenderStyle::initialOrder>::createHandler());
    19931993    setPropertyHandler(CSSPropertyWebkitPerspectiveOrigin, ApplyPropertyExpanding<SuppressValue, CSSPropertyWebkitPerspectiveOriginX, CSSPropertyWebkitPerspectiveOriginY>::createHandler());
    19941994    setPropertyHandler(CSSPropertyWebkitPerspectiveOriginX, ApplyPropertyLength<&RenderStyle::perspectiveOriginX, &RenderStyle::setPerspectiveOriginX, &RenderStyle::initialPerspectiveOriginX>::createHandler());
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r119408 r119455  
    41324132    case CSSPropertyWebkitFlexWrap:
    41334133    case CSSPropertyWebkitJustifyContent:
     4134    case CSSPropertyWebkitOrder:
    41344135#endif
    41354136#if ENABLE(CSS_REGIONS)
     
    41724173    case CSSPropertyWebkitMatchNearestMailBlockquoteColor:
    41734174    case CSSPropertyWebkitNbspMode:
    4174     case CSSPropertyWebkitOrder:
    41754175    case CSSPropertyWebkitPerspectiveOrigin:
    41764176    case CSSPropertyWebkitPerspectiveOriginX:
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r119316 r119455  
    4040namespace WebCore {
    4141
    42 // Normally, -1 and 0 are not valid in a HashSet, but these are relatively likely flex-order values. Instead,
    43 // we make the two smallest int values invalid flex-order values (in the css parser code we clamp them to
    44 // int min + 2).
    45 struct RenderFlexibleBox::OrderHashTraits : WTF::GenericHashTraits<int> {
    46     static const bool emptyValueIsZero = false;
    47     static int emptyValue() { return std::numeric_limits<int>::min(); }
    48     static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; }
    49     static bool isDeletedValue(int value) { return value == std::numeric_limits<int>::min() + 1; }
    50 };
    51 
    5242class RenderFlexibleBox::OrderIterator {
    5343public:
     
    10090    RenderFlexibleBox* m_flexibleBox;
    10191    RenderBox* m_currentChild;
    102     Vector<int> m_orderValues;
    103     Vector<int>::const_iterator m_orderValuesIterator;
     92    Vector<float> m_orderValues;
     93    Vector<float>::const_iterator m_orderValuesIterator;
    10494};
    10595
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r119298 r119455  
    6060    };
    6161
    62     struct OrderHashTraits;
    63     typedef HashSet<int, DefaultHash<int>::Hash, OrderHashTraits> OrderHashSet;
     62    typedef HashSet<float> OrderHashSet;
    6463
    6564    class OrderIterator;
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r119316 r119455  
    805805    EBoxPack boxPack() const { return static_cast<EBoxPack>(rareNonInheritedData->m_deprecatedFlexibleBox->pack); }
    806806
    807     int order() const { return rareNonInheritedData->m_order; }
     807    float order() const { return rareNonInheritedData->m_order; }
    808808    float positiveFlex() const { return rareNonInheritedData->m_flexibleBox->m_positiveFlex; }
    809809    float negativeFlex() const { return rareNonInheritedData->m_flexibleBox->m_negativeFlex; }
     
    12501250    void setNegativeFlex(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_negativeFlex, f); }
    12511251    void setFlexPreferredSize(Length l) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_preferredSize, l); }
    1252     void setOrder(int o) { SET_VAR(rareNonInheritedData, m_order, o); }
     1252    void setOrder(float o) { SET_VAR(rareNonInheritedData, m_order, o); }
    12531253    void setAlignContent(EAlignContent p) { SET_VAR(rareNonInheritedData, m_alignContent, p); }
    12541254    void setAlignItems(EAlignItems a) { SET_VAR(rareNonInheritedData, m_alignItems, a); }
     
    15841584    static float initialNegativeFlex() { return 1; }
    15851585    static Length initialFlexPreferredSize() { return Length(Auto); }
    1586     static int initialOrder() { return 0; }
     1586    static float initialOrder() { return 0; }
    15871587    static EAlignContent initialAlignContent() { return AlignContentStretch; }
    15881588    static EAlignItems initialAlignItems() { return AlignStretch; }
  • trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h

    r119298 r119455  
    147147    Color m_visitedLinkBorderBottomColor;
    148148
    149     int m_order;
     149    float m_order;
    150150
    151151    AtomicString m_flowThread;
Note: See TracChangeset for help on using the changeset viewer.