Bug 1460439 - Conversion from NS_STYLE_BORDER_STYLE_* macro to StyleBorderStyle::* enum class r=emilio
authorKristen Wright <kwright@mozilla.com>
Wed, 07 Nov 2018 11:56:17 -0800
changeset 447663 298dbb64883121de67570112df6bb2c90d1b889a
parent 447607 ad8114bf526cfa7c4e878bc6cb48dc582dc3363d
child 447664 9671513ce7e7f7eaa22553fadb8e32c53dcc4686
push id35085
push userebalazs@mozilla.com
push dateThu, 22 Nov 2018 09:21:47 +0000
treeherdermozilla-central@785032241b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1460439
milestone65.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 1460439 - Conversion from NS_STYLE_BORDER_STYLE_* macro to StyleBorderStyle::* enum class r=emilio Converted NS_STYLE_BORDER_STYLE_* consts to enum class. Updated corresponding values to enum class. reduced BCCornerInfo struct values to fit StyleBorderStyle values inside struct. Added defaults to switches that do not fully cover all instances of StyleBorderStyle.
dom/html/HTMLHRElement.cpp
dom/html/nsGenericHTMLElement.cpp
gfx/layers/LayersTypes.h
gfx/webrender_bindings/WebRenderTypes.h
layout/base/nsLayoutUtils.h
layout/forms/nsComboboxControlFrame.cpp
layout/generic/nsColumnSetFrame.cpp
layout/generic/nsFrame.cpp
layout/generic/nsImageFrame.cpp
layout/mathml/nsMathMLmtableFrame.cpp
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsCSSRenderingBorders.h
layout/painting/nsDisplayList.cpp
layout/style/ServoBindings.toml
layout/style/nsCSSProps.cpp
layout/style/nsComputedDOMStyle.cpp
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/tables/nsTableFrame.cpp
layout/xul/tree/nsTreeBodyFrame.cpp
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/longhands/border.mako.rs
servo/components/style/properties/longhands/column.mako.rs
widget/cocoa/nsNativeThemeCocoa.mm
--- a/dom/html/HTMLHRElement.cpp
+++ b/dom/html/HTMLHRElement.cpp
@@ -134,24 +134,24 @@ HTMLHRElement::MapAttributesIntoRule(con
     if (allSides) {
       aDecls.SetPixelValueIfUnset(eCSSProperty_border_right_width, sizePerSide);
       aDecls.SetPixelValueIfUnset(eCSSProperty_border_bottom_width, sizePerSide);
       aDecls.SetPixelValueIfUnset(eCSSProperty_border_left_width, sizePerSide);
     }
 
     if (!aDecls.PropertyIsSet(eCSSProperty_border_top_style))
       aDecls.SetKeywordValue(eCSSProperty_border_top_style,
-                             NS_STYLE_BORDER_STYLE_SOLID);
+                             StyleBorderStyle::Solid);
     if (allSides) {
       aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style,
-                                    NS_STYLE_BORDER_STYLE_SOLID);
+                                    StyleBorderStyle::Solid);
       aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style,
-                                    NS_STYLE_BORDER_STYLE_SOLID);
+                                    StyleBorderStyle::Solid);
       aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style,
-                                    NS_STYLE_BORDER_STYLE_SOLID);
+                                    StyleBorderStyle::Solid);
 
       // If it would be noticeable, set the border radius to
       // 10000px on all corners; this triggers the clamping to make
       // circular ends.  This assumes the <hr> isn't larger than
       // that in *both* dimensions.
       for (const nsCSSPropertyID* props =
             nsCSSProps::SubpropertyEntryFor(eCSSProperty_border_radius);
            *props != eCSSProperty_UNKNOWN; ++props) {
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -1437,23 +1437,23 @@ nsGenericHTMLElement::MapImageBorderAttr
     val = value->GetIntegerValue();
 
   aDecls.SetPixelValueIfUnset(eCSSProperty_border_top_width, (float)val);
   aDecls.SetPixelValueIfUnset(eCSSProperty_border_right_width, (float)val);
   aDecls.SetPixelValueIfUnset(eCSSProperty_border_bottom_width, (float)val);
   aDecls.SetPixelValueIfUnset(eCSSProperty_border_left_width, (float)val);
 
   aDecls.SetKeywordValueIfUnset(eCSSProperty_border_top_style,
-                                NS_STYLE_BORDER_STYLE_SOLID);
+                                StyleBorderStyle::Solid);
   aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style,
-                                NS_STYLE_BORDER_STYLE_SOLID);
+                                StyleBorderStyle::Solid);
   aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style,
-                                NS_STYLE_BORDER_STYLE_SOLID);
+                                StyleBorderStyle::Solid);
   aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style,
-                                NS_STYLE_BORDER_STYLE_SOLID);
+                                StyleBorderStyle::Solid);
 
   aDecls.SetCurrentColorIfUnset(eCSSProperty_border_top_color);
   aDecls.SetCurrentColorIfUnset(eCSSProperty_border_right_color);
   aDecls.SetCurrentColorIfUnset(eCSSProperty_border_bottom_color);
   aDecls.SetCurrentColorIfUnset(eCSSProperty_border_left_color);
 }
 
 void
--- a/gfx/layers/LayersTypes.h
+++ b/gfx/layers/LayersTypes.h
@@ -10,16 +10,17 @@
 #include <stdint.h>                     // for uint32_t
 
 #include "Units.h"
 #include "mozilla/DefineEnum.h"         // for MOZ_DEFINE_ENUM
 #include "mozilla/gfx/Point.h"          // for IntPoint
 #include "mozilla/Maybe.h"
 #include "mozilla/TypedEnumBits.h"
 #include "nsRegion.h"
+#include "nsStyleConsts.h"
 
 #include <stdio.h>            // FILE
 #include "mozilla/Logging.h"            // for PR_LOG
 
 #ifndef MOZ_LAYERS_HAVE_LOG
 #  define MOZ_LAYERS_HAVE_LOG
 #endif
 #define MOZ_LAYERS_LOG(_args)                             \
@@ -387,17 +388,17 @@ typedef gfx::Matrix4x4Typed<LayerPixel, 
 // matrices, a ViewAs operation is needed. A MultipleAsyncTransforms
 // PixelCastJustification is provided for this purpose.
 typedef gfx::Matrix4x4Typed<ParentLayerPixel, ParentLayerPixel> AsyncTransformComponentMatrix;
 typedef gfx::Matrix4x4Typed<CSSTransformedLayerPixel, ParentLayerPixel> AsyncTransformMatrix;
 
 typedef Array<gfx::Color, 4> BorderColors;
 typedef Array<LayerSize, 4> BorderCorners;
 typedef Array<LayerCoord, 4> BorderWidths;
-typedef Array<uint8_t, 4> BorderStyles;
+typedef Array<StyleBorderStyle, 4> BorderStyles;
 
 typedef Maybe<LayerRect> MaybeLayerRect;
 
 // This is used to communicate Layers across IPC channels. The Handle is valid
 // for layers in the same PLayerTransaction. Handles are created by ClientLayerManager,
 // and are cached in LayerTransactionParent on first use.
 class LayerHandle
 {
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -447,46 +447,46 @@ static inline wr::LayoutTransform ToLayo
   transform.m34 = m._34;
   transform.m41 = m._41;
   transform.m42 = m._42;
   transform.m43 = m._43;
   transform.m44 = m._44;
   return transform;
 }
 
-static inline wr::BorderStyle ToBorderStyle(const uint8_t& style)
+static inline wr::BorderStyle ToBorderStyle(const StyleBorderStyle& style)
 {
   switch (style) {
-  case NS_STYLE_BORDER_STYLE_NONE:
+  case StyleBorderStyle::None:
     return wr::BorderStyle::None;
-  case NS_STYLE_BORDER_STYLE_SOLID:
+  case StyleBorderStyle::Solid:
     return wr::BorderStyle::Solid;
-  case NS_STYLE_BORDER_STYLE_DOUBLE:
+  case StyleBorderStyle::Double:
     return wr::BorderStyle::Double;
-  case NS_STYLE_BORDER_STYLE_DOTTED:
+  case StyleBorderStyle::Dotted:
     return wr::BorderStyle::Dotted;
-  case NS_STYLE_BORDER_STYLE_DASHED:
+  case StyleBorderStyle::Dashed:
     return wr::BorderStyle::Dashed;
-  case NS_STYLE_BORDER_STYLE_HIDDEN:
+  case StyleBorderStyle::Hidden:
     return wr::BorderStyle::Hidden;
-  case NS_STYLE_BORDER_STYLE_GROOVE:
+  case StyleBorderStyle::Groove:
     return wr::BorderStyle::Groove;
-  case NS_STYLE_BORDER_STYLE_RIDGE:
+  case StyleBorderStyle::Ridge:
     return wr::BorderStyle::Ridge;
-  case NS_STYLE_BORDER_STYLE_INSET:
+  case StyleBorderStyle::Inset:
     return wr::BorderStyle::Inset;
-  case NS_STYLE_BORDER_STYLE_OUTSET:
+  case StyleBorderStyle::Outset:
     return wr::BorderStyle::Outset;
   default:
     MOZ_ASSERT(false);
   }
   return wr::BorderStyle::None;
 }
 
-static inline wr::BorderSide ToBorderSide(const gfx::Color& color, const uint8_t& style)
+static inline wr::BorderSide ToBorderSide(const gfx::Color& color, const StyleBorderStyle& style)
 {
   wr::BorderSide bs;
   bs.color = ToColorF(color);
   bs.style = ToBorderStyle(style);
   return bs;
 }
 
 static inline wr::BorderRadius EmptyBorderRadius()
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -1766,22 +1766,22 @@ public:
   static nsIFrame* GetClosestLayer(nsIFrame* aFrame);
 
   /**
    * Gets the graphics sampling filter for the frame
    */
   static SamplingFilter GetSamplingFilterForFrame(nsIFrame* aFrame);
 
   static inline void InitDashPattern(StrokeOptions& aStrokeOptions,
-                                     uint8_t aBorderStyle) {
-    if (aBorderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
+                                     mozilla::StyleBorderStyle aBorderStyle) {
+    if (aBorderStyle == mozilla::StyleBorderStyle::Dotted) {
       static Float dot[] = { 1.f, 1.f };
       aStrokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dot);
       aStrokeOptions.mDashPattern = dot;
-    } else if (aBorderStyle == NS_STYLE_BORDER_STYLE_DASHED) {
+    } else if (aBorderStyle == mozilla::StyleBorderStyle::Dashed) {
       static Float dash[] = { 5.f, 5.f };
       aStrokeOptions.mDashLength = MOZ_ARRAY_LENGTH(dash);
       aStrokeOptions.mDashPattern = dash;
     } else {
       aStrokeOptions.mDashLength = 0;
       aStrokeOptions.mDashPattern = nullptr;
     }
   }
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1633,17 +1633,17 @@ void nsComboboxControlFrame::PaintFocus(
   // REVIEW: Why does the old code paint mDisplayFrame again? We've
   // already painted it in the children above. So clipping it here won't do
   // us much good.
 
   /////////////////////
   // draw focus
 
   StrokeOptions strokeOptions;
-  nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
+  nsLayoutUtils::InitDashPattern(strokeOptions, StyleBorderStyle::Dotted);
   ColorPattern color(ToDeviceColor(StyleColor()->mColor));
   nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
   clipRect.width -= onePixel;
   clipRect.height -= onePixel;
   Rect r = ToRect(nsLayoutUtils::RectToGfxRect(clipRect, appUnitsPerDevPixel));
   StrokeSnappedEdgesOfRect(r, aDrawTarget, color, strokeOptions);
 
   aDrawTarget.PopClip();
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -190,23 +190,23 @@ void
 nsColumnSetFrame::CreateBorderRenderers(nsTArray<nsCSSBorderRenderer>& aBorderRenderers,
                                         gfxContext* aCtx,
                                         const nsRect& aDirtyRect,
                                         const nsPoint& aPt)
 {
   WritingMode wm = GetWritingMode();
   bool isVertical = wm.IsVertical();
   const nsStyleColumn* colStyle = StyleColumn();
-  uint8_t ruleStyle;
+  StyleBorderStyle ruleStyle;
 
   // Per spec, inset => ridge and outset => groove
-  if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_INSET)
-    ruleStyle = NS_STYLE_BORDER_STYLE_RIDGE;
-  else if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_OUTSET)
-    ruleStyle = NS_STYLE_BORDER_STYLE_GROOVE;
+  if (colStyle->mColumnRuleStyle == StyleBorderStyle::Inset)
+    ruleStyle = StyleBorderStyle::Ridge;
+  else if (colStyle->mColumnRuleStyle == StyleBorderStyle::Outset)
+    ruleStyle = StyleBorderStyle::Groove;
   else
     ruleStyle = colStyle->mColumnRuleStyle;
 
   nsPresContext* presContext = PresContext();
   nscoord ruleWidth = colStyle->GetComputedColumnRuleWidth();
   if (!ruleWidth)
     return;
 
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -9475,17 +9475,17 @@ ComputeAndIncludeOutlineArea(nsIFrame* a
 
   // Keep this code in sync with GetOutlineInnerRect in nsCSSRendering.cpp.
   aFrame->SetProperty(nsIFrame::OutlineInnerRectProperty(),
                            new nsRect(innerRect));
   const nscoord offset = outline->mOutlineOffset;
   nsRect outerRect(innerRect);
   bool useOutlineAuto = false;
   if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
-    useOutlineAuto = outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO;
+    useOutlineAuto = outline->mOutlineStyle == StyleBorderStyle::Auto;
     if (MOZ_UNLIKELY(useOutlineAuto)) {
       nsPresContext* presContext = aFrame->PresContext();
       nsITheme* theme = presContext->GetTheme();
       if (theme && theme->ThemeSupportsWidget(presContext, aFrame,
                                               StyleAppearance::FocusOutline)) {
         outerRect.Inflate(offset);
         theme->GetWidgetOverflow(presContext->DeviceContext(), aFrame,
                                  StyleAppearance::FocusOutline, &outerRect);
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1360,17 +1360,17 @@ struct nsRecessedBorder : public nsStyle
   nsRecessedBorder(nscoord aBorderWidth, nsPresContext* aPresContext)
     : nsStyleBorder(aPresContext)
   {
     NS_FOR_CSS_SIDES(side) {
       BorderColorFor(side) = StyleComplexColor::Black();
       mBorder.Side(side) = aBorderWidth;
       // Note: use SetBorderStyle here because we want to affect
       // mComputedBorder
-      SetBorderStyle(side, NS_STYLE_BORDER_STYLE_INSET);
+      SetBorderStyle(side, StyleBorderStyle::Inset);
     }
   }
 };
 
 class nsDisplayAltFeedback final : public nsDisplayItem
 {
 public:
   nsDisplayAltFeedback(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
@@ -1907,17 +1907,17 @@ nsImageFrame::PaintImage(gfxContext& aRe
 
     // solid white stroke:
     ColorPattern white(ToDeviceColor(Color(1.f, 1.f, 1.f, 1.f)));
     map->Draw(this, *drawTarget, white);
 
     // then dashed black stroke over the top:
     ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f)));
     StrokeOptions strokeOptions;
-    nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED);
+    nsLayoutUtils::InitDashPattern(strokeOptions, StyleBorderStyle::Dotted);
     map->Draw(this, *drawTarget, black, strokeOptions);
   }
 
   if (result == ImgDrawResult::SUCCESS) {
     mPrevImage = aImage;
   } else if (result == ImgDrawResult::BAD_IMAGE) {
     mPrevImage = nullptr;
   }
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -46,21 +46,21 @@ ParseStyleValue(nsAtom* aAttribute, cons
       return NS_STYLE_TEXT_ALIGN_LEFT;
     else if (aAttributeValue.EqualsLiteral("right"))
       return NS_STYLE_TEXT_ALIGN_RIGHT;
     else
       return NS_STYLE_TEXT_ALIGN_CENTER;
   } else if (aAttribute == nsGkAtoms::rowlines_ ||
              aAttribute == nsGkAtoms::columnlines_) {
     if (aAttributeValue.EqualsLiteral("solid"))
-      return NS_STYLE_BORDER_STYLE_SOLID;
+      return static_cast<int8_t>(StyleBorderStyle::Solid);
     else if (aAttributeValue.EqualsLiteral("dashed"))
-      return NS_STYLE_BORDER_STYLE_DASHED;
+      return static_cast<int8_t>(StyleBorderStyle::Dashed);
     else
-      return NS_STYLE_BORDER_STYLE_NONE;
+      return static_cast<int8_t>(StyleBorderStyle::None);
   } else {
     MOZ_CRASH("Unrecognized attribute.");
   }
 
   return -1;
 }
 
 static nsTArray<int8_t>*
