Merge inbound to mozilla-central. a=merge
authorMargareta Eliza Balazs <ebalazs@mozilla.com>
Thu, 22 Nov 2018 11:21:21 +0200
changeset 504112 785032241b2fe327aa833267416b3eb8d846cb4f
parent 504098 111154a7621cc50da7bed70c93171b96c8ef92f0 (current diff)
parent 504111 c12b84f575c3fe48d72f3c8c24a54b3dee1cc985 (diff)
child 504118 eab58dd901f7d09fdc771c55853a37359a0c1c92
child 504164 e01aacd86e0d4ed28414de3c1d57743bb3300f0e
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone65.0a1
first release with
nightly linux32
785032241b2f / 65.0a1 / 20181122100048 / files
nightly linux64
785032241b2f / 65.0a1 / 20181122100048 / files
nightly mac
785032241b2f / 65.0a1 / 20181122100048 / files
nightly win32
785032241b2f / 65.0a1 / 20181122100048 / files
nightly win64
785032241b2f / 65.0a1 / 20181122100048 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge inbound to mozilla-central. a=merge
dom/base/nsFrameLoader.cpp
dom/base/nsFrameLoader.h
dom/webidl/FrameLoader.webidl
layout/painting/nsDisplayList.cpp
--- 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/dom/payments/MerchantValidationEvent.cpp
+++ b/dom/payments/MerchantValidationEvent.cpp
@@ -129,30 +129,30 @@ MerchantValidationEvent::ResolvedCallbac
   // If we eventually end up supporting merchant validation
   // we would validate `aValue` here, as per:
   // https://w3c.github.io/payment-request/#validate-merchant-s-details-algorithm
   //
   // Right now, MerchantValidationEvent is only implemented for standards
   // conformance, which is why at this point we throw a
   // NS_ERROR_DOM_NOT_SUPPORTED_ERR.
 
-  mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false);
+  mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
   mRequest->SetUpdating(false);
 }
 
 void
 MerchantValidationEvent::RejectedCallback(JSContext* aCx,
                                           JS::Handle<JS::Value> aValue)
 {
   MOZ_ASSERT(mRequest);
   if (!mWaitForUpdate) {
     return;
   }
   mWaitForUpdate = false;
-  mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
+  mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
   mRequest->SetUpdating(false);
 }
 
 void
 MerchantValidationEvent::Complete(Promise& aPromise, ErrorResult& aRv)
 {
   if (!IsTrusted()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
--- a/dom/payments/PaymentRequest.cpp
+++ b/dom/payments/PaymentRequest.cpp
@@ -659,17 +659,16 @@ PaymentRequest::CreatePaymentRequest(nsP
 }
 
 PaymentRequest::PaymentRequest(nsPIDOMWindowInner* aWindow, const nsAString& aInternalId)
   : DOMEventTargetHelper(aWindow)
   , mInternalId(aInternalId)
   , mShippingAddress(nullptr)
   , mUpdating(false)
   , mRequestShipping(false)
-  , mDeferredShow(false)
   , mUpdateError(NS_OK)
   , mState(eCreated)
   , mIPC(nullptr)
 {
   MOZ_ASSERT(aWindow);
   RegisterActivityObserver();
 }
 
@@ -751,17 +750,16 @@ PaymentRequest::Show(const Optional<Owni
     mState = eClosed;
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   if (aDetailsPromise.WasPassed()) {
     aDetailsPromise.Value().AppendNativeHandler(this);
     mUpdating = true;
-    mDeferredShow = true;
   }
 
   RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
   MOZ_ASSERT(manager);
   nsresult rv = manager->ShowPayment(this);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     if (rv == NS_ERROR_ABORT) {
       promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
@@ -853,19 +851,17 @@ PaymentRequest::Abort(ErrorResult& aRv)
   RefPtr<Promise> promise = Promise::Create(global, result);
   if (result.Failed()) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
   MOZ_ASSERT(manager);
-  // It's possible to be called between show and its promise resolving.
-  nsresult rv = manager->AbortPayment(this, mDeferredShow);
-  mDeferredShow = false;
+  nsresult rv = manager->AbortPayment(this);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
   mAbortPromise = promise;
   return promise.forget();
 }
@@ -900,47 +896,45 @@ PaymentRequest::RespondAbortPayment(bool
     RejectShowPayment(NS_ERROR_DOM_ABORT_ERR);
   } else {
     mAbortPromise->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
     mAbortPromise = nullptr;
   }
 }
 
 nsresult
-PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails,
-                              bool aDeferredShow)
+PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails)
 {
   NS_ENSURE_ARG_POINTER(aCx);
   if (mState != eInteractive) {
     return NS_ERROR_DOM_INVALID_STATE_ERR;
   }
   RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
   if (NS_WARN_IF(!manager)) {
     return NS_ERROR_FAILURE;
   }
-  nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping,
-                                       aDeferredShow);
+  nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 void
-PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow)
+PaymentRequest::AbortUpdate(nsresult aRv)
 {
   MOZ_ASSERT(NS_FAILED(aRv));
 
   if (mState != eInteractive) {
     return;
   }
   // Close down any remaining user interface.
   RefPtr<PaymentRequestManager> manager = PaymentRequestManager::GetSingleton();
   MOZ_ASSERT(manager);
-  nsresult rv = manager->AbortPayment(this, aDeferredShow);
+  nsresult rv = manager->AbortPayment(this);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return;
   }
 
   // Remember update error |aRv| and do the following steps in RespondShowPayment.
   // 1. Set target.state to closed
   // 2. Reject the promise target.acceptPromise with exception "aRv"
   // 3. Abort the algorithm with update error
