Title: [106980] trunk/Source/WebCore
Revision
106980
Author
t...@chromium.org
Date
2012-02-07 13:22:29 -0800 (Tue, 07 Feb 2012)

Log Message

move warning about css values and render style constants closer to where it applies
https://bugs.webkit.org/show_bug.cgi?id=78017

Reviewed by Darin Adler.

Move the warning about keeping RenderStyleConstnats.h enums and
CSSValueKeywords.in values in the same order closer to the properties
that the warning applies to. The warning was easy to miss and was
confusing since it doesn't apply to most values.

Also refactor 2 conversion functions to
enumerate the possible values so the order doesn't matter.

No new tests, just refactoring and comment cleanup.

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::operator EListStylePosition): Name all possible values and add a NOT_REACHED().
(WebCore::CSSPrimitiveValue::operator EUserModify): Name all possible values and add a NOT_REACHED().
* css/CSSValueKeywords.in:
* css/SVGCSSPropertyNames.in:
* css/SVGCSSValueKeywords.in:
* rendering/style/RenderStyleConstants.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (106979 => 106980)


--- trunk/Source/WebCore/ChangeLog	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/ChangeLog	2012-02-07 21:22:29 UTC (rev 106980)
@@ -1,3 +1,28 @@
+2012-02-07  Tony Chang  <t...@chromium.org>
+
+        move warning about css values and render style constants closer to where it applies
+        https://bugs.webkit.org/show_bug.cgi?id=78017
+
+        Reviewed by Darin Adler.
+
+        Move the warning about keeping RenderStyleConstnats.h enums and
+        CSSValueKeywords.in values in the same order closer to the properties
+        that the warning applies to. The warning was easy to miss and was
+        confusing since it doesn't apply to most values.
+
+        Also refactor 2 conversion functions to
+        enumerate the possible values so the order doesn't matter.
+
+        No new tests, just refactoring and comment cleanup.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::operator EListStylePosition): Name all possible values and add a NOT_REACHED().
+        (WebCore::CSSPrimitiveValue::operator EUserModify): Name all possible values and add a NOT_REACHED().
+        * css/CSSValueKeywords.in:
+        * css/SVGCSSPropertyNames.in:
+        * css/SVGCSSValueKeywords.in:
+        * rendering/style/RenderStyleConstants.h:
+
 2012-02-06  Jer Noble  <jer.no...@apple.com>
 
         Use CMClock as a timing source for PlatformClock where available.

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (106979 => 106980)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2012-02-07 21:22:29 UTC (rev 106980)
@@ -1396,7 +1396,15 @@
 
 template<> inline CSSPrimitiveValue::operator EListStylePosition() const
 {
-    return (EListStylePosition)(m_value.ident - CSSValueOutside);
+    switch (m_value.ident) {
+    case CSSValueOutside:
+        return OUTSIDE;
+    case CSSValueInside:
+        return INSIDE;
+    default:
+        ASSERT_NOT_REACHED();
+        return OUTSIDE;
+    }
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EListStyleType e)
@@ -2285,7 +2293,17 @@
 
 template<> inline CSSPrimitiveValue::operator EUserModify() const
 {
-    return static_cast<EUserModify>(m_value.ident - CSSValueReadOnly);
+    switch (m_value.ident) {
+    case CSSValueReadOnly:
+        return READ_ONLY;
+    case CSSValueReadWrite:
+        return READ_WRITE;
+    case CSSValueReadWritePlaintextOnly:
+        return READ_WRITE_PLAINTEXT_ONLY;
+    default:
+        ASSERT_NOT_REACHED();
+        return READ_ONLY;
+    }
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EUserSelect e)

Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (106979 => 106980)


--- trunk/Source/WebCore/css/CSSValueKeywords.in	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in	2012-02-07 21:22:29 UTC (rev 106980)
@@ -1,14 +1,6 @@
-// These are all values accepted for CSS2.
 //
-// WARNING:
-// --------
+// CSS value names
 //
-// The Values are sorted according to the properties they belong to,
-// and have to be in the same order as the enums in RenderStyleConstants.h.
-//
-// If not, the optimizations in the cssparser and style selector will fail,
-// and produce incorrect results.
-//
 inherit
 initial
 //
@@ -16,6 +8,7 @@
 // CSS_PROP_BORDER_TOP_STYLE
 // CSS_PROP_BORDER_BOTTOM_STYLE
 // CSS_PROP_BORDER_LEFT_STYLE
+// The order here must match the order of the EBorderStyle enum in RenderStyleConstants.h.
 none
 hidden
 inset
@@ -215,6 +208,7 @@
 -webkit-baseline-middle
 //
 // CSS_PROP_TEXT_ALIGN:
