Bug 1274891 - Part 4: Use enum class for nsRestyleHint. draft
authorBoris Chiou <boris.chiou@gmail.com>
Thu, 22 Dec 2016 18:53:35 +0800
changeset 454001 1de9f2ed6e42f9bc58ced0bff88861bacfac8a4a
parent 453486 1173ee6305b09e7e2e1890a5b1f73cedae5acba9
child 454002 3cf89afdc97018dccd040daced0ff05526227f49
push id39792
push userbmo:boris.chiou@gmail.com
push dateTue, 27 Dec 2016 05:51:42 +0000
bugs1274891
milestone53.0a1
Bug 1274891 - Part 4: Use enum class for nsRestyleHint. MozReview-Commit-ID: DtzICOLIFDD
devtools/client/performance/modules/marker-formatters.js
devtools/client/performance/test/browser_perf-marker-details.js
docshell/base/timeline/RestyleTimelineMarker.h
dom/animation/EffectCompositor.cpp
dom/animation/test/chrome/test_restyles.html
dom/base/Element.cpp
dom/base/Location.cpp
dom/base/nsDOMWindowUtils.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsHistory.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
dom/mathml/nsMathMLElement.cpp
dom/smil/nsSMILAnimationController.cpp
dom/smil/nsSMILMappedAttribute.cpp
dom/svg/nsSVGElement.cpp
gfx/layers/apz/util/ActiveElementManager.cpp
layout/base/PresShell.cpp
layout/base/RestyleManager.cpp
layout/base/RestyleManagerBase.cpp
layout/base/RestyleTracker.cpp
layout/base/RestyleTracker.h
layout/base/ServoRestyleManager.cpp
layout/base/nsChangeHint.h
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/mathml/nsMathMLmtableFrame.cpp
layout/style/nsAnimationManager.cpp
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsHTMLCSSStyleSheet.cpp
layout/style/nsHTMLStyleSheet.cpp
layout/style/nsStyleSet.cpp
layout/style/nsTransitionManager.cpp
layout/style/test/test_restyles_in_smil_animation.html
--- a/devtools/client/performance/modules/marker-formatters.js
+++ b/devtools/client/performance/modules/marker-formatters.js
@@ -44,17 +44,17 @@ exports.Formatters = {
   UnknownLabel: function (marker = {}) {
     return marker.name || L10N.getStr("marker.label.unknown");
   },
 
   /* Group 0 - Reflow and Rendering pipeline */
 
   StylesFields: function (marker) {
     if ("restyleHint" in marker) {
-      let label = marker.restyleHint.replace(/eRestyle_/g, "");
+      let label = marker.restyleHint.replace(/nsRestyleHint::/g, "");
       return {
         [L10N.getStr("marker.field.restyleHint")]: label
       };
     }
     return null;
   },
 
   /* Group 1 - JS */
--- a/devtools/client/performance/test/browser_perf-marker-details.js
+++ b/devtools/client/performance/test/browser_perf-marker-details.js
@@ -83,17 +83,17 @@ function* spawnTest() {
       info("Got `TimeStamp` marker with data: " + JSON.stringify(marker));
       shouldHaveLabel($, "Label:", "go", marker);
       shouldHaveStack($, "stack", marker);
       return true;
     },
     Styles: function (marker) {
       info("Got `Styles` marker with data: " + JSON.stringify(marker));
       if (marker.restyleHint) {
-        shouldHaveLabel($, "Restyle Hint:", marker.restyleHint.replace(/eRestyle_/g, ""), marker);
+        shouldHaveLabel($, "Restyle Hint:", marker.restyleHint.replace(/nsRestyleHint::/g, ""), marker);
       }
       if (marker.stack) {
         shouldHaveStack($, "stack", marker);
         return true;
       }
     },
     Reflow: function (marker) {
       info("Got `Reflow` marker with data: " + JSON.stringify(marker));
--- a/docshell/base/timeline/RestyleTimelineMarker.h
+++ b/docshell/base/timeline/RestyleTimelineMarker.h
@@ -14,17 +14,17 @@ namespace mozilla {
 
 class RestyleTimelineMarker : public TimelineMarker
 {
 public:
   RestyleTimelineMarker(nsRestyleHint aRestyleHint,
                         MarkerTracingType aTracingType)
     : TimelineMarker("Styles", aTracingType)
   {
-    if (aRestyleHint) {
+    if (bool(aRestyleHint)) {
       mRestyleHint.AssignWithConversion(RestyleManager::RestyleHintToString(aRestyleHint));
     }
   }
 
   virtual void AddDetails(JSContext* aCx, dom::ProfileTimelineMarker& aMarker) override
   {
     TimelineMarker::AddDetails(aCx, aMarker);
 
--- a/dom/animation/EffectCompositor.cpp
+++ b/dom/animation/EffectCompositor.cpp
@@ -298,18 +298,18 @@ EffectCompositor::PostRestyleForAnimatio
   }
 
   dom::Element* element = GetElementToRestyle(aElement, aPseudoType);
   if (!element) {
     return;
   }
 
   nsRestyleHint hint = aCascadeLevel == CascadeLevel::Transitions ?
-                                        eRestyle_CSSTransitions :
-                                        eRestyle_CSSAnimations;
+                                        nsRestyleHint::CSSTransitions :
+                                        nsRestyleHint::CSSAnimations;
   mPresContext->PresShell()->RestyleForAnimation(element, hint);
 }
 
 void
 EffectCompositor::PostRestyleForThrottledAnimations()
 {
   for (size_t i = 0; i < kCascadeLevelCount; i++) {
     CascadeLevel cascadeLevel = CascadeLevel(i);
@@ -513,18 +513,18 @@ EffectCompositor::AddStyleUpdatesTo(Rest
                            pseudoElem.mPseudoType,
                            cascadeLevel,
                            mPresContext->RefreshDriver()->MostRecentRefresh());
 
       dom::Element* elementToRestyle =
         GetElementToRestyle(pseudoElem.mElement, pseudoElem.mPseudoType);
       if (elementToRestyle) {
         nsRestyleHint rshint = cascadeLevel == CascadeLevel::Transitions ?
-                               eRestyle_CSSTransitions :
-                               eRestyle_CSSAnimations;
+                               nsRestyleHint::CSSTransitions :
+                               nsRestyleHint::CSSAnimations;
         aTracker.AddPendingRestyle(elementToRestyle, rshint,
                                    nsChangeHint::None);
       }
     }
 
     elementSet.Clear();
     // Note: mElement pointers in elementsToRestyle might now dangle
   }
@@ -907,17 +907,17 @@ EffectCompositor::GetBaseStyle(nsCSSProp
   result = effectSet->GetBaseStyle(aProperty);
   if (!result.IsNull()) {
     return result;
   }
 
   RefPtr<nsStyleContext> styleContextWithoutAnimation =
     aStyleContext->PresContext()->StyleSet()->AsGecko()->
       ResolveStyleWithoutAnimation(&aElement, aStyleContext,
-                                   eRestyle_AllHintsWithAnimations);
+                                   nsRestyleHint::AllHintsWithAnimations);
 
   DebugOnly<bool> success =
     StyleAnimationValue::ExtractComputedValue(aProperty,
                                               styleContextWithoutAnimation,
                                               result);
   MOZ_ASSERT(success, "Should be able to extract computed animation value");
   MOZ_ASSERT(!result.IsNull(), "Should have a valid StyleAnimationValue");
 
--- a/dom/animation/test/chrome/test_restyles.html
+++ b/dom/animation/test/chrome/test_restyles.html
@@ -42,18 +42,18 @@ function observeStyling(frameCount, onFr
   docShell.popProfileTimelineMarkers();
 
   return new Promise(function(resolve) {
     return waitForAnimationFrames(frameCount, onFrame).then(function() {
       var markers = docShell.popProfileTimelineMarkers();
       docShell.recordProfileTimelineMarkers = false;
       var stylingMarkers = markers.filter(function(marker, index) {
         return marker.name == 'Styles' &&
-               (marker.restyleHint == 'eRestyle_CSSAnimations' ||
-                marker.restyleHint == 'eRestyle_CSSTransitions');
+               (marker.restyleHint == 'nsRestyleHint::CSSAnimations' ||
+                marker.restyleHint == 'nsRestyleHint::CSSTransitions');
       });
       resolve(stylingMarkers);
     });
   });
 }
 
 function ensureElementRemoval(aElement) {
   return new Promise(function(resolve) {
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1974,22 +1974,23 @@ Element::SetSMILOverrideStyleDeclaration
   if (aNotify) {
     nsIDocument* doc = GetComposedDoc();
     // Only need to request a restyle if we're in a document.  (We might not
     // be in a document, if we're clearing animation effects on a target node
     // that's been detached since the previous animation sample.)
     if (doc) {
       nsCOMPtr<nsIPresShell> shell = doc->GetShell();
       if (shell) {
-        // Pass both eRestyle_StyleAttribute and
-        // eRestyle_StyleAttribute_Animations since we don't know if
+        // Pass both nsRestyleHint::StyleAttribute and
+        // nsRestyleHint::StyleAttribute_Animations since we don't know if
         // this style represents only the ticking of an existing
         // animation or whether it's a new or changed animation.
-        shell->RestyleForAnimation(this, eRestyle_StyleAttribute |
-                                         eRestyle_StyleAttribute_Animations);
+        shell->RestyleForAnimation(this,
+                                   nsRestyleHint::StyleAttribute |
+                                     nsRestyleHint::StyleAttribute_Animations);
       }
     }
   }
 
   return NS_OK;
 }
 
 bool
--- a/dom/base/Location.cpp
+++ b/dom/base/Location.cpp
@@ -794,17 +794,18 @@ Location::Reload(bool aForceget)
     // page since some sites may use this trick to work around gecko
     // reflow bugs, and this should have the same effect.
 
     nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
 
     nsIPresShell *shell;
     nsPresContext *pcx;
     if (doc && (shell = doc->GetShell()) && (pcx = shell->GetPresContext())) {
-      pcx->RebuildAllStyleData(nsChangeHint::ReflowHints, eRestyle_Subtree);
+      pcx->RebuildAllStyleData(nsChangeHint::ReflowHints,
+                               nsRestyleHint::Subtree);
     }
 
     return NS_OK;
   }
 
   if (webNav) {
     uint32_t reloadFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
 
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -3806,17 +3806,18 @@ nsDOMWindowUtils::GetCompositorAPZTestDa
 NS_IMETHODIMP
 nsDOMWindowUtils::PostRestyleSelfEvent(nsIDOMElement* aElement)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
   if (!element) {
     return NS_ERROR_INVALID_ARG;
   }
 
-  nsLayoutUtils::PostRestyleEvent(element, eRestyle_Self, nsChangeHint::None);
+  nsLayoutUtils::PostRestyleEvent(element, nsRestyleHint::Self,
+                                  nsChangeHint::None);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMWindowUtils::GetMediaSuspend(uint32_t* aSuspend)
 {
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
   NS_ENSURE_STATE(window);
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1179,17 +1179,18 @@ nsFrameLoader::MarginsChanged(uint32_t a
   mDocShell->SetMarginWidth(aMarginWidth);
   mDocShell->SetMarginHeight(aMarginHeight);
 
   // Trigger a restyle if there's a prescontext
   // FIXME: This could do something much less expensive.
   RefPtr<nsPresContext> presContext;
   mDocShell->GetPresContext(getter_AddRefs(presContext));
   if (presContext)
-    presContext->RebuildAllStyleData(nsChangeHint::None, eRestyle_Subtree);
+    presContext->RebuildAllStyleData(nsChangeHint::None,
+                                     nsRestyleHint::Subtree);
 }
 
 bool
 nsFrameLoader::ShowRemoteFrame(const ScreenIntSize& size,
                                nsSubDocumentFrame *aFrame)
 {
   PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS);
   NS_ASSERTION(IsRemoteFrame(), "ShowRemote only makes sense on remote frames.");
--- a/dom/base/nsHistory.cpp
+++ b/dom/base/nsHistory.cpp
@@ -189,17 +189,18 @@ nsHistory::Go(int32_t aDelta, ErrorResul
       // trick to work around gecko reflow bugs, and this should have
       // the same effect.
 
       nsCOMPtr<nsIDocument> doc = window->GetExtantDoc();
 
       nsIPresShell *shell;
       nsPresContext *pcx;
       if (doc && (shell = doc->GetShell()) && (pcx = shell->GetPresContext())) {
-        pcx->RebuildAllStyleData(nsChangeHint::ReflowHints, eRestyle_Subtree);
+        pcx->RebuildAllStyleData(nsChangeHint::ReflowHints,
+                                 nsRestyleHint::Subtree);
       }
 
       return;
     }
   }
 
   nsCOMPtr<nsISHistory> session_history = GetSessionHistory();
   nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(session_history));
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -1825,17 +1825,17 @@ interface nsIDOMWindowUtils : nsISupport
   /**
    * Get the content- and compositor-side APZ test data instances.
    * The return values are of type APZTestData (see APZTestData.webidl).
    */
   [implicit_jscontext] jsval getContentAPZTestData();
   [implicit_jscontext] jsval getCompositorAPZTestData();
 
   /**
-   * Posts an eRestyle_Self restyle event for the given element.
+   * Posts an nsRestyleHint::Self restyle event for the given element.
    */
   void postRestyleSelfEvent(in nsIDOMElement aElement);
 
   /**
    * Used to pause or resume all media in this window. Use-cases are audio
    * competing, remote media control and to prevent auto-playing media.
    */
   attribute uint32_t mediaSuspend;
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -116,17 +116,18 @@ nsMathMLElement::BindToTree(nsIDocument*
       doc->EnsureOnDemandBuiltInUASheet(cache->MathMLSheet());
 
       // Rebuild style data for the presshell, because style system
       // optimizations may have taken place assuming MathML was disabled.
       // (See nsRuleNode::CheckSpecifiedProperties.)
       nsCOMPtr<nsIPresShell> shell = doc->GetShell();
       if (shell) {
         shell->GetPresContext()->
-          PostRebuildAllStyleDataEvent(nsChangeHint::None, eRestyle_Subtree);
+          PostRebuildAllStyleDataEvent(nsChangeHint::None,
+                                       nsRestyleHint::Subtree);
       }
     }
   }
 
   return rv;
 }
 
 void
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -732,18 +732,18 @@ nsSMILAnimationController::AddStyleUpdat
       // Something's wrong/missing about animation's target; skip this animation
       continue;
     }
 
     // mIsCSS true means that the rules are the ones returned from
     // Element::GetSMILOverrideStyleDeclaration (via nsSMILCSSProperty objects),
     // and mIsCSS false means the rules are nsSMILMappedAttribute objects
     // returned from nsSVGElement::GetAnimatedContentStyleRule.
-    nsRestyleHint rshint = key.mIsCSS ? eRestyle_StyleAttribute_Animations
-                                      : eRestyle_SVGAttrAnimations;
+    nsRestyleHint rshint = key.mIsCSS ? nsRestyleHint::StyleAttribute_Animations
+                                      : nsRestyleHint::SVGAttrAnimations;
     aTracker.AddPendingRestyle(key.mElement, rshint, nsChangeHint::None);
   }
 
   mMightHavePendingStyleUpdates = false;
 }
 
 //----------------------------------------------------------------------
 // Add/remove child time containers