@@ -1133,43 +1127,39 @@ PaymentRequest::ResolvedCallback(JSConte
   mUpdating = false;
   if (NS_WARN_IF(!aValue.isObject())) {
     return;
   }
 
   // Converting value to a PaymentDetailsUpdate dictionary
   PaymentDetailsUpdate details;
   if (!details.Init(aCx, aValue)) {
-    AbortUpdate(NS_ERROR_DOM_TYPE_ERR, mDeferredShow);
+    AbortUpdate(NS_ERROR_DOM_TYPE_ERR);
     JS_ClearPendingException(aCx);
     return;
   }
 
   nsresult rv = IsValidDetailsUpdate(details, mRequestShipping);
   if (NS_FAILED(rv)) {
-    AbortUpdate(rv, mDeferredShow);
+    AbortUpdate(rv);
     return;
   }
 
   // Update the PaymentRequest with the new details
-  if (NS_FAILED(UpdatePayment(aCx, details, mDeferredShow))) {
-    AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow);
+  if (NS_FAILED(UpdatePayment(aCx, details))) {
+    AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
     return;
   }
-
-  mDeferredShow = false;
 }
 
 void
 PaymentRequest::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
 {
-  MOZ_ASSERT(mDeferredShow);
   mUpdating = false;
-  AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow);
-  mDeferredShow = false;
+  AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
 }
 
 void
 PaymentRequest::RegisterActivityObserver()
 {
   if (nsPIDOMWindowInner* window = GetOwner()) {
     nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
     if (doc) {
--- a/dom/payments/PaymentRequest.h
+++ b/dom/payments/PaymentRequest.h
@@ -138,19 +138,18 @@ public:
 
   void SetShippingOption(const nsAString& aShippingOption);
   void GetShippingOption(nsAString& aRetVal) const;
   void GetOptions(PaymentOptions& aRetVal) const;
   void SetOptions(const PaymentOptions& aOptions);
   nsresult UpdateShippingOption(const nsAString& aShippingOption);
 
   nsresult UpdatePayment(JSContext* aCx,
-                         const PaymentDetailsUpdate& aDetails,
-                         bool aDeferredShow);
-  void AbortUpdate(nsresult aRv, bool aDeferredShow);
+                         const PaymentDetailsUpdate& aDetails);
+  void AbortUpdate(nsresult aRv);
 
   void SetShippingType(const Nullable<PaymentShippingType>& aShippingType);
   Nullable<PaymentShippingType> GetShippingType() const;
 
   inline void ShippingWasRequested() { mRequestShipping = true; }
 
   void ResolvedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
   void RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue) override;
@@ -205,20 +204,16 @@ protected:
   // "true" when there is a pending updateWith() call to update the payment
   // request and "false" otherwise.
   bool mUpdating;
 
   // Whether shipping was requested. This models [[options]].requestShipping,
   // but we don't actually store the full [[options]] internal slot.
   bool mRequestShipping;
 
-  // True if the user passed a promise to show, causing us to defer telling the
-  // front end about it.
-  bool mDeferredShow;
-
   // The error is set in AbortUpdate(). The value is NS_OK by default.
   nsresult mUpdateError;
 
   enum
   {
     eUnknown,
     eCreated,
     eInteractive,
--- a/dom/payments/PaymentRequestManager.cpp
+++ b/dom/payments/PaymentRequestManager.cpp
@@ -532,43 +532,35 @@ PaymentRequestManager::CreatePayment(JSC
 }
 
 nsresult
 PaymentRequestManager::CanMakePayment(PaymentRequest* aRequest)
 {
   nsAutoString requestId;
   aRequest->GetInternalId(requestId);
   IPCPaymentCanMakeActionRequest action(requestId);
-
   return SendRequestPayment(aRequest, action);
 }
 
 nsresult
 PaymentRequestManager::ShowPayment(PaymentRequest* aRequest)
 {
-  nsresult rv = NS_OK;
-  if (!aRequest->IsUpdating()) {
-    nsAutoString requestId;
-    aRequest->GetInternalId(requestId);
-    IPCPaymentShowActionRequest action(requestId);
-    rv = SendRequestPayment(aRequest, action);
-  }
-  return rv;
+  nsAutoString requestId;
+  aRequest->GetInternalId(requestId);
+  IPCPaymentShowActionRequest action(requestId, aRequest->IsUpdating());
+  return SendRequestPayment(aRequest, action);
 }
 
 nsresult
-PaymentRequestManager::AbortPayment(PaymentRequest* aRequest, bool aDeferredShow)
+PaymentRequestManager::AbortPayment(PaymentRequest* aRequest)
 {
   nsAutoString requestId;
   aRequest->GetInternalId(requestId);
   IPCPaymentAbortActionRequest action(requestId);
-
-  // If aDeferredShow is true, then show was called with a promise that was
-  // rejected. In that case, we need to remember that we called show earlier.
-  return SendRequestPayment(aRequest, action, aDeferredShow);
+  return SendRequestPayment(aRequest, action);
 }
 
 nsresult
 PaymentRequestManager::CompletePayment(PaymentRequest* aRequest,
                                        const PaymentComplete& aComplete,
                                        bool aTimedOut)
 {
   nsString completeStatusString(NS_LITERAL_STRING("unknown"));
@@ -580,26 +572,24 @@ PaymentRequestManager::CompletePayment(P
       completeStatusString.AssignASCII(
         PaymentCompleteValues::strings[completeIndex].value);
     }
   }
 
   nsAutoString requestId;
   aRequest->GetInternalId(requestId);
   IPCPaymentCompleteActionRequest action(requestId, completeStatusString);
-
   return SendRequestPayment(aRequest, action, false);
 }
 
 nsresult
 PaymentRequestManager::UpdatePayment(JSContext* aCx,
                                      PaymentRequest* aRequest,
                                      const PaymentDetailsUpdate& aDetails,
-                                     bool aRequestShipping,
-                                     bool aDeferredShow)
+                                     bool aRequestShipping)
 {
   NS_ENSURE_ARG_POINTER(aCx);
   IPCPaymentDetails details;
   nsresult rv = ConvertDetailsUpdate(aCx, aDetails, details, aRequestShipping);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
@@ -608,20 +598,17 @@ PaymentRequestManager::UpdatePayment(JSC
   if (aRequestShipping) {
     GetSelectedShippingOption(aDetails, shippingOption);
     aRequest->SetShippingOption(shippingOption);
   }
 
   nsAutoString requestId;
   aRequest->GetInternalId(requestId);
   IPCPaymentUpdateActionRequest action(requestId, details, shippingOption);
-
-  // If aDeferredShow is true, then this call serves as the ShowUpdate call for
-  // this request.
-  return SendRequestPayment(aRequest, action, aDeferredShow);
+  return SendRequestPayment(aRequest, action, false);
 }
 
 nsresult
 PaymentRequestManager::ClosePayment(PaymentRequest* aRequest)
 {
   // for the case, the payment request is waiting for response from user.
   if (auto entry = mActivePayments.Lookup(aRequest)) {
     NotifyRequestDone(aRequest);
--- a/dom/payments/PaymentRequestManager.h
+++ b/dom/payments/PaymentRequestManager.h
@@ -43,25 +43,24 @@ public:
                 nsIPrincipal* aTopLevelPrincipal,
                 const Sequence<PaymentMethodData>& aMethodData,
                 const PaymentDetailsInit& aDetails,
                 const PaymentOptions& aOptions,
                 PaymentRequest** aRequest);
 
   nsresult CanMakePayment(PaymentRequest* aRequest);
   nsresult ShowPayment(PaymentRequest* aRequest);
-  nsresult AbortPayment(PaymentRequest* aRequest, bool aDeferredShow);
+  nsresult AbortPayment(PaymentRequest* aRequest);
   nsresult CompletePayment(PaymentRequest* aRequest,
                            const PaymentComplete& aComplete,
                            bool aTimedOut = false);
   nsresult UpdatePayment(JSContext* aCx,
                          PaymentRequest* aRequest,
                          const PaymentDetailsUpdate& aDetails,
-                         bool aRequestShipping,
-                         bool aDeferredShow);
+                         bool aRequestShipping);
   nsresult ClosePayment(PaymentRequest* aRequest);
   nsresult RetryPayment(JSContext* aCx,
                         PaymentRequest* aRequest,
                         const PaymentValidationErrors& aErrors);
 
   nsresult RespondPayment(PaymentRequest* aRequest,
                           const IPCPaymentActionResponse& aResponse);
   nsresult ChangeShippingAddress(PaymentRequest* aRequest,
--- a/dom/payments/PaymentRequestService.cpp
+++ b/dom/payments/PaymentRequestService.cpp
@@ -274,17 +274,18 @@ PaymentRequestService::RequestPayment(co
       }
       rv = RespondPayment(canMakeResponse.get());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       break;
     }
     case IPCPaymentActionRequest::TIPCPaymentShowActionRequest: {
-      rv = ShowPayment(aRequestId);
+      const IPCPaymentShowActionRequest& action = aAction;
+      rv = ShowPayment(aRequestId, action.isUpdating());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       break;
     }
     case IPCPaymentActionRequest::TIPCPaymentAbortActionRequest: {
       MOZ_ASSERT(request);
       request->SetState(payments::PaymentRequest::eInteractive);
@@ -311,31 +312,28 @@ PaymentRequestService::RequestPayment(co
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
       MOZ_ASSERT(request);
       rv = request->UpdatePaymentDetails(details, action.shippingOption());
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
-
-      // mShowingRequest exists and it equals to the updated PaymentRequest
-      // Call UI::UpdatePayment
-      if (mShowingRequest && mShowingRequest == request) {
-        rv = LaunchUIAction(aRequestId, type);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-          return rv;
-        }
-      } else {
-        // mShowingRequest does not equal to the updated PaymentRequest, try to
-        // show the updated one.
-        rv = ShowPayment(aRequestId);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-          return rv;
-        }
+      nsAutoString completeStatus;
+      rv = request->GetCompleteStatus(completeStatus);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
+      }
+      if (completeStatus.Equals(NS_LITERAL_STRING("initial"))) {
+        request->SetCompleteStatus(EmptyString());
+      }
+      MOZ_ASSERT(mShowingRequest && mShowingRequest == request);
+      rv = LaunchUIAction(aRequestId, type);
+      if (NS_WARN_IF(NS_FAILED(rv))) {
+        return rv;
       }
       break;
     }
     case IPCPaymentActionRequest::TIPCPaymentCloseActionRequest: {
       rv = LaunchUIAction(aRequestId, type);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
@@ -511,26 +509,29 @@ PaymentRequestService::CanMakePayment(co
   /*
    *  TODO: Check third party payment app support by traversing all
    *        registered third party payment apps.
    */
   return IsBasicCardPayment(aRequestId);
 }
 
 nsresult
-PaymentRequestService::ShowPayment(const nsAString& aRequestId)
+PaymentRequestService::ShowPayment(const nsAString& aRequestId, bool aIsUpdating)
 {
   nsresult rv;
   RefPtr<payments::PaymentRequest> request;
   rv = GetPaymentRequestById(aRequestId, getter_AddRefs(request));
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   MOZ_ASSERT(request);
   request->SetState(payments::PaymentRequest::eInteractive);
+  if (aIsUpdating) {
+    request->SetCompleteStatus(NS_LITERAL_STRING("initial"));
+  }
 
   if (mShowingRequest || !CanMakePayment(aRequestId)) {
     uint32_t responseStatus;
     if (mShowingRequest) {
       responseStatus = nsIPaymentActionResponse::PAYMENT_REJECTED;
     } else {
       responseStatus = nsIPaymentActionResponse::PAYMENT_NOTSUPPORTED;
     }
--- a/dom/payments/PaymentRequestService.h
+++ b/dom/payments/PaymentRequestService.h
@@ -45,17 +45,17 @@ private:
 
   nsresult
   LaunchUIAction(const nsAString& aRequestId, uint32_t aActionType);
 
   bool
   CanMakePayment(const nsAString& aRequestId);
 
   nsresult
-  ShowPayment(const nsAString& aRequestId);
+  ShowPayment(const nsAString& aRequestId, bool aIsUpdating);
 
   bool
   IsBasicCardPayment(const nsAString& aRequestId);
 
   FallibleTArray<RefPtr<payments::PaymentRequest>> mRequestQueue;
 
   nsCOMPtr<nsIPaymentUIService> mTestingUIService;
 
--- a/dom/payments/PaymentRequestUpdateEvent.cpp
+++ b/dom/payments/PaymentRequestUpdateEvent.cpp
@@ -59,47 +59,47 @@ PaymentRequestUpdateEvent::ResolvedCallb
 
   if (NS_WARN_IF(!aValue.isObject()) || !mWaitForUpdate) {
     return;
   }
 
   // Converting value to a PaymentDetailsUpdate dictionary
   PaymentDetailsUpdate details;
   if (!details.Init(aCx, aValue)) {
-    mRequest->AbortUpdate(NS_ERROR_TYPE_ERR, false);
+    mRequest->AbortUpdate(NS_ERROR_TYPE_ERR);
     JS_ClearPendingException(aCx);
     return;
   }
 
   // Validate and canonicalize the details
   // requestShipping must be true here. PaymentRequestUpdateEvent is only
   // dispatched when shippingAddress/shippingOption is changed, and it also means
   // Options.RequestShipping must be true while creating the corresponding
   // PaymentRequest.
   nsresult rv = mRequest->IsValidDetailsUpdate(details, true/*aRequestShipping*/);
   if (NS_FAILED(rv)) {
-    mRequest->AbortUpdate(rv, false);
+    mRequest->AbortUpdate(rv);
     return;
   }
 
   // Update the PaymentRequest with the new details
-  if (NS_FAILED(mRequest->UpdatePayment(aCx, details, false))) {
-    mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
+  if (NS_FAILED(mRequest->UpdatePayment(aCx, details))) {
+    mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
     return;
   }
   mWaitForUpdate = false;
   mRequest->SetUpdating(false);
 }
 
 void
 PaymentRequestUpdateEvent::RejectedCallback(JSContext* aCx, JS::Handle<JS::Value> aValue)
 {
   MOZ_ASSERT(mRequest);
 
-  mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false);
+  mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR);
   mWaitForUpdate = false;
   mRequest->SetUpdating(false);
 }
 
 void
 PaymentRequestUpdateEvent::UpdateWith(Promise& aPromise, ErrorResult& aRv)
 {
   if (!IsTrusted()) {
--- a/dom/payments/ipc/PPaymentRequest.ipdl
+++ b/dom/payments/ipc/PPaymentRequest.ipdl
@@ -82,16 +82,17 @@ struct IPCPaymentCreateActionRequest
 struct IPCPaymentCanMakeActionRequest
 {
   nsString requestId;
 };
 
 struct IPCPaymentShowActionRequest
 {
   nsString requestId;
+  bool isUpdating;
 };
 
 struct IPCPaymentAbortActionRequest
 {
   nsString requestId;
 };
 
 struct IPCPaymentCompleteActionRequest
--- a/dom/payments/test/ShowPaymentChromeScript.js
+++ b/dom/payments/test/ShowPaymentChromeScript.js
@@ -1,25 +1,22 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 "use strict";
 
 const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService);
-let expectedCompleteStatus = null;
-let expectedShowAction = "accept";
-let expectedUpdateAction = "accept";
 
 function emitTestFail(message) {
-  sendAsyncMessage("test-fail", message);
+  sendAsyncMessage("test-fail", `${DummyUIService.testName}: ${message}`);
 }
 function emitTestPass(message) {
-  sendAsyncMessage("test-pass", message);
+  sendAsyncMessage("test-pass", `${DummyUIService.testName}: ${message}`);
 }
 
 const shippingAddress = Cc["@mozilla.org/dom/payments/payment-address;1"].
                            createInstance(Ci.nsIPaymentAddress);
 const addressLine = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
 const address = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
 address.data = "Easton Ave";
 addressLine.appendElement(address);
@@ -63,94 +60,106 @@ function rejectShow(requestId) {
                     responseData,       // payment method data
                     "",                 // payer name
                     "",                 // payer email
                     "");                // payer phone
   paymentSrv.respondPayment(showResponse.QueryInterface(Ci.nsIPaymentActionResponse));
 }
 
 function updateShow(requestId) {
-  if (expectedUpdateAction == "updateaddress") {
+  if (DummyUIService.expectedUpdateAction == "updateaddress") {
     paymentSrv.changeShippingAddress(requestId, shippingAddress);
-  } else if (expectedUpdateAction == "accept" || expectedUpdateAction == "error"){
+  } else if (DummyUIService.expectedUpdateAction == "accept" ||
+             DummyUIService.expectedUpdateAction == "error"){
     paymentSrv.changeShippingOption(requestId, "FastShipping");
   } else {
-    emitTestFail("Unknown expected update action: " + expectedUpdateAction);
+    emitTestFail("Unknown expected update action: " + DummyUIService.expectedUpdateAction);
   }
 }
 
 function showRequest(requestId) {
-  if (expectedShowAction == "accept") {
+  const request = paymentSrv.getPaymentRequestById(requestId);
+  if (request.completeStatus == "initial") {
+    return;
+  }
+  if (DummyUIService.expectedShowAction == "accept") {
     acceptShow(requestId);
-  } else if (expectedShowAction == "reject") {
+  } else if (DummyUIService.expectedShowAction == "reject") {
     rejectShow(requestId);
-  } else if (expectedShowAction == "update") {
+  } else if (DummyUIService.expectedShowAction == "update") {
     updateShow(requestId);
   } else {
-    emitTestFail("Unknown expected show action: " + expectedShowAction);
+    emitTestFail("Unknown expected show action: " + DummyUIService.expectedShowAction);
   }
 }
 
 function abortRequest(requestId) {
   let abortResponse = Cc["@mozilla.org/dom/payments/payment-abort-action-response;1"].
                          createInstance(Ci.nsIPaymentAbortActionResponse);
   abortResponse.init(requestId, Ci.nsIPaymentActionResponse.ABORT_SUCCEEDED);
   paymentSrv.respondPayment(abortResponse);
 }
 
 function completeRequest(requestId) {
-  let payRequest = paymentSrv.getPaymentRequestById(requestId);
-  if (expectedCompleteStatus) {
-    if (payRequest.completeStatus == expectedCompleteStatus) {
+  let request = paymentSrv.getPaymentRequestById(requestId);
+  if (DummyUIService.expectedCompleteStatus) {
+    if (request.completeStatus == DummyUIService.expectedCompleteStatus) {
       emitTestPass("request.completeStatus matches expectation of " +
-                   expectedCompleteStatus);
+                   DummyUIService.expectedCompleteStatus);
     } else {
       emitTestFail("request.completeStatus incorrect. Expected " +
-                   expectedCompleteStatus + ", got " + payRequest.completeStatus);
+                   DummyUIService.expectedCompleteStatus + ", got " + request.completeStatus);
     }
   }
   let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"].
                             createInstance(Ci.nsIPaymentCompleteActionResponse);
   completeResponse.init(requestId, Ci.nsIPaymentActionResponse.COMPLETE_SUCCEEDED);
   paymentSrv.respondPayment(completeResponse.QueryInterface(Ci.nsIPaymentActionResponse));
 }
 
 function updateRequest(requestId) {
   let request = paymentSrv.getPaymentRequestById(requestId);
-  if (expectedUpdateAction == "accept") {
+  if (request.completeStatus !== "") {
+    emitTestFail("request.completeStatus should be empty, but got '" + request.completeStatus + "'.");
+  }
+  if (DummyUIService.expectedUpdateAction == "accept") {
     if (request.paymentDetails.error != "") {
       emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ").");
     }
     const shippingOptions = request.paymentDetails.shippingOptions;
     let shippingOption = shippingOptions.queryElementAt(0, Ci.nsIPaymentShippingOption);
     if (shippingOption.selected) {
       emitTestFail(shippingOption.label + " should not be selected.");
     }
     shippingOption = shippingOptions.queryElementAt(1, Ci.nsIPaymentShippingOption);
     if (!shippingOption.selected) {
       emitTestFail(shippingOption.label + " should be selected.");
     }
     acceptShow(requestId);
-  } else if (expectedUpdateAction == "error") {
+  } else if (DummyUIService.expectedUpdateAction == "error") {
     if (request.paymentDetails.error != "Update with Error") {
       emitTestFail("details.error should be 'Update with Error', but got " + request.paymentDetails.error + ".");
     }
     rejectShow(requestId);
-  } else if (expectedUpdateAction == "updateaddress") {
+  } else if (DummyUIService.expectedUpdateAction == "updateaddress") {
     if (request.paymentDetails.error != "") {
       emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ").");
     }
-    expectedUpdateAction = "accept";
+    DummyUIService.expectedUpdateAction = "accept";
     paymentSrv.changeShippingOption(requestId, "FastShipping");
   } else {
-    emitTestFail("Unknown expected update aciton: " + expectedUpdateAction);
+    emitTestFail("Unknown expected update aciton: " + DummyUIService.expectedUpdateAction);
   }
 }
 
 const DummyUIService = {
+  testName: "",
+  expectedCompleteStatus: null,
+  expectedShowAction: "accept",
+  expectedUpdateAction: "accept",
   showPayment: showRequest,
   abortPayment: abortRequest,
   completePayment: completeRequest,
   updatePayment: updateRequest,
   closePayment: function(requestId) {},
   QueryInterface: ChromeUtils.generateQI([Ci.nsIPaymentUIService]),
 };
 
@@ -209,56 +218,69 @@ function testShowResponseInit() {
     if (e.name != "NS_ERROR_ILLEGAL_VALUE") {
       emitTestFail("Expected 'NS_ERROR_ILLEGAL_VALUE', but got " + e.name + ".");
     }
     emitTestPass("Get expected result for initializing response with accepted and null data.")
   }
   sendAsyncMessage("test-show-response-init-complete");
 }
 
-addMessageListener("set-simple-ui-service", function() {
-  expectedCompleteStatus = null;
-  expectedShowAction = "accept";
-  expectedUpdateAction = "accept";
+addMessageListener("set-simple-ui-service", function(testName) {
+  DummyUIService.testName = testName;
+  DummyUIService.expectedCompleteStatus = null;
+  DummyUIService.expectedShowAction = "accept";
+  DummyUIService.expectedUpdateAction = "accept";
+  sendAsyncMessage("set-simple-ui-service-complete");
 });
 
-addMessageListener("set-normal-ui-service", function() {
-  expectedCompleteStatus = null;
-  expectedShowAction = "update";
-  expectedUpdateAction = "updateaddress";
+addMessageListener("set-normal-ui-service", function(testName) {
+  DummyUIService.testName = testName;
+  DummyUIService.expectedCompleteStatus = null;
+  DummyUIService.expectedShowAction = "update";
+  DummyUIService.expectedUpdateAction = "updateaddress";
+  sendAsyncMessage("set-normal-ui-service-complete");
 });
 
-addMessageListener("set-reject-ui-service", function() {
-  expectedCompleteStatus = null;
-  expectedShowAction = "reject";
-  expectedUpdateAction = "accept";
+addMessageListener("set-reject-ui-service", function(testName) {
+  DummyUIService.testName = testName;
+  DummyUIService.expectedCompleteStatus = null;
+  DummyUIService.expectedShowAction = "reject";
+  DummyUIService.expectedUpdateAction = "error";
+  sendAsyncMessage("set-reject-ui-service-complete");
 });
 
-addMessageListener("set-update-with-ui-service", function() {
-  expectedCompleteStatus = null;
-  expectedShowAction = "update";
-  expectedUpdateAction = "accept";
+addMessageListener("set-update-with-ui-service", function(testName) {
+  DummyUIService.testName = testName;
+  DummyUIService.expectedCompleteStatus = null;
+  DummyUIService.expectedShowAction = "update";
+  DummyUIService.expectedUpdateAction = "accept";
+  sendAsyncMessage("set-update-with-ui-service-complete");
 });
 
-addMessageListener("set-update-with-error-ui-service", function() {
-  expectedCompleteStatus = null;
-  expectedShowAction = "update";
-  expectedUpdateAction = "error";
+addMessageListener("set-update-with-error-ui-service", function(testName) {
+  DummyUIService.testName = testName;
+  DummyUIService.expectedCompleteStatus = null;
+  DummyUIService.expectedShowAction = "update";
+  DummyUIService.expectedUpdateAction = "error";
+  sendAsyncMessage("set-update-with-error-ui-service-complete");
 });
 
 addMessageListener("test-show-response-init", testShowResponseInit);
 
 addMessageListener("set-complete-status-success", function() {
-  expectedCompleteStatus = "success";
+  DummyUIService.expectedCompleteStatus = "success";
+  sendAsyncMessage("set-complete-status-success-complete");
 });
 
 addMessageListener("set-complete-status-fail", function() {
-  expectedCompleteStatus = "fail";
+  DummyUIService.expectedCompleteStatus = "fail";
+  sendAsyncMessage("set-complete-status-fail-complete");
 });
 
 addMessageListener("set-complete-status-unknown", function() {
-  expectedCompleteStatus = "unknown";
+  DummyUIService.expectedCompleteStatus = "unknown";
+  sendAsyncMessage("set-complete-status-unknown-complete");
 });
 
 addMessageListener("teardown", function() {
   paymentSrv.setTestingUIService(null);
   sendAsyncMessage('teardown-complete');
 });
--- a/dom/payments/test/test_showPayment.html
+++ b/dom/payments/test/test_showPayment.html
@@ -20,16 +20,26 @@ https://bugzilla.mozilla.org/show_bug.cg
     ok(false, message);
   }
   function testPassHandler(message) {
     ok(true, message);
   }
   gScript.addMessageListener("test-fail", testFailHandler);
   gScript.addMessageListener("test-pass", testPassHandler);
 
+  async function requestChromeAction(action, params) {
+    await new Promise(resolve => {
+      gScript.addMessageListener(`${action}-complete`, function completeListener() {
+        gScript.removeMessageListener(`${action}-complete`, completeListener);
+        resolve();
+      });
+      gScript.sendAsyncMessage(action, params);
+    });
+  }
+
   // testing data declaration
   // default parameters for PaymentRequest construction
   const defaultMethods = [{
     supportedMethods: "basic-card",
     data: {
       supportedNetworks: ['unionpay', 'visa', 'mastercard', 'amex', 'discover',
                           'diners', 'jcb', 'mir',
       ],
@@ -122,348 +132,381 @@ https://bugzilla.mozilla.org/show_bug.cg
 
   // testing data for PaymentRequest.show() with Non-supported methods
   const nonSupportedMethods = [{
     supportedMethods: "nonsupported-method",
   }];
 
 
   // checking functions
-  function checkAddress(address, fromEvent) {
-    is(address.country, "USA", "address.country should be 'USA'.");
-    is(address.region, "CA", "address.region should be 'CA'.");
-    is(address.city, "San Bruno", "address.city should be 'San Bruno'.");
-    is(address.dependentLocality, "Test locality",
-       "address.dependentLocality should be 'Test locality'.");
-    is(address.postalCode, "94066", "address.postalCode should be '94066'.");
-    is(address.sortingCode, "123456", "address.sortingCode should be '123456'.");
+  function checkAddress(testName, address, fromEvent) {
+    is(address.country,
+       "USA",
+       `${testName}: address.country should be 'USA'.`);
+    is(address.region,
+       "CA",
+       `${testName}: address.region should be 'CA'.`);
+    is(address.city,
+       "San Bruno",
+       `${testName}: address.city should be 'San Bruno'.`);
+    is(address.dependentLocality,
+       "Test locality",
+       `${testName}: address.dependentLocality should be 'Test locality'.`);
+    is(address.postalCode,
+       "94066",
+       `${testName}: address.postalCode should be '94066'.`);
+    is(address.sortingCode,
+       "123456",
+       `${testName}: address.sortingCode should be '123456'.`);
     if (fromEvent) {
-      is(address.addressLine.length, 0, "address.addressLine.length should be 0 from event.");
-      is(address.organization, "", "address.organization should be empty from event.");
-      is(address.recipient, "", "address.recipient should be empty from event.");
-      is(address.phone, "", "address.phone should be empty from event.");
+      is(address.addressLine.length,
+         0,
+         `${testName}: address.addressLine.length should be 0 from event.`);
+      is(address.organization,
+         "",
+         `${testName}: address.organization should be empty from event.`);
+      is(address.recipient,
+         "",
+         `${testName}: address.recipient should be empty from event.`);
+      is(address.phone,
+         "",
+         `${testName}: address.phone should be empty from event.`);
     } else {
-      is(address.addressLine.length, 1, "address.addressLine.length should be 1 from promise.");
-      is(address.addressLine[0], "Easton Ave", "address.addressLine[0] should be 'Easton Ave' from promise.");
-      is(address.organization, "Testing Org", "address.organization should be 'Testing Org' from promise.");
-      is(address.recipient, "Bill A. Pacheco", "address.recipient should be 'Bill A. Pacheco' from promise.");
-      is(address.phone, "+1-434-441-3879", "address.phone should be '+1-434-441-3879' from promise.");
+      is(address.addressLine.length,
+         1,
+         `${testName}: address.addressLine.length should be 1 from promise.`);
+      is(address.addressLine[0],
+         "Easton Ave",
+         `${testName}: address.addressLine[0] should be 'Easton Ave' from promise.`);
+      is(address.organization,
+         "Testing Org",
+         `${testName}: address.organization should be 'Testing Org' from promise.`);
+      is(address.recipient,
+         "Bill A. Pacheco",
+         `${testName}: address.recipient should be 'Bill A. Pacheco' from promise.`);
+      is(address.phone,
+         "+1-434-441-3879",
+         `${testName}: address.phone should be '+1-434-441-3879' from promise.`);
     }
   }
 
-  function checkResponse(response) {
-    is(response.requestId, "test payment", "response.requestId should be 'test payment'.");
-    is(response.methodName, "testing-payment-method", "response.methodName should be 'testing-payment-method'.");
-    is(response.details.paymentToken, "6880281f-0df3-4b8e-916f-66575e2457c1", "response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'.");
-    checkAddress(response.shippingAddress, false/*fromEvent*/);
-    is(response.shippingOption, "FastShipping", "response.shippingOption should be 'FastShipping'.");
-    is(response.payerName, "Bill A. Pacheco", "response.payerName should be 'Bill A. Pacheco'.");
-    ok(!response.payerEmail, "response.payerEmail should be empty");
-    ok(!response.payerPhone, "response.payerPhone should be empty");
+  function checkResponse(testName, response) {
+    is(response.requestId,
+       "test payment",
+       `${testName}: response.requestId should be 'test payment'.`);
+    is(response.methodName,
+       "testing-payment-method",
+       `${testName}: response.methodName should be 'testing-payment-method'.`);
+    is(response.details.paymentToken,
+       "6880281f-0df3-4b8e-916f-66575e2457c1",
+       `${testName}: response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'.`);
+    checkAddress(testName, response.shippingAddress, false/*fromEvent*/);
+    is(response.shippingOption,
+       "FastShipping",
+       `${testName}: response.shippingOption should be 'FastShipping'.`);
+    is(response.payerName,
+       "Bill A. Pacheco",
+       `${testName}: response.payerName should be 'Bill A. Pacheco'.`);
+    ok(!response.payerEmail,
+       `${testName}: response.payerEmail should be empty`);
+    ok(!response.payerPhone,
+       `${testName}: response.payerPhone should be empty`);
   }
 
   // testing functions
-  function testShowNormalFlow() {
-    gScript.sendAsyncMessage("set-normal-ui-service");
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
-      payRequest.addEventListener("shippingaddresschange", event => {
-        checkAddress(payRequest.shippingAddress, true/*fromEvent*/);
+  async function testShowNormalFlow() {
+    const testName = "testShowNormalFlow";
+    await requestChromeAction("set-normal-ui-service", testName);
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
+      request.addEventListener("shippingaddresschange", event => {
+        checkAddress(testName, request.shippingAddress, true/*fromEvent*/);
         event.updateWith(updateWithPromise(defaultDetails));
       });
-      payRequest.addEventListener("shippingoptionchange", event => {
+      request.addEventListener("shippingoptionchange", event => {
         event.updateWith(updateWithPromise(updatedShippingOptionsDetails));
       });
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.show().then(response => {
-        checkResponse(response, false);
-	checkAddress(payRequest.shippingAddress, false);
-        response.complete().then(() =>{
-          resolve();
-        }).catch(e => {
-          ok(false, "Unexpected error: " + e.name);
-          resolve();
-        });
-      }).catch( e => {
-        ok(false, "Unexpected error: " + e.name);
-        resolve();
-      }).finally(handler.destruct);
+      try {
+        let response = await request.show();
+        checkResponse(testName, response, false);
+        await response.complete();
+      } catch (error) {
+        ok(false, `${testName} Unexpected error: ${e.name}`);
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
   // testing show with nonsupported methods
-  function testCannotMakePaymentShow() {
-    gScript.sendAsyncMessage("set-simple-ui-service");
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(nonSupportedMethods, defaultDetails);
+  async function testCannotMakePaymentShow() {
+    const testName = "testCannotMakePaymentShow";
+    await requestChromeAction("set-simple-ui-service", testName);
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(nonSupportedMethods, defaultDetails);
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.canMakePayment().then(result => {
-        ok(!result, "canMakePayment() should return false, but got " + result + ".");
-        payRequest.show().then( () => {
-          ok(false, "Should be rejected with 'NotSupportedError', but got resolved");
-          resolve();
-        }).catch( e => {
-          is(e.name, "NotSupportedError", "Should be rejected with 'NotSupportedError', but got " + e.name + ".");
-          resolve();
-        });
-      }).finally(handler.destruct);
+      let result = await request.canMakePayment();
+      ok(!result, `${testName}: canMakePayment() should return false.`);
+      try {
+        await request.show();
+        ok(false, `${testName}: should be rejected with 'NotSupportedError' but got resolved.`);
+      } catch (error) {
+        is(error.name, "NotSupportedError", `${testName}: should be rejected with 'NotSupportedError'.`);
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
   // testing show rejected by user
-  function testRejectShow() {
-    gScript.sendAsyncMessage("set-reject-ui-service");
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
+  async function testRejectShow() {
+    const testName = "testRejectShow";
+    await requestChromeAction("set-reject-ui-service", testName);
+    return new Promise(async(resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.show().then((result) => {
-        ok(false, "Should be rejected with 'AbortError', but got resolved");
-        resolve();
-      }, (result) => {
-        is(result.name, "AbortError", "Should be rejected with 'AbortError', but got " + result.name + ".");
-        resolve();
-      }).catch(e => {
-        ok(false, "Unexpected error: " + e.name);
-        resolve();
-      }).finally(handler.destruct);
+      try {
+        await request.show();
+        ok(false, `${testName}: Should be rejected with 'AbortError' but got resolved.`);
+      } catch(error) {
+        is(error.name, "AbortError", `${testName}: Should be rejected with 'AbortError'.`);
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
   // testing PaymentResponse.complete() with specified result
-  function testCompleteStatus(result) {
-    gScript.sendAsyncMessage("set-simple-ui-service");
+  async function testCompleteStatus(testName, result) {
+    await requestChromeAction("set-simple-ui-service", testName);
     if (result) {
-      gScript.sendAsyncMessage("set-complete-status-"+result);
+      await requestChromeAction(`set-complete-status-${result}`);
     } else {
-      gScript.sendAsyncMessage("set-complete-status-unknown");
+      await requestChromeAction(`set-complete-status-unknown`);
     }
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.show().then(response => {
-        response.complete(result).then(() => {
-          resolve();
-        }).catch(e => {
-          ok(false, "Unexpected error: " + e.name);
-          resolve();
-        });
-      }).catch( e => {
-        ok(false, "Unexpected error: " + e.name);
-        resolve();
-      }).finally(handler.destruct);
+      try {
+        let response = await request.show();
+        await response.complete(result);
+      } catch (error) {
+        ok(false, `${testName}: Unexpected error ${error.name}.`);
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
-  function testCompleteFail() {
-    return testCompleteStatus("fail");
+  async function testCompleteFail() {
+    const testName = "testCompleteFail";
+    return testCompleteStatus(testName, "fail");
   }
 
-  function testCompleteSuccess() {
-    return testCompleteStatus("success");
+  async function testCompleteSuccess() {
+    const testName = "testCompleteSuccess";
+    return testCompleteStatus(testName, "success");
   }
 
-  function testCompleteUnknown() {
-    return testCompleteStatus("unknown");
+  async function testCompleteUnknown() {
+    const testName = "testCompleteUnknown"
+    return testCompleteStatus(testName, "unknown");
   }
 
-  function testCompleteEmpty() {
-    return testCompleteStatus();
+  async function testCompleteEmpty() {
+    const testName = "testCompleteEmpty";
+    return testCompleteStatus(testName);
   }
 
   // testing PaymentRequestUpdateEvent.updateWith with specified details and error
-  function testUpdateWith(detailsUpdate, expectedError) {
+  async function testUpdateWith(testName, detailsUpdate, expectedError) {
     if (expectedError) {
-      gScript.sendAsyncMessage("set-update-with-error-ui-service");
+      await requestChromeAction("set-update-with-error-ui-service", testName);
     } else {
-      gScript.sendAsyncMessage("set-update-with-ui-service");
+      await requestChromeAction("set-update-with-ui-service", testName);
     }
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
-      payRequest.addEventListener("shippingaddresschange", event => {
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
+      request.addEventListener("shippingaddresschange", event => {
         event.updateWith(updateWithPromise(detailsUpdate));
       });
-      payRequest.addEventListener("shippingoptionchange", event => {
+      request.addEventListener("shippingoptionchange", event => {
         event.updateWith(updateWithPromise(detailsUpdate));
       });
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.show().then(response => {
-        if (expectedError) {
-          ok(false, "Should be rejected with " + expectedError + ", but got resolved");
-	  resolve();
-	} else {
-	  response.complete("success").then(() => {
-	    resolve();
-	  })
-	}
-      }, response => {
+      try {
+        const response = await request.show();
         if (expectedError) {
-          is(response.name, expectedError,
-	     "Should be rejected with " + expectedError + ", but got " + response.name);
-	} else {
-	  ok(false, "Unexpected error: " + response.name);
-	}
-	resolve();
-      }).catch(e => {
-        ok(false, "Unexpected error: " + e.name);
-	resolve();
-      }).finally(handler.destruct);
+          ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`);
+        } else {
+          await response.complete("success");
+        }
+      } catch(error) {
+        if (expectedError) {
+          is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`);
+        } else {
+          ok(false, `${testName}: Unexpected error ${error.name}.`);
+        }
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
-  function testUpdateWithReject() {
-    return testUpdateWith(null, "AbortError");
+  async function testUpdateWithReject() {
+    const testName = "testUpdateWithReject";
+    return testUpdateWith(testName, null, "AbortError");
   }
 
-  function testUpdateWithValidDetails() {
-    return testUpdateWith(updatedShippingOptionsDetails, null);
+  async function testUpdateWithValidDetails() {
+    const testName = "testUpdateWithValidDetails";
+    return testUpdateWith(testName, updatedShippingOptionsDetails, null);
   }
 
-  function testUpdateWithInvalidDetails() {
-    return testUpdateWith({total: "invalid details"}, "TypeError");
+  async function testUpdateWithInvalidDetails() {
+    const testName = "testUpdateWithInvalidDetails";
+    return testUpdateWith(testName, {total: "invalid details"}, "TypeError");
   }
 
-  function testUpdateWithError() {
-    return testUpdateWith(updatedErrorDetails, "AbortError");
+  async function testUpdateWithError() {
+    const testName = "testUpdateWithError";
+    return testUpdateWith(testName, updatedErrorDetails, "AbortError");
   }
 
   // testing show with detailsUpdate promise
-  function testShowWithDetailsPromise(detailsUpdate, expectedError) {
+  async function testShowWithDetailsPromise(testName, detailsUpdate, expectedError) {
     if (expectedError) {
-      gScript.sendAsyncMessage("set-reject-ui-service");
+      await requestChromeAction("set-reject-ui-service", testName);
     } else {
-      gScript.sendAsyncMessage("set-simple-ui-service");
+      await requestChromeAction("set-simple-ui-service", testName);
     }
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
-      ok(!payRequest.shippingOption, "payRequest.shippingOption should be null.");
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
+      ok(!request.shippingOption, `${testName}: request.shippingOption should be null.`);
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
-      payRequest.show(updateWithPromise(detailsUpdate)).then(response => {
+      try {
+        let response = await request.show(updateWithPromise(detailsUpdate));
         if (expectedError) {
-          ok(false, "Should be rejected with " + expectedError + ", but got resolved");
-	  resolve();
-	} else {
-          ok(response.shippingOption, "response.shippingOption should not be null.");
-	  response.complete().then(() => {
-	    resolve();
-	  })
-	}
-      }, response => {
+          ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`);
+        } else {
+          ok(response.shippingOption,
+             `${testName}: response.shippingOption should not be null.`);
+        }
+        await response.complete();
+      } catch(error) {
         if (expectedError) {
-          is(response.name, expectedError,
-	     "Should be rejected with " + expectedError + ", but got " + response.name);
-	} else {
-	  ok(false, "Unexpected error: " + response.name);
-	}
-	resolve();
-      }).catch(e => {
-        ok(false, "Unexpected error: " + e.name);
-	resolve();
-      }).finally(handler.destruct);
+          is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`);
+        } else {
+          ok(false, `${testName}: Unexpected error ${error.name}.`);
+        }
+      }
+      await handler.destruct();
+      resolve();
     });
   }
-  function testShowWithValidPromise() {
-    return testShowWithDetailsPromise(updatedShippingOptionsDetails, null);
+  async function testShowWithValidPromise() {
+    const testName = "testShowWithValidPromise";
+    return testShowWithDetailsPromise(testName, updatedShippingOptionsDetails, null);
   }
 
-  function testShowWithRejectedPromise() {
-    return testShowWithDetailsPromise(null, "AbortError");
+  async function testShowWithRejectedPromise() {
+    const testName = "testShowWithRejectedPromise";
+    return testShowWithDetailsPromise(testName, null, "AbortError");
   }
 
-  function testShowWithInvalidPromise() {
-    return testShowWithDetailsPromise({total: "invalid details"}, "TypeError");
+  async function testShowWithInvalidPromise() {
+    const testName = "testShowWithInvalidPromise";
+    return testShowWithDetailsPromise(testName, {total: "invalid details"}, "TypeError");
   }
 
-  function testShowWithErrorPromise() {
-    return testShowWithDetailsPromise(updatedErrorDetails, "AbortError");
+  async function testShowWithErrorPromise() {
+    const testName = "testShowWithErrorPromise";
+    return testShowWithDetailsPromise(testName, updatedErrorDetails, "AbortError");
   }
 
-  function testShowWithPromiseResolvedByRejectedPromise() {
-    gScript.sendAsyncMessage("set-reject-ui-service");
-    return new Promise((resolve, reject)=> {
+  async function testShowWithPromiseResolvedByRejectedPromise() {
+    const testName = "testShowWithPromiseResolvedByRejectedPromise";
+    await requestChromeAction("set-reject-ui-service", testName);
+    return new Promise(async (resolve)=> {
       const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions);
       const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true);
       let rejectPromise = Promise.reject(new TypeError());
       let detailsUpdatePromise = Promise.resolve(rejectPromise);
-      request.show(detailsUpdatePromise).then(response => {
-        ok(false, "should be rejected with 'AbortError', but got resolved.");
-	resolve();
-      }, response => {
-        is(response.name, "AbortError", "Exepcted 'AbortError', but got " + response.name + ".");
-	resolve();
-      }).catch(error => {
-        ok(false, "Unexpected error: " + error.name + ".");
-      }).finally(handler.destruct);
+      try {
+        await request.show(detailsUpdatePromise);
+        ok(false, `${testName}: should be rejected with AbortError but got resolved.`);
+      } catch(error) {
+        is(error.name, "AbortError", `${testName}: should be rejected with AbortError.`);
+      }
+      await handler.destruct();
+      resolve();
     });
   }
 
   // testing show response initialization in chrome process
-  function testShowResponseInit() {
-    return new Promise((resolve, reject) => {
-      gScript.addMessageListener("test-show-response-init-complete",
-                                 function showResponseInitCompleteHandler() {
-        gScript.removeMessageListener("test-show-response-init-complete",
-                                      showResponseInitCompleteHandler);
-        resolve();
-      });
-      gScript.sendAsyncMessage("test-show-response-init");
-    });
+  async function testShowResponseInit() {
+    const testName = "testShowResponseInit";
+    await requestChromeAction("test-show-response-init", testName);
   }
 
   // testing show that is not triggered by user.
-  function testShowNotTriggeredByUser() {
-    gScript.sendAsyncMessage("set-simple-ui-service");
-    return new Promise((resolve, reject) => {
-      const payRequest = new PaymentRequest(defaultMethods, defaultDetails);
-      payRequest.show().then(() => {
-        ok(false, "Expected 'SecurityError', but got resolved")
-        resolve();
-      }).catch((err) => {
-        is(err.name, "SecurityError", `Should be rejected with 'SecurityError', but got ${err.name}`);
-        resolve();
-      });
+  async function testShowNotTriggeredByUser() {
+    const testName = "testShowNotTriggeredByUser";
+    await requestChromeAction("set-simple-ui-service", testName);
+    return new Promise(async (resolve) => {
+      const request = new PaymentRequest(defaultMethods, defaultDetails);
+      try {
+        await request.show();
+        ok(false, `${testName}: should be rejected with SecurityError, but got resolved.`);
+      } catch (error) {
+        is(error.name, "SecurityError", `${testName}: should be rejected with SecurityError.`);
+      }
+      resolve();
     });
   }
 
   // teardown function
-  function teardown() {
+  async function teardown() {
     gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() {
       gScript.removeMessageListener("teardown-complete", teardownCompleteHandler);
       gScript.removeMessageListener("test-fail", testFailHandler);
       gScript.removeMessageListener("test-pass", testPassHandler);
       gScript.destroy();
       SimpleTest.finish();
     });
     gScript.sendAsyncMessage("teardown");
   }
 
   // test main body
-  function runTests() {
-    testCannotMakePaymentShow()
-    .then(testRejectShow)
-    .then(testShowNormalFlow)
-    .then(testCompleteSuccess)
-    .then(testCompleteFail)
-    .then(testCompleteUnknown)
-    .then(testCompleteEmpty)
-    .then(testUpdateWithReject)
-    .then(testUpdateWithValidDetails)
-    .then(testUpdateWithInvalidDetails)
-    .then(testUpdateWithError)
-    .then(testShowWithValidPromise)
-    .then(testShowWithInvalidPromise)
-    .then(testShowWithRejectedPromise)
-    .then(testShowWithErrorPromise)
-    .then(testShowWithPromiseResolvedByRejectedPromise)
-    .then(testShowResponseInit)
-    .then(testShowNotTriggeredByUser)
-    .then(teardown)
-    .catch( e => {
-      ok(false, "Unexpected error: " + e.name);
+  async function runTests() {
+    try {
+      await testCannotMakePaymentShow();
+      await testRejectShow();
+      await testShowNormalFlow();
+      await testCompleteSuccess();
+      await testCompleteFail();
+      await testCompleteUnknown();
+      await testCompleteEmpty();
+      await testUpdateWithReject();
+      await testUpdateWithValidDetails();
+      await testUpdateWithInvalidDetails();
+      await testUpdateWithError();
+      await testShowWithValidPromise();
+      await testShowWithInvalidPromise();
+      await testShowWithRejectedPromise();
+      await testShowWithErrorPromise();
+      await testShowWithPromiseResolvedByRejectedPromise();
+      await testShowResponseInit();
+      await testShowNotTriggeredByUser();
+      await teardown();
+    } catch (error) {
+      ok(false, `test_showPayment: Unexpected error: ${error.name}`);
       SimpleTest.finish();
-    });
+    }
   }
 
   window.addEventListener('load', function() {
     SpecialPowers.pushPrefEnv({
       'set': [
         ['dom.payments.request.enabled', true],
       ]
     }, runTests);
--- 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
@@ -5302,18 +5302,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);