Title: [124276] trunk
Revision
124276
Author
[email protected]
Date
2012-07-31 17:44:18 -0700 (Tue, 31 Jul 2012)

Log Message

-webkit-order should take an integer, not a number
https://bugs.webkit.org/show_bug.cgi?id=92688

Reviewed by Ojan Vafai.

Source/WebCore:

The spec changed back from floats to integers:
http://lists.w3.org/Archives/Public/www-style/2012Jul/0607.html

Tests: css3/flexbox/css-properties.html: Updated.
       css3/flexbox/flex-order.html: Test cases modified.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
* css/StyleBuilder.cpp:
(WebCore::StyleBuilder::StyleBuilder):
* rendering/RenderFlexibleBox.cpp:
(WebCore):
(RenderFlexibleBox::OrderHashTraits):
(WebCore::RenderFlexibleBox::OrderHashTraits::emptyValue):
(WebCore::RenderFlexibleBox::OrderHashTraits::constructDeletedValue):
(WebCore::RenderFlexibleBox::OrderHashTraits::isDeletedValue):
(RenderFlexibleBox::OrderIterator):
* rendering/RenderFlexibleBox.h:
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareNonInheritedData.h:
(StyleRareNonInheritedData):

LayoutTests:

Update tests.

* css3/flexbox/css-properties-expected.txt:
* css3/flexbox/css-properties.html:
* css3/flexbox/flex-order.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (124275 => 124276)


--- trunk/LayoutTests/ChangeLog	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/LayoutTests/ChangeLog	2012-08-01 00:44:18 UTC (rev 124276)
@@ -1,3 +1,16 @@
+2012-07-31  Tony Chang  <[email protected]>
+
+        -webkit-order should take an integer, not a number
+        https://bugs.webkit.org/show_bug.cgi?id=92688
+
+        Reviewed by Ojan Vafai.
+
+        Update tests.
+
+        * css3/flexbox/css-properties-expected.txt:
+        * css3/flexbox/css-properties.html:
+        * css3/flexbox/flex-order.html:
+
 2012-07-31  Luke Macpherson   <[email protected]>
 
         Heap-use-after-free in WebCore::StyleResolver::loadPendingImage

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


--- trunk/LayoutTests/css3/flexbox/css-properties-expected.txt	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/LayoutTests/css3/flexbox/css-properties-expected.txt	2012-08-01 00:44:18 UTC (rev 124276)
@@ -13,7 +13,7 @@
 PASS flexitem.style.webkitOrder is "-1"
 PASS flexitem.style.webkitOrder is "0"
 PASS flexitem.style.webkitOrder is "0"
-PASS flexitem.style.webkitOrder is "1.5"
+PASS flexitem.style.webkitOrder is "0"
 PASS flexitem.style.webkitOrder is ""
 PASS flexbox.style.webkitJustifyContent is ""
 PASS window.getComputedStyle(flexbox, null).webkitJustifyContent is "flex-start"

Modified: trunk/LayoutTests/css3/flexbox/css-properties.html (124275 => 124276)


--- trunk/LayoutTests/css3/flexbox/css-properties.html	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/LayoutTests/css3/flexbox/css-properties.html	2012-08-01 00:44:18 UTC (rev 124276)
@@ -40,12 +40,13 @@
 flexitem.style.webkitOrder = 0;
 shouldBeEqualToString('flexitem.style.webkitOrder', '0');
 
+// -webkit-order must be an integer.
+flexitem.style.webkitOrder = 1.5;
+shouldBeEqualToString('flexitem.style.webkitOrder', '0');
+
 flexitem.style.webkitOrder = "test";
 shouldBeEqualToString('flexitem.style.webkitOrder', '0');
 
-flexitem.style.webkitOrder = 1.5;
-shouldBeEqualToString('flexitem.style.webkitOrder', '1.5');
-
 flexitem.style.webkitOrder = '';
 shouldBeEqualToString('flexitem.style.webkitOrder', '');
 