--- a/dom/smil/nsSMILMappedAttribute.cpp
+++ b/dom/smil/nsSMILMappedAttribute.cpp
@@ -133,17 +133,17 @@ nsSMILMappedAttribute::FlushChangesToTar
   mElement->DeleteProperty(SMIL_MAPPED_ATTR_ANIMVAL,
                            SMIL_MAPPED_ATTR_STYLERULE_ATOM);
   nsIDocument* doc = mElement->GetUncomposedDoc();
 
   // Request animation restyle
   if (doc) {
     nsIPresShell* shell = doc->GetShell();
     if (shell) {
-      shell->RestyleForAnimation(mElement, eRestyle_Self);
+      shell->RestyleForAnimation(mElement, nsRestyleHint::Self);
     }
   }
 }
 
 already_AddRefed<nsIAtom>
 nsSMILMappedAttribute::GetAttrNameAtom() const
 {
   return NS_Atomize(nsCSSProps::GetStringValue(mPropID));
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -126,17 +126,17 @@ nsSVGElement::DidAnimateClass()
   mClassAttribute.GetAnimValue(src, this);
   if (!mClassAnimAttr) {
     mClassAnimAttr = new nsAttrValue();
   }
   mClassAnimAttr->ParseAtomArray(src);
 
   nsIPresShell* shell = OwnerDoc()->GetShell();
   if (shell) {
-    shell->RestyleForAnimation(this, eRestyle_Self);
+    shell->RestyleForAnimation(this, nsRestyleHint::Self);
   }
 }
 
 nsresult
 nsSVGElement::Init()
 {
   // Set up length attributes - can't do this in the constructor
   // because we can't do a virtual call at that point
--- a/gfx/layers/apz/util/ActiveElementManager.cpp
+++ b/gfx/layers/apz/util/ActiveElementManager.cpp
@@ -163,17 +163,17 @@ static bool
 ElementHasActiveStyle(dom::Element* aElement)
 {
   nsPresContext* pc = GetPresContextFor(aElement);
   if (!pc) {
     return false;
   }
   StyleSetHandle styleSet = pc->StyleSet();
   for (dom::Element* e = aElement; e; e = e->GetParentElement()) {
-    if (styleSet->HasStateDependentStyle(e, NS_EVENT_STATE_ACTIVE)) {
+    if (bool(styleSet->HasStateDependentStyle(e, NS_EVENT_STATE_ACTIVE))) {
       AEM_LOG("Element %p's style is dependent on the active state\n", e);
       return true;
     }
   }
   AEM_LOG("Element %p doesn't use active styles\n", aElement);
   return false;
 }
 
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -4238,17 +4238,17 @@ PresShell::DocumentStatesChanged(nsIDocu
                "changes yet (only matters for chrome documents). See bug 1290285.");
     return;
   }
 
   if (mDidInitialize &&
       styleSet->HasDocumentStateDependentStyle(mDocument->GetRootElement(),
                                                aStateMask)) {
     mPresContext->RestyleManager()->PostRestyleEvent(mDocument->GetRootElement(),
-                                                     eRestyle_Subtree,
+                                                     nsRestyleHint::Subtree,
                                                      nsChangeHint::None);
     VERIFY_STYLE_TREE;
   }
 
   if (aStateMask.HasState(NS_DOCUMENT_STATE_WINDOW_INACTIVE)) {
     nsIFrame* root = mFrameConstructor->GetRootFrame();
     if (root) {
       root->SchedulePaint();
@@ -4524,21 +4524,21 @@ nsIPresShell::RestyleForCSSRuleChanges()
     // Tell Servo that the contents of style sheets have changed.
     mStyleSet->AsServo()->NoteStyleSheetsChanged();
   }
 
   if (scopeRoots.IsEmpty()) {
     // If scopeRoots is empty, we know that mStylesHaveChanged was true at
     // the beginning of this function, and that we need to restyle the whole
     // document.
-    restyleManager->PostRestyleEvent(root, eRestyle_Subtree,
+    restyleManager->PostRestyleEvent(root, nsRestyleHint::Subtree,
                                      nsChangeHint::None);
   } else {
     for (Element* scopeRoot : scopeRoots) {
-      restyleManager->PostRestyleEvent(scopeRoot, eRestyle_Subtree,
+      restyleManager->PostRestyleEvent(scopeRoot, nsRestyleHint::Subtree,
                                        nsChangeHint::None);
     }
   }
 }
 
 void
 PresShell::RecordStyleSheetChange(StyleSheet* aStyleSheet)
 {
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -130,33 +130,33 @@ RestyleManager::RestyleElement(Element* 
     nsStyleContext* oldContext = aPrimaryFrame->StyleContext();
     if (!oldContext->GetParent()) { // check that we're the root element
       RefPtr<nsStyleContext> newContext = StyleSet()->
         ResolveStyleFor(aElement, nullptr /* == oldContext->GetParent() */);
       if (oldContext->StyleFont()->mFont.size !=
           newContext->StyleFont()->mFont.size) {
         // The basis for 'rem' units has changed.
         mRebuildAllRestyleHint |= aRestyleHint;
-        if (aRestyleHint & eRestyle_SomeDescendants) {
-          mRebuildAllRestyleHint |= eRestyle_Subtree;
+        if (aRestyleHint & nsRestyleHint::SomeDescendants) {
+          mRebuildAllRestyleHint |= nsRestyleHint::Subtree;
         }
         mRebuildAllExtraHint |= aMinHint;
         StartRebuildAllStyleData(aRestyleTracker);
         return;
       }
     }
   }
 
   if (aMinHint & nsChangeHint::ReconstructFrame) {
     FrameConstructor()->RecreateFramesForContent(aElement, false,
       nsCSSFrameConstructor::REMOVE_FOR_RECONSTRUCTION, nullptr);
   } else if (aPrimaryFrame) {
     ComputeAndProcessStyleChange(aPrimaryFrame, aMinHint, aRestyleTracker,
                                  aRestyleHint, aRestyleHintData);
-  } else if (aRestyleHint & ~eRestyle_LaterSiblings) {
+  } else if (aRestyleHint & ~nsRestyleHint::LaterSiblings) {
     // We're restyling an element with no frame, so we should try to
     // make one if its new style says it should have one.  But in order
     // to try to honor the restyle hint (which we'd like to do so that,
     // for example, an animation-only style flush doesn't flush other
     // buffered style changes), we only do this if the restyle hint says
     // we have *some* restyling for this frame.  This means we'll
     // potentially get ahead of ourselves in that case, but not as much
     // as we would if we didn't check the restyle hint.
@@ -386,21 +386,21 @@ RestyleManager::GetAnimationGenerationFo
   return effectSet ? effectSet->GetAnimationGeneration() : 0;
 }
 
 void
 RestyleManager::RestyleForEmptyChange(Element* aContainer)
 {
   // In some cases (:empty + E, :empty ~ E), a change in the content of
   // an element requires restyling its parent's siblings.
-  nsRestyleHint hint = eRestyle_Subtree;
+  nsRestyleHint hint = nsRestyleHint::Subtree;
   nsIContent* grandparent = aContainer->GetParent();
   if (grandparent &&
       (grandparent->GetFlags() & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS)) {
-    hint = nsRestyleHint(hint | eRestyle_LaterSiblings);
+    hint = nsRestyleHint(hint | nsRestyleHint::LaterSiblings);
   }
   PostRestyleEvent(aContainer, hint, nsChangeHint::None);
 }
 
 void
 RestyleManager::RestyleForAppend(nsIContent* aContainer,
                                  nsIContent* aFirstNewContent)
 {
@@ -441,48 +441,48 @@ RestyleManager::RestyleForAppend(nsICont
     }
     if (wasEmpty) {
       RestyleForEmptyChange(container);
       return;
     }
   }
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
-    PostRestyleEvent(container, eRestyle_Subtree, nsChangeHint::None);
+    PostRestyleEvent(container, nsRestyleHint::Subtree, nsChangeHint::None);
     // Restyling the container is the most we can do here, so we're done.
     return;
   }
 
   if (selectorFlags & NODE_HAS_EDGE_CHILD_SELECTOR) {
     // restyle the last element child before this node
     for (nsIContent* cur = aFirstNewContent->GetPreviousSibling();
          cur;
          cur = cur->GetPreviousSibling()) {
       if (cur->IsElement()) {
-        PostRestyleEvent(cur->AsElement(), eRestyle_Subtree,
+        PostRestyleEvent(cur->AsElement(), nsRestyleHint::Subtree,
                          nsChangeHint::None);
         break;
       }
     }
   }
 }
 
 // Needed since we can't use PostRestyleEvent on non-elements (with
-// eRestyle_LaterSiblings or nsRestyleHint(eRestyle_Subtree |
-// eRestyle_LaterSiblings) as appropriate).
+// nsRestyleHint::LaterSiblings or nsRestyleHint(nsRestyleHint::Subtree |
+// nsRestyleHint::LaterSiblings) as appropriate).
 static void
 RestyleSiblingsStartingWith(RestyleManager* aRestyleManager,
                             nsIContent* aStartingSibling /* may be null */)
 {
   for (nsIContent* sibling = aStartingSibling; sibling;
        sibling = sibling->GetNextSibling()) {
     if (sibling->IsElement()) {
       aRestyleManager->
         PostRestyleEvent(sibling->AsElement(),
-                         nsRestyleHint(eRestyle_Subtree | eRestyle_LaterSiblings),
+                         nsRestyleHint::Subtree | nsRestyleHint::LaterSiblings,
                          nsChangeHint::None);
       break;
     }
   }
 }
 
 // Restyling for a ContentInserted or CharacterDataChanged notification.
 // This could be used for ContentRemoved as well if we got the
@@ -526,17 +526,17 @@ RestyleManager::RestyleForInsertOrChange
     }
     if (wasEmpty) {
       RestyleForEmptyChange(container);
       return;
     }
   }
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
-    PostRestyleEvent(container, eRestyle_Subtree, nsChangeHint::None);
+    PostRestyleEvent(container, nsRestyleHint::Subtree, nsChangeHint::None);
     // Restyling the container is the most we can do here, so we're done.
     return;
   }
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
     // Restyle all later siblings.
     RestyleSiblingsStartingWith(this, aChild->GetNextSibling());
   }
@@ -548,34 +548,34 @@ RestyleManager::RestyleForInsertOrChange
          content;
          content = content->GetNextSibling()) {
       if (content == aChild) {
         passedChild = true;
         continue;
       }
       if (content->IsElement()) {
         if (passedChild) {
-          PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
+          PostRestyleEvent(content->AsElement(), nsRestyleHint::Subtree,
                            nsChangeHint::None);
         }
         break;
       }
     }
     // restyle the previously-last element child if it is before this node
     passedChild = false;
     for (nsIContent* content = container->GetLastChild();
          content;
          content = content->GetPreviousSibling()) {
       if (content == aChild) {
         passedChild = true;
         continue;
       }
       if (content->IsElement()) {
         if (passedChild) {
-          PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
+          PostRestyleEvent(content->AsElement(), nsRestyleHint::Subtree,
                            nsChangeHint::None);
         }
         break;
       }
     }
   }
 }
 
@@ -619,17 +619,17 @@ RestyleManager::ContentRemoved(nsINode* 
     }
     if (isEmpty) {
       RestyleForEmptyChange(container);
       return;
     }
   }
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR) {
-    PostRestyleEvent(container, eRestyle_Subtree, nsChangeHint::None);
+    PostRestyleEvent(container, nsRestyleHint::Subtree, nsChangeHint::None);
     // Restyling the container is the most we can do here, so we're done.
     return;
   }
 
   if (selectorFlags & NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
     // Restyle all later siblings.
     RestyleSiblingsStartingWith(this, aFollowingSibling);
   }