+// The order here must match the order of the ETextAlign enum in RenderStyleConstants.h.
 //
 -webkit-auto
 left
@@ -232,6 +226,7 @@
 inside
 //
 // CSS_PROP_LIST_STYLE_TYPE:
+// The order here must match the order of the EListStyleType enum in RenderStyleConstants.h.
 //
 disc
 circle
@@ -316,6 +311,7 @@
 //none
 //
 // CSS_PROP_DISPLAY:
+// The order here must match the order of the EDisplay enum in RenderStyleConstants.h.
 //
 inline
 block
@@ -344,6 +340,7 @@
 //none
 //
 // CSS_PROP_CURSOR:
+// The order here must match the order of the ECursor enum in RenderStyleConstants.h.
 //
 auto
 crosshair
@@ -603,7 +600,7 @@
 after-white-space
 
 // -webkit-appearance
-// The order here should match the order in the ControlPart enum in ThemeTypes.h.
+// The order here must match the order in the ControlPart enum in ThemeTypes.h.
 // All appearance values that should be accepted by the parser should be listed between 'checkbox' and 'textarea':
 checkbox
 radio

Modified: trunk/Source/WebCore/css/SVGCSSPropertyNames.in (106979 => 106980)


--- trunk/Source/WebCore/css/SVGCSSPropertyNames.in	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/css/SVGCSSPropertyNames.in	2012-02-07 21:22:29 UTC (rev 106980)
@@ -1,5 +1,5 @@
 //
-// all valid SVG CSS2 properties.
+// SVG CSS property names
 //
 
 // SVG style props

Modified: trunk/Source/WebCore/css/SVGCSSValueKeywords.in (106979 => 106980)


--- trunk/Source/WebCore/css/SVGCSSValueKeywords.in	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/css/SVGCSSValueKeywords.in	2012-02-07 21:22:29 UTC (rev 106980)
@@ -1,15 +1,6 @@
-// These are all values accepted for CSS2.
 //
-// WARNING:
-// --------
+// SVG CSS value names
 //
-// The Values are sorted according to the properties they belong to,
-// and have to be in the same order as the enums in RenderStyle.h.
-//
-// If not, the optimizations in the cssparser and style selector will fail,
-// and produce incorrect results.
-//
-//
 // CSS_PROP_*_COLOR
 //
 aliceblue

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (106979 => 106980)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2012-02-07 21:06:31 UTC (rev 106979)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2012-02-07 21:22:29 UTC (rev 106980)
@@ -28,14 +28,6 @@
 
 namespace WebCore {
 
-/*
- * WARNING:
- * --------
- *
- * The order of the values in the enums have to agree with the order specified
- * in CSSValueKeywords.in, otherwise some optimizations in the parser will fail,
- * and produce invalid results.
- */
 static const size_t PrintColorAdjustBits = 1;
 enum PrintColorAdjust {
     PrintColorAdjustEconomy,
@@ -93,7 +85,7 @@
 enum EBorderCollapse { BSEPARATE = 0, BCOLLAPSE = 1 };
 
 // These have been defined in the order of their precedence for border-collapsing. Do
-// not change this order!
+// not change this order! This order also must match the order in CSSValueKeywords.in.
 enum EBorderStyle { BNONE, BHIDDEN, INSET, GROOVE, OUTSET, RIDGE, DOTTED, DASHED, SOLID, DOUBLE };
 
 enum EBorderPrecedence { BOFF, BTABLE, BCOLGROUP, BCOL, BROWGROUP, BROW, BCELL };
@@ -229,7 +221,7 @@
     RESIZE_NONE, RESIZE_BOTH, RESIZE_HORIZONTAL, RESIZE_VERTICAL
 };
 
-// The order of this enum must match the order of the list style types in CSSValueKeywords.in. 
+// The order of this enum must match the order of the list style types in CSSValueKeywords.in.
 enum EListStyleType {
     Disc,
     Circle,
@@ -335,6 +327,7 @@
     NORMAL, PRE, PRE_WRAP, PRE_LINE, NOWRAP, KHTML_NOWRAP
 };
 
+// The order of this enum must match the order of the text align values in CSSValueKeywords.in.
 enum ETextAlign {
     TAAUTO, LEFT, RIGHT, CENTER, JUSTIFY, WEBKIT_LEFT, WEBKIT_RIGHT, WEBKIT_CENTER, TASTART, TAEND,
 };
@@ -408,6 +401,7 @@
     CURSOR_NONE
 };
 
+// The order of this enum must match the order of the display values in CSSValueKeywords.in.
 enum EDisplay {
     INLINE, BLOCK, LIST_ITEM, RUN_IN, COMPACT, INLINE_BLOCK,
     TABLE, INLINE_TABLE, TABLE_ROW_GROUP,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to