Modified: trunk/LayoutTests/css3/flexbox/flex-order.html (124275 => 124276)


--- trunk/LayoutTests/css3/flexbox/flex-order.html	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/LayoutTests/css3/flexbox/flex-order.html	2012-08-01 00:44:18 UTC (rev 124276)
@@ -72,12 +72,12 @@
   <div class="first"  style="-webkit-order: -1000000000"></div>
 </div>
 
-<!-- Decimal numbers are OK. -->
+<!-- Floating numbers are ignored and we use the default of 1 instead. -->
 <div class="horizontal-box">
-  <div class="fourth" style="-webkit-order: 2.5"></div>
-  <div class="third"  style="-webkit-order: 1.1"></div>
-  <div class="first"  style="-webkit-order: -1.7"></div>
-  <div class="second" style=""></div>
+  <div class="second" style="-webkit-order: 2.5"></div>
+  <div class="fourth" style="-webkit-order: 2"></div>
+  <div class="first"  style="-webkit-order: -1"></div>
+  <div class="third"  style=""></div>
 </div>
 
 <div class="horizontal-box">
@@ -87,25 +87,26 @@
   <div class="third"  style=""></div>
 </div>
 
-<!-- Values greater than what can be stored in a float are clamped. -->
+<!-- Values greater than what can be stored in an int are clamped from
+     -2,147,483,646 (int min + 2) to 2,147,483,647. -->
 <div class="horizontal-box">
-  <div class="third"  style="-webkit-order: 99999999999999999999999999999999999999999"></div>
-  <div class="fourth" style="-webkit-order: 88888888888888888888888888888888888888888"></div>
+  <div class="third"  style="-webkit-order: 4000000000"></div>
+  <div class="fourth" style="-webkit-order: 3000000000"></div>
   <div class="first"  style=""></div>
   <div class="second" style="-webkit-order: 2147483646"></div>
 </div>
 
 <div class="horizontal-box">
-  <div class="fourth" style="-webkit-order: 4000000000"></div>
+  <div class="second" style="-webkit-order: 4000000000"></div>
   <div class="third"  style="-webkit-order: 3000000000"></div>
   <div class="first"  style=""></div>
-  <div class="second" style="-webkit-order: 2147483647"></div>
+  <div class="fourth" style="-webkit-order: 2147483647"></div>
 </div>
 
 <div class="horizontal-box">
-  <div class="first"  style="-webkit-order: -99999999999999999999999999999999999999999"></div>
-  <div class="second" style="-webkit-order: -88888888888888888888888888888888888888888"></div>
-  <div class="third"  style="-webkit-order: -77777777777777777777777777777777777777777"></div>
+  <div class="third"  style="-webkit-order: -2147483645"></div>
+  <div class="first"  style="-webkit-order: -2147483646"></div>
+  <div class="second" style="-webkit-order: -2147483647"></div>
   <div class="fourth" style=""></div>
 </div>
 

Modified: trunk/Source/WebCore/ChangeLog (124275 => 124276)


--- trunk/Source/WebCore/ChangeLog	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/ChangeLog	2012-08-01 00:44:18 UTC (rev 124276)
@@ -1,3 +1,35 @@
+2012-07-31  Tony Chang  <[email protected]>
+
+        -webkit-order should take an integer, not a number
+        https://bugs.webkit.org/show_bug.cgi?id=92688
+
+        Reviewed by Ojan Vafai.
+
+        The spec changed back from floats to integers:
+        http://lists.w3.org/Archives/Public/www-style/2012Jul/0607.html
+
+        Tests: css3/flexbox/css-properties.html: Updated.
+               css3/flexbox/flex-order.html: Test cases modified.
+
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        * css/StyleBuilder.cpp:
+        (WebCore::StyleBuilder::StyleBuilder):
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore):
+        (RenderFlexibleBox::OrderHashTraits):
+        (WebCore::RenderFlexibleBox::OrderHashTraits::emptyValue):
+        (WebCore::RenderFlexibleBox::OrderHashTraits::constructDeletedValue):
+        (WebCore::RenderFlexibleBox::OrderHashTraits::isDeletedValue):
+        (RenderFlexibleBox::OrderIterator):
+        * rendering/RenderFlexibleBox.h:
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleRareNonInheritedData.h:
+        (StyleRareNonInheritedData):
+
 2012-07-31  James Robinson  <[email protected]>
 
         [chromium] Use skia directly in CCHeadsUpDisplayLayerImpl

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (124275 => 124276)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-08-01 00:44:18 UTC (rev 124276)
@@ -1689,7 +1689,7 @@
         case CSSPropertyWebkitJustifyContent:
             return cssValuePool().createValue(style->justifyContent());
         case CSSPropertyWebkitOrder:
