Bug 1288383 - Replace NS_STYLE_BOX_SHADOW_* and NS_STYLE_BASIC_SHAPE_* with enum classes; r=heycam draft
authorManish Goregaokar <manishearth@gmail.com>
Fri, 22 Jul 2016 15:36:19 +0530
changeset 391233 b62e7fdc687193c4d122f7ba2c6526c1ab6e758b
parent 391232 e4c9b2adb4847c13d3e81dfd48288dab90bceed1
child 391234 c9ea29a9d70fdfd4d71d995695f713e2cae61bbf
push id23854
push usermanishearth@gmail.com
push dateFri, 22 Jul 2016 10:05:05 +0000
reviewersheycam
bugs1288383
milestone50.0a1
Bug 1288383 - Replace NS_STYLE_BOX_SHADOW_* and NS_STYLE_BASIC_SHAPE_* with enum classes; r=heycam MozReview-Commit-ID: 664T0yY145z
layout/style/StyleAnimationValue.cpp
layout/style/nsCSSProps.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
--- a/layout/style/StyleAnimationValue.cpp
+++ b/layout/style/StyleAnimationValue.cpp
@@ -270,17 +270,17 @@ AppendCSSShadowValue(const nsCSSShadowIt
   nscoordToCSSValue(aShadow->mRadius, arr->Item(2));
   // NOTE: This code sometimes stores mSpread: 0 even when
   // the parser would be required to leave it null.
   nscoordToCSSValue(aShadow->mSpread, arr->Item(3));
   if (aShadow->mHasColor) {
     arr->Item(4).SetColorValue(aShadow->mColor);
   }
   if (aShadow->mInset) {
-    arr->Item(5).SetIntValue(NS_STYLE_BOX_SHADOW_INSET,
+    arr->Item(5).SetIntValue(uint8_t(StyleBoxShadowType::Inset),
                              eCSSUnit_Enumerated);
   }
 
   nsCSSValueList *resultItem = new nsCSSValueList;
   resultItem->mValue.SetArrayValue(arr, eCSSUnit_Array);
   *aResultTail = resultItem;
   aResultTail = &resultItem->mNext;
 }
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -1035,17 +1035,17 @@ const KTableEntry nsCSSProps::kBorderWid
 
 const KTableEntry nsCSSProps::kBoxDecorationBreakKTable[] = {
   { eCSSKeyword_slice, NS_STYLE_BOX_DECORATION_BREAK_SLICE },
   { eCSSKeyword_clone, NS_STYLE_BOX_DECORATION_BREAK_CLONE },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxShadowTypeKTable[] = {
-  { eCSSKeyword_inset, NS_STYLE_BOX_SHADOW_INSET },
+  { eCSSKeyword_inset, uint8_t(StyleBoxShadowType::Inset) },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxSizingKTable[] = {
   { eCSSKeyword_content_box,  uint8_t(StyleBoxSizing::Content) },
   { eCSSKeyword_border_box,   uint8_t(StyleBoxSizing::Border) },
   { eCSSKeyword_UNKNOWN,      -1 }
 };
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -3399,18 +3399,19 @@ nsComputedDOMStyle::GetCSSShadowArray(ns
       val->SetAppUnits(item->*(shadowValues[i]));
       itemList->AppendCSSValue(val.forget());
     }
 
     if (item->mInset && aIsBoxShadow) {
       // This is an inset box-shadow
       val = new nsROCSSPrimitiveValue;
       val->SetIdent(
-        nsCSSProps::ValueToKeywordEnum(NS_STYLE_BOX_SHADOW_INSET,
-                                       nsCSSProps::kBoxShadowTypeKTable));
+        nsCSSProps::ValueToKeywordEnum(
+            uint8_t(StyleBoxShadowType::Inset),
+            nsCSSProps::kBoxShadowTypeKTable));
       itemList->AppendCSSValue(val.forget());
     }
     valueList->AppendCSSValue(itemList.forget());
   }
 
   return valueList.forget();
 }
 
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -4248,17 +4248,18 @@ nsRuleNode::GetShadowData(const nsCSSVal
       item->mHasColor = true;
       // 2nd argument can be bogus since inherit is not a valid color
       unitOK = SetColor(arr->Item(4), 0, mPresContext, aContext, item->mColor,
                         aConditions);
       NS_ASSERTION(unitOK, "unexpected unit");
     }
 
     if (aIsBoxShadow && arr->Item(5).GetUnit() == eCSSUnit_Enumerated) {
-      NS_ASSERTION(arr->Item(5).GetIntValue() == NS_STYLE_BOX_SHADOW_INSET,
+      NS_ASSERTION(arr->Item(5).GetIntValue() 
+                   == uint8_t(StyleBoxShadowType::Inset),
                    "invalid keyword type for box shadow");
       item->mInset = true;
     } else {
       item->mInset = false;
     }
   }
 
   return shadowList.forget();
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -49,22 +49,35 @@ static inline css::Side operator++(css::
 #define NS_FULL_TO_HALF_CORNER(var_, vert_) ((var_)*2 + !!(vert_))
 
 #define NS_SIDE_IS_VERTICAL(side_) ((side_) % 2)
 #define NS_SIDE_TO_FULL_CORNER(side_, second_) \
   (((side_) + !!(second_)) % 4)
 #define NS_SIDE_TO_HALF_CORNER(side_, second_, parallel_) \
   ((((side_) + !!(second_))*2 + ((side_) + !(parallel_))%2) % 8)
 
+// Basic Shapes (currently unused)
+enum class StyleBasicShape : uint8_t{
+  Polygon,
+  Circle,
+  Ellipse,
+  Inset,
+};
+
 // box-sizing
 enum class StyleBoxSizing : uint8_t {
   Content,
   Border
 };
 
+// box-shadow
+enum class StyleBoxShadowType : uint8_t {
+  Inset,
+};
+
 // clip-path type
 // X11 has a #define for None causing conflicts, so we use None_ here
 enum class StyleClipPathType : uint8_t {
   None_,
   URL,
   Shape,
   Box,
 };
@@ -76,25 +89,16 @@ enum class StyleClipShapeSizing : uint8_
     Padding,
     Border,
     Margin,
     Fill,
     Stroke,
     View,
 };
 
-// Basic Shapes
-#define NS_STYLE_BASIC_SHAPE_POLYGON       0
-#define NS_STYLE_BASIC_SHAPE_CIRCLE        1
-#define NS_STYLE_BASIC_SHAPE_ELLIPSE       2
-#define NS_STYLE_BASIC_SHAPE_INSET         3
-
-// box-shadow
-#define NS_STYLE_BOX_SHADOW_INSET         0
-
 // float-edge
 #define NS_STYLE_FLOAT_EDGE_CONTENT_BOX    0
 #define NS_STYLE_FLOAT_EDGE_MARGIN_BOX     1
 
 // user-focus
 #define NS_STYLE_USER_FOCUS_NONE            0
 #define NS_STYLE_USER_FOCUS_IGNORE          1
 #define NS_STYLE_USER_FOCUS_NORMAL          2