@@ -195,36 +195,36 @@ ApplyBorderToStyle(const nsMathMLmtdFram
     FindCellProperty(aFrame, ColumnLinesProperty());
 
   // We don't place a row line on top of the first row
   if (rowIndex > 0 && rowLinesList) {
     // If the row number is greater than the number of provided rowline
     // values, we simply repeat the last value.
     uint32_t listLength = rowLinesList->Length();
     if (rowIndex < listLength) {
-      aStyleBorder.SetBorderStyle(eSideTop,
-                    rowLinesList->ElementAt(rowIndex - 1));
+      aStyleBorder.SetBorderStyle(eSideTop, static_cast<StyleBorderStyle>(
+                    rowLinesList->ElementAt(rowIndex - 1)));
     } else {
-      aStyleBorder.SetBorderStyle(eSideTop,
-                    rowLinesList->ElementAt(listLength - 1));
+      aStyleBorder.SetBorderStyle(eSideTop, static_cast<StyleBorderStyle>(
+                    rowLinesList->ElementAt(listLength - 1)));
     }
     aStyleBorder.SetBorderWidth(eSideTop, borderWidth);
   }
 
   // We don't place a column line on the left of the first column.
   if (columnIndex > 0 && columnLinesList) {
     // If the column number is greater than the number of provided columline
     // values, we simply repeat the last value.
     uint32_t listLength = columnLinesList->Length();
     if (columnIndex < listLength) {
-      aStyleBorder.SetBorderStyle(eSideLeft,
-                    columnLinesList->ElementAt(columnIndex - 1));
+      aStyleBorder.SetBorderStyle(eSideLeft, static_cast<StyleBorderStyle>(
+                    columnLinesList->ElementAt(columnIndex - 1)));
     } else {
-      aStyleBorder.SetBorderStyle(eSideLeft,
-                    columnLinesList->ElementAt(listLength - 1));
+      aStyleBorder.SetBorderStyle(eSideLeft, static_cast<StyleBorderStyle>(
+                    columnLinesList->ElementAt(listLength - 1)));
     }
     aStyleBorder.SetBorderWidth(eSideLeft, borderWidth);
   }
 }
 
 static nsMargin
 ComputeBorderOverflow(nsMathMLmtdFrame* aFrame,
                       const nsStyleBorder& aStyleBorder)
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -451,29 +451,29 @@ nsCSSRendering::Shutdown()
   gInlineBGData = nullptr;
 }
 
 /**
  * Make a bevel color
  */
 static nscolor
 MakeBevelColor(mozilla::Side whichSide,
-               uint8_t style,
+               StyleBorderStyle style,
                nscolor aBorderColor)
 {
 
   nscolor colors[2];
   nscolor theColor;
 
   // Given a background color and a border color
   // calculate the color used for the shading
   NS_GetSpecial3DColors(colors, aBorderColor);
 
-  if ((style == NS_STYLE_BORDER_STYLE_OUTSET) ||
-      (style == NS_STYLE_BORDER_STYLE_RIDGE)) {
+  if ((style == StyleBorderStyle::Outset) ||
+      (style == StyleBorderStyle::Ridge)) {
     // Flip colors for these two border styles
     switch (whichSide) {
       case eSideBottom:
         whichSide = eSideTop;
         break;
       case eSideRight:
         whichSide = eSideLeft;
         break;
@@ -889,31 +889,31 @@ ConstructBorderRenderer(nsPresContext* a
   nscoord oneDevPixel = aPresContext->DevPixelsToAppUnits(1);
   Rect joinedBorderAreaPx = NSRectToRect(joinedBorderArea, oneDevPixel);
   Float borderWidths[4] = { Float(border.top) / oneDevPixel,
                             Float(border.right) / oneDevPixel,
                             Float(border.bottom) / oneDevPixel,
                             Float(border.left) / oneDevPixel };
   Rect dirtyRect = NSRectToRect(aDirtyRect, oneDevPixel);
 
-  uint8_t borderStyles[4];
+  StyleBorderStyle borderStyles[4];
   nscolor borderColors[4];
 
   // pull out styles, colors
   NS_FOR_CSS_SIDES(i)
   {
     borderStyles[i] = aStyleBorder.GetBorderStyle(i);
     borderColors[i] = aStyleBorder.BorderColorFor(i).CalcColor(aComputedStyle);
   }
 
   PrintAsFormatString(" borderStyles: %d %d %d %d\n",
-                      borderStyles[0],
-                      borderStyles[1],
-                      borderStyles[2],
-                      borderStyles[3]);
+                      static_cast<int>(borderStyles[0]),
+                      static_cast<int>(borderStyles[1]),
+                      static_cast<int>(borderStyles[2]),
+                      static_cast<int>(borderStyles[3]));
 
   nsIDocument* document = nullptr;
   nsIContent* content = aForFrame->GetContent();
   if (content) {
     document = content->OwnerDoc();
   }
 
   return nsCSSBorderRenderer(
@@ -1148,18 +1148,18 @@ nsCSSRendering::CreateBorderRendererForO
   // get the outer rectangles
   Rect oRect(NSRectToRect(outerRect, oneDevPixel));
 
   // convert the radii
   nsMargin outlineMargin(width, width, width, width);
   RectCornerRadii outlineRadii;
   ComputePixelRadii(twipsRadii, oneDevPixel, &outlineRadii);
 
-  uint8_t outlineStyle = ourOutline->mOutlineStyle;
-  if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) {
+  StyleBorderStyle outlineStyle = ourOutline->mOutlineStyle;
+  if (outlineStyle == StyleBorderStyle::Auto) {
     if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
       nsITheme* theme = aPresContext->GetTheme();
       if (theme && theme->ThemeSupportsWidget(
                      aPresContext, aForFrame, StyleAppearance::FocusOutline)) {
         theme->DrawWidgetBackground(aRenderingContext,
                                     aForFrame,
                                     StyleAppearance::FocusOutline,
                                     innerRect,
@@ -1167,20 +1167,20 @@ nsCSSRendering::CreateBorderRendererForO
         return Nothing();
       }
     }
     if (width == 0) {
       return Nothing(); // empty outline
     }
     // http://dev.w3.org/csswg/css-ui/#outline
     // "User agents may treat 'auto' as 'solid'."
-    outlineStyle = NS_STYLE_BORDER_STYLE_SOLID;
+    outlineStyle = StyleBorderStyle::Solid;
   }
 
-  uint8_t outlineStyles[4] = {
+  StyleBorderStyle outlineStyles[4] = {
     outlineStyle, outlineStyle, outlineStyle, outlineStyle
   };
 
   // This handles treating the initial color as 'currentColor'; if we
   // ever want 'invert' back we'll need to do a bit of work here too.
   nscolor outlineColor =
     aComputedStyle->GetVisitedDependentColor(&nsStyleOutline::mOutlineColor);
   nscolor outlineColors[4] = {
@@ -1258,20 +1258,20 @@ nsCSSRendering::PaintFocus(nsPresContext
     nscoord twipsRadii[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
     ComputePixelRadii(twipsRadii, oneDevPixel, &focusRadii);
   }
   Float focusWidths[4] = { Float(oneCSSPixel) / oneDevPixel,
                            Float(oneCSSPixel) / oneDevPixel,
                            Float(oneCSSPixel) / oneDevPixel,
                            Float(oneCSSPixel) / oneDevPixel };
 
-  uint8_t focusStyles[4] = { NS_STYLE_BORDER_STYLE_DOTTED,
-                             NS_STYLE_BORDER_STYLE_DOTTED,
-                             NS_STYLE_BORDER_STYLE_DOTTED,
-                             NS_STYLE_BORDER_STYLE_DOTTED };
+  StyleBorderStyle focusStyles[4] = { StyleBorderStyle::Dotted,
+                                      StyleBorderStyle::Dotted,
+                                      StyleBorderStyle::Dotted,
+                                      StyleBorderStyle::Dotted };
   nscolor focusColors[4] = { aColor, aColor, aColor, aColor };
 
   // Because this renders a dotted border, the background color
   // should not be used.  Therefore, we provide a value that will
   // be blatantly wrong if it ever does get used.  (If this becomes
   // something that CSS can style, this function will then have access
   // to a ComputedStyle and can use the same logic that PaintBorder
   // and PaintOutline do.)
@@ -2225,21 +2225,21 @@ nsCSSRendering::BuildWebRenderDisplayIte
 }
 
 static bool
 IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide)
 {
   if (aBorder.GetComputedBorder().Side(aSide) == 0)
     return true;
   switch (aBorder.GetBorderStyle(aSide)) {
-    case NS_STYLE_BORDER_STYLE_SOLID:
-    case NS_STYLE_BORDER_STYLE_GROOVE:
-    case NS_STYLE_BORDER_STYLE_RIDGE:
-    case NS_STYLE_BORDER_STYLE_INSET:
-    case NS_STYLE_BORDER_STYLE_OUTSET:
+    case StyleBorderStyle::Solid:
+    case StyleBorderStyle::Groove:
+    case StyleBorderStyle::Ridge:
+    case StyleBorderStyle::Inset:
+    case StyleBorderStyle::Outset:
       break;
     default:
       return false;
   }
 
   // If we're using a border image, assume it's not fully opaque,
   // because we may not even have the image loaded at this point, and
   // even if we did, checking whether the relevant tile is fully
@@ -3746,52 +3746,52 @@ GetDashInfo(nscoord aBorderLength,
       aStartDashLength += half;
       aEndDashLength += (extra - half);
     }
   }
 }
 
 void
 nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
-                                       uint8_t aBorderStyle,
+                                       StyleBorderStyle aBorderStyle,
                                        nscolor aBorderColor,
                                        const nsRect& aBorder,
                                        int32_t aAppUnitsPerDevPixel,
                                        mozilla::Side aStartBevelSide,
                                        nscoord aStartBevelOffset,
                                        mozilla::Side aEndBevelSide,
                                        nscoord aEndBevelOffset)
 {
   bool horizontal =
     ((eSideTop == aStartBevelSide) || (eSideBottom == aStartBevelSide));
   nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel);
 
   if ((oneDevPixel >= aBorder.width) || (oneDevPixel >= aBorder.height) ||
-      (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) ||
-      (NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) {
+      (StyleBorderStyle::Dashed == aBorderStyle) ||
+      (StyleBorderStyle::Dotted == aBorderStyle)) {
     // no beveling for 1 pixel border, dash or dot
     aStartBevelOffset = 0;
     aEndBevelOffset = 0;
   }
 
   switch (aBorderStyle) {
-    case NS_STYLE_BORDER_STYLE_NONE:
-    case NS_STYLE_BORDER_STYLE_HIDDEN:
+    case StyleBorderStyle::None:
+    case StyleBorderStyle::Hidden:
       // NS_ASSERTION(false, "style of none or hidden");
       break;
-    case NS_STYLE_BORDER_STYLE_DOTTED:
-    case NS_STYLE_BORDER_STYLE_DASHED: {
-      nscoord dashLength = (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle)
+    case StyleBorderStyle::Dotted:
+    case StyleBorderStyle::Dashed: {
+      nscoord dashLength = (StyleBorderStyle::Dashed == aBorderStyle)
                              ? DASH_LENGTH
                              : DOT_LENGTH;
       // make the dash length proportional to the border thickness
       dashLength *= (horizontal) ? aBorder.height : aBorder.width;
       // make the min dash length for the ends 1/2 the dash length
       nscoord minDashLength =
-        (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle)
+        (StyleBorderStyle::Dashed == aBorderStyle)
           ? RoundFloatToPixel(((float)dashLength) / 2.0f, aAppUnitsPerDevPixel)
           : dashLength;
       minDashLength = std::max(minDashLength, oneDevPixel);
       nscoord numDashSpaces = 0;
       nscoord startDashLength = minDashLength;
       nscoord endDashLength = minDashLength;
       if (horizontal) {
         GetDashInfo(aBorder.width,
@@ -3869,38 +3869,38 @@ nsCSSRendering::DrawTableBorderSegment(D
     }
     break;
   }
 }
 
 void
 nsCSSRendering::GetTableBorderSolidSegments(
     nsTArray<SolidBeveledBorderSegment>& aSegments,
-    uint8_t       aBorderStyle,
-    nscolor       aBorderColor,
-    const nsRect& aBorder,
-    int32_t       aAppUnitsPerDevPixel,
-    mozilla::Side aStartBevelSide,
-    nscoord       aStartBevelOffset,
-    mozilla::Side aEndBevelSide,
-    nscoord       aEndBevelOffset)
+    StyleBorderStyle aBorderStyle,
+    nscolor          aBorderColor,
+    const nsRect&    aBorder,
+    int32_t          aAppUnitsPerDevPixel,
+    mozilla::Side    aStartBevelSide,
+    nscoord          aStartBevelOffset,
+    mozilla::Side    aEndBevelSide,
+    nscoord          aEndBevelOffset)
 {
   const bool horizontal = eSideTop == aStartBevelSide || eSideBottom == aStartBevelSide;
   const nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel);
 
   switch (aBorderStyle) {
-  case NS_STYLE_BORDER_STYLE_NONE:
-  case NS_STYLE_BORDER_STYLE_HIDDEN:
+  case StyleBorderStyle::None:
+  case StyleBorderStyle::Hidden:
     return;
-  case NS_STYLE_BORDER_STYLE_DOTTED:
-  case NS_STYLE_BORDER_STYLE_DASHED:
+  case StyleBorderStyle::Dotted:
+  case StyleBorderStyle::Dashed:
     MOZ_ASSERT_UNREACHABLE("Caller should have checked");
     return;
-  case NS_STYLE_BORDER_STYLE_GROOVE:
-  case NS_STYLE_BORDER_STYLE_RIDGE:
+  case StyleBorderStyle::Groove:
+  case StyleBorderStyle::Ridge:
     if ((horizontal && (oneDevPixel >= aBorder.height)) ||
         (!horizontal && (oneDevPixel >= aBorder.width))) {
       aSegments.AppendElement(SolidBeveledBorderSegment {
         aBorder,
         aBorderColor,
         { aStartBevelSide, aStartBevelOffset },
         { aEndBevelSide, aEndBevelOffset }
       });
@@ -3990,17 +3990,17 @@ nsCSSRendering::GetTableBorderSolidSegme
           rect,
           bevelColor,
           { aStartBevelSide, startBevel },
           { aEndBevelSide, endBevel }
         });
       }
     }
     break;
-  case NS_STYLE_BORDER_STYLE_DOUBLE:
+  case StyleBorderStyle::Double:
     // We can only do "double" borders if the thickness of the border
     // is more than 2px.  Otherwise, we fall through to painting a
     // solid border.
     if ((aBorder.width > 2 * oneDevPixel || horizontal) &&
         (aBorder.height > 2 * oneDevPixel || !horizontal)) {
       nscoord startBevel = (aStartBevelOffset > 0)
                             ? RoundFloatToPixel(0.333333f *
                                                 (float)aStartBevelOffset,
@@ -4081,29 +4081,29 @@ nsCSSRendering::GetTableBorderSolidSegme
           aBorderColor,
           { aStartBevelSide, startBevel },
           { aEndBevelSide, endBevel }
         });
       }
     }
     // else fall through to solid
     MOZ_FALLTHROUGH;
-  case NS_STYLE_BORDER_STYLE_SOLID:
+  case StyleBorderStyle::Solid:
     aSegments.AppendElement(SolidBeveledBorderSegment {
       aBorder,
       aBorderColor,
       { aStartBevelSide, aStartBevelOffset },
       { aEndBevelSide, aEndBevelOffset }
     });
     break;
-  case NS_STYLE_BORDER_STYLE_OUTSET:
-  case NS_STYLE_BORDER_STYLE_INSET:
+  case StyleBorderStyle::Outset:
+  case StyleBorderStyle::Inset:
     MOZ_ASSERT_UNREACHABLE("inset, outset should have been converted to groove, ridge");
     break;
-  case NS_STYLE_BORDER_STYLE_AUTO:
+  case StyleBorderStyle::Auto:
     MOZ_ASSERT_UNREACHABLE("Unexpected 'auto' table border");
     break;
   }
 }
 
 // End table border-collapsing section
 
 Rect
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -590,17 +590,17 @@ struct nsCSSRendering
    * the frame tree may start changing again.
    */
   static void EndFrameTreesLocked();
 
   // Draw a border segment in the table collapsing border model with beveling
   // corners.
   static void DrawTableBorderSegment(
     DrawTarget& aDrawTarget,
-    uint8_t aBorderStyle,
+    mozilla::StyleBorderStyle aBorderStyle,
     nscolor aBorderColor,
     const nsRect& aBorderRect,
     int32_t aAppUnitsPerDevPixel,
     mozilla::Side aStartBevelSide,
     nscoord aStartBevelOffset,
     mozilla::Side aEndBevelSide,
     nscoord aEndBevelOffset);
 
@@ -619,17 +619,17 @@ struct nsCSSRendering
     Bevel mStartBevel;
     Bevel mEndBevel;
   };
 
   // Collect the table border segments with beveling. Can't be called with
   // dashed / dotted borders, since we don't support beveling those.
   static void GetTableBorderSolidSegments(
       nsTArray<SolidBeveledBorderSegment>& aSegments,
-      uint8_t aBorderStyle,
+      mozilla::StyleBorderStyle aBorderStyle,
       nscolor aBorderColor,
       const nsRect& aBorderRect,
       int32_t aAppUnitsPerDevPixel,
       mozilla::Side aStartBevelSide,
       nscoord aStartBevelOffset,
       mozilla::Side aEndBevelSide,
       nscoord aEndBevelOffset);
 
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -169,17 +169,17 @@ typedef enum {
   CORNER_DOT
 } CornerStyle;
 
 nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext,
                                          const nsIDocument* aDocument,
                                          DrawTarget* aDrawTarget,
                                          const Rect& aDirtyRect,
                                          Rect& aOuterRect,