-            return cssValuePool().createValue(style->order());
+            return cssValuePool().createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
 #endif
         case CSSPropertyFloat:
             return cssValuePool().createValue(style->floating());

Modified: trunk/Source/WebCore/css/CSSParser.cpp (124275 => 124276)


--- trunk/Source/WebCore/css/CSSParser.cpp	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2012-08-01 00:44:18 UTC (rev 124276)
@@ -2291,7 +2291,12 @@
         validPrimitive = validUnit(value, FNumber | FNonNeg);
         break;
     case CSSPropertyWebkitOrder:
-        validPrimitive = validUnit(value, FNumber);
+        if (validUnit(value, FInteger, CSSStrictMode)) {
+            // 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.
+            parsedValue = cssValuePool().createValue(max(static_cast<double>(std::numeric_limits<int>::min() + 2), value->fValue),
+                                                             static_cast<CSSPrimitiveValue::UnitTypes>(value->unit));
+            m_valueList->next();
+        }
         break;
 #endif
     case CSSPropertyWebkitMarquee:

Modified: trunk/Source/WebCore/css/StyleBuilder.cpp (124275 => 124276)


--- trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/css/StyleBuilder.cpp	2012-08-01 00:44:18 UTC (rev 124276)
@@ -1996,7 +1996,7 @@
     setPropertyHandler(CSSPropertyWebkitFlexShrink, ApplyPropertyDefault<float, &RenderStyle::flexShrink, float, &RenderStyle::setFlexShrink, float, &RenderStyle::initialFlexShrink>::createHandler());
     setPropertyHandler(CSSPropertyWebkitFlexWrap, ApplyPropertyDefault<EFlexWrap, &RenderStyle::flexWrap, EFlexWrap, &RenderStyle::setFlexWrap, EFlexWrap, &RenderStyle::initialFlexWrap>::createHandler());
     setPropertyHandler(CSSPropertyWebkitJustifyContent, ApplyPropertyDefault<EJustifyContent, &RenderStyle::justifyContent, EJustifyContent, &RenderStyle::setJustifyContent, EJustifyContent, &RenderStyle::initialJustifyContent>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<float, &RenderStyle::order, float, &RenderStyle::setOrder, float, &RenderStyle::initialOrder>::createHandler());