@@ -641,30 +641,30 @@ RestyleManager::ContentRemoved(nsINode* 
          content;
          content = content->GetNextSibling()) {
       if (content == aFollowingSibling) {
         reachedFollowingSibling = true;
         // do NOT continue here; we might want to restyle this node
       }
       if (content->IsElement()) {
         if (reachedFollowingSibling) {
-          PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
+          PostRestyleEvent(content->AsElement(), nsRestyleHint::Subtree,
                            nsChangeHint::None);
         }
         break;
       }
     }
     // restyle the now-last element child if it was before aOldChild
     reachedFollowingSibling = (aFollowingSibling == nullptr);
     for (nsIContent* content = container->GetLastChild();
          content;
          content = content->GetPreviousSibling()) {
       if (content->IsElement()) {
         if (reachedFollowingSibling) {
-          PostRestyleEvent(content->AsElement(), eRestyle_Subtree,
+          PostRestyleEvent(content->AsElement(), nsRestyleHint::Subtree,
                            nsChangeHint::None);
         }
         break;
       }
       if (content == aFollowingSibling) {
         reachedFollowingSibling = true;
       }
     }
@@ -673,19 +673,20 @@ RestyleManager::ContentRemoved(nsINode* 
 
 void
 RestyleManager::RebuildAllStyleData(nsChangeHint aExtraHint,
                                     nsRestyleHint aRestyleHint)
 {
   NS_ASSERTION(!(aExtraHint & nsChangeHint::ReconstructFrame),
                "Should not reconstruct the root of the frame tree.  "
                "Use ReconstructDocElementHierarchy instead.");
-  MOZ_ASSERT(!(aRestyleHint & ~(eRestyle_Subtree | eRestyle_ForceDescendants)),
-             "the only bits allowed in aRestyleHint are eRestyle_Subtree and "
-             "eRestyle_ForceDescendants");
+  MOZ_ASSERT(!(aRestyleHint &
+                ~(nsRestyleHint::Subtree | nsRestyleHint::ForceDescendants)),
+             "the only bits allowed in aRestyleHint are "
+             "nsRestyleHint::Subtree and nsRestyleHint::ForceDescendants");
 
   mRebuildAllExtraHint |= aExtraHint;
   mRebuildAllRestyleHint |= aRestyleHint;
 
   // Processing the style changes could cause a flush that propagates to
   // the parent frame and thus destroys the pres shell, so we must hold
   // a reference.
   nsCOMPtr<nsIPresShell> presShell = PresContext()->GetPresShell();
@@ -729,20 +730,20 @@ RestyleManager::StartRebuildAllStyleData
     MOZ_CRASH("unable to rebuild style data");
   }
 
   nsRestyleHint restyleHint = mRebuildAllRestyleHint;
   nsChangeHint changeHint = mRebuildAllExtraHint;
   mRebuildAllExtraHint = nsChangeHint::None;
   mRebuildAllRestyleHint = nsRestyleHint(0);
 
-  restyleHint |= eRestyle_ForceDescendants;
-
-  if (!(restyleHint & eRestyle_Subtree) &&
-      (restyleHint & ~(eRestyle_Force | eRestyle_ForceDescendants))) {
+  restyleHint |= nsRestyleHint::ForceDescendants;
+
+  if (!(restyleHint & nsRestyleHint::Subtree) &&
+      (restyleHint & ~(nsRestyleHint::Force | nsRestyleHint::ForceDescendants))) {
     // We want this hint to apply to the root node's primary frame
     // rather than the root frame, since it's the primary frame that has
     // the styles for the root element (rather than the ancestors of the
     // primary frame whose mContent is the root node but which have
     // different styles).  If we use up the hint for one of the
     // ancestors that we hit first, then we'll fail to do the restyling
     // we need to do.
     Element* root = PresContext()->Document()->GetRootElement();
@@ -945,45 +946,45 @@ RestyleManager::PostRestyleEvent(Element
                                  nsChangeHint aMinChangeHint,
                                  const RestyleHintData* aRestyleHintData)
 {
   if (MOZ_UNLIKELY(IsDisconnected()) ||
       MOZ_UNLIKELY(PresContext()->PresShell()->IsDestroying())) {
     return;
   }
 
-  if (aRestyleHint == 0 && !bool(aMinChangeHint)) {
+  if (!bool(aRestyleHint) && !bool(aMinChangeHint)) {
     // Nothing to do here
     return;
   }
 
   mPendingRestyles.AddPendingRestyle(aElement, aRestyleHint, aMinChangeHint,
                                      aRestyleHintData);
 
   // Set mHavePendingNonAnimationRestyles for any restyle that could
   // possibly contain non-animation styles (i.e., those that require us
   // to do an animation-only style flush before processing style changes
   // to ensure correct initialization of CSS transitions).
-  if (aRestyleHint & ~eRestyle_AllHintsWithAnimations) {
+  if (aRestyleHint & ~nsRestyleHint::AllHintsWithAnimations) {
     mHavePendingNonAnimationRestyles = true;
   }
 
   PostRestyleEventInternal(false);
 }
 
 void
 RestyleManager::PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
                                              nsRestyleHint aRestyleHint)
 {
   NS_ASSERTION(!(aExtraHint & nsChangeHint::ReconstructFrame),
                "Should not reconstruct the root of the frame tree.  "
                "Use ReconstructDocElementHierarchy instead.");
-  MOZ_ASSERT(!(aRestyleHint & eRestyle_SomeDescendants),
+  MOZ_ASSERT(!(aRestyleHint & nsRestyleHint::SomeDescendants),
              "PostRebuildAllStyleDataEvent does not handle "
-             "eRestyle_SomeDescendants");
+             "nsRestyleHint::SomeDescendants");
 
   mDoRebuildAllStyleData = true;
   mRebuildAllExtraHint |= aExtraHint;
   mRebuildAllRestyleHint |= aRestyleHint;
 
   // Get a restyle event posted if necessary
   PostRestyleEventInternal(false);
 }
@@ -1650,46 +1651,46 @@ public:
   }
 
 private:
   nsTArray<nsCSSSelector*>& mSelectorsForDescendants;
   size_t mOriginalLength;
 };
 
 /**
- * Called when we are stopping a restyle with eRestyle_SomeDescendants, to
+ * Called when we are stopping a restyle with nsRestyleHint::SomeDescendants, to
  * search for descendants that match any of the selectors in
  * mSelectorsForDescendants.  If the element does match one of the selectors,
- * we cause it to be restyled with eRestyle_Self.
+ * we cause it to be restyled with nsRestyleHint::Self.
  *
  * We traverse down the frame tree (and through the flattened content tree
  * when we find undisplayed content) unless we find an element that (a) already
  * has a pending restyle, or (b) does not have a pending restyle but does match
  * one of the selectors in mSelectorsForDescendants.  For (a), we add the
  * current mSelectorsForDescendants into the existing restyle data, and for (b)
  * we add a new pending restyle with that array.  So in both cases, when we
  * come to restyling this element back up in ProcessPendingRestyles, we will
- * again find the eRestyle_SomeDescendants hint and its selectors array.
+ * again find the nsRestyleHint::SomeDescendants hint and its selectors array.
  *
  * This ensures that we don't visit descendant elements and check them
  * against mSelectorsForDescendants more than once.
  */
 void
 ElementRestyler::ConditionallyRestyleChildren()
 {
   MOZ_ASSERT(mContent == mFrame->GetContent());
 
   if (!mContent->IsElement() || mSelectorsForDescendants.IsEmpty()) {
     return;
   }
 
   Element* element = mContent->AsElement();
 
   LOG_RESTYLE("traversing descendants of frame %s (with element %s) to "
-              "propagate eRestyle_SomeDescendants for these %d selectors:",
+              "propagate nsRestyleHint::SomeDescendants for these %d selectors:",
               FrameTagToString(mFrame).get(),
               ElementTagToString(element).get(),
               int(mSelectorsForDescendants.Length()));
   LOG_RESTYLE_INDENT();
 #ifdef RESTYLE_LOGGING
   for (nsCSSSelector* sel : mSelectorsForDescendants) {
     LOG_RESTYLE("%s", sel->RestrictedSelectorToString().get());
   }
@@ -1865,45 +1866,46 @@ ElementRestyler::ConditionallyRestyle(ns
 
   return ConditionallyRestyle(aFrame->GetContent()->AsElement(), aRestyleRoot);
 }
 
 bool
 ElementRestyler::ConditionallyRestyle(Element* aElement, Element* aRestyleRoot)
 {
   MOZ_ASSERT(!aElement->IsStyledByServo());
-  LOG_RESTYLE("considering element %s for eRestyle_SomeDescendants",
+  LOG_RESTYLE("considering element %s for nsRestyleHint::SomeDescendants",
               ElementTagToString(aElement).get());
   LOG_RESTYLE_INDENT();
 
   if (aElement->HasFlag(mRestyleTracker.RootBit())) {
     aRestyleRoot = aElement;
   }
 
   if (mRestyleTracker.HasRestyleData(aElement)) {
-    nsRestyleHint rshint = eRestyle_SomeDescendants;
+    nsRestyleHint rshint = nsRestyleHint::SomeDescendants;
     if (SelectorMatchesForRestyle(aElement)) {
       LOG_RESTYLE("element has existing restyle data and matches a selector");
-      rshint |= eRestyle_Self;
+      rshint |= nsRestyleHint::Self;
     } else {
       LOG_RESTYLE("element has existing restyle data but doesn't match selectors");
     }
     RestyleHintData data;
     data.mSelectorsForDescendants = mSelectorsForDescendants;
     mRestyleTracker.AddPendingRestyle(aElement, rshint, nsChangeHint::None,
                                       &data, Some(aRestyleRoot));
     return true;
   }
 
   if (SelectorMatchesForRestyle(aElement)) {
     LOG_RESTYLE("element has no restyle data but matches a selector");
     RestyleHintData data;
     data.mSelectorsForDescendants = mSelectorsForDescendants;
     mRestyleTracker.AddPendingRestyle(aElement,
-                                      eRestyle_Self | eRestyle_SomeDescendants,
+                                      nsRestyleHint::Self |
+                                        nsRestyleHint::SomeDescendants,
                                       nsChangeHint::None, &data,
                                       Some(aRestyleRoot));
     return true;
   }
 
   return false;
 }
 
@@ -1998,30 +2000,30 @@ ElementRestyler::MoveStyleContextsForChi
       return false;
     }
   }
 
   nsTArray<nsStyleContext*> contextsToMove;
 
   MOZ_ASSERT(!MustReframeForBeforePseudo(),
              "shouldn't need to reframe ::before as we would have had "
-             "eRestyle_Subtree and wouldn't get in here");
+             "nsRestyleHint::Subtree and wouldn't get in here");
 
   DebugOnly<nsIFrame*> lastContinuation;
   for (nsIFrame* f = mFrame; f;
        f = RestyleManager::GetNextContinuationWithSameStyle(f, f->StyleContext())) {
     lastContinuation = f;
     if (!MoveStyleContextsForContentChildren(f, aOldContext, contextsToMove)) {
       return false;
     }
   }
 
   MOZ_ASSERT(!MustReframeForAfterPseudo(lastContinuation),
              "shouldn't need to reframe ::after as we would have had "
-             "eRestyle_Subtree and wouldn't get in here");
+             "nsRestyleHint::Subtree and wouldn't get in here");
 
   nsStyleContext* newParent = mFrame->StyleContext();
   for (nsStyleContext* child : contextsToMove) {
     // We can have duplicate entries in contextsToMove, so only move
     // each style context once.
     if (child->GetParent() != newParent) {
       child->MoveTo(newParent);
     }
@@ -2056,18 +2058,18 @@ ElementRestyler::Restyle(nsRestyleHint a
   NS_ASSERTION(mFrame->GetContent() || !mParentContent ||
                !mParentContent->GetParent(),
                "frame must have content (unless at the top of the tree)");
   MOZ_ASSERT(mPresContext == mFrame->PresContext(), "pres contexts match");
 
   NS_ASSERTION(!GetPrevContinuationWithSameStyle(mFrame),
                "should not be trying to restyle this frame separately");
 
-  MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
-             "eRestyle_LaterSiblings must not be part of aRestyleHint");
+  MOZ_ASSERT(!(aRestyleHint & nsRestyleHint::LaterSiblings),
+             "nsRestyleHint::LaterSiblings must not be part of aRestyleHint");
 
   mPresContext->RestyledElement();
 
   AutoDisplayContentsAncestorPusher adcp(mTreeMatchContext, mPresContext,
       mFrame->GetContent() ? mFrame->GetContent()->GetParent() : nullptr);
 
   AutoSelectorArrayTruncater asat(mSelectorsForDescendants);
 
@@ -2105,23 +2107,23 @@ ElementRestyler::Restyle(nsRestyleHint a
           restyleData->mRestyleHintData.mSelectorsForDescendants);
       hintToRestore = restyleData->mRestyleHint;
       hintDataToRestore = Move(restyleData->mRestyleHintData);
       aRestyleHint = nsRestyleHint(aRestyleHint | restyleData->mRestyleHint);
       descendants.SwapElements(restyleData->mDescendants);
     }
   }
 
-  // If we are restyling this frame with eRestyle_Self or weaker hints,
+  // If we are restyling this frame with nsRestyleHint::Self or weaker hints,
   // we restyle children with nsRestyleHint(0).  But we pass the
-  // eRestyle_ForceDescendants flag down too.
+  // nsRestyleHint::ForceDescendants flag down too.
   nsRestyleHint childRestyleHint =
-    nsRestyleHint(aRestyleHint & (eRestyle_SomeDescendants |
-                                  eRestyle_Subtree |
-                                  eRestyle_ForceDescendants));
+    aRestyleHint & (nsRestyleHint::SomeDescendants |
+                    nsRestyleHint::Subtree |
+                    nsRestyleHint::ForceDescendants);
 
   RefPtr<nsStyleContext> oldContext = mFrame->StyleContext();
 
   nsTArray<SwapInstruction> swaps;
 
   // TEMPORARY (until bug 918064):  Call RestyleSelf for each
   // continuation or block-in-inline sibling.
 
