Bug 1288383 - Replace NS_STYLE_BOX_SHADOW_* and NS_STYLE_BASIC_SHAPE_* with enum classes; r=heycam draft
authorManish Goregaokar <manishearth@gmail.com>
Mon, 25 Jul 2016 11:53:27 +0530
changeset 392235 8bd51a9bd776c02979093a0ec76cfc42bcee8ffd
parent 392234 db3ab986f7708540219cefa18a21b4624a2dc27a
child 392236 73c3446ba07f31f3fbfb6eca304ebe88cccf359a
push id23970
push usermanishearth@gmail.com
push dateMon, 25 Jul 2016 06:25: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: EgC9rPNXbod
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