-                                         const uint8_t* aBorderStyles,
+                                         const StyleBorderStyle* aBorderStyles,
                                          const Float* aBorderWidths,
                                          RectCornerRadii& aBorderRadii,
                                          const nscolor* aBorderColors,
                                          bool aBackfaceIsVisible,
                                          const Maybe<Rect>& aClipRect)
   : mPresContext(aPresContext)
   , mDocument(aDocument)
   , mDrawTarget(aDrawTarget)
@@ -189,20 +189,20 @@ nsCSSBorderRenderer::nsCSSBorderRenderer
   , mBackfaceIsVisible(aBackfaceIsVisible)
   , mLocalClip(aClipRect)
 {
   PodCopy(mBorderStyles, aBorderStyles, 4);
   PodCopy(mBorderWidths, aBorderWidths, 4);
   PodCopy(mBorderColors, aBorderColors, 4);
   mInnerRect = mOuterRect;
   mInnerRect.Deflate(Margin(
-    mBorderStyles[0] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[0] : 0,
-    mBorderStyles[1] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[1] : 0,
-    mBorderStyles[2] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[2] : 0,
-    mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0));
+    mBorderStyles[0] != StyleBorderStyle::None ? mBorderWidths[0] : 0,
+    mBorderStyles[1] != StyleBorderStyle::None ? mBorderWidths[1] : 0,
+    mBorderStyles[2] != StyleBorderStyle::None ? mBorderWidths[2] : 0,
+    mBorderStyles[3] != StyleBorderStyle::None ? mBorderWidths[3] : 0));
 
   ComputeBorderCornerDimensions(
     mBorderWidths, mBorderRadii, &mBorderCornerDimensions);
 
   mOneUnitBorder = CheckFourFloatsEqual(mBorderWidths, 1.0);
   mNoBorderRadius = AllCornersZeroSize(mBorderRadii);
   mAllBordersSameStyle = AreBorderSideFinalStylesSame(eSideBitsAll);
   mAllBordersSameWidth = AllBordersSameWidth();
@@ -333,44 +333,44 @@ nsCSSBorderRenderer::AreBorderSideFinalS
         mBorderColors[firstStyle] != mBorderColors[i]) {
       return false;
     }
   }
 
   /* Then if it's one of the two-tone styles and we're not
    * just comparing the TL or BR sides */
   switch (mBorderStyles[firstStyle]) {
-    case NS_STYLE_BORDER_STYLE_GROOVE:
-    case NS_STYLE_BORDER_STYLE_RIDGE:
-    case NS_STYLE_BORDER_STYLE_INSET:
-    case NS_STYLE_BORDER_STYLE_OUTSET:
+    case StyleBorderStyle::Groove:
+    case StyleBorderStyle::Ridge:
+    case StyleBorderStyle::Inset:
+    case StyleBorderStyle::Outset:
       return ((aSides & ~(eSideBitsTop | eSideBitsLeft)) == 0 ||
               (aSides & ~(eSideBitsBottom | eSideBitsRight)) == 0);
+    default:
+      return true;
   }
-
-  return true;
 }
 
 bool
-nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, Corner aCorner)
+nsCSSBorderRenderer::IsSolidCornerStyle(StyleBorderStyle aStyle, Corner aCorner)
 {
   switch (aStyle) {
-    case NS_STYLE_BORDER_STYLE_SOLID:
+    case StyleBorderStyle::Solid:
       return true;
 
-    case NS_STYLE_BORDER_STYLE_INSET:
-    case NS_STYLE_BORDER_STYLE_OUTSET:
+    case StyleBorderStyle::Inset:
+    case StyleBorderStyle::Outset:
       return (aCorner == eCornerTopLeft || aCorner == eCornerBottomRight);
 
-    case NS_STYLE_BORDER_STYLE_GROOVE:
-    case NS_STYLE_BORDER_STYLE_RIDGE:
+    case StyleBorderStyle::Groove:
+    case StyleBorderStyle::Ridge:
       return mOneUnitBorder &&
              (aCorner == eCornerTopLeft || aCorner == eCornerBottomRight);
 
-    case NS_STYLE_BORDER_STYLE_DOUBLE:
+    case StyleBorderStyle::Double:
       return mOneUnitBorder;
 
     default:
       return false;
   }
 }
 
 bool