@@ -2136,18 +2138,18 @@ ElementRestyler::Restyle(nsRestyleHint a
 
   bool haveMoreContinuations = false;
   for (nsIFrame* f = mFrame; f; ) {
     RestyleResult thisResult =
       RestyleSelf(f, thisRestyleHint, &swappedStructs, swaps);
 
     if (thisResult != RestyleResult::eStop) {
       // Calls to RestyleSelf for later same-style continuations must not
-      // return RestyleResult::eStop, so pass eRestyle_Force in to them.
-      thisRestyleHint = nsRestyleHint(thisRestyleHint | eRestyle_Force);
+      // return RestyleResult::eStop, so pass nsRestyleHint::Force in to them.
+      thisRestyleHint |= nsRestyleHint::Force;
 
       if (result == RestyleResult::eStop) {
         // We received RestyleResult::eStop for earlier same-style
         // continuations, and RestyleResult::eStopWithStyleChange or
         // RestyleResult::eContinue(AndForceDescendants) for this one; go
         // back and force-restyle the earlier continuations.
         result = thisResult;
         f = mFrame;
@@ -2175,17 +2177,17 @@ ElementRestyler::Restyle(nsRestyleHint a
   // Although we only expect this code path to be called when computed style
   // is not changing, we can sometimes reach this at the end of a transition
   // when the animated style is being removed. Since
   // AddLayerChangesForAnimation checks if mFrame has a transform style or not,
   // we need to call it *after* calling RestyleSelf to ensure the animated
   // transform has been removed first.
   AddLayerChangesForAnimation();
 
-  if (haveMoreContinuations && hintToRestore) {
+  if (haveMoreContinuations && bool(hintToRestore)) {
     // If we have more continuations with different style (e.g., because
     // we're inside a ::first-letter or ::first-line), put the restyle
     // hint back.
     mRestyleTracker.AddPendingRestyleToTable(mContent->AsElement(),
                                              hintToRestore,
                                              nsChangeHint::None);
   }
 
@@ -2220,17 +2222,17 @@ ElementRestyler::Restyle(nsRestyleHint a
     // Send the accessibility notifications that RestyleChildren otherwise
     // would have sent.
     if (!(mHintsHandled & nsChangeHint::ReconstructFrame)) {
       InitializeAccessibilityNotifications(mFrame->StyleContext());
       SendAccessibilityNotifications();
     }
 
     mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants);
-    if (aRestyleHint & eRestyle_SomeDescendants) {
+    if (aRestyleHint & nsRestyleHint::SomeDescendants) {
       ConditionallyRestyleChildren();
     }
     return;
   }
 
   if (result == RestyleResult::eStopWithStyleChange &&
       !(mHintsHandled & nsChangeHint::ReconstructFrame)) {
     MOZ_ASSERT(mFrame->StyleContext() != oldContext,
@@ -2252,17 +2254,17 @@ ElementRestyler::Restyle(nsRestyleHint a
       // Send the accessibility notifications that RestyleChildren otherwise
       // would have sent.
       if (!(mHintsHandled & nsChangeHint::ReconstructFrame)) {
         InitializeAccessibilityNotifications(mFrame->StyleContext());
         SendAccessibilityNotifications();
       }
 
       mRestyleTracker.AddRestyleRootsIfAwaitingRestyle(descendants);
-      if (aRestyleHint & eRestyle_SomeDescendants) {
+      if (aRestyleHint & nsRestyleHint::SomeDescendants) {
         ConditionallyRestyleChildren();
       }
       return;
     }
 
     // Turns out we couldn't stop restyling here.  Process the struct
     // swaps that RestyleSelf would've done had we not returned
     // RestyleResult::eStopWithStyleChange.
@@ -2278,18 +2280,17 @@ ElementRestyler::Restyle(nsRestyleHint a
   if (!swappedStructs) {
     // If we swapped any structs from the old context, then we need to keep
     // it alive until after the RestyleChildren call so that we can fix up
     // its descendants' cached structs.
     oldContext = nullptr;
   }
 
   if (result == RestyleResult::eContinueAndForceDescendants) {
-    childRestyleHint =
-      nsRestyleHint(childRestyleHint | eRestyle_ForceDescendants);
+    childRestyleHint |= nsRestyleHint::ForceDescendants;
   }
 
   // No need to do this if we're planning to reframe already.
   // It's also important to check mHintsHandled since we use
   // mFrame->StyleContext(), which is out of date if mHintsHandled
   // has a ReconstructFrame hint.  Using an out of date style
   // context could trigger assertions about mismatched rule trees.
   if (!(mHintsHandled & nsChangeHint::ReconstructFrame)) {
@@ -2546,32 +2547,32 @@ ElementRestyler::SelectorMatchesForResty
   }
   return false;
 }
 
 bool
 ElementRestyler::MustRestyleSelf(nsRestyleHint aRestyleHint,
                                  Element* aElement)
 {
-  return (aRestyleHint & (eRestyle_Self | eRestyle_Subtree)) ||
-         ((aRestyleHint & eRestyle_SomeDescendants) &&
+  return (aRestyleHint & (nsRestyleHint::Self | nsRestyleHint::Subtree)) ||
+         ((aRestyleHint & nsRestyleHint::SomeDescendants) &&
           SelectorMatchesForRestyle(aElement));
 }
 
 bool
 ElementRestyler::CanReparentStyleContext(nsRestyleHint aRestyleHint)
 {
   // If we had any restyle hints other than the ones listed below,
   // which don't control whether the current frame/element needs
   // a new style context by looking up a new rule node, or if
   // we are reconstructing the entire rule tree, then we can't
   // use ReparentStyleContext.
-  return !(aRestyleHint & ~(eRestyle_Force |
-                            eRestyle_ForceDescendants |
-                            eRestyle_SomeDescendants)) &&
+  return !(aRestyleHint & ~(nsRestyleHint::Force |
+                            nsRestyleHint::ForceDescendants |
+                            nsRestyleHint::SomeDescendants)) &&
          !StyleSet()->IsInRuleTreeReconstruct();
 }
 
 // Returns true iff any rule node that is an ancestor-or-self of the
 // two specified rule nodes, but which is not an ancestor of both,
 // has any inherited style data.  If false is returned, then we know
 // that a change from one rule node to the other must not result in
 // any change in inherited style data.
@@ -2654,26 +2655,27 @@ CommonInheritedStyleData(nsRuleNode* aRu
 }
 
 ElementRestyler::RestyleResult
 ElementRestyler::RestyleSelf(nsIFrame* aSelf,
                              nsRestyleHint aRestyleHint,
                              uint32_t* aSwappedStructs,
                              nsTArray<SwapInstruction>& aSwaps)
 {
-  MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
-             "eRestyle_LaterSiblings must not be part of aRestyleHint");
+  MOZ_ASSERT(!(aRestyleHint & nsRestyleHint::LaterSiblings),
+             "nsRestyleHint::LaterSiblings must not be part of aRestyleHint");
 
   // XXXldb get new context from prev-in-flow if possible, to avoid
   // duplication.  (Or should we just let |GetContext| handle that?)
   // Getting the hint would be nice too, but that's harder.
 
   // XXXbryner we may be able to avoid some of the refcounting goop here.
-  // We do need a reference to oldContext for the lifetime of this function, and it's possible
-  // that the frame has the last reference to it, so AddRef it here.
+  // We do need a reference to oldContext for the lifetime of this function,
+  // and it's possible that the frame has the last reference to it,
+  // so AddRef it here.
 
   LOG_RESTYLE("RestyleSelf %s, aRestyleHint = %s",
               FrameTagToString(aSelf).get(),
               RestyleManagerBase::RestyleHintToString(aRestyleHint).get());
   LOG_RESTYLE_INDENT();
 
   // Initially assume that it is safe to stop restyling.
   //
@@ -2684,25 +2686,25 @@ ElementRestyler::RestyleSelf(nsIFrame* a
   // that would not allow us to return RestyleResult::eStopWithStyleChange.
   //
   // Towards the end of this function, we reconcile these two variables --
   // if |canStopWithStyleChange| is true, we convert |result| into
   // RestyleResult::eStopWithStyleChange.
   RestyleResult result = RestyleResult::eStop;
   bool canStopWithStyleChange = true;
 
-  if (aRestyleHint & ~eRestyle_SomeDescendants) {
+  if (aRestyleHint & ~nsRestyleHint::SomeDescendants) {
     // If we are doing any restyling of the current element, or if we're
     // forced to continue, we must.
     result = RestyleResult::eContinue;
 
     // If we have to restyle children, we can't return
     // RestyleResult::eStopWithStyleChange.
-    if (aRestyleHint & (eRestyle_Subtree | eRestyle_Force |
-                        eRestyle_ForceDescendants)) {
+    if (aRestyleHint & (nsRestyleHint::Subtree | nsRestyleHint::Force |
+                        nsRestyleHint::ForceDescendants)) {
       canStopWithStyleChange = false;
     }
   }
 
   // We only consider returning RestyleResult::eStopWithStyleChange if this
   // is the root of the restyle.  (Otherwise, we would need to track the
   // style changes of the ancestors we just restyled.)
   if (!mIsRootOfRestyle) {
@@ -2808,17 +2810,17 @@ ElementRestyler::RestyleSelf(nsIFrame* a
         // rather than reusing the rule node, as we need to do during a
         // rule tree reconstruct.
         Element* pseudoElement = PseudoElementForStyleContext(aSelf, pseudoType);
         MOZ_ASSERT(!element || element != pseudoElement,
                    "pseudo-element for selector matching should be "
                    "the anonymous content node that we create, "
                    "not the real element");
         LOG_RESTYLE("resolving style with replacement");
-        nsRestyleHint rshint = aRestyleHint & ~eRestyle_SomeDescendants;
+        nsRestyleHint rshint = aRestyleHint & ~nsRestyleHint::SomeDescendants;
         newContext =
           styleSet->ResolveStyleWithReplacement(element, pseudoElement,
                                                 parentContext, oldContext,
                                                 rshint);
       }
     } else if (pseudoType == CSSPseudoElementType::AnonBox) {
       newContext = styleSet->ResolveAnonymousBoxStyle(pseudoTag,
                                                       parentContext);
@@ -3046,17 +3048,17 @@ ElementRestyler::RestyleSelf(nsIFrame* a
     // RestyleResult::eContinue or RestyleResult::eStop) into
     // RestyleResult::eStopWithStyleChange.
     if (canStopWithStyleChange) {
       LOG_RESTYLE("converting %s into RestyleResult::eStopWithStyleChange",
                   RestyleResultToString(result).get());
       result = RestyleResult::eStopWithStyleChange;
     }
 
-    if (aRestyleHint & eRestyle_ForceDescendants) {
+    if (aRestyleHint & nsRestyleHint::ForceDescendants) {
       result = RestyleResult::eContinueAndForceDescendants;
     }
 
     if (!(mHintsHandled & nsChangeHint::ReconstructFrame)) {
       // If the frame gets regenerated, let it keep its old context,
       // which is important to maintain various invariants about
       // frame types matching their style contexts.
       // Note that this check even makes sense if we didn't call
@@ -3114,17 +3116,17 @@ ElementRestyler::RestyleSelf(nsIFrame* a
       // ElementRestyler::Restyle comment where we append to
       // mSwappedStructOwners.
       //
       // We really only need to do this if we did swap structs on the
       // parent, but we don't have that information here.
       mSwappedStructOwners.AppendElement(newContext->GetParent());
     }
   } else {
-    if (aRestyleHint & eRestyle_ForceDescendants) {
+    if (aRestyleHint & nsRestyleHint::ForceDescendants) {
       result = RestyleResult::eContinueAndForceDescendants;
     }
   }
   oldContext = nullptr;
 
   // do additional contexts
   // XXXbz might be able to avoid selector matching here in some
   // cases; won't worry about it for now.
@@ -3206,24 +3208,24 @@ ElementRestyler::RestyleChildren(nsResty
   MOZ_ASSERT(!(mHintsHandled & nsChangeHint::ReconstructFrame),
              "No need to do this if we're planning to reframe already.");
 
   // We'd like style resolution to be exact in the sense that an
   // animation-only style flush flushes only the styles it requests
   // flushing and doesn't update any other styles.  This means avoiding
   // constructing new frames during such a flush.
   //
-  // For a ::before or ::after, we'll do an eRestyle_Subtree due to
+  // For a ::before or ::after, we'll do an nsRestyleHint::Subtree due to
   // RestyleHintForOp in nsCSSRuleProcessor.cpp (via its
   // HasAttributeDependentStyle or HasStateDependentStyle), given that
   // we store pseudo-elements in selectors like they were children.
   //
   // Also, it's faster to skip the work we do on undisplayed children
   // and pseudo-elements when we can skip it.
-  bool mightReframePseudos = aChildRestyleHint & eRestyle_Subtree;
+  bool mightReframePseudos = !!(aChildRestyleHint & nsRestyleHint::Subtree);
 
   RestyleUndisplayedDescendants(aChildRestyleHint);
 
   // Check whether we might need to create a new ::before frame.
   // There's no need to do this if we're planning to reframe already
   // or if we're not forcing restyles on kids.
   // It's also important to check mHintsHandled since we use
   // mFrame->StyleContext(), which is out of date if mHintsHandled has a
@@ -3271,17 +3273,17 @@ ElementRestyler::RestyleChildrenOfDispla
   nsChangeHint           aMinHint,
   RestyleTracker&        aRestyleTracker,
   nsRestyleHint          aRestyleHint,
   const RestyleHintData& aRestyleHintData)
 {
   MOZ_ASSERT(!(mHintsHandled & nsChangeHint::ReconstructFrame),
              "why call me?");
 
-  const bool mightReframePseudos = aRestyleHint & eRestyle_Subtree;
+  const bool mightReframePseudos = !!(aRestyleHint & nsRestyleHint::Subtree);
   DoRestyleUndisplayedDescendants(nsRestyleHint(0), mContent, aNewContext);
   if (!(mHintsHandled & nsChangeHint::ReconstructFrame) &&
       mightReframePseudos) {
     MaybeReframeForPseudo(CSSPseudoElementType::before,
                           aParentFrame, nullptr, mContent, aNewContext);
   }
   if (!(mHintsHandled & nsChangeHint::ReconstructFrame) &&
       mightReframePseudos) {
@@ -3371,17 +3373,17 @@ ElementRestyler::ComputeStyleChangeFor(n
   nsTArray<nsIContent*> visibleKidsOfHiddenElement;
   nsIFrame* nextIBSibling;
   for (nsIFrame* ibSibling = aFrame; ibSibling; ibSibling = nextIBSibling) {
     nextIBSibling = RestyleManager::GetNextBlockInInlineSibling(propTable, ibSibling);
 
     if (nextIBSibling) {
       // Don't allow some ib-split siblings to be processed with
       // RestyleResult::eStopWithStyleChange and others not.
-      aRestyleHint |= eRestyle_Force;
+      aRestyleHint |= nsRestyleHint::Force;
     }
 
     // Outer loop over ib-split siblings
     for (nsIFrame* cont = ibSibling; cont; cont = cont->GetNextContinuation()) {
       if (GetPrevContinuationWithSameStyle(cont)) {
         // We already handled this element when dealing with its earlier
         // continuation.
         continue;
@@ -3473,18 +3475,17 @@ ElementRestyler::RestyleUndisplayedNodes
       insertionPointPusher.PushAncestorAndStyleScope(parent);
     }
 
     nsRestyleHint thisChildHint = aChildRestyleHint;
     nsAutoPtr<RestyleTracker::RestyleData> undisplayedRestyleData;
     Element* element = undisplayed->mContent->AsElement();
     if (mRestyleTracker.GetRestyleData(element,
                                        undisplayedRestyleData)) {
-      thisChildHint =
-        nsRestyleHint(thisChildHint | undisplayedRestyleData->mRestyleHint);
+      thisChildHint |= undisplayedRestyleData->mRestyleHint;
     }
     RefPtr<nsStyleContext> undisplayedContext;
     nsStyleSet* styleSet = StyleSet();
     if (MustRestyleSelf(thisChildHint, element)) {
       undisplayedContext =
         styleSet->ResolveStyleFor(element, aParentContext, mTreeMatchContext);
     } else if (CanReparentStyleContext(thisChildHint)) {
       undisplayedContext =
@@ -3492,17 +3493,17 @@ ElementRestyler::RestyleUndisplayedNodes
                                        aParentContext,
                                        element);
     } else {
       // Use ResolveStyleWithReplacement either for actual
       // replacements, or as a substitute for ReparentStyleContext
       // that rebuilds the path in the rule tree rather than reusing
       // the rule node, as we need to do during a rule tree
       // reconstruct.
-      nsRestyleHint rshint = thisChildHint & ~eRestyle_SomeDescendants;
+      nsRestyleHint rshint = thisChildHint & ~nsRestyleHint::SomeDescendants;
       undisplayedContext =
         styleSet->ResolveStyleWithReplacement(element, nullptr,
                                               aParentContext,
                                               undisplayed->mStyle,
                                               rshint);
     }
     const nsStyleDisplay* display = undisplayedContext->StyleDisplay();
     if (display->mDisplay != aDisplay) {
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManagerBase.cpp
@@ -85,17 +85,17 @@ RestyleManagerBase::ContentStateChangedI
     Element* ancestor =
       ElementForStyleContext(nullptr, primaryFrame, pseudoType);
     *aOutRestyleHint = styleSet->HasStateDependentStyle(ancestor, pseudoType,
                                                         aElement, aStateMask);
   } else {
     *aOutRestyleHint = nsRestyleHint(0);
   }
 
-  if (aStateMask.HasState(NS_EVENT_STATE_HOVER) && *aOutRestyleHint != 0) {
+  if (aStateMask.HasState(NS_EVENT_STATE_HOVER) && bool(*aOutRestyleHint)) {
     IncrementHoverGeneration();
   }
 
   if (aStateMask.HasState(NS_EVENT_STATE_VISITED)) {
     // Exposing information to the page about whether the link is
     // visited or not isn't really something we can worry about here.
     // FIXME: We could probably do this a bit better.
     *aOutChangeHint |= nsChangeHint::RepaintFrame;
@@ -107,24 +107,26 @@ RestyleManagerBase::RestyleHintToString(
 {
   nsCString result;
   bool any = false;
   const char* names[] = {
     "Self", "SomeDescendants", "Subtree", "LaterSiblings", "CSSTransitions",
     "CSSAnimations", "SVGAttrAnimations", "StyleAttribute",
     "StyleAttribute_Animations", "Force", "ForceDescendants"
   };
-  uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
-  uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
+  uint32_t hint = static_cast<nsRestyleHintTypeBase>(aHint) &
+                    ((1 << ArrayLength(names)) - 1);
+  uint32_t rest = static_cast<nsRestyleHintTypeBase>(aHint) &
+                    ~((1 << ArrayLength(names)) - 1);
   for (uint32_t i = 0; i < ArrayLength(names); i++) {
     if (hint & (1 << i)) {
       if (any) {
         result.AppendLiteral(" | ");
       }
-      result.AppendPrintf("eRestyle_%s", names[i]);
+      result.AppendPrintf("nsRestyleHint::%s", names[i]);
       any = true;
     }
   }
   if (rest) {
     if (any) {
       result.AppendLiteral(" | ");
     }
     result.AppendPrintf("0x%0x", rest);
--- a/layout/base/RestyleTracker.cpp
+++ b/layout/base/RestyleTracker.cpp
@@ -67,29 +67,29 @@ struct RestyleEnumerateData : RestyleTra
 };
 
 inline void
 RestyleTracker::ProcessOneRestyle(Element* aElement,
                                   nsRestyleHint aRestyleHint,
                                   nsChangeHint aChangeHint,
                                   const RestyleHintData& aRestyleHintData)
 {
-  NS_PRECONDITION((aRestyleHint & eRestyle_LaterSiblings) == 0,
+  NS_PRECONDITION(!(aRestyleHint & nsRestyleHint::LaterSiblings),
                   "Someone should have handled this before calling us");
   NS_PRECONDITION(Document(), "Must have a document");
   NS_PRECONDITION(aElement->GetComposedDoc() == Document(),
                   "Element has unexpected document");
 
   LOG_RESTYLE("aRestyleHint = %s, aChangeHint = %s",
               RestyleManager::RestyleHintToString(aRestyleHint).get(),
               RestyleManager::ChangeHintToString(aChangeHint).get());
 
   nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
 
-  if (aRestyleHint & ~eRestyle_LaterSiblings) {
+  if (aRestyleHint & ~nsRestyleHint::LaterSiblings) {
 #ifdef RESTYLE_LOGGING
     if (ShouldLogRestyle() && primaryFrame &&
         RestyleManager::StructsToLog() != 0) {
       LOG_RESTYLE("style context tree before restyle:");
       LOG_RESTYLE_INDENT();
       primaryFrame->StyleContext()->LogStyleContextTree(
           LoggingDepth(), RestyleManager::StructsToLog());
     }
@@ -172,57 +172,58 @@ RestyleTracker::DoProcessRestyles()
           MOZ_ASSERT(!element->IsStyledByServo(),
                      "Should not have Servo-styled elements here");
           // Only collect the entries that actually need restyling by us (and
           // haven't, for example, already been restyled).
           // It's important to not mess with the flags on entries not in our
           // document.
           if (element->GetComposedDoc() == Document() &&
               element->HasFlag(RestyleBit()) &&
-              (iter.Data()->mRestyleHint & eRestyle_LaterSiblings)) {
+              (iter.Data()->mRestyleHint & nsRestyleHint::LaterSiblings)) {
             laterSiblingArr.AppendElement(element);
           }
         }
         for (uint32_t i = 0; i < laterSiblingArr.Length(); ++i) {
           Element* element = laterSiblingArr[i];
           MOZ_ASSERT(!element->IsStyledByServo());
           for (nsIContent* sibling = element->GetNextSibling();
                sibling;
                sibling = sibling->GetNextSibling()) {
             if (sibling->IsElement()) {
               LOG_RESTYLE("adding pending restyle for %s due to "
-                          "eRestyle_LaterSiblings hint on %s",
+                          "nsRestyleHint::LaterSiblings hint on %s",
                           FrameTagToString(sibling->AsElement()).get(),
                           FrameTagToString(element->AsElement()).get());
-              if (AddPendingRestyle(sibling->AsElement(), eRestyle_Subtree,
+              if (AddPendingRestyle(sibling->AsElement(),
+                                    nsRestyleHint::Subtree,
                                     nsChangeHint::None)) {
                   // Nothing else to do here; we'll handle the following
                   // siblings when we get to |sibling| in laterSiblingArr.
                 break;
               }
             }
           }
         }
 
-        // Now remove all those eRestyle_LaterSiblings bits
+        // Now remove all those nsRestyleHint::LaterSiblings bits
         for (uint32_t i = 0; i < laterSiblingArr.Length(); ++i) {
           Element* element = laterSiblingArr[i];
           NS_ASSERTION(element->HasFlag(RestyleBit()), "How did that happen?");
           RestyleData* data;
 #ifdef DEBUG
           bool found =
 #endif
             mPendingRestyles.Get(element, &data);
           NS_ASSERTION(found, "Where did our entry go?");
           data->mRestyleHint =
-            nsRestyleHint(data->mRestyleHint & ~eRestyle_LaterSiblings);
+            nsRestyleHint(data->mRestyleHint & ~nsRestyleHint::LaterSiblings);
         }
 
         LOG_RESTYLE("%d pending restyles after expanding out "
-                    "eRestyle_LaterSiblings", mPendingRestyles.Count());
+                    "nsRestyleHint::LaterSiblings", mPendingRestyles.Count());
 
         mHaveLaterSiblingRestyles = false;
       }
 
       uint32_t rootCount;
       while ((rootCount = mRestyleRoots.Length())) {
         // Make sure to pop the element off our restyle root array, so
         // that we can freely append to the array as we process this
@@ -407,41 +408,40 @@ RestyleTracker::GetRestyleData(Element* 
   if (!aElement->HasFlag(RestyleBit())) {
     NS_ASSERTION(!aElement->HasFlag(RootBit()), "Bogus root bit?");
     return false;
   }
 
   mPendingRestyles.RemoveAndForget(aElement, aData);
   NS_ASSERTION(aData.get(), "Must have data if restyle bit is set");
 
-  if (aData->mRestyleHint & eRestyle_LaterSiblings) {
-    // Someone readded the eRestyle_LaterSiblings hint for this
+  if (aData->mRestyleHint & nsRestyleHint::LaterSiblings) {
+    // Someone readded the nsRestyleHint::LaterSiblings hint for this
     // element.  Leave it around for now, but remove the other restyle
     // hints and the change hint for it.  Also unset its root bit,
     // since it's no longer a root with the new restyle data.
 
     // During a normal restyle, we should have already processed the
     // mDescendants array the last time we processed the restyle
     // for this element.  But in RebuildAllStyleData, we don't initially
-    // expand out eRestyle_LaterSiblings, so we can get in here the
+    // expand out nsRestyleHint::LaterSiblings, so we can get in here the
     // first time we need to process a restyle for this element.  In that
     // case, it's fine for us to have a non-empty mDescendants, since
-    // we know that RebuildAllStyleData adds eRestyle_ForceDescendants
+    // we know that RebuildAllStyleData adds nsRestyleHint::ForceDescendants
     // and we're guaranteed we'll restyle the entire tree.
     NS_ASSERTION(mRestyleManager->InRebuildAllStyleData() ||
                  aData->mDescendants.IsEmpty(),
                  "expected descendants to be handled by now");
 
     RestyleData* newData = new RestyleData;
     newData->mChangeHint = nsChangeHint::None;
-    newData->mRestyleHint = eRestyle_LaterSiblings;
+    newData->mRestyleHint = nsRestyleHint::LaterSiblings;
     mPendingRestyles.Put(aElement, newData);
     aElement->UnsetFlags(RootBit());
-    aData->mRestyleHint =
-      nsRestyleHint(aData->mRestyleHint & ~eRestyle_LaterSiblings);
+    aData->mRestyleHint = aData->mRestyleHint & ~nsRestyleHint::LaterSiblings;
   } else {
     aElement->UnsetFlags(mRestyleBits);
   }
 
   return true;
 }
 
 void
@@ -474,19 +474,20 @@ RestyleTracker::AddRestyleRootsIfAwaitin
 void
 RestyleTracker::ClearSelectors()
 {
   if (!mHaveSelectors) {
     return;
   }
   for (auto it = mPendingRestyles.Iter(); !it.Done(); it.Next()) {
     RestyleData* data = it.Data();
-    if (data->mRestyleHint & eRestyle_SomeDescendants) {
+    if (data->mRestyleHint & nsRestyleHint::SomeDescendants) {
       data->mRestyleHint =
-        (data->mRestyleHint & ~eRestyle_SomeDescendants) | eRestyle_Subtree;
+        (data->mRestyleHint & ~nsRestyleHint::SomeDescendants) |
+          nsRestyleHint::Subtree;
       data->mRestyleHintData.mSelectorsForDescendants.Clear();
     } else {
       MOZ_ASSERT(data->mRestyleHintData.mSelectorsForDescendants.IsEmpty());
     }
   }
   mHaveSelectors = false;
 }
 
--- a/layout/base/RestyleTracker.h
+++ b/layout/base/RestyleTracker.h
@@ -61,17 +61,17 @@ public:
   }
 
   uint32_t Count() const {
     return mPendingRestyles.Count();
   }
 
   /**
    * Add a restyle for the given element to the tracker.  Returns true
-   * if the element already had eRestyle_LaterSiblings set on it.
+   * if the element already had nsRestyleHint::LaterSiblings set on it.
    *
    * aRestyleRoot is the closest restyle root for aElement.  If the caller
    * does not know what the closest restyle root is, Nothing should be
    * passed.  A Some(nullptr) restyle root can be passed if there is no
    * ancestor element that is a restyle root.
    */
   bool AddPendingRestyle(Element* aElement, nsRestyleHint aRestyleHint,
                          nsChangeHint aMinChangeHint,
@@ -131,19 +131,19 @@ public:
 #if defined(MOZ_ENABLE_PROFILER_SPS)
     UniquePtr<ProfilerBacktrace> mBacktrace;
 #endif
   };
 
   /**
    * If the given Element has a restyle pending for it, return the
    * relevant restyle data.  This function will clear everything other
-   * than a possible eRestyle_LaterSiblings hint for aElement out of
+   * than a possible nsRestyleHint::LaterSiblings hint for aElement out of
    * our hashtable.  The returned aData will never have an
-   * eRestyle_LaterSiblings hint in it.
+   * nsRestyleHint::LaterSiblings hint in it.
    *
    * The return value indicates whether any restyle data was found for
    * the element.  aData is set to nullptr iff false is returned.
    */
   bool GetRestyleData(Element* aElement, nsAutoPtr<RestyleData>& aData);
 
   /**
    * Returns whether there is a RestyleData entry in mPendingRestyles
@@ -164,20 +164,21 @@ public:
    * This function must be called with elements in order such that
    * appending them to mRestyleRoots maintains its ordering invariant that
    * ancestors appear after descendants.
    */
   void AddRestyleRootsIfAwaitingRestyle(
                                   const nsTArray<RefPtr<Element>>& aElements);
 
   /**
-   * Converts any eRestyle_SomeDescendants restyle hints in the pending restyle
-   * table into eRestyle_Subtree hints and clears out the associated arrays of
-   * nsCSSSelector pointers.  This is called in response to a style sheet change
-   * that might have cause an nsCSSSelector to be destroyed.
+   * Converts any nsRestyleHint::SomeDescendants restyle hints in the pending
+   * restyle table into nsRestyleHint::Subtree hints and clears out the
+   * associated arrays of nsCSSSelector pointers.  This is called in response
+   * to a style sheet change that might have cause an nsCSSSelector to be
+   * destroyed.
    */
   void ClearSelectors();
 
   /**
    * The document we're associated with.
    */
   inline nsIDocument* Document() const;
 
@@ -189,17 +190,17 @@ public:
 
 private:
   bool AddPendingRestyleToTable(Element* aElement, nsRestyleHint aRestyleHint,
                                 nsChangeHint aMinChangeHint,
                                 const RestyleHintData* aRestyleHintData = nullptr);
 
   /**
    * Handle a single mPendingRestyles entry.  aRestyleHint must not
-   * include eRestyle_LaterSiblings; that needs to be dealt with
+   * include nsRestyleHint::LaterSiblings; that needs to be dealt with
    * before calling this function.
    */
   inline void ProcessOneRestyle(Element* aElement,
                                 nsRestyleHint aRestyleHint,
                                 nsChangeHint aChangeHint,
                                 const RestyleHintData& aRestyleHintData);
 
   typedef nsClassHashtable<nsISupportsHashKey, RestyleData> PendingRestyleTable;
@@ -218,17 +219,17 @@ private:
   PendingRestyleTable mPendingRestyles;
   // An array that keeps track of our possible restyle roots.  This
   // maintains the invariant that if A and B are both restyle roots
   // and A is an ancestor of B then A will come after B in the array.
   // We maintain this invariant by checking whether an element has an
   // ancestor with the restyle root bit set before appending it to the
   // array.
   RestyleRootArray mRestyleRoots;
-  // True if we have some entries with the eRestyle_LaterSiblings
+  // True if we have some entries with the nsRestyleHint::LaterSiblings
   // flag.  We need this to avoid enumerating the hashtable looking
   // for such entries when we can't possibly have any.
   bool mHaveLaterSiblingRestyles;
   // True if we have some entries with selectors in the restyle hint data.
   // We use this to skip iterating over mPendingRestyles in ClearSelectors.
   bool mHaveSelectors;
 };
 
@@ -250,19 +251,19 @@ RestyleTracker::AddPendingRestyleToTable
   // relevant anymore (if the flag is not set).
   if (aElement->HasFlag(RestyleBit())) {
     mPendingRestyles.Get(aElement, &existingData);
   } else {
     aElement->SetFlags(RestyleBit());
     existingData = nullptr;
   }
 
-  if (aRestyleHint & eRestyle_SomeDescendants) {
+  if (aRestyleHint & nsRestyleHint::SomeDescendants) {
     NS_ASSERTION(ConditionalDescendantsBit(),
-                 "why are we getting eRestyle_SomeDescendants in an "
+                 "why are we getting nsRestyleHint::SomeDescendants in an "
                  "animation-only restyle?");
     aElement->SetFlags(ConditionalDescendantsBit());
   }
 
   if (!existingData) {
     RestyleData* rd =
       new RestyleData(aRestyleHint, aMinChangeHint, aRestyleHintData);
 #if defined(MOZ_ENABLE_PROFILER_SPS)
@@ -270,19 +271,18 @@ RestyleTracker::AddPendingRestyleToTable
       rd->mBacktrace.reset(profiler_get_backtrace());
     }
 #endif
     mPendingRestyles.Put(aElement, rd);
     return false;
   }
 
   bool hadRestyleLaterSiblings =
-    (existingData->mRestyleHint & eRestyle_LaterSiblings) != 0;
-  existingData->mRestyleHint =
-    nsRestyleHint(existingData->mRestyleHint | aRestyleHint);
+    !!(existingData->mRestyleHint & nsRestyleHint::LaterSiblings);
+  existingData->mRestyleHint |= aRestyleHint;
   existingData->mChangeHint |= aMinChangeHint;
   if (aRestyleHintData) {
     existingData->mRestyleHintData.mSelectorsForDescendants
       .AppendElements(aRestyleHintData->mSelectorsForDescendants);
   }
 
   return hadRestyleLaterSiblings;
 }
@@ -324,17 +324,17 @@ RestyleTracker::AddPendingRestyle(Elemen
 {
   bool hadRestyleLaterSiblings =
     AddPendingRestyleToTable(aElement, aRestyleHint, aMinChangeHint,
                              aRestyleHintData);
 
   // We can only treat this element as a restyle root if we would
   // actually restyle its descendants (so either call
   // ElementRestyler::Restyle on it or just reframe it).
-  if ((aRestyleHint & ~eRestyle_LaterSiblings) ||
+  if ((aRestyleHint & ~nsRestyleHint::LaterSiblings) ||
       (aMinChangeHint & nsChangeHint::ReconstructFrame)) {
     Element* cur =
       aRestyleRoot ? *aRestyleRoot : FindClosestRestyleRoot(aElement);
     if (!cur) {
       mRestyleRoots.AppendElement(aElement);
       cur = aElement;
     }
     // At this point some ancestor of aElement (possibly aElement
@@ -349,25 +349,26 @@ RestyleTracker::AddPendingRestyle(Elemen
       //
       // As with the mRestyleRoots array, mDescendants maintains the
       // invariant that if two elements appear in the array and one
       // is an ancestor of the other, that the ancestor appears after
       // the descendant.
       RestyleData* curData;
       mPendingRestyles.Get(cur, &curData);
       NS_ASSERTION(curData, "expected to find a RestyleData for cur");
-      // If cur has an eRestyle_ForceDescendants restyle hint, then we
+      // If cur has an nsRestyleHint::ForceDescendants restyle hint, then we
       // know that we will get to all descendants.  Don't bother
       // recording the descendant to restyle in that case.
-      if (curData && !(curData->mRestyleHint & eRestyle_ForceDescendants)) {
+      if (curData &&
+          !(curData->mRestyleHint & nsRestyleHint::ForceDescendants)) {
         curData->mDescendants.AppendElement(aElement);
       }
     }
   }
 
-  mHaveLaterSiblingRestyles =
-    mHaveLaterSiblingRestyles || (aRestyleHint & eRestyle_LaterSiblings) != 0;
+  mHaveLaterSiblingRestyles = mHaveLaterSiblingRestyles ||
+                              !!(aRestyleHint & nsRestyleHint::LaterSiblings);
   return hadRestyleLaterSiblings;
 }
 
 } // namespace mozilla
 
 #endif /* mozilla_RestyleTracker_h */
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -30,52 +30,51 @@ ServoRestyleManager::PostRestyleEvent(El
                                       nsRestyleHint aRestyleHint,
                                       nsChangeHint aMinChangeHint)
 {
   if (MOZ_UNLIKELY(IsDisconnected()) ||
       MOZ_UNLIKELY(PresContext()->PresShell()->IsDestroying())) {
     return;
   }
 
-  if (aRestyleHint == 0 && !bool(aMinChangeHint) &&
-      !HasPendingRestyles()) {
+  if (!bool(aRestyleHint) && !bool(aMinChangeHint) && !HasPendingRestyles()) {
     return; // Nothing to do.
   }
 
   // We allow posting change hints during restyling, but not restyle hints
   // themselves, since those would require us to re-traverse the tree.
-  MOZ_ASSERT_IF(mInStyleRefresh, aRestyleHint == 0);
+  MOZ_ASSERT_IF(mInStyleRefresh, !bool(aRestyleHint));
 
   // Processing change hints sometimes causes new change hints to be generated.
   // Doing this after the gecko post-traversal is problematic, so instead we just
   // queue them up for special handling.
   if (mReentrantChanges) {
-    MOZ_ASSERT(aRestyleHint == 0);
+    MOZ_ASSERT(!bool(aRestyleHint));
     mReentrantChanges->AppendElement(ReentrantChange { aElement, aMinChangeHint });
     return;
   }
 
   // XXX This is a temporary hack to make style attribute change works.
   //     In the future, we should be able to use this hint directly.
-  if (aRestyleHint & eRestyle_StyleAttribute) {
-    aRestyleHint &= ~eRestyle_StyleAttribute;
-    aRestyleHint |= eRestyle_Self | eRestyle_Subtree;
+  if (aRestyleHint & nsRestyleHint::StyleAttribute) {
+    aRestyleHint &= ~nsRestyleHint::StyleAttribute;
+    aRestyleHint |= nsRestyleHint::Self | nsRestyleHint::Subtree;
   }
 
-  // XXX For now, convert eRestyle_Subtree into (eRestyle_Self |
-  // eRestyle_SomeDescendants), which Servo will interpret as
+  // XXX For now, convert nsRestyleHint::Subtree into (nsRestyleHint::Self |
+  // nsRestyleHint::SomeDescendants), which Servo will interpret as
   // RESTYLE_SELF | RESTYLE_DESCENDANTS, since this is a commonly
   // posted restyle hint that doesn't yet align with RestyleHint's
   // bits.
-  if (aRestyleHint & eRestyle_Subtree) {
-    aRestyleHint &= ~eRestyle_Subtree;
-    aRestyleHint |= eRestyle_Self | eRestyle_SomeDescendants;
+  if (aRestyleHint & nsRestyleHint::Subtree) {
+    aRestyleHint &= ~nsRestyleHint::Subtree;
+    aRestyleHint |= nsRestyleHint::Self | nsRestyleHint::SomeDescendants;
   }
 
-  if (aRestyleHint || bool(aMinChangeHint)) {
+  if (bool(aRestyleHint) || bool(aMinChangeHint)) {
     Servo_NoteExplicitHints(aElement, aRestyleHint, aMinChangeHint);
   }
 
   PostRestyleEventInternal(false);
 }
 
 void
 ServoRestyleManager::PostRestyleEventForLazyConstruction()
@@ -459,17 +458,19 @@ ServoRestyleManager::AttributeChanged(El
                                       nsIAtom* aAttribute, int32_t aModType,
                                       const nsAttrValue* aOldValue)
 {
 #ifdef DEBUG
   ServoElementSnapshot* snapshot = Servo_Element_GetSnapshot(aElement);
   MOZ_ASSERT_IF(snapshot, snapshot->HasAttrs());
 #endif
   if (aAttribute == nsGkAtoms::style) {
-    PostRestyleEvent(aElement, eRestyle_StyleAttribute, nsChangeHint::None);
+    PostRestyleEvent(aElement,
+                     nsRestyleHint::StyleAttribute,
+                     nsChangeHint::None);
   }
 }
 
 nsresult
 ServoRestyleManager::ReparentStyleContext(nsIFrame* aFrame)
 {
   NS_WARNING("stylo: ServoRestyleManager::ReparentStyleContext not implemented");
   return NS_OK;
--- a/layout/base/nsChangeHint.h
+++ b/layout/base/nsChangeHint.h
@@ -345,157 +345,115 @@ inline nsChangeHint NS_HintsNotHandledFo
   return result;
 }
 
 /**
  * |nsRestyleHint| is a bitfield for the result of
  * |HasStateDependentStyle| and |HasAttributeDependentStyle|.  When no
  * restyling is necessary, use |nsRestyleHint(0)|.
  *
- * Without eRestyle_Force or eRestyle_ForceDescendants, the restyling process
- * can stop processing at a frame when it detects no style changes and it is
- * known that the styles of the subtree beneath it will not change, leaving
- * the old style context on the frame.  eRestyle_Force can be used to skip this
- * optimization on a frame, and to force its new style context to be used.
+ * Without nsRestyleHint::Force or nsRestyleHint::ForceDescendants, the
+ * restyling process can stop processing at a frame when it detects no style
+ * changes and it is known that the styles of the subtree beneath it will not
+ * change, leaving the old style context on the frame.
+ * nsRestyleHint::Force can be used to skip this optimization on a frame, and
+ * to force its new style context to be used.
  *
- * Similarly, eRestyle_ForceDescendants will cause the frame and all of its
- * descendants to be traversed and for the new style contexts that are created
- * to be set on the frames.
+ * Similarly, nsRestyleHint::ForceDescendants will cause the frame and all of
+ * its descendants to be traversed and for the new style contexts that are
+ * created to be set on the frames.
  *
  * NOTE: When adding new restyle hints, please also add them to
  * RestyleManager::RestyleHintToString.
  */
-enum nsRestyleHint {
+typedef uint32_t nsRestyleHintTypeBase;
+enum class nsRestyleHint : nsRestyleHintTypeBase {
   // Rerun selector matching on the element.  If a new style context
   // results, update the style contexts of descendants.  (Irrelevant if
-  // eRestyle_Subtree is also set, since that implies a superset of the
+  // |Subtree| is also set, since that implies a superset of the
   // work.)
-  eRestyle_Self = 1 << 0,
+  Self = 1 << 0,
 
   // Rerun selector matching on descendants of the element that match
   // a given selector.
-  eRestyle_SomeDescendants = 1 << 1,
+  SomeDescendants = 1 << 1,
 
   // Rerun selector matching on the element and all of its descendants.
-  // (Implies eRestyle_ForceDescendants, which ensures that we continue
+  // (Implies |ForceDescendants|, which ensures that we continue
   // the restyling process for all descendants, but doesn't cause
   // selector matching.)
-  eRestyle_Subtree = 1 << 2,
+  Subtree = 1 << 2,
 
   // Rerun selector matching on all later siblings of the element and
   // all of their descendants.
-  eRestyle_LaterSiblings = 1 << 3,
+  LaterSiblings = 1 << 3,
 
   // Replace the style data coming from CSS transitions without updating
   // any other style data.  If a new style context results, update style
-  // contexts on the descendants.  (Irrelevant if eRestyle_Self or
-  // eRestyle_Subtree is also set, since those imply a superset of the
+  // contexts on the descendants.  (Irrelevant if |Self| or
+  // |Subtree| is also set, since those imply a superset of the
   // work.)
-  eRestyle_CSSTransitions = 1 << 4,
+  CSSTransitions = 1 << 4,
 
   // Replace the style data coming from CSS animations without updating
   // any other style data.  If a new style context results, update style
-  // contexts on the descendants.  (Irrelevant if eRestyle_Self or
-  // eRestyle_Subtree is also set, since those imply a superset of the
+  // contexts on the descendants.  (Irrelevant if |Self| or
+  // |Subtree| is also set, since those imply a superset of the
   // work.)
-  eRestyle_CSSAnimations = 1 << 5,
+  CSSAnimations = 1 << 5,
 
   // Replace the style data coming from SVG animations (SMIL Animations)
   // without updating any other style data.  If a new style context
   // results, update style contexts on the descendants.  (Irrelevant if
-  // eRestyle_Self or eRestyle_Subtree is also set, since those imply a
+  // |Self| or |Subtree| is also set, since those imply a
   // superset of the work.)
-  eRestyle_SVGAttrAnimations = 1 << 6,
+  SVGAttrAnimations = 1 << 6,
 
   // Replace the style data coming from inline style without updating
   // any other style data.  If a new style context results, update style
-  // contexts on the descendants.  (Irrelevant if eRestyle_Self or
-  // eRestyle_Subtree is also set, since those imply a superset of the
+  // contexts on the descendants.  (Irrelevant if |Self| or
+  // |Subtree| is also set, since those imply a superset of the
   // work.)  Supported only for element style contexts and not for
-  // pseudo-elements or anonymous boxes, on which it converts to
-  // eRestyle_Self.
+  // pseudo-elements or anonymous boxes, on which it converts to |Self|.
   // If the change is for the advance of a declarative animation, use
   // the value below instead.
-  eRestyle_StyleAttribute = 1 << 7,
+  StyleAttribute = 1 << 7,
 
-  // Same as eRestyle_StyleAttribute, but for when the change results
+  // Same as |StyleAttribute|, but for when the change results
   // from the advance of a declarative animation.
-  eRestyle_StyleAttribute_Animations = 1 << 8,
+  StyleAttribute_Animations = 1 << 8,
 
   // Continue the restyling process to the current frame's children even
   // if this frame's restyling resulted in no style changes.
-  eRestyle_Force = 1 << 9,
+  Force = 1 << 9,
 
   // Continue the restyling process to all of the current frame's
   // descendants, even if any frame's restyling resulted in no style
-  // changes.  (Implies eRestyle_Force.)  Note that this is weaker than
-  // eRestyle_Subtree, which makes us rerun selector matching on all
+  // changes.  (Implies |Force|.)  Note that this is weaker than
+  // |Subtree|, which makes us rerun selector matching on all
   // descendants rather than just continuing the restyling process.
-  eRestyle_ForceDescendants = 1 << 10,
+  ForceDescendants = 1 << 10,
 
   // Useful unions:
-  eRestyle_AllHintsWithAnimations = eRestyle_CSSTransitions |
-                                    eRestyle_CSSAnimations |
-                                    eRestyle_SVGAttrAnimations |
-                                    eRestyle_StyleAttribute_Animations,
+  AllHintsWithAnimations = CSSTransitions |
+                           CSSAnimations |
+                           SVGAttrAnimations |
+                           StyleAttribute_Animations,
 };
 
-// The functions below need an integral type to cast to to avoid
-// infinite recursion.
-typedef decltype(nsRestyleHint(0) + nsRestyleHint(0)) nsRestyleHint_size_t;
-
-inline constexpr nsRestyleHint operator|(nsRestyleHint aLeft,
-                                             nsRestyleHint aRight)
-{
-  return nsRestyleHint(nsRestyleHint_size_t(aLeft) |
-                       nsRestyleHint_size_t(aRight));
-}
-
-inline constexpr nsRestyleHint operator&(nsRestyleHint aLeft,
-                                             nsRestyleHint aRight)
-{
-  return nsRestyleHint(nsRestyleHint_size_t(aLeft) &
-                       nsRestyleHint_size_t(aRight));
-}
-
-inline nsRestyleHint& operator|=(nsRestyleHint& aLeft, nsRestyleHint aRight)
-{
-  return aLeft = aLeft | aRight;
-}
-
-inline nsRestyleHint& operator&=(nsRestyleHint& aLeft, nsRestyleHint aRight)
-{
-  return aLeft = aLeft & aRight;
-}
-
-inline constexpr nsRestyleHint operator~(nsRestyleHint aArg)
-{
-  return nsRestyleHint(~nsRestyleHint_size_t(aArg));
-}
-
-inline constexpr nsRestyleHint operator^(nsRestyleHint aLeft,
-                                             nsRestyleHint aRight)
-{
-  return nsRestyleHint(nsRestyleHint_size_t(aLeft) ^
-                       nsRestyleHint_size_t(aRight));
-}
-
-inline nsRestyleHint operator^=(nsRestyleHint& aLeft, nsRestyleHint aRight)
-{
-  return aLeft = aLeft ^ aRight;
-}
+MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(nsRestyleHint)
 
 namespace mozilla {
 
 /**
  * Additional data used in conjunction with an nsRestyleHint to control the
  * restyle process.
  */
 struct RestyleHintData
 {
-  // When eRestyle_SomeDescendants is used, this array contains the selectors
-  // that identify which descendants will be restyled.
+  // When nsRestyleHint::SomeDescendants is used, this array contains the
+  // selectors that identify which descendants will be restyled.
   nsTArray<nsCSSSelector*> mSelectorsForDescendants;
 };
 
 } // namespace mozilla
 
 #endif /* nsChangeHint_h___ */
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -630,17 +630,17 @@ nsPresContext::AppUnitsPerDevPixelChange
   InvalidatePaintedLayers();
 
   if (mDeviceContext) {
     mDeviceContext->FlushFontCache();
   }
 
   if (HasCachedStyleData()) {
     // All cached style data must be recomputed.
-    MediaFeatureValuesChanged(eRestyle_ForceDescendants,
+    MediaFeatureValuesChanged(nsRestyleHint::ForceDescendants,
                               nsChangeHint::ReflowHints);
   }
 
   mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
 }
 
 void
 nsPresContext::PreferenceChanged(const char* aPrefName)
@@ -757,17 +757,17 @@ nsPresContext::UpdateAfterPreferencesCha
   nsChangeHint hint = nsChangeHint::None;
 
   if (mPrefChangePendingNeedsReflow) {
     hint |= nsChangeHint::ReflowHints;
   }
 
   // Preferences require rerunning selector matching because we rebuild
   // the pref style sheet for some preference changes.
-  RebuildAllStyleData(hint, eRestyle_Subtree);
+  RebuildAllStyleData(hint, nsRestyleHint::Subtree);
 }
 
 nsresult
 nsPresContext::Init(nsDeviceContext* aDeviceContext)
 {
   NS_ASSERTION(!mInitialized, "attempt to reinit pres context");
   NS_ENSURE_ARG(aDeviceContext);
 
@@ -1640,22 +1640,22 @@ nsPresContext::ThemeChangedInternal()
     // in bug 940625 we decided theme changes are rare enough not to bother.)
     image::SurfaceCacheUtils::DiscardAll();
   }
 
   // This will force the system metrics to be generated the next time they're used
   nsCSSRuleProcessor::FreeSystemMetrics();
 
   // Changes to system metrics can change media queries on them, or
-  // :-moz-system-metric selectors (which requires eRestyle_Subtree).
+  // :-moz-system-metric selectors (which requires nsRestyleHint::Subtree).
   // Changes in theme can change system colors (whose changes are
   // properly reflected in computed style data), system fonts (whose
   // changes are not), and -moz-appearance (whose changes likewise are
   // not), so we need to reflow.
-  MediaFeatureValuesChanged(eRestyle_Subtree, nsChangeHint::ReflowHints);
+  MediaFeatureValuesChanged(nsRestyleHint::Subtree, nsChangeHint::ReflowHints);
 
   // Recursively notify all remote leaf descendants that the
   // system theme has changed.
   nsContentUtils::CallOnAllRemoteChildren(mDocument->GetWindow(),
                                           NotifyThemeChanged, nullptr);
 }
 
 void
@@ -1866,30 +1866,30 @@ nsPresContext::MediaFeatureValuesChanged
   mPendingMediaFeatureValuesChanged = false;
 
   // MediumFeaturesChanged updates the applied rules, so it always gets called.
   if (mShell) {
     // XXXheycam ServoStyleSets don't support responding to medium
     // changes yet.
     if (mShell->StyleSet()->IsGecko()) {
       if (mShell->StyleSet()->AsGecko()->MediumFeaturesChanged()) {
-        aRestyleHint |= eRestyle_Subtree;
+        aRestyleHint |= nsRestyleHint::Subtree;
       }
     } else {
       NS_WARNING("stylo: ServoStyleSets don't support responding to medium "
                  "changes yet. See bug 1290228.");
     }
   }
 
   if (mUsesViewportUnits && mPendingViewportChange) {
     // Rebuild all style data without rerunning selector matching.
-    aRestyleHint |= eRestyle_ForceDescendants;
+    aRestyleHint |= nsRestyleHint::ForceDescendants;
   }
 
-  if (aRestyleHint || bool(aChangeHint)) {
+  if (bool(aRestyleHint) || bool(aChangeHint)) {
     RebuildAllStyleData(aChangeHint, aRestyleHint);
   }
 
   mPendingViewportChange = false;
 
   if (mDocument->IsBeingUsedAsImage()) {
     MOZ_ASSERT(PR_CLIST_IS_EMPTY(mDocument->MediaQueryLists()));
     return;
@@ -2074,27 +2074,27 @@ nsPresContext::UserFontSetUpdated(gfxUse
   // restyle to force updates with gfxPangoFontGroup usage
   // Note: this method is called without a font when rules in the userfont set
   // are updated, which may occur during reflow as a result of the lazy
   // initialization of the userfont set. It would be better to avoid a full
   // restyle but until this method is only called outside of reflow, schedule a
   // full restyle in these cases.
   if (!usePlatformFontList || !aUpdatedFont) {
     PostRebuildAllStyleDataEvent(nsChangeHint::ReflowHints,
-                                 eRestyle_ForceDescendants);
+                                 nsRestyleHint::ForceDescendants);
     return;
   }
 
   // Special case - if either the 'ex' or 'ch' units are used, these
   // depend upon font metrics. Updating this information requires
   // rebuilding the rule tree from the top, avoiding the reuse of cached
   // data even when no style rules have changed.
   if (UsesExChUnits()) {
     PostRebuildAllStyleDataEvent(nsChangeHint::None,
-                                 eRestyle_ForceDescendants);
+                                 nsRestyleHint::ForceDescendants);
   }
 
   // Iterate over the frame tree looking for frames associated with the
   // downloadable font family in question. If a frame's nsStyleFont has
   // the name, check the font group associated with the metrics to see if
   // it contains that specific font (i.e. the one chosen within the family
   // given the weight, width, and slant from the nsStyleFont). If it does,
   // mark that frame dirty and skip inspecting its descendants.
@@ -2115,17 +2115,17 @@ nsPresContext::FlushCounterStyles()
     return;
   }
 
   if (mCounterStylesDirty) {
     bool changed = mCounterStyleManager->NotifyRuleChanged();
     if (changed) {
       PresShell()->NotifyCounterStylesAreDirty();
       PostRebuildAllStyleDataEvent(nsChangeHint::ReflowHints,
-                                   eRestyle_ForceDescendants);
+                                   nsRestyleHint::ForceDescendants);
     }
     mCounterStylesDirty = false;
   }
 }
 
 void
 nsPresContext::RebuildCounterStyles()
 {
@@ -2163,17 +2163,17 @@ nsPresContext::EnsureSafeToHandOutCSSRul
     return;
   }
 
   if (!styleSet->EnsureUniqueInnerOnCSSSheets()) {
     // Nothing to do.
     return;
   }
 
-  RebuildAllStyleData(nsChangeHint::None, eRestyle_Subtree);
+  RebuildAllStyleData(nsChangeHint::None, nsRestyleHint::Subtree);
 }
 
 void
 nsPresContext::FireDOMPaintEvent(nsInvalidateRequestList* aList, uint64_t aTransactionId)
 {
   nsPIDOMWindowInner* ourWindow = mDocument->GetInnerWindow();
   if (!ourWindow)
     return;
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -270,23 +270,23 @@ public:
 
   /**
    * Handle changes in the values of media features (used in media
    * queries).
    *
    * There are three sensible values to use for aRestyleHint:
    *  * nsRestyleHint(0) to rebuild style data, with rerunning of
    *    selector matching, only if media features have changed
-   *  * eRestyle_ForceDescendants to force rebuilding of style data (but
+   *  * nsRestyleHint::ForceDescendants to force rebuilding of style data (but
    *    still only rerun selector matching if media query results have
    *    changed).  (RebuildAllStyleData always adds
-   *    eRestyle_ForceDescendants internally, so here we're only using
+   *    nsRestyleHint::ForceDescendants internally, so here we're only using
    *    it to distinguish from nsRestyleHint(0) whether we need to call
    *    RebuildAllStyleData at all.)
-   *  * eRestyle_Subtree to force rebuilding of style data with
+   *  * nsRestyleHint::Subtree to force rebuilding of style data with
    *    rerunning of selector matching
    *
    * For aChangeHint, see RestyleManager::RebuildAllStyleData.  (Passing
    * a nonzero aChangeHint forces rebuilding style data even if
    * nsRestyleHint(0) is passed.)
    */
   void MediaFeatureValuesChanged(nsRestyleHint aRestyleHint,
                                  nsChangeHint aChangeHint = nsChangeHint::None);
@@ -555,17 +555,17 @@ public:
     MOZ_ASSERT(aZoom > 0.0f, "invalid zoom factor");
     if (aZoom == mTextZoom)
       return;
 
     mTextZoom = aZoom;
     if (HasCachedStyleData()) {
       // Media queries could have changed, since we changed the meaning
       // of 'em' units in them.
-      MediaFeatureValuesChanged(eRestyle_ForceDescendants,
+      MediaFeatureValuesChanged(nsRestyleHint::ForceDescendants,
                                 nsChangeHint::ReflowHints);
     }
   }
 
   /**
    * Get the minimum font size for the specified language. If aLanguage
    * is nullptr, then the document's language is used.  This combines
    * the language-specific global preference with the per-presentation
@@ -591,17 +591,17 @@ public:
   void SetBaseMinFontSize(int32_t aMinFontSize) {
     if (aMinFontSize == mBaseMinFontSize)
       return;
 
     mBaseMinFontSize = aMinFontSize;
     if (HasCachedStyleData()) {
       // Media queries could have changed, since we changed the meaning
       // of 'em' units in them.
-      MediaFeatureValuesChanged(eRestyle_ForceDescendants,
+      MediaFeatureValuesChanged(nsRestyleHint::ForceDescendants,
                                 nsChangeHint::ReflowHints);
     }
   }
 
   float GetFullZoom() { return mFullZoom; }
   void SetFullZoom(float aZoom);
 
   float GetOverrideDPPX() { return mOverrideDPPX; }
--- a/layout/mathml/nsMathMLmtableFrame.cpp
+++ b/layout/mathml/nsMathMLmtableFrame.cpp
@@ -944,19 +944,21 @@ nsMathMLmtableFrame::SetInitialChildList
 }
 
 void
 nsMathMLmtableFrame::RestyleTable()
 {
   // re-sync MathML specific style data that may have changed
   MapAllAttributesIntoCSS(this);
 
-  // Explicitly request a re-resolve and reflow in our subtree to pick up any changes
+  // Explicitly request a re-resolve and reflow in our subtree to pick up any
+  // changes
   PresContext()->RestyleManager()->
-    PostRestyleEvent(mContent->AsElement(), eRestyle_Subtree,
+    PostRestyleEvent(mContent->AsElement(),
+                     nsRestyleHint::Subtree,
                      nsChangeHint::AllReflowHints);
 }
 
 nscoord
 nsMathMLmtableFrame::GetColSpacing(int32_t aColIndex)
 {
   if (mUseCSSSpacing) {
     return nsTableFrame::GetColSpacing(aColIndex);
--- a/layout/style/nsAnimationManager.cpp
+++ b/layout/style/nsAnimationManager.cpp
@@ -1017,17 +1017,17 @@ CSSAnimationBuilder::GetComputedValue(ns
   StyleAnimationValue computedValue;
 
   if (!mStyleWithoutAnimation) {
     MOZ_ASSERT(aPresContext->StyleSet()->IsGecko(),
                "ServoStyleSet should not use nsAnimationManager for "
                "animations");
     mStyleWithoutAnimation = aPresContext->StyleSet()->AsGecko()->
       ResolveStyleWithoutAnimation(mTarget, mStyleContext,
-                                   eRestyle_AllHintsWithAnimations);
+                                   nsRestyleHint::AllHintsWithAnimations);
   }
 
   if (StyleAnimationValue::ExtractComputedValue(aProperty,
                                                 mStyleWithoutAnimation,
                                                 computedValue)) {
     DebugOnly<bool> uncomputeResult =
       StyleAnimationValue::UncomputeValue(aProperty, Move(computedValue),
                                           result);
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2277,18 +2277,18 @@ nsCSSRuleProcessor::RestrictedSelectorMa
     nsCSSSelector* aSelector,
     TreeMatchContext& aTreeMatchContext)
 {
   MOZ_ASSERT(aSelector->IsRestrictedSelector(),
              "aSelector must not have a pseudo-element");
 
   NS_WARNING_ASSERTION(
     !HasPseudoClassSelectorArgsWithCombinators(aSelector),
-    "processing eRestyle_SomeDescendants can be slow if pseudo-classes with "
-    "selector arguments can now have combinators in them");
+    "processing nsRestyleHint::SomeDescendants can be slow if pseudo-classes "
+    "with selector arguments can now have combinators in them");
 
   // We match aSelector as if :visited and :link both match visited and
   // unvisited links.
 
   NodeMatchContext nodeContext(EventStates(),
                                nsCSSRuleProcessor::IsLink(aElement));
   if (nodeContext.mIsRelevantLink) {
     aTreeMatchContext.SetHaveRelevantLink();
@@ -2317,17 +2317,17 @@ nsCSSRuleProcessor::RestrictedSelectorMa
  * Flags for SelectorMatchesTree.
  */
 enum SelectorMatchesTreeFlags {
   // Whether we still have not found the closest ancestor link element and
   // thus have to check the current element for it.
   eLookForRelevantLink = 0x1,
 
   // Whether SelectorMatchesTree should check for, and return true upon
-  // finding, an ancestor element that has an eRestyle_SomeDescendants
+  // finding, an ancestor element that has an nsRestyleHint::SomeDescendants
   // restyle hint pending.
   eMatchOnConditionalRestyleAncestor = 0x2,
 };
 
 static bool
 SelectorMatchesTree(Element* aPrevElement,
                     nsCSSSelector* aSelector,
                     TreeMatchContext& aTreeMatchContext,
@@ -2400,24 +2400,24 @@ SelectorMatchesTree(Element* aPrevElemen
       }
     }
     if (!element) {
       return false;
     }
     if ((aFlags & eMatchOnConditionalRestyleAncestor) &&
         element->HasFlag(ELEMENT_IS_CONDITIONAL_RESTYLE_ANCESTOR)) {
       // If we're looking at an element that we already generated an
-      // eRestyle_SomeDescendants restyle hint for, then we should pretend
+      // nsRestyleHint::SomeDescendants restyle hint for, then we should pretend
       // that we matched here, because we don't know what the values of
       // attributes on |element| were at the time we generated the
-      // eRestyle_SomeDescendants.  This causes AttributeEnumFunc and
+      // nsRestyleHint::SomeDescendants.  This causes AttributeEnumFunc and
       // HasStateDependentStyle below to generate a restyle hint for the
       // change we're currently looking at, as we don't know whether the LHS
       // of the selector we looked up matches or not.  (We only pass in aFlags
-      // to cause us to look for eRestyle_SomeDescendants here under
+      // to cause us to look for nsRestyleHint::SomeDescendants here under
       // AttributeEnumFunc and HasStateDependentStyle.)
       return true;
     }
     const bool isRelevantLink = (aFlags & eLookForRelevantLink) &&
                                 nsCSSRuleProcessor::IsLink(element);
     NodeMatchContext nodeContext(EventStates(), isRelevantLink);
     if (isRelevantLink) {
       // If we find an ancestor of the matched node that is a link
@@ -2611,24 +2611,24 @@ nsCSSRuleProcessor::RulesMatching(XULTre
     }
   }
 }
 #endif
 
 static inline nsRestyleHint RestyleHintForOp(char16_t oper)
 {
   if (oper == char16_t('+') || oper == char16_t('~')) {
-    return eRestyle_LaterSiblings;
+    return nsRestyleHint::LaterSiblings;
   }
 
   if (oper != char16_t(0)) {
-    return eRestyle_Subtree;
+    return nsRestyleHint::Subtree;
   }
 
-  return eRestyle_Self;
+  return nsRestyleHint::Self;
 }
 
 nsRestyleHint
 nsCSSRuleProcessor::HasStateDependentStyle(ElementDependentRuleProcessorData* aData,
                                            Element* aStatefulElement,
                                            CSSPseudoElementType aPseudoType,
                                            EventStates aStateMask)
 {
@@ -2704,17 +2704,17 @@ nsCSSRuleProcessor::HasStateDependentSty
                                 nodeContext, aData->mTreeMatchContext,
                                 selectorFlags, nullptr, aStateMask)) &&
           SelectorMatches(aData->mElement, selector, nodeContext,
                           aData->mTreeMatchContext, selectorFlags) &&
           SelectorMatchesTree(aData->mElement, selector->mNext,
                               aData->mTreeMatchContext,
                               eMatchOnConditionalRestyleAncestor))
       {
-        hint = nsRestyleHint(hint | possibleChange);
+        hint |= possibleChange;
       }
     }
   }
   return hint;
 }
 
 nsRestyleHint
 nsCSSRuleProcessor::HasStateDependentStyle(StateRuleProcessorData* aData)
@@ -2758,65 +2758,66 @@ RestyleHintForSelectorWithAttributeChang
                                           nsCSSSelector* aSelector,
                                           nsCSSSelector* aRightmostSelector)
 {
   MOZ_ASSERT(aSelector);
 
   char16_t oper = aSelector->mOperator;
 
   if (oper == char16_t('+') || oper == char16_t('~')) {
-    return eRestyle_LaterSiblings;
+    return nsRestyleHint::LaterSiblings;
   }
 
   if (oper == char16_t(':')) {
-    return eRestyle_Subtree;
+    return nsRestyleHint::Subtree;
   }
 
   if (oper != char16_t(0)) {
     // Check whether the selector is in a form that supports
-    // eRestyle_SomeDescendants.  If it isn't, return eRestyle_Subtree.
-
-    if (aCurrentHint & eRestyle_Subtree) {
+    // nsRestyleHint::SomeDescendants.
+    // If it isn't, return nsRestyleHint::Subtree.
+
+    if (aCurrentHint & nsRestyleHint::Subtree) {
       // No point checking, since we'll end up restyling the whole
       // subtree anyway.
-      return eRestyle_Subtree;
+      return nsRestyleHint::Subtree;
     }
 
     if (!aRightmostSelector) {
       // aSelector wasn't a top-level selector, which means we were inside
       // a :not() or :-moz-any().  We don't support that.
-      return eRestyle_Subtree;
+      return nsRestyleHint::Subtree;
     }
 
     MOZ_ASSERT(aSelector != aRightmostSelector,
                "if aSelector == aRightmostSelector then we should have "
                "no operator");
 
     // Check that aRightmostSelector can be passed to RestrictedSelectorMatches.
     if (!aRightmostSelector->IsRestrictedSelector()) {
-      return eRestyle_Subtree;
+      return nsRestyleHint::Subtree;
     }
 
     // We also don't support pseudo-elements on any of the selectors
     // between aRightmostSelector and aSelector.
     // XXX Can we lift this restriction, so that we don't have to loop
     // over all the selectors?
     for (nsCSSSelector* sel = aRightmostSelector->mNext;
          sel != aSelector;
          sel = sel->mNext) {
       MOZ_ASSERT(sel, "aSelector must be reachable from aRightmostSelector");
       if (sel->PseudoType() != CSSPseudoElementType::NotPseudo) {
-        return eRestyle_Subtree;
+        return nsRestyleHint::Subtree;
       }
     }
 
-    return eRestyle_SomeDescendants;
+    return nsRestyleHint::SomeDescendants;
   }
 
-  return eRestyle_Self;
+  return nsRestyleHint::Self;
 }
 
 static void
 AttributeEnumFunc(nsCSSSelector* aSelector,
                   nsCSSSelector* aRightmostSelector,
                   AttributeEnumData* aData)
 {
   AttributeRuleProcessorData *data = aData->data;
@@ -2827,31 +2828,32 @@ AttributeEnumFunc(nsCSSSelector* aSelect
     // of the selector matching is not in its scope.
     return;
   }
 
   nsRestyleHint possibleChange =
     RestyleHintForSelectorWithAttributeChange(aData->change,
                                               aSelector, aRightmostSelector);
 
-  // If, ignoring eRestyle_SomeDescendants, enumData->change already includes
-  // all the bits of possibleChange, don't bother calling SelectorMatches, since
-  // even if it returns false enumData->change won't change.  If possibleChange
-  // has eRestyle_SomeDescendants, we need to call SelectorMatches(Tree)
-  // regardless as it might give us new selectors to append to
-  // mSelectorsForDescendants.
+  // If, ignoring nsRestyleHint::SomeDescendants, enumData->change already
+  // includes all the bits of possibleChange, don't bother calling
+  // SelectorMatches, since even if it returns false enumData->change won't
+  // change.  If possibleChange has nsRestyleHint::SomeDescendants, we need
+  // to call SelectorMatches(Tree) regardless as it might give us new
+  // selectors to append to mSelectorsForDescendants.
   NodeMatchContext nodeContext(EventStates(), false);
-  if (((possibleChange & (~(aData->change) | eRestyle_SomeDescendants))) &&
+  if (((possibleChange &
+          (~(aData->change) | nsRestyleHint::SomeDescendants))) &&
       SelectorMatches(data->mElement, aSelector, nodeContext,
                       data->mTreeMatchContext, SelectorMatchesFlags::UNKNOWN) &&
       SelectorMatchesTree(data->mElement, aSelector->mNext,
                           data->mTreeMatchContext,
                           eMatchOnConditionalRestyleAncestor)) {
-    aData->change = nsRestyleHint(aData->change | possibleChange);
-    if (possibleChange & eRestyle_SomeDescendants) {
+    aData->change |= possibleChange;
+    if (possibleChange & nsRestyleHint::SomeDescendants) {
       aData->hintData.mSelectorsForDescendants.AppendElement(aRightmostSelector);
     }
   }
 }
 
 static MOZ_ALWAYS_INLINE void
 EnumerateSelectors(nsTArray<SelectorPair>& aSelectors, AttributeEnumData* aData)
 {
@@ -2886,25 +2888,25 @@ nsCSSRuleProcessor::HasAttributeDependen
   // hasn't changed yet.
   if (aData->mAttrHasChanged) {
     // check for the lwtheme and lwthemetextcolor attribute on root XUL elements
     if ((aData->mAttribute == nsGkAtoms::lwtheme ||
          aData->mAttribute == nsGkAtoms::lwthemetextcolor) &&
         aData->mElement->GetNameSpaceID() == kNameSpaceID_XUL &&
         aData->mElement == aData->mElement->OwnerDoc()->GetRootElement())
       {
-        data.change = nsRestyleHint(data.change | eRestyle_Subtree);
+        data.change |= nsRestyleHint::Subtree;
       }
 
     // We don't know the namespace of the attribute, and xml:lang applies to
     // all elements.  If the lang attribute changes, we need to restyle our
     // whole subtree, since the :lang selector on our descendants can examine
     // our lang attribute.
     if (aData->mAttribute == nsGkAtoms::lang) {
-      data.change = nsRestyleHint(data.change | eRestyle_Subtree);
+      data.change |= nsRestyleHint::Subtree;
     }
   }
 
   RuleCascadeData* cascade = GetRuleCascade(aData->mPresContext);
 
   // Since we get both before and after notifications for attributes, we
   // don't have to ignore aData->mAttribute while matching.  Just check
   // whether we have selectors relevant to aData->mAttribute that we
--- a/layout/style/nsHTMLCSSStyleSheet.cpp
+++ b/layout/style/nsHTMLCSSStyleSheet.cpp
@@ -150,17 +150,17 @@ nsHTMLCSSStyleSheet::HasDocumentStateDep
 /* virtual */ nsRestyleHint
 nsHTMLCSSStyleSheet::HasAttributeDependentStyle(
     AttributeRuleProcessorData* aData,
     RestyleHintData& aRestyleHintDataResult)
 {
   // Perhaps should check that it's XUL, SVG, (or HTML) namespace, but
   // it doesn't really matter.
   if (aData->mAttrHasChanged && aData->mAttribute == nsGkAtoms::style) {
-    return eRestyle_StyleAttribute;
+    return nsRestyleHint::StyleAttribute;
   }
 
   return nsRestyleHint(0);
 }
 
 /* virtual */ bool
 nsHTMLCSSStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext)
 {
--- a/layout/style/nsHTMLStyleSheet.cpp
+++ b/layout/style/nsHTMLStyleSheet.cpp
@@ -366,17 +366,17 @@ nsHTMLStyleSheet::RulesMatching(ElementR
 /* virtual */ nsRestyleHint
 nsHTMLStyleSheet::HasStateDependentStyle(StateRuleProcessorData* aData)
 {
   if (aData->mElement->IsHTMLElement(nsGkAtoms::a) &&
       nsCSSRuleProcessor::IsLink(aData->mElement) &&
       ((mActiveRule && aData->mStateMask.HasState(NS_EVENT_STATE_ACTIVE)) ||
        (mLinkRule && aData->mStateMask.HasState(NS_EVENT_STATE_VISITED)) ||
        (mVisitedRule && aData->mStateMask.HasState(NS_EVENT_STATE_VISITED)))) {
-    return eRestyle_Self;
+    return nsRestyleHint::Self;
   }
   
   return nsRestyleHint(0);
 }
 
 /* virtual */ nsRestyleHint
 nsHTMLStyleSheet::HasStateDependentStyle(PseudoElementStateRuleProcessorData* aData)
 {
@@ -403,31 +403,31 @@ nsHTMLStyleSheet::HasAttributeDependentS
   // attribute here, because we handle that under HasStateDependentStyle() as
   // needed.
 
   // Result is true for |href| changes on HTML links if we have link rules.
   Element *element = aData->mElement;
   if (aData->mAttribute == nsGkAtoms::href &&
       (mLinkRule || mVisitedRule || mActiveRule) &&
       element->IsHTMLElement(nsGkAtoms::a)) {
-    return eRestyle_Self;
+    return nsRestyleHint::Self;
   }
 
   // Don't worry about the mDocumentColorRule since it only applies
   // to descendants of body, when we're already reresolving.
 
   // Handle the content style rules.
   if (element->IsAttributeMapped(aData->mAttribute)) {
     // cellpadding on tables is special and requires reresolving all
     // the cells in the table
     if (aData->mAttribute == nsGkAtoms::cellpadding &&
         element->IsHTMLElement(nsGkAtoms::table)) {
-      return eRestyle_Subtree;
+      return nsRestyleHint::Subtree;
     }
-    return eRestyle_Self;
+    return nsRestyleHint::Self;
   }
 
   return nsRestyleHint(0);
 }
 
 /* virtual */ bool
 nsHTMLStyleSheet::MediumFeaturesChanged(nsPresContext* aPresContext)
 {
@@ -493,17 +493,17 @@ nsHTMLStyleSheet::ImplLinkColorSetter(Re
 
   aRule->mColor = aColor;
   // Now make sure we restyle any links that might need it.  This
   // shouldn't happen often, so just rebuilding everything is ok.
   if (mDocument && mDocument->GetShell()) {
     Element* root = mDocument->GetRootElement();
     if (root) {
       mDocument->GetShell()->GetPresContext()->RestyleManager()->
-        PostRestyleEvent(root, eRestyle_Subtree, nsChangeHint::None);
+        PostRestyleEvent(root, nsRestyleHint::Subtree, nsChangeHint::None);
     }
   }
   return NS_OK;
 }
 
 nsresult
 nsHTMLStyleSheet::SetLinkColor(nscolor aColor)
 {
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -413,17 +413,17 @@ SortStyleSheetsByScope(nsTArray<CSSStyle
 nsresult
 nsStyleSet::GatherRuleProcessors(SheetType aType)
 {
   NS_ENSURE_FALSE(mInShutdown, NS_ERROR_FAILURE);
 
   // We might be in GatherRuleProcessors because we are dropping a sheet,
   // resulting in an nsCSSSelector being destroyed.  Tell the
   // RestyleManager for each document we're used in so that they can
-  // drop any nsCSSSelector pointers (used for eRestyle_SomeDescendants)
+  // drop any nsCSSSelector pointers (used for nsRestyleHint::SomeDescendants)
   // in their mPendingRestyles.
   if (IsCSSSheetType(aType)) {
     ClearSelectors();
   }
   nsCOMPtr<nsIStyleRuleProcessor> oldRuleProcessor(mRuleProcessors[aType]);
   nsTArray<nsCOMPtr<nsIStyleRuleProcessor>> oldScopedDocRuleProcessors;
   if (aType == SheetType::Agent || aType == SheetType::User) {
     // drop reference to cached rule processor
@@ -1473,31 +1473,31 @@ struct CascadeLevel {
   bool mCheckForImportantRules;
   nsRestyleHint mLevelReplacementHint;
 };
 
 static const CascadeLevel gCascadeLevels[] = {
   { SheetType::Agent,            false, false, nsRestyleHint(0) },
   { SheetType::User,             false, false, nsRestyleHint(0) },
   { SheetType::PresHint,         false, false, nsRestyleHint(0) },
-  { SheetType::SVGAttrAnimation, false, false, eRestyle_SVGAttrAnimations },
+  { SheetType::SVGAttrAnimation, false, false, nsRestyleHint::SVGAttrAnimations },
   { SheetType::Doc,              false, false, nsRestyleHint(0) },
   { SheetType::ScopedDoc,        false, false, nsRestyleHint(0) },
-  { SheetType::StyleAttr,        false, true,  eRestyle_StyleAttribute |
-                                               eRestyle_StyleAttribute_Animations },
+  { SheetType::StyleAttr,        false, true,  nsRestyleHint::StyleAttribute |
+                                               nsRestyleHint::StyleAttribute_Animations },
   { SheetType::Override,         false, false, nsRestyleHint(0) },
-  { SheetType::Animation,        false, false, eRestyle_CSSAnimations },
+  { SheetType::Animation,        false, false, nsRestyleHint::CSSAnimations },
   { SheetType::ScopedDoc,        true,  false, nsRestyleHint(0) },
   { SheetType::Doc,              true,  false, nsRestyleHint(0) },
-  { SheetType::StyleAttr,        true,  false, eRestyle_StyleAttribute |
-                                               eRestyle_StyleAttribute_Animations },
+  { SheetType::StyleAttr,        true,  false, nsRestyleHint::StyleAttribute |
+                                               nsRestyleHint::StyleAttribute_Animations },
   { SheetType::Override,         true,  false, nsRestyleHint(0) },
   { SheetType::User,             true,  false, nsRestyleHint(0) },
   { SheetType::Agent,            true,  false, nsRestyleHint(0) },
-  { SheetType::Transition,       false, false, eRestyle_CSSTransitions },
+  { SheetType::Transition,       false, false, nsRestyleHint::CSSTransitions },
 };
 
 nsRuleNode*
 nsStyleSet::RuleNodeWithReplacement(Element* aElement,
                                     Element* aPseudoElement,
                                     nsRuleNode* aOldRuleNode,
                                     CSSPseudoElementType aPseudoType,
                                     nsRestyleHint aReplacements)
@@ -1505,23 +1505,23 @@ nsStyleSet::RuleNodeWithReplacement(Elem
   NS_ASSERTION(mBatching == 0, "rule processors out of date");
 
   MOZ_ASSERT(!aPseudoElement ==
              (aPseudoType >= CSSPseudoElementType::Count ||
               !(nsCSSPseudoElements::PseudoElementSupportsStyleAttribute(aPseudoType) ||
                 nsCSSPseudoElements::PseudoElementSupportsUserActionState(aPseudoType))),
              "should have aPseudoElement only for certain pseudo elements");
 
-  MOZ_ASSERT(!(aReplacements & ~(eRestyle_CSSTransitions |
-                                 eRestyle_CSSAnimations |
-                                 eRestyle_SVGAttrAnimations |
-                                 eRestyle_StyleAttribute |
-                                 eRestyle_StyleAttribute_Animations |
-                                 eRestyle_Force |
-                                 eRestyle_ForceDescendants)),
+  MOZ_ASSERT(!(aReplacements & ~(nsRestyleHint::CSSTransitions |
+                                 nsRestyleHint::CSSAnimations |
+                                 nsRestyleHint::SVGAttrAnimations |
+                                 nsRestyleHint::StyleAttribute |
+                                 nsRestyleHint::StyleAttribute_Animations |
+                                 nsRestyleHint::Force |
+                                 nsRestyleHint::ForceDescendants)),
              "unexpected replacement bits");
 
   // FIXME (perf): This should probably not rebuild the whole path, but
   // only the path from the last change in the rule tree, like
   // ReplaceAnimationRule in nsStyleSet.cpp does.  (That could then
   // perhaps share this code, too?)
   // But if we do that, we'll need to pass whether we are rebuilding the
   // rule tree from ElementRestyler::RestyleSelf to avoid taking that
@@ -1547,17 +1547,17 @@ nsStyleSet::RuleNodeWithReplacement(Elem
   nsRuleNode* lastScopedRN = nullptr;
   nsRuleNode* lastStyleAttrRN = nullptr;
   bool haveImportantStyleAttrRules = false;
 
   for (const CascadeLevel *level = gCascadeLevels,
                        *levelEnd = ArrayEnd(gCascadeLevels);
        level != levelEnd; ++level) {
 
-    bool doReplace = level->mLevelReplacementHint & aReplacements;
+    bool doReplace = !!(level->mLevelReplacementHint & aReplacements);
 
     ruleWalker.SetLevel(level->mLevel, level->mIsImportant,
                         level->mCheckForImportantRules && doReplace);
 
     if (doReplace) {
       switch (level->mLevel) {
         case SheetType::Animation: {
           if (aPseudoType == CSSPseudoElementType::NotPseudo ||
@@ -1713,17 +1713,18 @@ nsStyleSet::ResolveStyleWithReplacement(
     // because at this point the parameter is more than just the element
     // for animation; it's also used for the SetBodyTextColor call when
     // it's the body element.
     // However, we only want to set the flag to call CheckAnimationRule
     // if we're dealing with a replacement (such as style attribute
     // replacement) that could lead to the animation property changing,
     // and we explicitly do NOT want to call CheckAnimationRule when
     // we're trying to do an animation-only update.
-    if (aReplacements & ~(eRestyle_CSSTransitions | eRestyle_CSSAnimations)) {
+    if (aReplacements &
+          ~(nsRestyleHint::CSSTransitions | nsRestyleHint::CSSAnimations)) {
       flags |= eDoAnimation;
     }
     elementForAnimation = aElement;
 #ifdef DEBUG
     {
       nsIFrame* styleFrame = nsLayoutUtils::GetStyleFrame(elementForAnimation);
       NS_ASSERTION(pseudoType == CSSPseudoElementType::NotPseudo ||
                    !styleFrame ||
@@ -2311,17 +2312,17 @@ struct MOZ_STACK_CLASS StatefulPseudoEle
   nsRestyleHint   mHint;
 };
 
 static bool SheetHasDocumentStateStyle(nsIStyleRuleProcessor* aProcessor,
                                          void *aData)
 {
   StatefulData* data = (StatefulData*)aData;
   if (aProcessor->HasDocumentStateDependentStyle(data)) {
-    data->mHint = eRestyle_Self;
+    data->mHint = nsRestyleHint::Self;
     return false; // don't continue
   }
   return true; // continue
 }
 
 // Test if style is dependent on a document state.
 bool
 nsStyleSet::HasDocumentStateDependentStyle(nsIContent*    aContent,
@@ -2331,34 +2332,34 @@ nsStyleSet::HasDocumentStateDependentSty
     return false;
 
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aContent->OwnerDoc());
   InitStyleScopes(treeContext, aContent->AsElement());
   StatefulData data(PresContext(), aContent->AsElement(), aStateMask,
                     treeContext);
   WalkRuleProcessors(SheetHasDocumentStateStyle, &data, true);
-  return data.mHint != 0;
+  return bool(data.mHint);
 }
 
 static bool SheetHasStatefulStyle(nsIStyleRuleProcessor* aProcessor,
                                     void *aData)
 {
   StatefulData* data = (StatefulData*)aData;
   nsRestyleHint hint = aProcessor->HasStateDependentStyle(data);
-  data->mHint = nsRestyleHint(data->mHint | hint);
+  data->mHint |= hint;
   return true; // continue
 }
 
 static bool SheetHasStatefulPseudoElementStyle(nsIStyleRuleProcessor* aProcessor,
                                                void *aData)
 {
   StatefulPseudoElementData* data = (StatefulPseudoElementData*)aData;
   nsRestyleHint hint = aProcessor->HasStateDependentStyle(data);
-  data->mHint = nsRestyleHint(data->mHint | hint);
+  data->mHint |= hint;
   return true; // continue
 }
 
 // Test if style is dependent on content state
 nsRestyleHint
 nsStyleSet::HasStateDependentStyle(Element*             aElement,
                                    EventStates          aStateMask)
 {
@@ -2400,17 +2401,17 @@ struct MOZ_STACK_CLASS AttributeData : p
 };
 
 static bool
 SheetHasAttributeStyle(nsIStyleRuleProcessor* aProcessor, void *aData)
 {
   AttributeData* data = (AttributeData*)aData;
   nsRestyleHint hint =
     aProcessor->HasAttributeDependentStyle(data, data->mHintData);
-  data->mHint = nsRestyleHint(data->mHint | hint);
+  data->mHint |= hint;
   return true; // continue
 }
 
 // Test if style is dependent on content state
 nsRestyleHint
 nsStyleSet::HasAttributeDependentStyle(Element*       aElement,
                                        int32_t        aNameSpaceID,
                                        nsIAtom*       aAttribute,
@@ -2421,17 +2422,17 @@ nsStyleSet::HasAttributeDependentStyle(E
                                          aRestyleHintDataResult)
 {
   TreeMatchContext treeContext(false, nsRuleWalker::eLinksVisitedOrUnvisited,
                                aElement->OwnerDoc());
   InitStyleScopes(treeContext, aElement);
   AttributeData data(PresContext(), aElement, aNameSpaceID, aAttribute,
                      aModType, aAttrHasChanged, aOtherValue, treeContext);
   WalkRuleProcessors(SheetHasAttributeStyle, &data, false);
-  if (!(data.mHint & eRestyle_Subtree)) {
+  if (!(data.mHint & nsRestyleHint::Subtree)) {
     // No point keeping the list of selectors around if we are going to
     // restyle the whole subtree unconditionally.
     aRestyleHintDataResult = Move(data.mHintData);
   }
   return data.mHint;
 }
 
 bool
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -517,17 +517,17 @@ nsTransitionManager::StyleContextChanged
   RefPtr<nsStyleContext> afterChangeStyle;
   if (collection) {
     MOZ_ASSERT(mPresContext->StyleSet()->IsGecko(),
                "ServoStyleSets should not use nsTransitionManager "
                "for transitions");
     nsStyleSet* styleSet = mPresContext->StyleSet()->AsGecko();
     afterChangeStyle =
       styleSet->ResolveStyleWithoutAnimation(aElement, newStyleContext,
-                                             eRestyle_CSSTransitions);
+                                             nsRestyleHint::CSSTransitions);
   } else {
     afterChangeStyle = newStyleContext;
   }
 
   nsAutoAnimationMutationBatch mb(aElement->OwnerDoc());
 
   DebugOnly<bool> startedAny = false;
   // We don't have to update transitions if display:none, although we will
--- a/layout/style/test/test_restyles_in_smil_animation.html
+++ b/layout/style/test/test_restyles_in_smil_animation.html
@@ -41,17 +41,17 @@ function observeStyling(frameCount) {
   docShell.recordProfileTimelineMarkers = true;
   docShell.popProfileTimelineMarkers();
 
   return new Promise(function(resolve) {
     return waitForAnimationFrames(frameCount).then(function() {
       var markers = docShell.popProfileTimelineMarkers();
       docShell.recordProfileTimelineMarkers = false;
       var stylingMarkers = markers.filter(function(marker, index) {
-        return marker.restyleHint == "eRestyle_SVGAttrAnimations";
+        return marker.restyleHint == "nsRestyleHint::SVGAttrAnimations";
       });
       resolve(stylingMarkers);
     });
   });
 }
 
 function ensureElementRemoval(aElement) {
   return new Promise(function(resolve) {