Bug 1223653 patch 2 - Use an enum class for NS_STYLE_BOX_SIZING_*. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Thu, 19 Nov 2015 18:09:29 -0800
changeset 273422 965b8e749d1f06b34ec176e4a7ddc5dcfd444e6e
parent 273421 73e519e9ec5e8a458d95dcf2ef6bda5ccb232cd4
child 273423 105ecf853d5aedb474f76f36bc3dadba92b6fb9a
push id68272
push userdbaron@mozilla.com
push dateFri, 20 Nov 2015 02:10:18 +0000
treeherdermozilla-inbound@965b8e749d1f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1223653, 1224918
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1223653 patch 2 - Use an enum class for NS_STYLE_BOX_SIZING_*. r=heycam The casts in nsCSSProps.cpp (defining kBoxSizingKTable) and in nsComputedDOMStyle::DoGetBoxSizing (using nsCSSProps::ValueToKeywordEnum) are a little bit annoying, though aren't a net reduction in typesafety. The casts in nsRuleNode.cpp (SetDiscrete) are a little more annoying, though the change in this patch should be sufficient for converting all properties -- but that may also mean reducing typesafety a bit for all properties. I'd like to find something better to do about them, but I think I'm ok landing this before doing that. Bug 1224918 covers doing better.
dom/html/nsGenericHTMLElement.cpp
layout/base/nsLayoutUtils.cpp
layout/generic/nsFrame.cpp
layout/generic/nsHTMLReflowState.cpp
layout/generic/nsHTMLReflowState.h
layout/style/nsCSSProps.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsRuleNode.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/tables/BasicTableLayoutStrategy.cpp
layout/tables/FixedTableLayoutStrategy.cpp
layout/tables/nsTableRowFrame.cpp
layout/xul/nsResizerFrame.cpp
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -399,17 +399,17 @@ nsGenericHTMLElement::GetOffsetRect(CSSI
       if (html_doc) {
         offsetParent = static_cast<nsHTMLDocument*>(html_doc.get())->GetBody();
       }
     }
   }
 
   // Subtract the parent border unless it uses border-box sizing.
   if (parent &&
-      parent->StylePosition()->mBoxSizing != NS_STYLE_BOX_SIZING_BORDER) {
+      parent->StylePosition()->mBoxSizing != StyleBoxSizing::Border) {
     const nsStyleBorder* border = parent->StyleBorder();
     origin.x -= border->GetComputedBorderWidth(NS_SIDE_LEFT);
     origin.y -= border->GetComputedBorderWidth(NS_SIDE_TOP);
   }
 
   // XXX We should really consider subtracting out padding for
   // content-box sizing, but we should see what IE does....
 
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -4502,17 +4502,17 @@ static int32_t gNoiseIndent = 0;
  * @param aFlags same as for IntrinsicForContainer
  * @param aContainerWM the container's WM
  */
 static nscoord
 AddIntrinsicSizeOffset(nsRenderingContext* aRenderingContext,
                        nsIFrame* aFrame,
                        const nsIFrame::IntrinsicISizeOffsetData& aOffsets,
                        nsLayoutUtils::IntrinsicISizeType aType,
-                       uint8_t aBoxSizing,
+                       StyleBoxSizing aBoxSizing,
                        nscoord aContentSize,
                        nscoord aContentMinSize,
                        const nsStyleCoord& aStyleSize,
                        const nscoord* aFixedMinSize,
                        const nsStyleCoord& aStyleMinSize,
                        const nscoord* aFixedMaxSize,
                        const nsStyleCoord& aStyleMaxSize,
                        uint32_t aFlags,
@@ -4523,29 +4523,29 @@ AddIntrinsicSizeOffset(nsRenderingContex
   nscoord coordOutsideSize = 0;
   float pctOutsideSize = 0;
   float pctTotal = 0.0f;
 
   if (!(aFlags & nsLayoutUtils::IGNORE_PADDING)) {
     coordOutsideSize += aOffsets.hPadding;
     pctOutsideSize += aOffsets.hPctPadding;
 
-    if (aBoxSizing == NS_STYLE_BOX_SIZING_PADDING) {
+    if (aBoxSizing == StyleBoxSizing::Padding) {
       min += coordOutsideSize;
       result = NSCoordSaturatingAdd(result, coordOutsideSize);
       pctTotal += pctOutsideSize;
 
       coordOutsideSize = 0;
       pctOutsideSize = 0.0f;
     }
   }
 
   coordOutsideSize += aOffsets.hBorder;
 
-  if (aBoxSizing == NS_STYLE_BOX_SIZING_BORDER) {
+  if (aBoxSizing == StyleBoxSizing::Border) {
     min += coordOutsideSize;
     result = NSCoordSaturatingAdd(result, coordOutsideSize);
     pctTotal += pctOutsideSize;
 
     coordOutsideSize = 0;
     pctOutsideSize = 0.0f;
   }
 
@@ -4663,17 +4663,17 @@ nsLayoutUtils::IntrinsicForAxis(Physical
   // If aFrame is a container for font size inflation, then shrink
   // wrapping inside of it should not apply font size inflation.
   AutoMaybeDisableFontInflation an(aFrame);
 
   // We want the size this frame will contribute to the parent's inline-size,
   // so we work in the parent's writing mode; but if aFrame is orthogonal to
   // its parent, we'll need to look at its BSize instead of min/pref-ISize.
   const nsStylePosition* stylePos = aFrame->StylePosition();
-  uint8_t boxSizing = stylePos->mBoxSizing;
+  StyleBoxSizing boxSizing = stylePos->mBoxSizing;
 
   const nsStyleCoord& styleMinISize =
     horizontalAxis ? stylePos->mMinWidth : stylePos->mMinHeight;
   const nsStyleCoord& styleISize =
     (aFlags & MIN_INTRINSIC_ISIZE) ? styleMinISize :
     (horizontalAxis ? stylePos->mWidth : stylePos->mHeight);
   MOZ_ASSERT(!(aFlags & MIN_INTRINSIC_ISIZE) ||
              styleISize.GetUnit() == eStyleUnit_Auto ||
@@ -4720,17 +4720,17 @@ nsLayoutUtils::IntrinsicForAxis(Physical
   // we'll never need the intrinsic dimensions.
   if (styleISize.GetUnit() == eStyleUnit_Enumerated &&
       (styleISize.GetIntValue() == NS_STYLE_WIDTH_MAX_CONTENT ||
        styleISize.GetIntValue() == NS_STYLE_WIDTH_MIN_CONTENT)) {
     // -moz-fit-content and -moz-available enumerated widths compute intrinsic
     // widths just like auto.
     // For -moz-max-content and -moz-min-content, we handle them like
     // specified widths, but ignore box-sizing.
-    boxSizing = NS_STYLE_BOX_SIZING_CONTENT;
+    boxSizing = StyleBoxSizing::Content;
   } else if (!styleISize.ConvertsToLength() &&
              !(haveFixedMinISize && haveFixedMaxISize && maxISize <= minISize)) {
 #ifdef DEBUG_INTRINSIC_WIDTH
     ++gNoiseIndent;
 #endif
     if (MOZ_UNLIKELY(aAxis != ourInlineAxis)) {
       // We need aFrame's block-dir size.
       if (aFlags & BAIL_IF_REFLOW_NEEDED) {
@@ -4782,24 +4782,24 @@ nsLayoutUtils::IntrinsicForAxis(Physical
       nscoord ratioISize = (horizontalAxis ? ratio.width  : ratio.height);
       nscoord ratioBSize = (horizontalAxis ? ratio.height : ratio.width);
       if (ratioBSize != 0) {
         AddStateBitToAncestors(aFrame,
             NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE);
 
         nscoord bSizeTakenByBoxSizing = 0;
         switch (boxSizing) {
-        case NS_STYLE_BOX_SIZING_BORDER: {
+        case StyleBoxSizing::Border: {
           const nsStyleBorder* styleBorder = aFrame->StyleBorder();
           bSizeTakenByBoxSizing +=
             horizontalAxis ? styleBorder->GetComputedBorder().TopBottom()
                            : styleBorder->GetComputedBorder().LeftRight();
           // fall through
         }
-        case NS_STYLE_BOX_SIZING_PADDING: {
+        case StyleBoxSizing::Padding: {
           if (!(aFlags & IGNORE_PADDING)) {
             const nsStyleSides& stylePadding =
               aFrame->StylePadding()->mPadding;
             const nsStyleCoord& paddingStart =
               stylePadding.Get(horizontalAxis ? NS_SIDE_TOP : NS_SIDE_LEFT);
             const nsStyleCoord& paddingEnd =
               stylePadding.Get(horizontalAxis ? NS_SIDE_BOTTOM : NS_SIDE_RIGHT);
             nscoord pad;
@@ -4809,17 +4809,17 @@ nsLayoutUtils::IntrinsicForAxis(Physical
             }
             if (GetAbsoluteCoord(paddingEnd, pad) ||
                 GetPercentBSize(paddingEnd, aFrame, pad)) {
               bSizeTakenByBoxSizing += pad;
             }
           }
           // fall through
         }
-        case NS_STYLE_BOX_SIZING_CONTENT:
+        case StyleBoxSizing::Content:
         default:
           break;
         }
 
         nscoord h;
         if (GetAbsoluteCoord(styleBSize, h) ||
             GetPercentBSize(styleBSize, aFrame, h)) {
           h = std::max(0, h - bSizeTakenByBoxSizing);
@@ -5186,21 +5186,25 @@ nsLayoutUtils::ComputeSizeWithIntrinsicD
   // a * (b / c) because of its reduced accuracy relative to a * b / c
   // or (a * b) / c (which are equivalent).
 
   const bool isAutoISize = inlineStyleCoord->GetUnit() == eStyleUnit_Auto;
   const bool isAutoBSize = IsAutoBSize(*blockStyleCoord, aCBSize.BSize(aWM));
 
   LogicalSize boxSizingAdjust(aWM);
   switch (stylePos->mBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       boxSizingAdjust += aBorder;
       // fall through
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       boxSizingAdjust += aPadding;
+      // fall through
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
   nscoord boxSizingToMarginEdgeISize =
     aMargin.ISize(aWM) + aBorder.ISize(aWM) + aPadding.ISize(aWM) -
       boxSizingAdjust.ISize(aWM);
 
   nscoord iSize, minISize, maxISize, bSize, minBSize, maxBSize;
 
   if (!isAutoISize) {
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4299,21 +4299,25 @@ nsFrame::ComputeSize(nsRenderingContext 
   LogicalSize result = ComputeAutoSize(aRenderingContext, aWM,
                                        aCBSize, aAvailableISize,
                                        aMargin, aBorder, aPadding,
                                        aFlags & ComputeSizeFlags::eShrinkWrap);
   LogicalSize boxSizingAdjust(aWM);
   const nsStylePosition *stylePos = StylePosition();
 
   switch (stylePos->mBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       boxSizingAdjust += aBorder;
       // fall through
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       boxSizingAdjust += aPadding;
+      // fall through
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
   nscoord boxSizingToMarginEdgeISize =
     aMargin.ISize(aWM) + aBorder.ISize(aWM) + aPadding.ISize(aWM) -
     boxSizingAdjust.ISize(aWM);
 
   const nsStyleCoord* inlineStyleCoord = &stylePos->ISize(aWM);
   const nsStyleCoord* blockStyleCoord = &stylePos->BSize(aWM);
 
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -246,50 +246,56 @@ nsCSSOffsetState::ComputeISizeValue(nsco
                                           aContainingBlockISize,
                                           aContentEdgeToBoxSizing,
                                           aBoxSizingToMarginEdge,
                                           aCoord);
 }
 
 nscoord
 nsCSSOffsetState::ComputeISizeValue(nscoord aContainingBlockISize,
-                                    uint8_t aBoxSizing,
+                                    StyleBoxSizing aBoxSizing,
                                     const nsStyleCoord& aCoord)
 {
   WritingMode wm = GetWritingMode();
   nscoord inside = 0, outside = ComputedLogicalBorderPadding().IStartEnd(wm) +
                                 ComputedLogicalMargin().IStartEnd(wm);
   switch (aBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       inside = ComputedLogicalBorderPadding().IStartEnd(wm);
       break;
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       inside = ComputedLogicalPadding().IStartEnd(wm);
       break;
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
   outside -= inside;
 
   return ComputeISizeValue(aContainingBlockISize, inside,
                            outside, aCoord);
 }
 
 nscoord
 nsCSSOffsetState::ComputeBSizeValue(nscoord aContainingBlockBSize,
-                                    uint8_t aBoxSizing,
+                                    StyleBoxSizing aBoxSizing,
                                     const nsStyleCoord& aCoord)
 {
   WritingMode wm = GetWritingMode();
   nscoord inside = 0;
   switch (aBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       inside = ComputedLogicalBorderPadding().BStartEnd(wm);
       break;
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       inside = ComputedLogicalPadding().BStartEnd(wm);
       break;
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
   return nsLayoutUtils::ComputeBSizeValue(aContainingBlockBSize,
                                           inside, aCoord);
 }
 
 void
 nsHTMLReflowState::SetComputedWidth(nscoord aComputedWidth)
 {
@@ -1128,21 +1134,25 @@ nsHTMLReflowState::CalculateBorderPaddin
                                 mStyleMargin->mMargin.Get(endSide));
     }
     marginStartEnd = start + end;
   }
 
   nscoord outside = paddingStartEnd + borderStartEnd + marginStartEnd;
   nscoord inside = 0;
   switch (mStylePosition->mBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       inside += borderStartEnd;
       // fall through
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       inside += paddingStartEnd;
+      // fall through
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
   outside -= inside;
   *aInsideBoxSizing = inside;
   *aOutsideBoxSizing = outside;
   return;
 }
 
 /**
--- a/layout/generic/nsHTMLReflowState.h
+++ b/layout/generic/nsHTMLReflowState.h
@@ -245,21 +245,21 @@ protected:
    */
   inline nscoord ComputeISizeValue(nscoord aContainingBlockISize,
                                    nscoord aContentEdgeToBoxSizing,
                                    nscoord aBoxSizingToMarginEdge,
                                    const nsStyleCoord& aCoord);
   // same as previous, but using mComputedBorderPadding, mComputedPadding,
   // and mComputedMargin
   nscoord ComputeISizeValue(nscoord aContainingBlockISize,
-                            uint8_t aBoxSizing,
+                            mozilla::StyleBoxSizing aBoxSizing,
                             const nsStyleCoord& aCoord);
 
   nscoord ComputeBSizeValue(nscoord aContainingBlockBSize,
-                            uint8_t aBoxSizing,
+                            mozilla::StyleBoxSizing aBoxSizing,
                             const nsStyleCoord& aCoord);
 };
 
 /**
  * State passed to a frame during reflow or intrinsic size calculation.
  *
  * XXX Refactor so only a base class (nsSizingState?) is used for intrinsic
  * size calculation.
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -983,19 +983,19 @@ const KTableEntry nsCSSProps::kBoxDecora
 };
 
 const KTableEntry nsCSSProps::kBoxShadowTypeKTable[] = {
   { eCSSKeyword_inset, NS_STYLE_BOX_SHADOW_INSET },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxSizingKTable[] = {
-  { eCSSKeyword_content_box,  NS_STYLE_BOX_SIZING_CONTENT },
-  { eCSSKeyword_border_box,   NS_STYLE_BOX_SIZING_BORDER },
-  { eCSSKeyword_padding_box,  NS_STYLE_BOX_SIZING_PADDING },
+  { eCSSKeyword_content_box,  uint8_t(StyleBoxSizing::Content) },
+  { eCSSKeyword_border_box,   uint8_t(StyleBoxSizing::Border) },
+  { eCSSKeyword_padding_box,  uint8_t(StyleBoxSizing::Padding) },
   { eCSSKeyword_UNKNOWN,      -1 }
 };
 
 const KTableEntry nsCSSProps::kCaptionSideKTable[] = {
   { eCSSKeyword_top,                  NS_STYLE_CAPTION_SIDE_TOP },
   { eCSSKeyword_right,                NS_STYLE_CAPTION_SIDE_RIGHT },
   { eCSSKeyword_bottom,               NS_STYLE_CAPTION_SIDE_BOTTOM },
   { eCSSKeyword_left,                 NS_STYLE_CAPTION_SIDE_LEFT },
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -528,22 +528,25 @@ nsMargin
 nsComputedDOMStyle::GetAdjustedValuesForBoxSizing()
 {
   // We want the width/height of whatever parts 'width' or 'height' controls,
   // which can be different depending on the value of the 'box-sizing' property.
   const nsStylePosition* stylePos = StylePosition();
 
   nsMargin adjustment;
   switch(stylePos->mBoxSizing) {
-    case NS_STYLE_BOX_SIZING_BORDER:
+    case StyleBoxSizing::Border:
       adjustment += mInnerFrame->GetUsedBorder();
       // fall through
-
-    case NS_STYLE_BOX_SIZING_PADDING:
+    case StyleBoxSizing::Padding:
       adjustment += mInnerFrame->GetUsedPadding();
+      // fall through
+    case StyleBoxSizing::Content:
+      // nothing
+      break;
   }
 
   return adjustment;
 }
 
 /* static */
 nsIPresShell*
 nsComputedDOMStyle::GetPresShellForContent(nsIContent* aContent)
@@ -3774,17 +3777,17 @@ nsComputedDOMStyle::DoGetBoxPack()
   return val;
 }
 
 CSSValue*
 nsComputedDOMStyle::DoGetBoxSizing()
 {
   nsROCSSPrimitiveValue *val = new nsROCSSPrimitiveValue;
   val->SetIdent(
-    nsCSSProps::ValueToKeywordEnum(StylePosition()->mBoxSizing,
+    nsCSSProps::ValueToKeywordEnum(uint8_t(StylePosition()->mBoxSizing),
                                    nsCSSProps::kBoxSizingKTable));
   return val;
 }
 
 /* Border image properties */
 
 CSSValue*
 nsComputedDOMStyle::DoGetBorderImageSource()
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -1302,24 +1302,24 @@ SetDiscrete(const nsCSSValue& aValue, Fi
   case eCSSUnit_Initial:
     aField = aInitialValue;
     return;
 
     // every caller provides one or other of these alternatives,
     // but they have to say which
   case eCSSUnit_Enumerated:
     if (aMask & SETDSC_ENUMERATED) {
-      aField = aValue.GetIntValue();
+      aField = FieldT(aValue.GetIntValue());
       return;
     }
     break;
 
   case eCSSUnit_Integer:
     if (aMask & SETDSC_INTEGER) {
-      aField = aValue.GetIntValue();
+      aField = FieldT(aValue.GetIntValue());
       return;
     }
     break;
 
     // remaining possibilities in descending order of frequency of use
   case eCSSUnit_Auto:
     if (aMask & SETDSC_AUTO) {
       aField = aAutoValue;
@@ -7851,17 +7851,21 @@ nsRuleNode::ComputePositionData(void* aS
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   // box-sizing: enum, inherit, initial
   SetDiscrete(*aRuleData->ValueForBoxSizing(),
               pos->mBoxSizing, conditions,
               SETDSC_ENUMERATED | SETDSC_UNSET_INITIAL,
               parentPos->mBoxSizing,
-              NS_STYLE_BOX_SIZING_CONTENT, 0, 0, 0, 0);
+              StyleBoxSizing::Content,
+              StyleBoxSizing::Content /* ignored */,
+              StyleBoxSizing::Content /* ignored */,
+              StyleBoxSizing::Content /* ignored */,
+              StyleBoxSizing::Content /* ignored */);
 
   // align-content: enum, inherit, initial
   const auto& alignContentValue = *aRuleData->ValueForAlignContent();
   if (MOZ_UNLIKELY(alignContentValue.GetUnit() == eCSSUnit_Inherit)) {
     if (MOZ_LIKELY(parentContext)) {
       pos->mAlignContent =
         parentPos->ComputedAlignContent(parentContext->StyleDisplay());
     } else {
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -13,23 +13,22 @@
 
 // XXX fold this into nsStyleContext and group by nsStyleXXX struct
 
 // Indices into border/padding/margin arrays
 namespace mozilla {
 namespace css {
 typedef mozilla::Side Side;
 } // namespace css
-} // namespace mozilla
 
 #define NS_FOR_CSS_SIDES(var_) for (mozilla::css::Side var_ = NS_SIDE_TOP; var_ <= NS_SIDE_LEFT; var_++)
-static inline mozilla::css::Side operator++(mozilla::css::Side& side, int) {
+static inline css::Side operator++(css::Side& side, int) {
     NS_PRECONDITION(side >= NS_SIDE_TOP &&
                     side <= NS_SIDE_LEFT, "Out of range side");
-    side = mozilla::css::Side(side + 1);
+    side = css::Side(side + 1);
     return side;
 }
 
 #define NS_FOR_CSS_FULL_CORNERS(var_) for (int32_t var_ = 0; var_ < 4; ++var_)
 
 // Indices into "half corner" arrays (nsStyleCorners e.g.)
 #define NS_CORNER_TOP_LEFT_X      0
 #define NS_CORNER_TOP_LEFT_Y      1
@@ -52,19 +51,21 @@ static inline mozilla::css::Side operato
 
 #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)
 
 // box-sizing
-#define NS_STYLE_BOX_SIZING_CONTENT       0
-#define NS_STYLE_BOX_SIZING_PADDING       1
-#define NS_STYLE_BOX_SIZING_BORDER        2
+enum class StyleBoxSizing : uint8_t {
+  Content,
+  Padding,
+  Border
+};
 
 // clip-path sizing
 #define NS_STYLE_CLIP_SHAPE_SIZING_NOBOX   0
 #define NS_STYLE_CLIP_SHAPE_SIZING_CONTENT 1
 #define NS_STYLE_CLIP_SHAPE_SIZING_PADDING 2
 #define NS_STYLE_CLIP_SHAPE_SIZING_BORDER  3
 #define NS_STYLE_CLIP_SHAPE_SIZING_MARGIN  4
 #define NS_STYLE_CLIP_SHAPE_SIZING_FILL    5
@@ -1153,9 +1154,11 @@ static inline mozilla::css::Side operato
 // orientation
 #define NS_STYLE_ORIENTATION_PORTRAIT           0
 #define NS_STYLE_ORIENTATION_LANDSCAPE          1
 
 // scan
 #define NS_STYLE_SCAN_PROGRESSIVE               0
 #define NS_STYLE_SCAN_INTERLACE                 1
 
+} // namespace mozilla
+
 #endif /* nsStyleConsts_h___ */
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -1429,17 +1429,17 @@ nsStylePosition::nsStylePosition(void)
   // The initial value of grid-auto-columns and grid-auto-rows is 'auto',
   // which computes to 'minmax(auto, auto)'.
   mGridAutoColumnsMin.SetAutoValue();
   mGridAutoColumnsMax.SetAutoValue();
   mGridAutoRowsMin.SetAutoValue();
   mGridAutoRowsMax.SetAutoValue();
 
   mGridAutoFlow = NS_STYLE_GRID_AUTO_FLOW_ROW;
-  mBoxSizing = NS_STYLE_BOX_SIZING_CONTENT;
+  mBoxSizing = StyleBoxSizing::Content;
   mAlignContent = NS_STYLE_ALIGN_AUTO;
   mAlignItems = NS_STYLE_ALIGN_AUTO;
   mAlignSelf = NS_STYLE_ALIGN_AUTO;
   mJustifyContent = NS_STYLE_JUSTIFY_AUTO;
   mJustifyItems = NS_STYLE_JUSTIFY_AUTO;
   mJustifySelf = NS_STYLE_JUSTIFY_AUTO;
   mFlexDirection = NS_STYLE_FLEX_DIRECTION_ROW;
   mFlexWrap = NS_STYLE_FLEX_WRAP_NOWRAP;
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1454,17 +1454,17 @@ struct nsStylePosition {
   nsStyleCoord  mMinHeight;             // [reset] coord, percent, calc
   nsStyleCoord  mMaxHeight;             // [reset] coord, percent, calc, none
   nsStyleCoord  mFlexBasis;             // [reset] coord, percent, enum, calc, auto
   nsStyleCoord  mGridAutoColumnsMin;    // [reset] coord, percent, enum, calc, flex
   nsStyleCoord  mGridAutoColumnsMax;    // [reset] coord, percent, enum, calc, flex
   nsStyleCoord  mGridAutoRowsMin;       // [reset] coord, percent, enum, calc, flex
   nsStyleCoord  mGridAutoRowsMax;       // [reset] coord, percent, enum, calc, flex
   uint8_t       mGridAutoFlow;          // [reset] enumerated. See nsStyleConsts.h
-  uint8_t       mBoxSizing;             // [reset] see nsStyleConsts.h
+  mozilla::StyleBoxSizing mBoxSizing;   // [reset] see nsStyleConsts.h
 private:
   friend class nsRuleNode;
   // Helper for the ComputedAlign/Justify* methods.
   uint8_t MapLeftRightToStart(uint8_t aAlign, mozilla::LogicalAxis aAxis,
                               const nsStyleDisplay* aDisplay) const;
 
   uint16_t      mAlignContent;          // [reset] fallback value in the high byte
   uint8_t       mAlignItems;            // [reset] see nsStyleConsts.h
--- a/layout/tables/BasicTableLayoutStrategy.cpp
+++ b/layout/tables/BasicTableLayoutStrategy.cpp
@@ -116,26 +116,25 @@ GetISizeInfo(nsRenderingContext *aRender
         // for bsize).
         // For this reason, we also do not use box-sizing for just one of
         // them, as this may be confusing.
         if (isQuirks) {
             boxSizingToBorderEdge = offsets.hPadding + offsets.hBorder;
         }
         else {
             switch (stylePos->mBoxSizing) {
-                case NS_STYLE_BOX_SIZING_CONTENT:
+                case StyleBoxSizing::Content:
                     boxSizingToBorderEdge = offsets.hPadding + offsets.hBorder;
                     break;
-                case NS_STYLE_BOX_SIZING_PADDING:
+                case StyleBoxSizing::Padding:
                     minCoord += offsets.hPadding;
                     prefCoord += offsets.hPadding;
                     boxSizingToBorderEdge = offsets.hBorder;
                     break;
-                default:
-                    // NS_STYLE_BOX_SIZING_BORDER
+                case StyleBoxSizing::Border:
                     minCoord += offsets.hPadding + offsets.hBorder;
                     prefCoord += offsets.hPadding + offsets.hBorder;
                     break;
             }
         }
     } else {
         minCoord = 0;
         prefCoord = 0;
--- a/layout/tables/FixedTableLayoutStrategy.cpp
+++ b/layout/tables/FixedTableLayoutStrategy.cpp
@@ -253,23 +253,23 @@ FixedTableLayoutStrategy::ComputeColumnI
           // XXX This should use real percentage padding
           nsIFrame::IntrinsicISizeOffsetData offsets =
             cellFrame->IntrinsicISizeOffsets();
           float pct = styleISize->GetPercentValue();
           colISize = NSToCoordFloor(pct * float(tableISize));
 
           nscoord boxSizingAdjust = 0;
           switch (cellFrame->StylePosition()->mBoxSizing) {
-            case NS_STYLE_BOX_SIZING_CONTENT:
+            case StyleBoxSizing::Content:
               boxSizingAdjust += offsets.hPadding;
               // Fall through
-            case NS_STYLE_BOX_SIZING_PADDING:
+            case StyleBoxSizing::Padding:
               boxSizingAdjust += offsets.hBorder;
               // Fall through
-            case NS_STYLE_BOX_SIZING_BORDER:
+            case StyleBoxSizing::Border:
               // Don't add anything
               break;
           }
           colISize += boxSizingAdjust;
 
           pct /= float(colSpan);
           colFrame->AddPrefPercent(pct);
           pctTotal += pct;
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -664,26 +664,25 @@ nsTableRowFrame::CalculateCellActualBSiz
       nscoord outsideBoxSizing = 0;
       // In quirks mode, table cell isize should be content-box, but bsize
       // should be border-box.
       // Because of this historic anomaly, we do not use quirk.css
       // (since we can't specify one value of box-sizing for isize and another
       // for bsize)
       if (PresContext()->CompatibilityMode() != eCompatibility_NavQuirks) {
         switch (position->mBoxSizing) {
-          case NS_STYLE_BOX_SIZING_CONTENT:
+          case StyleBoxSizing::Content:
             outsideBoxSizing =
               aCellFrame->GetLogicalUsedBorderAndPadding(aWM).BStartEnd(aWM);
             break;
-          case NS_STYLE_BOX_SIZING_PADDING:
+          case StyleBoxSizing::Padding:
             outsideBoxSizing =
               aCellFrame->GetLogicalUsedBorder(aWM).BStartEnd(aWM);
             break;
-          default:
-            // NS_STYLE_BOX_SIZING_BORDER
+          case StyleBoxSizing::Border:
             break;
         }
       }
 
       specifiedBSize =
         nsRuleNode::ComputeCoordPercentCalc(bsizeStyleCoord, 0) +
         outsideBoxSizing;
 
--- a/layout/xul/nsResizerFrame.cpp
+++ b/layout/xul/nsResizerFrame.cpp
@@ -76,21 +76,24 @@ nsResizerFrame::HandleEvent(nsPresContex
           if (!frameToResize)
             break;
 
           // cache the content rectangle for the frame to resize
           // GetScreenRectInAppUnits returns the border box rectangle, so
           // adjust to get the desired content rectangle.
           nsRect rect = frameToResize->GetScreenRectInAppUnits();
           switch (frameToResize->StylePosition()->mBoxSizing) {
-            case NS_STYLE_BOX_SIZING_CONTENT:
+            case StyleBoxSizing::Content:
               rect.Deflate(frameToResize->GetUsedPadding());
-            case NS_STYLE_BOX_SIZING_PADDING:
+              // fall through
+            case StyleBoxSizing::Padding:
               rect.Deflate(frameToResize->GetUsedBorder());
-            default:
+              // fall through
+            case StyleBoxSizing::Border:
+              // nothing
               break;
           }
 
           mMouseDownRect =
             LayoutDeviceIntRect::FromAppUnitsToNearest(rect, aPresContext->AppUnitsPerDevPixel());
           doDefault = false;
         }
         else {