@@ -401,59 +401,61 @@ nsCSSBorderRenderer::IsCornerMergeable(C
   // |   ###################   |
   // |     ###############     |
   // |         #######         |
   // +-------------------------+----
   // |                         |
   // |                         |
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
-  uint8_t styleH = mBorderStyles[sideH];
-  uint8_t styleV = mBorderStyles[sideV];
-  if (styleH != styleV || styleH != NS_STYLE_BORDER_STYLE_DOTTED) {
+  StyleBorderStyle styleH = mBorderStyles[sideH];
+  StyleBorderStyle styleV = mBorderStyles[sideV];
+  if (styleH != styleV || styleH != StyleBorderStyle::Dotted) {
     return false;
   }
 
   Float widthH = mBorderWidths[sideH];
   Float widthV = mBorderWidths[sideV];
   if (widthH != widthV) {
     return false;
   }
 
   Size radius = mBorderRadii[aCorner];
   return IsZeroSize(radius) ||
          (radius.width < widthH / 2.0f && radius.height < widthH / 2.0f);
 }
 
 BorderColorStyle
-nsCSSBorderRenderer::BorderColorStyleForSolidCorner(uint8_t aStyle,
+nsCSSBorderRenderer::BorderColorStyleForSolidCorner(StyleBorderStyle aStyle,
                                                     Corner aCorner)
 {
   // note that this function assumes that the corner is already solid,
   // as per the earlier function
   switch (aStyle) {
-    case NS_STYLE_BORDER_STYLE_SOLID:
-    case NS_STYLE_BORDER_STYLE_DOUBLE:
+    case StyleBorderStyle::Solid:
+    case StyleBorderStyle::Double:
       return BorderColorStyleSolid;
 
-    case NS_STYLE_BORDER_STYLE_INSET:
-    case NS_STYLE_BORDER_STYLE_GROOVE:
+    case StyleBorderStyle::Inset:
+    case StyleBorderStyle::Groove:
       if (aCorner == eCornerTopLeft)
         return BorderColorStyleDark;
       else if (aCorner == eCornerBottomRight)
         return BorderColorStyleLight;
       break;
 
-    case NS_STYLE_BORDER_STYLE_OUTSET:
-    case NS_STYLE_BORDER_STYLE_RIDGE:
+    case StyleBorderStyle::Outset:
+    case StyleBorderStyle::Ridge:
       if (aCorner == eCornerTopLeft)
         return BorderColorStyleLight;
       else if (aCorner == eCornerBottomRight)
         return BorderColorStyleDark;
       break;
+    default:
+      return BorderColorStyleNone;
   }
 
   return BorderColorStyleNone;
 }
 
 Rect
 nsCSSBorderRenderer::GetCornerRect(Corner aCorner)
 {
@@ -611,17 +613,17 @@ nsCSSBorderRenderer::GetSideClipSubPath(
   // |         /
   // s1 ----- e1
   //
   // that is, the second point will always be on the inside
 
   Point start[2];
   Point end[2];
 
-#define IS_DOTTED(_s) ((_s) == NS_STYLE_BORDER_STYLE_DOTTED)
+#define IS_DOTTED(_s) ((_s) == StyleBorderStyle::Dotted)
   bool isDotted = IS_DOTTED(mBorderStyles[aSide]);
   bool startIsDotted = IS_DOTTED(mBorderStyles[PREV_SIDE(aSide)]);
   bool endIsDotted = IS_DOTTED(mBorderStyles[NEXT_SIDE(aSide)]);
 #undef IS_DOTTED
 
   SideClipType startType = SIDE_CLIP_TRAPEZOID;
   SideClipType endType = SIDE_CLIP_TRAPEZOID;
 
@@ -731,48 +733,48 @@ nsCSSBorderRenderer::GetStraightBorderPo
   const Float signsList[4][2] = {
     { +1.0f, +1.0f }, { -1.0f, +1.0f }, { -1.0f, -1.0f }, { +1.0f, -1.0f }
   };
   const Float(&signs)[2] = signsList[aCorner];
 
   *aIsUnfilled = false;
 
   Point P = mOuterRect.AtCorner(aCorner);
-  uint8_t style = mBorderStyles[aSide];
+  StyleBorderStyle style = mBorderStyles[aSide];
   Float borderWidth = mBorderWidths[aSide];
   Size dim = mBorderCornerDimensions[aCorner];
   bool isHorizontal = IsHorizontalSide(aSide);
   //
   //    aCorner      aSide
   //           +--------------
   //           |
   //           |   +----------
   //           |   |
   // otherSide |   |
   //           |   |
   mozilla::Side otherSide =
     ((uint8_t)aSide == (uint8_t)aCorner) ? PREV_SIDE(aSide) : NEXT_SIDE(aSide);
-  uint8_t otherStyle = mBorderStyles[otherSide];
+  StyleBorderStyle otherStyle = mBorderStyles[otherSide];
   Float otherBorderWidth = mBorderWidths[otherSide];
   Size radius = mBorderRadii[aCorner];
   if (IsZeroSize(radius)) {
     radius.width = 0.0f;
     radius.height = 0.0f;
   }
-  if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
+  if (style == StyleBorderStyle::Dotted) {
     // Offset the dot's location along the side toward the corner by a
     // multiple of its width.
     if (isHorizontal) {
       P.x -= signs[0] * aDotOffset * borderWidth;
     } else {
       P.y -= signs[1] * aDotOffset * borderWidth;
     }
   }
-  if (style == NS_STYLE_BORDER_STYLE_DOTTED &&
-      otherStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
+  if (style == StyleBorderStyle::Dotted &&
+      otherStyle == StyleBorderStyle::Dotted) {
     if (borderWidth == otherBorderWidth) {
       if (radius.width < borderWidth / 2.0f &&
           radius.height < borderWidth / 2.0f) {
         // Two dots are merged into one and placed at the corner.
         //
         //  borderWidth / 2.0
         // |<---------->|
         // |            |
@@ -958,17 +960,17 @@ nsCSSBorderRenderer::GetStraightBorderPo
       P.y += signs[1] * borderWidth / 2.0f;
     } else {
       P.x += signs[0] * borderWidth / 2.0f;
       P.y += signs[1] * std::max(radius.height, borderWidth / 2.0f);
     }
     return P;
   }
 
-  if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
+  if (style == StyleBorderStyle::Dotted) {
     // If only this side is dotted, other side draws the corner.
     //
     //  otherBorderWidth + borderWidth / 2.0
     // |<------->|
     // |         |
     // +------+--+--------
     // |##  ##| *|*  ###
     // |##  ##|**|**#####
@@ -1019,17 +1021,17 @@ nsCSSBorderRenderer::GetStraightBorderPo
         P.y += signs[1] * minimum;
       } else {
         P.y += signs[1] * radius.height;
       }
     }
     return P;
   }
 
-  if (otherStyle == NS_STYLE_BORDER_STYLE_DOTTED && IsZeroSize(radius)) {
+  if (otherStyle == StyleBorderStyle::Dotted && IsZeroSize(radius)) {
     // If other side is dotted and radius=0, draw side to the end of corner.
     //
     //   +-------------------------------
     //   |##########          ##########
     // P +##########          ##########
     //   |##########          ##########
     //   +-----+-------------------------
     //   | *** |
@@ -1285,38 +1287,38 @@ ComputeColorForLine(uint32_t aLineIndex,
 void
 nsCSSBorderRenderer::DrawBorderSides(int aSides)
 {
   if (aSides == 0 || (aSides & ~eSideBitsAll) != 0) {
     NS_WARNING("DrawBorderSides: invalid sides!");
     return;
   }
 
-  uint8_t borderRenderStyle = NS_STYLE_BORDER_STYLE_NONE;
+  StyleBorderStyle borderRenderStyle = StyleBorderStyle::None;
   nscolor borderRenderColor;
 
   uint32_t borderColorStyleCount = 0;
   BorderColorStyle borderColorStyleTopLeft[3], borderColorStyleBottomRight[3];
   BorderColorStyle* borderColorStyle = nullptr;
 
   NS_FOR_CSS_SIDES(i)
   {
     if ((aSides & (1 << i)) == 0)
       continue;
     borderRenderStyle = mBorderStyles[i];
     borderRenderColor = mBorderColors[i];
     break;
   }
 
-  if (borderRenderStyle == NS_STYLE_BORDER_STYLE_NONE ||
-      borderRenderStyle == NS_STYLE_BORDER_STYLE_HIDDEN)
+  if (borderRenderStyle == StyleBorderStyle::None ||
+      borderRenderStyle == StyleBorderStyle::Hidden)
     return;
 
-  if (borderRenderStyle == NS_STYLE_BORDER_STYLE_DASHED ||
-      borderRenderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
+  if (borderRenderStyle == StyleBorderStyle::Dashed ||
+      borderRenderStyle == StyleBorderStyle::Dotted) {
     // Draw each corner separately, with the given side's color.
     if (aSides & eSideBitsTop) {
       DrawDashedOrDottedCorner(eSideTop, C_TL);
     } else if (aSides & eSideBitsLeft) {
       DrawDashedOrDottedCorner(eSideLeft, C_TL);
     }
 
     if (aSides & eSideBitsTop) {
@@ -1339,70 +1341,70 @@ nsCSSBorderRenderer::DrawBorderSides(int
     return;
   }
 
   // The borderColorStyle array goes from the outer to the inner style.
   //
   // If the border width is 1, we need to change the borderRenderStyle
   // a bit to make sure that we get the right colors -- e.g. 'ridge'
   // with a 1px border needs to look like solid, not like 'outset'.
-  if (mOneUnitBorder && (borderRenderStyle == NS_STYLE_BORDER_STYLE_RIDGE ||
-                         borderRenderStyle == NS_STYLE_BORDER_STYLE_GROOVE ||
-                         borderRenderStyle == NS_STYLE_BORDER_STYLE_DOUBLE))
-    borderRenderStyle = NS_STYLE_BORDER_STYLE_SOLID;
+  if (mOneUnitBorder && (borderRenderStyle == StyleBorderStyle::Ridge ||
+                         borderRenderStyle == StyleBorderStyle::Groove ||
+                         borderRenderStyle == StyleBorderStyle::Double))
+    borderRenderStyle = StyleBorderStyle::Solid;
 
   switch (borderRenderStyle) {
-    case NS_STYLE_BORDER_STYLE_SOLID:
+    case StyleBorderStyle::Solid:
       borderColorStyleTopLeft[0] = BorderColorStyleSolid;
 
       borderColorStyleBottomRight[0] = BorderColorStyleSolid;
 
       borderColorStyleCount = 1;
       break;
 
-    case NS_STYLE_BORDER_STYLE_GROOVE:
+    case StyleBorderStyle::Groove:
       borderColorStyleTopLeft[0] = BorderColorStyleDark;
       borderColorStyleTopLeft[1] = BorderColorStyleLight;
 
       borderColorStyleBottomRight[0] = BorderColorStyleLight;
       borderColorStyleBottomRight[1] = BorderColorStyleDark;
 
       borderColorStyleCount = 2;
       break;
 
-    case NS_STYLE_BORDER_STYLE_RIDGE:
+    case StyleBorderStyle::Ridge:
       borderColorStyleTopLeft[0] = BorderColorStyleLight;
       borderColorStyleTopLeft[1] = BorderColorStyleDark;
 
       borderColorStyleBottomRight[0] = BorderColorStyleDark;
       borderColorStyleBottomRight[1] = BorderColorStyleLight;
 
       borderColorStyleCount = 2;
       break;
 
-    case NS_STYLE_BORDER_STYLE_DOUBLE:
+    case StyleBorderStyle::Double:
       borderColorStyleTopLeft[0] = BorderColorStyleSolid;
       borderColorStyleTopLeft[1] = BorderColorStyleNone;
       borderColorStyleTopLeft[2] = BorderColorStyleSolid;
 
       borderColorStyleBottomRight[0] = BorderColorStyleSolid;
       borderColorStyleBottomRight[1] = BorderColorStyleNone;
       borderColorStyleBottomRight[2] = BorderColorStyleSolid;
 
       borderColorStyleCount = 3;
       break;
 
-    case NS_STYLE_BORDER_STYLE_INSET:
+    case StyleBorderStyle::Inset:
       borderColorStyleTopLeft[0] = BorderColorStyleDark;
       borderColorStyleBottomRight[0] = BorderColorStyleLight;
 
       borderColorStyleCount = 1;
       break;
 
-    case NS_STYLE_BORDER_STYLE_OUTSET:
+    case StyleBorderStyle::Outset:
       borderColorStyleTopLeft[0] = BorderColorStyleLight;
       borderColorStyleBottomRight[0] = BorderColorStyleDark;
 
       borderColorStyleCount = 1;
       break;
 
     default:
       MOZ_ASSERT_UNREACHABLE("Unhandled border style!!");
@@ -1487,48 +1489,48 @@ nsCSSBorderRenderer::DrawBorderSides(int
   bool noMarginTop = false;
   bool noMarginRight = false;
   bool noMarginBottom = false;
   bool noMarginLeft = false;
 
   // If there is at least one dotted side, every side is rendered separately.
   if (IsSingleSide(aSides)) {
     if (aSides == eSideBitsTop) {
-      if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_TR])) {
         noMarginRight = true;
       }
-      if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_TL])) {
         noMarginLeft = true;
       }
     } else if (aSides == eSideBitsRight) {
-      if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_TR])) {
         noMarginTop = true;
       }
-      if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_BR])) {
         noMarginBottom = true;
       }
     } else if (aSides == eSideBitsBottom) {
-      if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_BR])) {
         noMarginRight = true;
       }
-      if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_BL])) {
         noMarginLeft = true;
       }
     } else {
-      if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_TL])) {
         noMarginTop = true;
       }