+    setPropertyHandler(CSSPropertyWebkitOrder, ApplyPropertyDefault<int, &RenderStyle::order, int, &RenderStyle::setOrder, int, &RenderStyle::initialOrder>::createHandler());
 #endif
 #if ENABLE(CSS_REGIONS)
     setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler());

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (124275 => 124276)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2012-08-01 00:44:18 UTC (rev 124276)
@@ -39,6 +39,16 @@
 
 namespace WebCore {
 
+// Normally, -1 and 0 are not valid in a HashSet, but these are relatively likely order: values. Instead,
+// we make the two smallest int values invalid order: values (in the css parser code we clamp them to
+// int min + 2).
+struct RenderFlexibleBox::OrderHashTraits : WTF::GenericHashTraits<int> {
+    static const bool emptyValueIsZero = false;
+    static int emptyValue() { return std::numeric_limits<int>::min(); }
+    static void constructDeletedValue(int& slot) { slot = std::numeric_limits<int>::min() + 1; }
+    static bool isDeletedValue(int value) { return value == std::numeric_limits<int>::min() + 1; }
+};
+
 class RenderFlexibleBox::OrderIterator {
 public:
     OrderIterator(RenderFlexibleBox* flexibleBox, const OrderHashSet& orderValues)
@@ -89,8 +99,8 @@
 private:
     RenderFlexibleBox* m_flexibleBox;
     RenderBox* m_currentChild;
-    Vector<float> m_orderValues;
-    Vector<float>::const_iterator m_orderValuesIterator;
+    Vector<int> m_orderValues;
+    Vector<int>::const_iterator m_orderValuesIterator;
 };
 
 struct RenderFlexibleBox::LineContext {

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.h (124275 => 124276)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.h	2012-08-01 00:44:18 UTC (rev 124276)
@@ -62,7 +62,8 @@
         NoFlipForRowReverse,
     };
 
-    typedef HashSet<float> OrderHashSet;
+    struct OrderHashTraits;
+    typedef HashSet<int, DefaultHash<int>::Hash, OrderHashTraits> OrderHashSet;
 
     class OrderIterator;
     typedef WTF::HashMap<const RenderBox*, LayoutUnit> InflexibleFlexItemSize;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (124275 => 124276)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2012-08-01 00:44:18 UTC (rev 124276)
@@ -798,7 +798,7 @@
     EBoxOrient boxOrient() const { return static_cast<EBoxOrient>(rareNonInheritedData->m_deprecatedFlexibleBox->orient); }
     EBoxPack boxPack() const { return static_cast<EBoxPack>(rareNonInheritedData->m_deprecatedFlexibleBox->pack); }
 
-    float order() const { return rareNonInheritedData->m_order; }
+    int order() const { return rareNonInheritedData->m_order; }
     float flexGrow() const { return rareNonInheritedData->m_flexibleBox->m_flexGrow; }
     float flexShrink() const { return rareNonInheritedData->m_flexibleBox->m_flexShrink; }
     Length flexBasis() const { return rareNonInheritedData->m_flexibleBox->m_flexBasis; }
@@ -1268,7 +1268,7 @@
     void setFlexGrow(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexGrow, f); }
     void setFlexShrink(float f) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexShrink, f); }
     void setFlexBasis(Length length) { SET_VAR(rareNonInheritedData.access()->m_flexibleBox, m_flexBasis, length); }
-    void setOrder(float o) { SET_VAR(rareNonInheritedData, m_order, o); }
+    void setOrder(int o) { SET_VAR(rareNonInheritedData, m_order, o); }
     void setAlignContent(EAlignContent p) { SET_VAR(rareNonInheritedData, m_alignContent, p); }
     void setAlignItems(EAlignItems a) { SET_VAR(rareNonInheritedData, m_alignItems, a); }
     void setAlignSelf(EAlignItems a) { SET_VAR(rareNonInheritedData, m_alignSelf, a); }
@@ -1610,7 +1610,7 @@
     static float initialFlexGrow() { return 0; }
     static float initialFlexShrink() { return 1; }
     static Length initialFlexBasis() { return Length(Auto); }
-    static float initialOrder() { return 0; }
+    static int initialOrder() { return 0; }
     static EAlignContent initialAlignContent() { return AlignContentStretch; }
     static EAlignItems initialAlignItems() { return AlignStretch; }
     static EAlignItems initialAlignSelf() { return AlignAuto; }

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (124275 => 124276)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2012-08-01 00:34:43 UTC (rev 124275)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2012-08-01 00:44:18 UTC (rev 124276)
@@ -146,7 +146,7 @@
     Color m_visitedLinkBorderTopColor;
     Color m_visitedLinkBorderBottomColor;
 
-    float m_order;
+    int m_order;
 
     AtomicString m_flowThread;
     AtomicString m_regionThread;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to