-      if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED &&
+      if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted &&
           IsZeroSize(mBorderRadii[C_BL])) {
         noMarginBottom = true;
       }
     }
   }
 
   for (unsigned int i = 0; i < borderColorStyleCount; i++) {
     // walk siRect inwards at the start of the loop to get the
@@ -1575,21 +1577,21 @@ nsCSSBorderRenderer::DrawBorderSides(int
 
 void
 nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions,
                                         Float aDash[2],
                                         mozilla::Side aSide,
                                         Float aBorderLength,
                                         bool isCorner)
 {
-  MOZ_ASSERT(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
-               mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  MOZ_ASSERT(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
+               mBorderStyles[aSide] == StyleBorderStyle::Dotted,
              "Style should be dashed or dotted.");
 
-  uint8_t style = mBorderStyles[aSide];
+  StyleBorderStyle style = mBorderStyles[aSide];
   Float borderWidth = mBorderWidths[aSide];
 
   // Dashed line starts and ends with half segment in most case.
   //
   // __--+---+---+---+---+---+---+---+---+--__
   //     |###|   |   |###|###|   |   |###|
   //     |###|   |   |###|###|   |   |###|
   //     |###|   |   |###|###|   |   |###|
@@ -1609,46 +1611,46 @@ nsCSSBorderRenderer::SetupDashedOptions(
   // |    |                             |    |
   // | ## |                             | ## |
   // |####|                             |####|
   // |####|                             |####|
   // | ## |                             | ## |
   // |    |                             |    |
   bool fullStart = false, fullEnd = false;
   Float halfDash;
-  if (style == NS_STYLE_BORDER_STYLE_DASHED) {
+  if (style == StyleBorderStyle::Dashed) {
     // If either end of the side is not connecting onto a corner then we want a
     // full dash at that end.
     //
     // Note that in the case that a corner is empty, either the adjacent side
     // has zero width, or else DrawBorders() set the corner to be empty
     // (it does that if the adjacent side has zero length and the border widths
     // of this and the adjacent sides are thin enough that the corner will be
     // insignificantly small).
 
     if (mBorderRadii[GetCCWCorner(aSide)].IsEmpty() &&
         (mBorderCornerDimensions[GetCCWCorner(aSide)].IsEmpty() ||
-         mBorderStyles[PREV_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED ||
+         mBorderStyles[PREV_SIDE(aSide)] == StyleBorderStyle::Dotted ||
          // XXX why this <=1 check?
          borderWidth <= 1.0f)) {
       fullStart = true;
     }
 
     if (mBorderRadii[GetCWCorner(aSide)].IsEmpty() &&
         (mBorderCornerDimensions[GetCWCorner(aSide)].IsEmpty() ||
-         mBorderStyles[NEXT_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED)) {
+         mBorderStyles[NEXT_SIDE(aSide)] == StyleBorderStyle::Dotted)) {
       fullEnd = true;
     }
 
     halfDash = borderWidth * DOT_LENGTH * DASH_LENGTH / 2.0f;
   } else {
     halfDash = borderWidth * DOT_LENGTH / 2.0f;
   }
 
-  if (style == NS_STYLE_BORDER_STYLE_DASHED && aBorderLength > 0.0f) {
+  if (style == StyleBorderStyle::Dashed && aBorderLength > 0.0f) {
     // The number of half segments, with maximum dash length.
     int32_t count = floor(aBorderLength / halfDash);
     Float minHalfDash = borderWidth * DOT_LENGTH / 2.0f;
 
     if (fullStart && fullEnd) {
       // count should be 4n + 2
       //
       //   1 +       4       +        4      + 1
@@ -1730,22 +1732,22 @@ nsCSSBorderRenderer::SetupDashedOptions(
     halfDash = aBorderLength / count;
   }
 
   Float fullDash = halfDash * 2.0f;
 
   aDash[0] = fullDash;
   aDash[1] = fullDash;
 
-  if (style == NS_STYLE_BORDER_STYLE_DASHED && fullDash > 1.0f) {
+  if (style == StyleBorderStyle::Dashed && fullDash > 1.0f) {
     if (!fullStart) {
       // Draw half segments on both ends.
       aStrokeOptions->mDashOffset = halfDash;
     }
-  } else if (style != NS_STYLE_BORDER_STYLE_DOTTED && isCorner) {
+  } else if (style != StyleBorderStyle::Dotted && isCorner) {
     // If side ends with filled full segment, corner should start with unfilled
     // full segment. Not needed for dotted corners, as they overlap one dot with
     // the side's end.
     //
     //     corner            side
     //   ------------>|<---------------------------
     //                |
     //          __+---+---+---+---+---+---+---+---+
@@ -1804,26 +1806,26 @@ nsCSSBorderRenderer::DrawDashedOrDottedS
   //   if the side is too short and there's only 2 dots, it can be more smaller.
   //   If there's no space to place 2 dots at the side, draw single dot at the
   //   middle of the side.
   //   In most case, line ends with filled dot, to joint with corner easily,
   //   If adjacent side is dotted with larger border-width, or other style,
   //   the line ends with unfilled dot.
   //   (see comment for GetStraightBorderPoint for more detail)
 
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
-                 mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
+                 mBorderStyles[aSide] == StyleBorderStyle::Dotted,
                "Style should be dashed or dotted.");
 
   Float borderWidth = mBorderWidths[aSide];
   if (borderWidth == 0.0f) {
     return;
   }
 
-  if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED &&
+  if (mBorderStyles[aSide] == StyleBorderStyle::Dotted &&
       borderWidth > 2.0f) {
     DrawDottedSideSlow(aSide);
     return;
   }
 
   nscolor borderColor = mBorderColors[aSide];
   bool ignored;
   // Get the start and end points of the side, ensuring that any dot origins get
@@ -1876,34 +1878,34 @@ nsCSSBorderRenderer::DrawDashedOrDottedS
     // dot's width to avoid drawing a dot that would overdraw where the merged
     // side would have ended in a gap, i.e. O_O_
     //                                    O
     strokeOptions.mDashOffset += mergeLength + borderWidth;
     mergeSide = NEXT_SIDE(mergeSide);
   }
 
   DrawOptions drawOptions;
-  if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED) {
+  if (mBorderStyles[aSide] == StyleBorderStyle::Dotted) {
     drawOptions.mAntialiasMode = AntialiasMode::NONE;
   }
 
   mDrawTarget->StrokeLine(start,
                           end,
                           ColorPattern(ToDeviceColor(borderColor)),
                           strokeOptions,
                           drawOptions);
 }
 
 void
 nsCSSBorderRenderer::DrawDottedSideSlow(mozilla::Side aSide)
 {
   // Draw each circles separately for dotted with borderWidth > 2.0.
   // Dashed line with CapStyle::ROUND doesn't render perfect circles.
 
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted,
                "Style should be dotted.");
 
   Float borderWidth = mBorderWidths[aSide];
   if (borderWidth == 0.0f) {
     return;
   }
 
   nscolor borderColor = mBorderColors[aSide];
@@ -2297,53 +2299,53 @@ nsCSSBorderRenderer::DrawDashedOrDottedC
   //   change along the corner, that is tangent to the outer curver and the
   //   inner curve.  The ratio of the gap to circle diameter is the maximum
   //   value in [0.5, 1] range.
   //   (see DottedCornerFinder.h for more detail)
   //   Corner ends with filled dots but those dots are drawn by
   //   DrawDashedOrDottedSide.  So this may draw no circles if there's no space
   //   between 2 dots at both ends.
 
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
-                 mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
+                 mBorderStyles[aSide] == StyleBorderStyle::Dotted,
                "Style should be dashed or dotted.");
 
   if (IsCornerMergeable(aCorner)) {
     // DrawDashedOrDottedSide will draw corner.
     return;
   }
 
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
   Float borderWidthH = mBorderWidths[sideH];
   Float borderWidthV = mBorderWidths[sideV];
   if (borderWidthH == 0.0f && borderWidthV == 0.0f) {
     return;
   }
 
-  Float styleH = mBorderStyles[sideH];
-  Float styleV = mBorderStyles[sideV];
+  StyleBorderStyle styleH = mBorderStyles[sideH];
+  StyleBorderStyle styleV = mBorderStyles[sideV];
 
   // Corner between dotted and others with radius=0 is drawn by side.
   if (IsZeroSize(mBorderRadii[aCorner]) &&
-      (styleV == NS_STYLE_BORDER_STYLE_DOTTED ||
-       styleH == NS_STYLE_BORDER_STYLE_DOTTED)) {
+      (styleV == StyleBorderStyle::Dotted ||
+       styleH == StyleBorderStyle::Dotted)) {
     return;
   }
 
   Float maxRadius =
     std::max(mBorderRadii[aCorner].width, mBorderRadii[aCorner].height);
   if (maxRadius > BORDER_DOTTED_CORNER_MAX_RADIUS) {
     DrawFallbackSolidCorner(aSide, aCorner);
     return;
   }
 
   if (borderWidthH != borderWidthV || borderWidthH > 2.0f) {
-    uint8_t style = mBorderStyles[aSide];
-    if (style == NS_STYLE_BORDER_STYLE_DOTTED) {
+    StyleBorderStyle style = mBorderStyles[aSide];
+    if (style == StyleBorderStyle::Dotted) {
       DrawDottedCornerSlow(aSide, aCorner);
     } else {
       DrawDashedCornerSlow(aSide, aCorner);
     }
     return;
   }
 
   nscolor borderColor = mBorderColors[aSide];
@@ -2379,17 +2381,17 @@ nsCSSBorderRenderer::DrawDashedOrDottedC
   RefPtr<Path> path = builder->Finish();
   mDrawTarget->Stroke(
     path, ColorPattern(ToDeviceColor(borderColor)), strokeOptions);
 }
 
 void
 nsCSSBorderRenderer::DrawDottedCornerSlow(mozilla::Side aSide, Corner aCorner)
 {
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted,
                "Style should be dotted.");
 
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
   Float R0 = mBorderWidths[sideH] / 2.0f;
   Float Rn = mBorderWidths[sideV] / 2.0f;
   if (R0 == 0.0f && Rn == 0.0f) {
     return;
@@ -2463,17 +2465,17 @@ DashedPathOverlapsRect(Rect& pathRect,
   pathRect.ExpandToEnclose(result.innerSectionBezier.mPoints[3]);
 
   return pathRect.Intersects(marginedDirtyRect);
 }
 
 void
 nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::Side aSide, Corner aCorner)
 {
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed,
                "Style should be dashed.");
 
   mozilla::Side sideH(GetHorizontalSide(aCorner));
   mozilla::Side sideV(GetVerticalSide(aCorner));
   Float borderWidthH = mBorderWidths[sideH];
   Float borderWidthV = mBorderWidths[sideV];
   if (borderWidthH == 0.0f && borderWidthV == 0.0f) {
     return;
@@ -2584,18 +2586,18 @@ nsCSSBorderRenderer::DrawDashedCornerSlo
 
 void
 nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide,
                                              Corner aCorner)
 {
   // Render too large dashed or dotted corner with solid style, to avoid hangup
   // inside DashedCornerFinder and DottedCornerFinder.
 
-  NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED ||
-                 mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED,
+  NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed ||
+                 mBorderStyles[aSide] == StyleBorderStyle::Dotted,
                "Style should be dashed or dotted.");
 
   nscolor borderColor = mBorderColors[aSide];
   Bezier outerBezier;
   Bezier innerBezier;
   GetOuterAndInnerBezier(&outerBezier, &innerBezier, aCorner);
 
   RefPtr<PathBuilder> builder = mDrawTarget->CreatePathBuilder();
@@ -2614,17 +2616,17 @@ nsCSSBorderRenderer::DrawFallbackSolidCo
   if (mDocument) {
     if (!mPresContext->HasWarnedAboutTooLargeDashedOrDottedRadius()) {
       mPresContext->SetHasWarnedAboutTooLargeDashedOrDottedRadius();
       nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                       NS_LITERAL_CSTRING("CSS"),
                                       mDocument,
                                       nsContentUtils::eCSS_PROPERTIES,
                                       mBorderStyles[aSide] ==
-                                          NS_STYLE_BORDER_STYLE_DASHED
+                                          StyleBorderStyle::Dashed
                                         ? "TooLargeDashedRadius"
                                         : "TooLargeDottedRadius");
     }
   }
 }
 
 bool
 nsCSSBorderRenderer::AllBordersSameWidth()
@@ -2638,32 +2640,32 @@ nsCSSBorderRenderer::AllBordersSameWidth
   return false;
 }
 
 bool
 nsCSSBorderRenderer::AllBordersSolid()
 {
   NS_FOR_CSS_SIDES(i)
   {
-    if (mBorderStyles[i] == NS_STYLE_BORDER_STYLE_SOLID ||
-        mBorderStyles[i] == NS_STYLE_BORDER_STYLE_NONE ||
-        mBorderStyles[i] == NS_STYLE_BORDER_STYLE_HIDDEN) {
+    if (mBorderStyles[i] == StyleBorderStyle::Solid ||
+        mBorderStyles[i] == StyleBorderStyle::None ||
+        mBorderStyles[i] == StyleBorderStyle::Hidden) {
       continue;
     }
     return false;
   }
 
   return true;
 }
 
 static bool
-IsVisible(int aStyle)
+IsVisible(StyleBorderStyle aStyle)
 {
-  if (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
-      aStyle != NS_STYLE_BORDER_STYLE_HIDDEN) {
+  if (aStyle != StyleBorderStyle::None &&
+      aStyle != StyleBorderStyle::Hidden) {
     return true;
   }
   return false;
 }
 
 struct twoFloats
 {
   Float a, b;
@@ -3152,18 +3154,18 @@ nsCSSBorderRenderer::DrawSolidBorder()
     }
   }
 }
 
 void
 nsCSSBorderRenderer::DrawBorders()
 {
   if (mAllBordersSameStyle &&
-      (mBorderStyles[0] == NS_STYLE_BORDER_STYLE_NONE ||
-       mBorderStyles[0] == NS_STYLE_BORDER_STYLE_HIDDEN ||
+      (mBorderStyles[0] == StyleBorderStyle::None ||
+       mBorderStyles[0] == StyleBorderStyle::Hidden ||
        mBorderColors[0] == NS_RGBA(0, 0, 0, 0))) {
     // All borders are the same style, and the style is either none or hidden,
     // or the color is transparent.
     return;
   }
 
   if (mAllBordersSameWidth && mBorderWidths[0] == 0.0) {
     // Some of the mAllBordersSameWidth codepaths depend on the border
@@ -3201,26 +3203,26 @@ nsCSSBorderRenderer::DrawBorders()
   // Initial values only used when the border colors/widths are all the same:
   ColorPattern color(ToDeviceColor(mBorderColors[eSideTop]));
   StrokeOptions strokeOptions(mBorderWidths[eSideTop]); // stroke width
 
   // First there's a couple of 'special cases' that have specifically optimized
   // drawing paths, when none of these can be used we move on to the generalized
   // border drawing code.
   if (mAllBordersSameStyle && mAllBordersSameWidth &&
-      mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID && mNoBorderRadius &&
+      mBorderStyles[0] == StyleBorderStyle::Solid && mNoBorderRadius &&
       !mAvoidStroke) {
     // Very simple case.
     Rect rect = mOuterRect;
     rect.Deflate(mBorderWidths[0] / 2.0);
     mDrawTarget->StrokeRect(rect, color, strokeOptions);
     return;
   }
 
-  if (mAllBordersSameStyle && mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID &&
+  if (mAllBordersSameStyle && mBorderStyles[0] == StyleBorderStyle::Solid &&
       !mAvoidStroke && !mNoBorderRadius) {
     // Relatively simple case.
     RoundedRect borderInnerRect(mOuterRect, mBorderRadii);
     borderInnerRect.Deflate(mBorderWidths[eSideTop],
                             mBorderWidths[eSideBottom],
                             mBorderWidths[eSideLeft],
                             mBorderWidths[eSideRight]);
 
@@ -3283,19 +3285,19 @@ nsCSSBorderRenderer::DrawBorders()
     mInnerRect = ToRect(innerRect);
   }
 
   int dashedSides = 0;
   bool forceSeparateCorners = false;
 
   NS_FOR_CSS_SIDES(i)
   {
-    uint8_t style = mBorderStyles[i];
-    if (style == NS_STYLE_BORDER_STYLE_DASHED ||
-        style == NS_STYLE_BORDER_STYLE_DOTTED) {
+    StyleBorderStyle style = mBorderStyles[i];
+    if (style == StyleBorderStyle::Dashed ||
+        style == StyleBorderStyle::Dotted) {
       // we need to draw things separately for dashed/dotting
       forceSeparateCorners = true;
       dashedSides |= (1 << i);
     }
   }
 
   PrintAsFormatString(" mAllBordersSameStyle: %d dashedSides: 0x%02x\n",
                       mAllBordersSameStyle,
@@ -3425,23 +3427,23 @@ nsCSSBorderRenderer::DrawBorders()
         // has an alpha channel, we could just clear the region and
         // avoid the temporary, but that situation doesn't happen all
         // that often in practice (we double buffer to no-alpha
         // surfaces). We choose just to seam though, as the performance
         // advantages outway the modest easthetic improvement.
 
         for (int cornerSide = 0; cornerSide < 2; cornerSide++) {
           mozilla::Side side = mozilla::Side(sides[cornerSide]);
-          uint8_t style = mBorderStyles[side];
+          StyleBorderStyle style = mBorderStyles[side];
 
           PrintAsFormatString("corner: %d cornerSide: %d side: %d style: %d\n",
                               corner,
                               cornerSide,
                               side,
-                              style);
+                              static_cast<int>(style));
 
           RefPtr<Path> path = GetSideClipSubPath(side);
           mDrawTarget->PushClip(path);
 
           DrawBorderSides(1 << side);
 
           mDrawTarget->PopClip();
         }
@@ -3483,18 +3485,18 @@ nsCSSBorderRenderer::DrawBorders()
     NS_FOR_CSS_SIDES(side)
     {
       // if we drew it above, skip it
       if (alreadyDrawnSides & (1 << side))
         continue;
 
       // If there's no border on this side, skip it
       if (mBorderWidths[side] == 0.0 ||
-          mBorderStyles[side] == NS_STYLE_BORDER_STYLE_HIDDEN ||
-          mBorderStyles[side] == NS_STYLE_BORDER_STYLE_NONE)
+          mBorderStyles[side] == StyleBorderStyle::Hidden ||
+          mBorderStyles[side] == StyleBorderStyle::None)
         continue;
 
       if (dashedSides & (1 << side)) {
         // Dashed sides will always draw just the part ignoring the
         // corners for the side, so no need to clip.
         DrawDashedOrDottedSide(side);
 
         PrintAsStringNewline("---------------- (d)");
--- a/layout/painting/nsCSSRenderingBorders.h
+++ b/layout/painting/nsCSSRenderingBorders.h
@@ -87,17 +87,17 @@ class nsCSSBorderRenderer final
   friend class nsDisplayButtonForeground;
 
 public:
   nsCSSBorderRenderer(nsPresContext* aPresContext,
                       const nsIDocument* aDocument,
                       DrawTarget* aDrawTarget,
                       const Rect& aDirtyRect,
                       Rect& aOuterRect,
-                      const uint8_t* aBorderStyles,
+                      const mozilla::StyleBorderStyle* aBorderStyles,
                       const Float* aBorderWidths,
                       RectCornerRadii& aBorderRadii,
                       const nscolor* aBorderColors,
                       bool aBackfaceIsVisible,
                       const mozilla::Maybe<Rect>& aClipRect);
 
   // draw the entire border
   void DrawBorders();
@@ -134,17 +134,17 @@ private:
   DrawTarget* mDrawTarget;
   Rect mDirtyRect;
 
   // the rectangle of the outside and the inside of the border
   Rect mOuterRect;
   Rect mInnerRect;
 
   // the style and size of the border
-  uint8_t mBorderStyles[4];
+  mozilla::StyleBorderStyle mBorderStyles[4];
   Float mBorderWidths[4];
   RectCornerRadii mBorderRadii;
 
   // the colors for 'border-top-color' et. al.
   nscolor mBorderColors[4];
 
   // calculated values
   bool mAllBordersSameStyle;
@@ -155,23 +155,23 @@ private:
   bool mBackfaceIsVisible;
   mozilla::Maybe<Rect> mLocalClip;
 
   // For all the sides in the bitmask, would they be rendered
   // in an identical color and style?
   bool AreBorderSideFinalStylesSame(uint8_t aSides);
 
   // For the given style, is the given corner a solid color?
-  bool IsSolidCornerStyle(uint8_t aStyle, mozilla::Corner aCorner);
+  bool IsSolidCornerStyle(mozilla::StyleBorderStyle aStyle, mozilla::Corner aCorner);
 
   // For the given corner, is the given corner mergeable into one dot?
   bool IsCornerMergeable(mozilla::Corner aCorner);
 
   // For the given solid corner, what color style should be used?
-  BorderColorStyle BorderColorStyleForSolidCorner(uint8_t aStyle,
+  BorderColorStyle BorderColorStyleForSolidCorner(mozilla::StyleBorderStyle aStyle,
                                                   mozilla::Corner aCorner);
 
   //
   // Path generation functions
   //
 
   // Get the Rect for drawing the given corner
   Rect GetCornerRect(mozilla::Corner aCorner);
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -5258,18 +5258,18 @@ nsDisplayOutline::CreateWebRenderCommand
   mozilla::wr::DisplayListBuilder& aBuilder,
   mozilla::wr::IpcResourceUpdateQueue& aResources,
   const StackingContextHelper& aSc,
   mozilla::layers::WebRenderLayerManager* aManager,
   nsDisplayListBuilder* aDisplayListBuilder)
 {
   ContainerLayerParameters parameter;
 
-  uint8_t outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle;
-  if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO &&
+  StyleBorderStyle outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle;
+  if (outlineStyle == StyleBorderStyle::Auto &&
       nsLayoutUtils::IsOutlineStyleAutoEnabled()) {
     nsITheme* theme = mFrame->PresContext()->GetTheme();
     if (theme && theme->ThemeSupportsWidget(mFrame->PresContext(),
                                             mFrame,
                                             StyleAppearance::FocusOutline)) {
       return false;
     }
   }
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -128,16 +128,17 @@ rusty-enums = [
     "mozilla::StyleBoxPack",
     "mozilla::StyleBoxOrient",
     "mozilla::StyleBoxAlign",
     "mozilla::StyleUserFocus",
     "mozilla::StyleUserSelect",
     "mozilla::StyleImageLayerRepeat",
     "mozilla::StyleImageLayerAttachment",
     "mozilla::StyleBoxDecorationBreak",
+    "mozilla::StyleBorderStyle",
     "mozilla::StyleRuleInclusion",
     "mozilla::StyleGridTrackBreadth",
     "mozilla::StyleOverscrollBehavior",
     "mozilla::StyleScrollbarWidth",
     "mozilla::StyleWhiteSpace",
     "nsStyleImageType",
     "nsStyleSVGPaintType",
     "nsStyleSVGFallbackType",
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -184,26 +184,26 @@ nsCSSProps::GetStringValue(nsCSSCounterD
     static nsDependentCString sNullStr("");
     return sNullStr;
   }
 }
 
 /***************************************************************************/
 
 const KTableEntry nsCSSProps::kBorderStyleKTable[] = {
-  { eCSSKeyword_none,   NS_STYLE_BORDER_STYLE_NONE },
-  { eCSSKeyword_hidden, NS_STYLE_BORDER_STYLE_HIDDEN },
-  { eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED },
-  { eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED },
-  { eCSSKeyword_solid,  NS_STYLE_BORDER_STYLE_SOLID },
-  { eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE },
-  { eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE },
-  { eCSSKeyword_ridge,  NS_STYLE_BORDER_STYLE_RIDGE },
-  { eCSSKeyword_inset,  NS_STYLE_BORDER_STYLE_INSET },
-  { eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET },
+  { eCSSKeyword_none,   StyleBorderStyle::None },
+  { eCSSKeyword_hidden, StyleBorderStyle::Hidden },
+  { eCSSKeyword_dotted, StyleBorderStyle::Dotted },
+  { eCSSKeyword_dashed, StyleBorderStyle::Dashed },
+  { eCSSKeyword_solid,  StyleBorderStyle::Solid },
+  { eCSSKeyword_double, StyleBorderStyle::Double },
+  { eCSSKeyword_groove, StyleBorderStyle::Groove },
+  { eCSSKeyword_ridge,  StyleBorderStyle::Ridge },
+  { eCSSKeyword_inset,  StyleBorderStyle::Inset },
+  { eCSSKeyword_outset, StyleBorderStyle::Outset },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kBoxShadowTypeKTable[] = {
   { eCSSKeyword_inset, uint8_t(StyleBoxShadowType::Inset) },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
@@ -493,26 +493,26 @@ const KTableEntry nsCSSProps::kContainKT
   { eCSSKeyword_style,   NS_STYLE_CONTAIN_STYLE },
   { eCSSKeyword_paint,   NS_STYLE_CONTAIN_PAINT },
   { eCSSKeyword_size,    NS_STYLE_CONTAIN_SIZE },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 // Same as kBorderStyleKTable except 'hidden'.
 const KTableEntry nsCSSProps::kOutlineStyleKTable[] = {
-  { eCSSKeyword_none,   NS_STYLE_BORDER_STYLE_NONE },
-  { eCSSKeyword_auto,   NS_STYLE_BORDER_STYLE_AUTO },
-  { eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED },
-  { eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED },
-  { eCSSKeyword_solid,  NS_STYLE_BORDER_STYLE_SOLID },
-  { eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE },
-  { eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE },
-  { eCSSKeyword_ridge,  NS_STYLE_BORDER_STYLE_RIDGE },
-  { eCSSKeyword_inset,  NS_STYLE_BORDER_STYLE_INSET },
-  { eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET },
+  { eCSSKeyword_none,   StyleBorderStyle::None },
+  { eCSSKeyword_auto,   StyleBorderStyle::Auto },
+  { eCSSKeyword_dotted, StyleBorderStyle::Dotted },
+  { eCSSKeyword_dashed, StyleBorderStyle::Dashed },
+  { eCSSKeyword_solid,  StyleBorderStyle::Solid },
+  { eCSSKeyword_double, StyleBorderStyle::Double },
+  { eCSSKeyword_groove, StyleBorderStyle::Groove },
+  { eCSSKeyword_ridge,  StyleBorderStyle::Ridge },
+  { eCSSKeyword_inset,  StyleBorderStyle::Inset },
+  { eCSSKeyword_outset, StyleBorderStyle::Outset },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kOverflowKTable[] = {
   { eCSSKeyword_auto, NS_STYLE_OVERFLOW_AUTO },
   { eCSSKeyword_visible, NS_STYLE_OVERFLOW_VISIBLE },
   { eCSSKeyword_hidden, NS_STYLE_OVERFLOW_HIDDEN },
   { eCSSKeyword_scroll, NS_STYLE_OVERFLOW_SCROLL },
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -2200,17 +2200,17 @@ nsComputedDOMStyle::DoGetScrollbarColor(
 already_AddRefed<CSSValue>
 nsComputedDOMStyle::DoGetOutlineWidth()
 {
   RefPtr<nsROCSSPrimitiveValue> val = new nsROCSSPrimitiveValue;
 
   const nsStyleOutline* outline = StyleOutline();
 
   nscoord width;
-  if (outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_NONE) {
+  if (outline->mOutlineStyle == StyleBorderStyle::None) {
     NS_ASSERTION(outline->GetOutlineWidth() == 0, "unexpected width");
     width = 0;
   } else {
     width = outline->GetOutlineWidth();
   }
   val->SetAppUnits(width);
 
   return val.forget();
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -301,28 +301,29 @@ enum class StyleImageLayerRepeat : uint8
 #define NS_STYLE_BORDER_SEPARATE                1
 
 // Possible enumerated specified values of border-*-width, used by nsCSSMargin
 #define NS_STYLE_BORDER_WIDTH_THIN              0
 #define NS_STYLE_BORDER_WIDTH_MEDIUM            1
 #define NS_STYLE_BORDER_WIDTH_THICK             2
 // XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE      3
 
-// See nsStyleBorder mBorderStyle
-#define NS_STYLE_BORDER_STYLE_NONE              0
-#define NS_STYLE_BORDER_STYLE_GROOVE            1
-#define NS_STYLE_BORDER_STYLE_RIDGE             2
-#define NS_STYLE_BORDER_STYLE_DOTTED            3
-#define NS_STYLE_BORDER_STYLE_DASHED            4
-#define NS_STYLE_BORDER_STYLE_SOLID             5
-#define NS_STYLE_BORDER_STYLE_DOUBLE            6
-#define NS_STYLE_BORDER_STYLE_INSET             7
-#define NS_STYLE_BORDER_STYLE_OUTSET            8
-#define NS_STYLE_BORDER_STYLE_HIDDEN            9
-#define NS_STYLE_BORDER_STYLE_AUTO              10 // for outline-style only
+enum class StyleBorderStyle : uint8_t {
+  None,
+  Groove,
+  Ridge,
+  Dotted,
+  Dashed,
+  Solid,
+  Double,
+  Inset,
+  Outset,
+  Hidden,
+  Auto,     // for outline-style only
+};
 
 // border-image-repeat
 enum class StyleBorderImageRepeat : uint8_t {
   Stretch,
   Repeat,
   Round,
   Space
 };
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -286,17 +286,17 @@ nsStyleBorder::nsStyleBorder(const nsPre
   nscoord medium =
     (StaticPresData::Get()->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM];
   NS_FOR_CSS_SIDES(side) {
     mBorderImageSlice.Set(side, nsStyleCoord(1.0f, eStyleUnit_Percent));
     mBorderImageWidth.Set(side, nsStyleCoord(1.0f, eStyleUnit_Factor));
     mBorderImageOutset.Set(side, nsStyleCoord(0.0f, eStyleUnit_Factor));
 
     mBorder.Side(side) = medium;
-    mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE;
+    mBorderStyle[side] = StyleBorderStyle::None;
   }
 
   mTwipsPerPixel = aContext->DevPixelsToAppUnits(1);
 }
 
 nsStyleBorder::nsStyleBorder(const nsStyleBorder& aSrc)
   : mBorderRadius(aSrc.mBorderRadius)
   , mBorderImageSource(aSrc.mBorderImageSource)
@@ -444,17 +444,17 @@ nsStyleBorder::CalcDifference(const nsSt
   return nsChangeHint(0);
 }
 
 nsStyleOutline::nsStyleOutline(const nsPresContext* aContext)
   : mOutlineWidth((StaticPresData::Get()
                      ->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
   , mOutlineOffset(0)
   , mOutlineColor(StyleComplexColor::CurrentColor())
-  , mOutlineStyle(NS_STYLE_BORDER_STYLE_NONE)
+  , mOutlineStyle(StyleBorderStyle::None)
   , mActualOutlineWidth(0)
   , mTwipsPerPixel(aContext->DevPixelsToAppUnits(1))
 {
   MOZ_COUNT_CTOR(nsStyleOutline);
   // spacing values not inherited
   nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
   NS_FOR_CSS_HALF_CORNERS(corner) {
     mOutlineRadius.Set(corner, zero);
@@ -471,17 +471,17 @@ nsStyleOutline::nsStyleOutline(const nsS
   , mTwipsPerPixel(aSrc.mTwipsPerPixel)
 {
   MOZ_COUNT_CTOR(nsStyleOutline);
 }
 
 void
 nsStyleOutline::RecalcData()
 {
-  if (NS_STYLE_BORDER_STYLE_NONE == mOutlineStyle) {
+  if (StyleBorderStyle::None == mOutlineStyle) {
     mActualOutlineWidth = 0;
   } else {
     mActualOutlineWidth =
       NS_ROUND_BORDER_TO_PIXELS(mOutlineWidth, mTwipsPerPixel);
   }
 }
 
 nsChangeHint
@@ -662,17 +662,17 @@ nsStyleXUL::CalcDifference(const nsStyle
 // nsStyleColumn
 //
 /* static */ const uint32_t nsStyleColumn::kMaxColumnCount;
 /* static */ const uint32_t nsStyleColumn::kColumnCountAuto;
 
 nsStyleColumn::nsStyleColumn(const nsPresContext* aContext)
   : mColumnWidth(eStyleUnit_Auto)
   , mColumnRuleColor(StyleComplexColor::CurrentColor())
-  , mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE)
+  , mColumnRuleStyle(StyleBorderStyle::None)
   , mColumnRuleWidth((StaticPresData::Get()
                         ->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM])
   , mTwipsPerPixel(aContext->AppUnitsPerDevPixel())
 {
   MOZ_COUNT_CTOR(nsStyleColumn);
 }
 
 nsStyleColumn::~nsStyleColumn()
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -960,20 +960,20 @@ private:
 
 // Border widths are rounded to the nearest-below integer number of pixels,
 // but values between zero and one device pixels are always rounded up to
 // one device pixel.
 #define NS_ROUND_BORDER_TO_PIXELS(l,tpp) \
   ((l) == 0) ? 0 : std::max((tpp), (l) / (tpp) * (tpp))
 
 // Returns if the given border style type is visible or not
-static bool IsVisibleBorderStyle(uint8_t aStyle)
+static bool IsVisibleBorderStyle(mozilla::StyleBorderStyle aStyle)
 {
-  return (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
-          aStyle != NS_STYLE_BORDER_STYLE_HIDDEN);
+  return (aStyle != mozilla::StyleBorderStyle::None &&
+          aStyle != mozilla::StyleBorderStyle::Hidden);
 }
 
 struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder
 {
   explicit nsStyleBorder(const nsPresContext* aContext);
   nsStyleBorder(const nsStyleBorder& aBorder);
   ~nsStyleBorder();
 
@@ -1023,23 +1023,23 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   // this is zero if and only if there is no border to be painted for this
   // side.  That is, this value takes into account the border style and the
   // value is rounded to the nearest device pixel by NS_ROUND_BORDER_TO_PIXELS.
   nscoord GetComputedBorderWidth(mozilla::Side aSide) const
   {
     return GetComputedBorder().Side(aSide);
   }
 
-  uint8_t GetBorderStyle(mozilla::Side aSide) const
+  mozilla::StyleBorderStyle GetBorderStyle(mozilla::Side aSide) const
   {
     NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side");
     return mBorderStyle[aSide];
   }
 
-  void SetBorderStyle(mozilla::Side aSide, uint8_t aStyle)
+  void SetBorderStyle(mozilla::Side aSide, mozilla::StyleBorderStyle aStyle)
   {
     NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side");
     mBorderStyle[aSide] = aStyle;
     mComputedBorder.Side(aSide) =
       (HasVisibleStyle(aSide) ? mBorder.Side(aSide) : 0);
   }
 
   inline bool IsBorderImageLoaded() const
@@ -1066,17 +1066,17 @@ public:
 
   uint8_t        mBorderImageFill;
   mozilla::StyleBorderImageRepeat mBorderImageRepeatH;
   mozilla::StyleBorderImageRepeat mBorderImageRepeatV;
   mozilla::StyleFloatEdge mFloatEdge;
   mozilla::StyleBoxDecorationBreak mBoxDecorationBreak;
 
 protected:
-  uint8_t       mBorderStyle[4];  // NS_STYLE_BORDER_STYLE_*
+  mozilla::StyleBorderStyle mBorderStyle[4];  // StyleBorderStyle::*
 
 public:
   // the colors to use for a simple border.
   // not used for -moz-border-colors
   mozilla::StyleComplexColor mBorderTopColor;
   mozilla::StyleComplexColor mBorderRightColor;
   mozilla::StyleComplexColor mBorderBottomColor;
   mozilla::StyleComplexColor mBorderLeftColor;
@@ -1167,28 +1167,28 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   // This is the specified value of outline-width, but with length values
   // computed to absolute.  mActualOutlineWidth stores the outline-width
   // value used by layout.  (We must store mOutlineWidth for the same
   // style struct resolution reasons that we do nsStyleBorder::mBorder;
   // see that field's comment.)
   nscoord       mOutlineWidth;
   nscoord       mOutlineOffset;
   mozilla::StyleComplexColor mOutlineColor;
-  uint8_t       mOutlineStyle;  // NS_STYLE_BORDER_STYLE_*
+  mozilla::StyleBorderStyle  mOutlineStyle;  // StyleBorderStyle::*
 
   nscoord GetOutlineWidth() const
   {
     return mActualOutlineWidth;
   }
 
   bool ShouldPaintOutline() const
   {
-    return mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO ||
+    return mOutlineStyle == mozilla::StyleBorderStyle::Auto ||
            (GetOutlineWidth() > 0 &&
-            mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE);
+            mOutlineStyle != mozilla::StyleBorderStyle::None);
   }
 
 protected:
   // The actual value of outline-width is the computed value (an absolute
   // length, forced to zero when outline-style is none) rounded to device
   // pixels.  This is the value used by layout.
   nscoord       mActualOutlineWidth;
   nscoord       mTwipsPerPixel;
@@ -2776,17 +2776,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
 
   // This represents the value of column-count: auto.
   static const uint32_t kColumnCountAuto = 0;
 
   uint32_t mColumnCount = kColumnCountAuto;
   nsStyleCoord mColumnWidth; // coord, auto
 
   mozilla::StyleComplexColor mColumnRuleColor;
-  uint8_t      mColumnRuleStyle;  // NS_STYLE_BORDER_STYLE_*
+  mozilla::StyleBorderStyle  mColumnRuleStyle;  // StyleborderStyle::*
   mozilla::StyleColumnFill mColumnFill = mozilla::StyleColumnFill::Balance;
   mozilla::StyleColumnSpan mColumnSpan = mozilla::StyleColumnSpan::None;
 
   nscoord GetComputedColumnRuleWidth() const {
     return (IsVisibleBorderStyle(mColumnRuleStyle) ? mColumnRuleWidth : 0);
   }
 
   bool IsColumnContainerStyle() const {
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -4420,34 +4420,34 @@ nsTableFrame::SetFullBCDamageArea()
  * XXX_Bernd this asymmetry is the root of those rowspan bc border errors
  */
 struct BCCellBorder
 {
   BCCellBorder() { Reset(0, 1); }
   void Reset(uint32_t aRowIndex, uint32_t aRowSpan);
   nscolor       color;    // border segment color
   BCPixelSize   width;    // border segment width in pixel coordinates !!
-  uint8_t       style;    // border segment style, possible values are defined
-                          // in nsStyleConsts.h as NS_STYLE_BORDER_STYLE_*
+  StyleBorderStyle style; // border segment style, possible values are defined
+                          // in nsStyleConsts.h as StyleBorderStyle::*
   BCBorderOwner owner;    // border segment owner, possible values are defined
                           // in celldata.h. In the cellmap for each border
                           // segment we store the owner and later when
                           // painting we know the owner and can retrieve the
                           // style info from the corresponding frame
   int32_t       rowIndex; // rowIndex of temporary stored inline-dir border
                           // segments relative to the table
   int32_t       rowSpan;  // row span of temporary stored inline-dir border
                           // segments
 };
 
 void
 BCCellBorder::Reset(uint32_t aRowIndex,
                     uint32_t aRowSpan)
 {
-  style = NS_STYLE_BORDER_STYLE_NONE;
+  style = StyleBorderStyle::None;
   color = 0;
   width = 0;
   owner = eTableOwner;
   rowIndex = aRowIndex;
   rowSpan  = aRowSpan;
 }
 
 class BCMapCellIterator;
@@ -4997,28 +4997,28 @@ BCMapCellIterator::PeekBEnd(BCMapCellInf
   if (cellData->IsColSpan()) {
     aColIndex -= cellData->GetColSpanOffset();
     cellData =
       static_cast<BCCellData*>(cellMap->GetDataAt(rgRowIndex, aColIndex));
   }
   aAjaInfo.SetInfo(nextRow, aColIndex, cellData, this, cellMap);
 }
 
-// Assign priorities to border styles. For example, styleToPriority(NS_STYLE_BORDER_STYLE_SOLID)
-// will return the priority of NS_STYLE_BORDER_STYLE_SOLID.
-static uint8_t styleToPriority[13] = { 0,  // NS_STYLE_BORDER_STYLE_NONE
-                                       2,  // NS_STYLE_BORDER_STYLE_GROOVE
-                                       4,  // NS_STYLE_BORDER_STYLE_RIDGE
-                                       5,  // NS_STYLE_BORDER_STYLE_DOTTED
-                                       6,  // NS_STYLE_BORDER_STYLE_DASHED
-                                       7,  // NS_STYLE_BORDER_STYLE_SOLID
-                                       8,  // NS_STYLE_BORDER_STYLE_DOUBLE
-                                       1,  // NS_STYLE_BORDER_STYLE_INSET
-                                       3,  // NS_STYLE_BORDER_STYLE_OUTSET
-                                       9 };// NS_STYLE_BORDER_STYLE_HIDDEN
+// Assign priorities to border styles. For example, styleToPriority(StyleBorderStyle::Solid)
+// will return the priority of StyleBorderStyle::Solid.
+static uint8_t styleToPriority[13] = { 0,  // StyleBorderStyle::None
+                                       2,  // StyleBorderStyle::Groove
+                                       4,  // StyleBorderStyle::Ridge
+                                       5,  // StyleBorderStyle::Dotted
+                                       6,  // StyleBorderStyle::Dashed
+                                       7,  // StyleBorderStyle::Solid
+                                       8,  // StyleBorderStyle::Double
+                                       1,  // StyleBorderStyle::Inset
+                                       3,  // StyleBorderStyle::Outset
+                                       9 };// StyleBorderStyle::Hidden
 // priority rules follow CSS 2.1 spec
 // 'hidden', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove',
 // and the lowest: 'inset'. none is even weaker
 #define CELL_CORNER true
 
 /** return the border style, border color and optionally the width in
   * pixel for a given frame and side
   * @param aFrame           - query the info for this frame
@@ -5027,35 +5027,35 @@ static uint8_t styleToPriority[13] = { 0
   * @param aStyle           - the border style
   * @param aColor           - the border color
   * @param aWidth           - the border width in px
   */
 static void
 GetColorAndStyle(const nsIFrame* aFrame,
                  WritingMode aTableWM,
                  LogicalSide aSide,
-                 uint8_t* aStyle,
+                 StyleBorderStyle* aStyle,
                  nscolor* aColor,
                  BCPixelSize* aWidth = nullptr)
 {
   MOZ_ASSERT(aFrame, "null frame");
   MOZ_ASSERT(aStyle && aColor, "null argument");
 
   // initialize out arg
   *aColor = 0;
   if (aWidth) {
     *aWidth = 0;
   }
 
   const nsStyleBorder* styleData = aFrame->StyleBorder();
   mozilla::Side physicalSide = aTableWM.PhysicalSide(aSide);
   *aStyle = styleData->GetBorderStyle(physicalSide);
 
-  if ((NS_STYLE_BORDER_STYLE_NONE == *aStyle) ||
-      (NS_STYLE_BORDER_STYLE_HIDDEN == *aStyle)) {
+  if ((StyleBorderStyle::None == *aStyle) ||
+      (StyleBorderStyle::Hidden == *aStyle)) {
     return;
   }
   *aColor = aFrame->Style()->
     GetVisitedDependentColor(nsStyleBorder::BorderColorFieldFor(physicalSide));
 
   if (aWidth) {
     nscoord width = styleData->GetComputedBorderWidth(physicalSide);
     *aWidth = aFrame->PresContext()->AppUnitsToDevPixels(width);
@@ -5068,24 +5068,24 @@ GetColorAndStyle(const nsIFrame* aFrame,
   * @param aSide            - the side of the frame
   * @param aStyle           - the border style
   * @param aColor           - the border color
   */
 static void
 GetPaintStyleInfo(const nsIFrame* aFrame,
                   WritingMode aTableWM,
                   LogicalSide aSide,
-                  uint8_t* aStyle,
+                  StyleBorderStyle* aStyle,
                   nscolor* aColor)
 {
   GetColorAndStyle(aFrame, aTableWM, aSide, aStyle, aColor);
-  if (NS_STYLE_BORDER_STYLE_INSET == *aStyle) {
-    *aStyle = NS_STYLE_BORDER_STYLE_RIDGE;
-  } else if (NS_STYLE_BORDER_STYLE_OUTSET == *aStyle) {
-    *aStyle = NS_STYLE_BORDER_STYLE_GROOVE;
+  if (StyleBorderStyle::Inset == *aStyle) {
+    *aStyle = StyleBorderStyle::Ridge;
+  } else if (StyleBorderStyle::Outset == *aStyle) {
+    *aStyle = StyleBorderStyle::Groove;
   }
 }
 
 class nsDelayedCalcBCBorders : public Runnable {
 public:
   explicit nsDelayedCalcBCBorders(nsIFrame* aFrame)
     : mozilla::Runnable("nsDelayedCalcBCBorders")
     , mFrame(aFrame)
@@ -5146,30 +5146,32 @@ static const BCCellBorder&
 CompareBorders(bool                aIsCorner, // Pass true for corner calculations
                const BCCellBorder& aBorder1,
                const BCCellBorder& aBorder2,
                bool                aSecondIsInlineDir,
                bool*               aFirstDominates = nullptr)
 {
   bool firstDominates = true;
 
-  if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder1.style) {
+  if (StyleBorderStyle::Hidden == aBorder1.style) {
     firstDominates = (aIsCorner) ? false : true;
   }
-  else if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder2.style) {
+  else if (StyleBorderStyle::Hidden == aBorder2.style) {
     firstDominates = (aIsCorner) ? true : false;
   }
   else if (aBorder1.width < aBorder2.width) {
     firstDominates = false;
   }
   else if (aBorder1.width == aBorder2.width) {
-    if (styleToPriority[aBorder1.style] < styleToPriority[aBorder2.style]) {
+    if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] <
+        styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
       firstDominates = false;
     }
-    else if (styleToPriority[aBorder1.style] == styleToPriority[aBorder2.style]) {
+    else if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] ==
+             styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
       if (aBorder1.owner == aBorder2.owner) {
         firstDominates = !aSecondIsInlineDir;
       }
       else if (aBorder1.owner < aBorder2.owner) {
         firstDominates = false;
       }
     }
   }
@@ -5215,58 +5217,58 @@ CompareBorders(const nsIFrame*  aTableFr
   BCCellBorder border, tempBorder;
   bool inlineAxis = IsBlock(aSide);
 
   // start with the table as dominant if present
   if (aTableFrame) {
     GetColorAndStyle(aTableFrame, aTableWM, aSide,
                      &border.style, &border.color, &border.width);
     border.owner = eTableOwner;
-    if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
+    if (StyleBorderStyle::Hidden == border.style) {
       return border;
     }
   }
   // see if the colgroup is dominant
   if (aColGroupFrame) {
     GetColorAndStyle(aColGroupFrame, aTableWM, aSide,
                      &tempBorder.style, &tempBorder.color, &tempBorder.width);
     tempBorder.owner = aAja && !inlineAxis ? eAjaColGroupOwner : eColGroupOwner;
     // pass here and below false for aSecondIsInlineDir as it is only used for corner calculations.
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
-    if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
+    if (StyleBorderStyle::Hidden == border.style) {
       return border;
     }
   }
   // see if the col is dominant
   if (aColFrame) {
     GetColorAndStyle(aColFrame, aTableWM, aSide,
                      &tempBorder.style, &tempBorder.color, &tempBorder.width);
     tempBorder.owner = aAja && !inlineAxis ? eAjaColOwner : eColOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
-    if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
+    if (StyleBorderStyle::Hidden == border.style) {
       return border;
     }
   }
   // see if the rowgroup is dominant
   if (aRowGroupFrame) {
     GetColorAndStyle(aRowGroupFrame, aTableWM, aSide,
                      &tempBorder.style, &tempBorder.color, &tempBorder.width);
     tempBorder.owner = aAja && inlineAxis ? eAjaRowGroupOwner : eRowGroupOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
-    if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
+    if (StyleBorderStyle::Hidden == border.style) {
       return border;
     }
   }
   // see if the row is dominant
   if (aRowFrame) {
     GetColorAndStyle(aRowFrame, aTableWM, aSide,
                      &tempBorder.style, &tempBorder.color, &tempBorder.width);
     tempBorder.owner = aAja && inlineAxis ? eAjaRowOwner : eRowOwner;
     border = CompareBorders(!CELL_CORNER, border, tempBorder, false);
-    if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) {
+    if (StyleBorderStyle::Hidden == border.style) {
       return border;
     }
   }
   // see if the cell is dominant
   if (aCellFrame) {
     GetColorAndStyle(aCellFrame, aTableWM, aSide,
                      &tempBorder.style, &tempBorder.color, &tempBorder.width);
     tempBorder.owner = aAja ? eAjaCellOwner : eCellOwner;
@@ -5278,46 +5280,46 @@ CompareBorders(const nsIFrame*  aTableFr
 static bool
 Perpendicular(mozilla::LogicalSide aSide1,
               mozilla::LogicalSide aSide2)
 {
   return IsInline(aSide1) != IsInline(aSide2);
 }
 
 // Initial value indicating that BCCornerInfo's ownerStyle hasn't been set yet.
-#define BORDER_STYLE_UNSET 0xF
+#define BORDER_STYLE_UNSET static_cast<StyleBorderStyle>(255)
 
 // XXX allocate this as number-of-cols+1 instead of number-of-cols+1 * number-of-rows+1
 struct BCCornerInfo
 {
   BCCornerInfo() { ownerColor = 0; ownerWidth = subWidth = ownerElem = subSide =
                    subElem = hasDashDot = numSegs = bevel = 0; ownerSide = eLogicalSideBStart;
                    ownerStyle = BORDER_STYLE_UNSET;
-                   subStyle = NS_STYLE_BORDER_STYLE_SOLID; }
+                   subStyle = StyleBorderStyle::Solid; }
 
   void Set(mozilla::LogicalSide aSide,
            BCCellBorder  border);
 
   void Update(mozilla::LogicalSide aSide,
               BCCellBorder  border);
 
-  nscolor   ownerColor;     // color of borderOwner
-  uint16_t  ownerWidth;     // pixel width of borderOwner
-  uint16_t  subWidth;       // pixel width of the largest border intersecting the border perpendicular
-                            // to ownerSide
-  uint32_t  ownerSide:2;    // LogicalSide (e.g eLogicalSideBStart, etc) of the border
-                            // owning the corner relative to the corner
-  uint32_t  ownerElem:4;    // elem type (e.g. eTable, eGroup, etc) owning the corner
-  uint32_t  ownerStyle:4;   // border style of ownerElem
-  uint32_t  subSide:2;      // side of border with subWidth relative to the corner
-  uint32_t  subElem:4;      // elem type (e.g. eTable, eGroup, etc) of sub owner
-  uint32_t  subStyle:4;     // border style of subElem
-  uint32_t  hasDashDot:1;   // does a dashed, dotted segment enter the corner, they cannot be beveled
-  uint32_t  numSegs:3;      // number of segments entering corner
-  uint32_t  bevel:1;        // is the corner beveled (uses the above two fields together with subWidth)
+  nscolor   ownerColor;       // color of borderOwner
+  uint16_t  ownerWidth;       // pixel width of borderOwner
+  uint16_t  subWidth;         // pixel width of the largest border intersecting the border perpendicular
+                              // to ownerSide
+  StyleBorderStyle subStyle;  // border style of subElem
+  StyleBorderStyle ownerStyle;// border style of ownerElem
+  uint16_t  ownerSide:2;      // LogicalSide (e.g eLogicalSideBStart, etc) of the border
+                              // owning the corner relative to the corner
+  uint16_t  ownerElem:4;      // elem type (e.g. eTable, eGroup, etc) owning the corner
+  uint16_t  subSide:2;        // side of border with subWidth relative to the corner
+  uint16_t  subElem:4;        // elem type (e.g. eTable, eGroup, etc) of sub owner
+  uint16_t  hasDashDot:1;     // does a dashed, dotted segment enter the corner, they cannot be beveled
+  uint16_t  numSegs:3;        // number of segments entering corner
+  uint16_t  bevel:1;          // is the corner beveled (uses the above two fields together with subWidth)
   // 7 bits are unused
 };
 
 void
 BCCornerInfo::Set(mozilla::LogicalSide aSide,
                   BCCellBorder  aBorder)
 {
   // FIXME bug 1508921: We mask 4-bit BCBorderOwner enum to 3 bits to preserve
@@ -5327,25 +5329,25 @@ BCCornerInfo::Set(mozilla::LogicalSide a
   ownerStyle = aBorder.style;
   ownerWidth = aBorder.width;
   ownerColor = aBorder.color;
   ownerSide  = aSide;
   hasDashDot = 0;
   numSegs    = 0;
   if (aBorder.width > 0) {
     numSegs++;
-    hasDashDot = (NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) ||
-                 (NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style);
+    hasDashDot = (StyleBorderStyle::Dashed == aBorder.style) ||
+                 (StyleBorderStyle::Dotted == aBorder.style);
   }
   bevel      = 0;
   subWidth   = 0;
   // the following will get set later
   subSide    = IsInline(aSide) ? eLogicalSideBStart : eLogicalSideIStart;
   subElem    = eTableOwner;
-  subStyle   = NS_STYLE_BORDER_STYLE_SOLID;
+  subStyle   = StyleBorderStyle::Solid;
 }
 
 void
 BCCornerInfo::Update(mozilla::LogicalSide aSide,
                      BCCellBorder  aBorder)
 {
   if (ownerStyle == BORDER_STYLE_UNSET) {
     Set(aSide, aBorder);
@@ -5393,18 +5395,18 @@ BCCornerInfo::Update(mozilla::LogicalSid
         subElem  = oldBorder.owner;
         subStyle = oldBorder.style;
         subWidth = oldBorder.width;
         subSide  = oldSide;
       }
     }
     if (aBorder.width > 0) {
       numSegs++;
-      if (!hasDashDot && ((NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) ||
-                          (NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style))) {
+      if (!hasDashDot && ((StyleBorderStyle::Dashed == aBorder.style) ||
+                          (StyleBorderStyle::Dotted == aBorder.style))) {
         hasDashDot = 1;
       }
     }
 
     // bevel the corner if only two perpendicular non dashed/dotted segments enter the corner
     bevel = (2 == numSegs) && (subWidth > 1) && (0 == hasDashDot);
   }
 }
@@ -6498,34 +6500,34 @@ nsTableFrame::CalcBCBorders()
   mCellMap->Dump();
 #endif
 }
 
 class BCPaintBorderIterator;
 
 struct BCBorderParameters
 {
-  uint8_t mBorderStyle;
+  StyleBorderStyle mBorderStyle;
   nscolor mBorderColor;
   nsRect mBorderRect;
   int32_t mAppUnitsPerDevPixel;
   mozilla::Side mStartBevelSide;
   nscoord mStartBevelOffset;
   mozilla::Side mEndBevelSide;
   nscoord mEndBevelOffset;
   bool mBackfaceIsVisible;
 
   bool NeedToBevel() const
   {
     if (!mStartBevelOffset && !mEndBevelOffset) {
       return false;
     }
 
-    if (mBorderStyle == NS_STYLE_BORDER_STYLE_DASHED ||
-        mBorderStyle == NS_STYLE_BORDER_STYLE_DOTTED) {
+    if (mBorderStyle == StyleBorderStyle::Dashed ||
+        mBorderStyle == StyleBorderStyle::Dotted) {
       return false;
     }
 
     return true;
   }
 };
 
 struct BCBlockDirSeg
@@ -7379,17 +7381,17 @@ BCBlockDirSeg::BuildBorderParameters(BCP
 
   // get the border style, color and paint the segment
   LogicalSide side =
     aIter.IsDamageAreaIEndMost() ? eLogicalSideIEnd : eLogicalSideIStart;
   int32_t relColIndex = aIter.GetRelativeColIndex();
   nsTableColFrame* col           = mCol; if (!col) ABORT1(Nothing());
   nsTableCellFrame* cell         = mFirstCell; // ???
   nsIFrame* owner = nullptr;
-  result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID;
+  result.mBorderStyle = StyleBorderStyle::Solid;
   result.mBorderColor = 0xFFFFFFFF;
   result.mBackfaceIsVisible = true;
 
   // All the tables frames have the same presContext, so we just use any one
   // that exists here:
   nsPresContext* presContext = aIter.mTable->PresContext();
   result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
 
@@ -7529,17 +7531,17 @@ AdjustAndPushBevel(wr::DisplayListBuilde
   const bool horizontal =
     aBevel.mSide == eSideTop || aBevel.mSide == eSideBottom;
 
   // Crappy CSS triangle as known by every web developer ever :)
   Float offset = NSAppUnitsToFloatPixels(aBevel.mOffset, aAppUnitsPerDevPixel);
   wr::LayoutRect bevelRect = aRect;
   wr::BorderSide bevelBorder[4];
   NS_FOR_CSS_SIDES(i) {
-    bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), NS_STYLE_BORDER_STYLE_SOLID);
+    bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), StyleBorderStyle::Solid);
   }
 
   // We're creating a half-transparent triangle using the border primitive.
   //
   // Classic web-dev trick, with a gotcha: we use a single corner to avoid
   // seams and rounding errors.
   //
   // Classic web-dev trick :P
@@ -7664,17 +7666,17 @@ CreateWRCommandsForBorderSegment(const B
 
   auto borderRect = LayoutDeviceRect::FromUnknownRect(
       NSRectToRect(aBorderParams.mBorderRect + aOffset,
                    aBorderParams.mAppUnitsPerDevPixel));
 
   wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect);
   wr::BorderSide wrSide[4];
   NS_FOR_CSS_SIDES(i) {
-    wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), NS_STYLE_BORDER_STYLE_NONE);
+    wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), StyleBorderStyle::None);
   }
   const bool horizontal = aBorderParams.mStartBevelSide == eSideTop ||
                           aBorderParams.mStartBevelSide == eSideBottom;
   auto borderWidth = horizontal ? roundedRect.size.height : roundedRect.size.width;
 
   // All border style is set to none except left side. So setting the widths of
   // each side to width of rect is fine.
   auto borderWidths =
@@ -7828,17 +7830,17 @@ BCInlineDirSeg::BuildBorderParameters(BC
   nsIFrame* owner = nullptr;
   result.mBackfaceIsVisible = true;
 
   // All the tables frames have the same presContext, so we just use any one
   // that exists here:
   nsPresContext* presContext = aIter.mTable->PresContext();
   result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
 
-  result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID;
+  result.mBorderStyle = StyleBorderStyle::Solid;
   result.mBorderColor = 0xFFFFFFFF;
 
   switch (mOwner) {
     case eTableOwner:
       owner = aIter.mTable;
       break;
     case eAjaColGroupOwner:
       NS_ERROR("neighboring colgroups can never own an inline-dir border");
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -3222,17 +3222,17 @@ nsTreeBodyFrame::PaintCell(int32_t      
       twistyContext->StyleMargin()->GetMargin(twistyMargin);
       twistyRect.Inflate(twistyMargin);
 
       const nsStyleBorder* borderStyle = lineContext->StyleBorder();
       // Resolve currentcolor values against the treeline context
       nscolor color = borderStyle->mBorderLeftColor.CalcColor(lineContext);
       ColorPattern colorPatt(ToDeviceColor(color));
 
-      uint8_t style = borderStyle->GetBorderStyle(eSideLeft);
+      StyleBorderStyle style = borderStyle->GetBorderStyle(eSideLeft);
       StrokeOptions strokeOptions;
       nsLayoutUtils::InitDashPattern(strokeOptions, style);
 
       nscoord srcX = currX + twistyRect.width - mIndentation / 2;
       nscoord lineY = (aRowIndex - mTopRowIndex) * mRowHeight + aPt.y;
 
       DrawTarget* drawTarget = aRenderingContext.GetDrawTarget();
       nsPresContext* pc = PresContext();
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -1511,17 +1511,19 @@ fn static_assert() {
     // Note: using the above technique with an enum hits a rust bug when |structs| is in a different crate.
     % for side in SIDES:
     { const DETAIL: u32 = [0][(structs::Side::eSide${side.name} as usize != ${side.index}) as usize]; let _ = DETAIL; }
     % endfor
 }
 
 
 <% border_style_keyword = Keyword("border-style",
-                                  "none solid double dotted dashed hidden groove ridge inset outset") %>
+                                  "none solid double dotted dashed hidden groove ridge inset outset",
+                                  gecko_enum_prefix="StyleBorderStyle",
+                                  gecko_inexhaustive=True) %>
 
 <% skip_border_longhands = " ".join(["border-{0}-{1}".format(x.ident, y)
                                      for x in SIDES
                                      for y in ["color", "style", "width"]] +
                                     ["border-{0}-radius".format(x.ident.replace("_", "-"))
                                      for x in CORNERS]) %>
 
 <%self:impl_trait style_struct_name="Border"
--- a/servo/components/style/properties/longhands/border.mako.rs
+++ b/servo/components/style/properties/longhands/border.mako.rs
@@ -58,17 +58,19 @@
         flags="APPLIES_TO_FIRST_LETTER GETCS_NEEDS_LAYOUT_FLUSH",
         allow_quirks=not is_logical,
         servo_restyle_damage="reflow rebuild_and_reflow_inline"
     )}
 % endfor
 
 ${helpers.gecko_keyword_conversion(
     Keyword('border-style',
-    "none solid double dotted dashed hidden groove ridge inset outset"),
+    "none solid double dotted dashed hidden groove ridge inset outset",
+    gecko_enum_prefix="StyleBorderStyle",
+    gecko_inexhaustive=True),
     type="crate::values::specified::BorderStyle",
 )}
 
 // FIXME(#4126): when gfx supports painting it, make this Size2D<LengthOrPercentage>
 % for corner in ["top-left", "top-right", "bottom-right", "bottom-left"]:
     ${helpers.predefined_type(
         "border-" + corner + "-radius",
         "BorderCornerRadius",
--- a/servo/components/style/properties/longhands/column.mako.rs
+++ b/servo/components/style/properties/longhands/column.mako.rs
@@ -78,12 +78,13 @@
     extra_prefixes="moz:layout.css.column-span.enabled",
 )}
 
 ${helpers.single_keyword(
     "column-rule-style",
     "none hidden dotted dashed solid double groove ridge inset outset",
     products="gecko",
     extra_prefixes="moz",
-    gecko_constant_prefix="NS_STYLE_BORDER_STYLE",
+    gecko_enum_prefix="StyleBorderStyle",
+    gecko_inexhaustive=True,
     animation_value_type="discrete",
     spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-style",
 )}
--- a/widget/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/cocoa/nsNativeThemeCocoa.mm
@@ -3920,20 +3920,20 @@ nsNativeThemeCocoa::CreateWebRenderComma
         return false;
       }
 
       // White background
       aBuilder.PushRect(bounds, bounds, true,
                         wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0)));
 
       wr::BorderSide side[4] = {
-        wr::ToBorderSide(kMultilineTextFieldTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
+        wr::ToBorderSide(kMultilineTextFieldTopBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid),
       };
 
       wr::BorderRadius borderRadius = wr::EmptyBorderRadius();
       float borderWidth = presContext->CSSPixelsToDevPixels(1.0f);
       wr::LayoutSideOffsets borderWidths =
         wr::ToBorderWidths(borderWidth, borderWidth, borderWidth, borderWidth);
 
       mozilla::Range<const wr::BorderSide> wrsides(side, 4);
@@ -3943,20 +3943,20 @@ nsNativeThemeCocoa::CreateWebRenderComma
     }
 
     case StyleAppearance::Listbox: {
       // White background
       aBuilder.PushRect(bounds, bounds, true,
                         wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0)));
 
       wr::BorderSide side[4] = {
-        wr::ToBorderSide(kListboxTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
-        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID),
+        wr::ToBorderSide(kListboxTopBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
+        wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid),
       };
 
       wr::BorderRadius borderRadius = wr::EmptyBorderRadius();
       float borderWidth = presContext->CSSPixelsToDevPixels(1.0f);
       wr::LayoutSideOffsets borderWidths =
         wr::ToBorderWidths(borderWidth, borderWidth, borderWidth, borderWidth);
 
       mozilla::Range<const wr::BorderSide> wrsides(side, 4);