Bug 958375 - 8/9 - Make remaining Moz2D enums typed - r=Bas
authorBenoit Jacob <bjacob@mozilla.com>
Fri, 10 Jan 2014 14:06:17 -0500
changeset 167281 01dbbc492f157260cf4112bcddddb08e6d4e1351
parent 167280 a605e6378301c38ce4ee81260cc5b6c9779161b5
child 167282 63dbfbe6e47417346f47d7f38e67710cf1955d9b
push idunknown
push userunknown
push dateunknown
reviewersBas
bugs958375
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 958375 - 8/9 - Make remaining Moz2D enums typed - r=Bas Specifically: r=Bas for manual changes f=Bas for automatic changes See attachments on the bug for the specific breakdown.
content/canvas/src/CanvasGradient.h
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
content/svg/content/src/SVGPathData.cpp
content/svg/content/src/nsSVGPathGeometryElement.cpp
gfx/2d/2D.h
gfx/2d/BaseMargin.h
gfx/2d/DrawTargetCG.cpp
gfx/2d/DrawTargetCG.h
gfx/2d/DrawTargetCairo.cpp
gfx/2d/DrawTargetCairo.h
gfx/2d/DrawTargetD2D.cpp
gfx/2d/DrawTargetD2D.h
gfx/2d/DrawTargetD2D1.cpp
gfx/2d/DrawTargetD2D1.h
gfx/2d/DrawTargetDual.cpp
gfx/2d/DrawTargetDual.h
gfx/2d/DrawTargetRecording.cpp
gfx/2d/DrawTargetRecording.h
gfx/2d/DrawTargetSkia.cpp
gfx/2d/DrawTargetSkia.h
gfx/2d/FilterNodeD2D1.cpp
gfx/2d/FilterNodeSoftware.cpp
gfx/2d/HelpersCairo.h
gfx/2d/HelpersD2D.h
gfx/2d/HelpersSkia.h
gfx/2d/PathCG.cpp
gfx/2d/PathCG.h
gfx/2d/PathCairo.cpp
gfx/2d/PathCairo.h
gfx/2d/PathD2D.cpp
gfx/2d/PathD2D.h
gfx/2d/PathRecording.h
gfx/2d/PathSkia.cpp
gfx/2d/PathSkia.h
gfx/2d/RecordedEvent.cpp
gfx/2d/ScaledFontBase.cpp
gfx/2d/ScaledFontDWrite.cpp
gfx/2d/ScaledFontMac.cpp
gfx/2d/Tools.h
gfx/2d/Types.h
gfx/cairo/cairo/NEWS
gfx/cairo/cairo/src/cairo-qt-surface.cpp
gfx/cairo/cairo/src/cairo-script-surface.c
gfx/cairo/cairo/src/cairo-xml-surface.c
gfx/layers/Effects.h
gfx/layers/LayersLogging.cpp
gfx/layers/RotatedBuffer.cpp
gfx/layers/RotatedBuffer.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/client/ContentClient.cpp
gfx/layers/composite/ThebesLayerComposite.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d9/CompositorD3D9.cpp
gfx/layers/opengl/CompositorOGL.cpp
gfx/src/nsRect.cpp
gfx/thebes/gfx2DGlue.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxContext.h
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxGradientCache.cpp
gfx/thebes/gfxPattern.cpp
gfx/thebes/gfxPlatform.h
image/src/imgTools.cpp
layout/base/nsCSSRendering.cpp
layout/base/nsCSSRenderingBorders.cpp
widget/cocoa/nsChildView.mm
widget/gtk/nsWindow.cpp
--- a/content/canvas/src/CanvasGradient.h
+++ b/content/canvas/src/CanvasGradient.h
@@ -40,17 +40,17 @@ public:
   {
     if (mStops && mStops->GetBackendType() == aRT->GetType()) {
       return mStops;
     }
 
     mStops =
       gfx::gfxGradientCache::GetOrCreateGradientStops(aRT,
                                                       mRawStops,
-                                                      gfx::EXTEND_CLAMP);
+                                                      gfx::ExtendMode::CLAMP);
 
     return mStops;
   }
 
   // WebIDL
   void AddColorStop(float offset, const nsAString& colorstr, ErrorResult& rv);
 
   JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -245,19 +245,19 @@ public:
         CanvasUtils::DoDrawImageSecurityCheck(aCtx->mCanvasElement,
                                               state.patternStyles[aStyle]->mPrincipal,
                                               state.patternStyles[aStyle]->mForceWriteOnly,
                                               state.patternStyles[aStyle]->mCORSUsed);
       }
 
       ExtendMode mode;
       if (state.patternStyles[aStyle]->mRepeat == CanvasPattern::NOREPEAT) {
-        mode = EXTEND_CLAMP;
+        mode = ExtendMode::CLAMP;
       } else {
-        mode = EXTEND_REPEAT;
+        mode = ExtendMode::REPEAT;
       }
       mPattern = new (mSurfacePattern.addr())
         SurfacePattern(state.patternStyles[aStyle]->mSurface, mode);
     }
 
     return *mPattern;
   }
 
@@ -1376,32 +1376,32 @@ CanvasRenderingContext2D::SetStyleFromUn
 }
 
 void
 CanvasRenderingContext2D::SetFillRule(const nsAString& aString)
 {
   FillRule rule;
 
   if (aString.EqualsLiteral("evenodd"))
-    rule = FILL_EVEN_ODD;
+    rule = FillRule::FILL_EVEN_ODD;
   else if (aString.EqualsLiteral("nonzero"))
-    rule = FILL_WINDING;
+    rule = FillRule::FILL_WINDING;
   else
     return;
 
   CurrentState().fillRule = rule;
 }
 
 void
 CanvasRenderingContext2D::GetFillRule(nsAString& aString)
 {
   switch (CurrentState().fillRule) {
-  case FILL_WINDING:
+  case FillRule::FILL_WINDING:
     aString.AssignLiteral("nonzero"); break;
-  case FILL_EVEN_ODD:
+  case FillRule::FILL_EVEN_ODD:
     aString.AssignLiteral("evenodd"); break;
   }
 }
 //
 // gradients and patterns
 //
 already_AddRefed<CanvasGradient>
 CanvasRenderingContext2D::CreateLinearGradient(double x0, double y0, double x1, double y1)
@@ -1615,36 +1615,36 @@ CanvasRenderingContext2D::StrokeRect(dou
 
   if (NeedToDrawShadow()) {
     bounds = mgfx::Rect(x - state.lineWidth / 2.0f, y - state.lineWidth / 2.0f,
                         w + state.lineWidth, h + state.lineWidth);
     bounds = mTarget->GetTransform().TransformBounds(bounds);
   }
 
   if (!h) {
-    CapStyle cap = CAP_BUTT;
-    if (state.lineJoin == JOIN_ROUND) {
-      cap = CAP_ROUND;
+    CapStyle cap = CapStyle::BUTT;
+    if (state.lineJoin == JoinStyle::ROUND) {
+      cap = CapStyle::ROUND;
     }
     AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
       StrokeLine(Point(x, y), Point(x + w, y),
                   CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
                   StrokeOptions(state.lineWidth, state.lineJoin,
                                 cap, state.miterLimit,
                                 state.dash.Length(),
                                 state.dash.Elements(),
                                 state.dashOffset),
                   DrawOptions(state.globalAlpha, UsedOperation()));
     return;
   }
 
   if (!w) {
-    CapStyle cap = CAP_BUTT;
-    if (state.lineJoin == JOIN_ROUND) {
-      cap = CAP_ROUND;
+    CapStyle cap = CapStyle::BUTT;
+    if (state.lineJoin == JoinStyle::ROUND) {
+      cap = CapStyle::ROUND;
     }
     AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
       StrokeLine(Point(x, y), Point(x, y + h),
                   CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
                   StrokeOptions(state.lineWidth, state.lineJoin,
                                 cap, state.miterLimit,
                                 state.dash.Length(),
                                 state.dash.Elements(),
@@ -1742,20 +1742,20 @@ void CanvasRenderingContext2D::DrawSyste
     Save();
 
     // set state to conforming focus state
     ContextState& state = CurrentState();
     state.globalAlpha = 1.0;
     state.shadowBlur = 0;
     state.shadowOffset.x = 0;
     state.shadowOffset.y = 0;
-    state.op = mozilla::gfx::OP_OVER;
-
-    state.lineCap = CAP_BUTT;
-    state.lineJoin = mozilla::gfx::JOIN_MITER_OR_BEVEL;
+    state.op = mozilla::gfx::CompositionOp::OP_OVER;
+
+    state.lineCap = CapStyle::BUTT;
+    state.lineJoin = mozilla::gfx::JoinStyle::MITER_OR_BEVEL;
     state.lineWidth = 1;
     CurrentState().dash.Clear();
 
     // color and style of the rings is the same as for image maps
     // set the background focus color
     CurrentState().SetColorStyle(STYLE_STROKE, NS_RGBA(255, 255, 255, 255));
     // draw the focus ring
     Stroke();
@@ -1958,17 +1958,17 @@ CanvasRenderingContext2D::EnsureWritable
   }
 }
 
 void
 CanvasRenderingContext2D::EnsureUserSpacePath(const CanvasWindingRule& winding)
 {
   FillRule fillRule = CurrentState().fillRule;
   if(winding == CanvasWindingRule::Evenodd)
-    fillRule = FILL_EVEN_ODD;
+    fillRule = FillRule::FILL_EVEN_ODD;
 
   if (!mPath && !mPathBuilder && !mDSPathBuilder) {
     EnsureTarget();
     mPathBuilder = mTarget->CreatePathBuilder(fillRule);
   }
 
   if (mPathBuilder) {
     mPath = mPathBuilder->Finish();
@@ -2835,75 +2835,75 @@ gfxFontGroup *CanvasRenderingContext2D::
 //
 
 void
 CanvasRenderingContext2D::SetLineCap(const nsAString& capstyle)
 {
   CapStyle cap;
 
   if (capstyle.EqualsLiteral("butt")) {
-    cap = CAP_BUTT;
+    cap = CapStyle::BUTT;
   } else if (capstyle.EqualsLiteral("round")) {
-    cap = CAP_ROUND;
+    cap = CapStyle::ROUND;
   } else if (capstyle.EqualsLiteral("square")) {
-    cap = CAP_SQUARE;
+    cap = CapStyle::SQUARE;
   } else {
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     return;
   }
 
   CurrentState().lineCap = cap;
 }
 
 void
 CanvasRenderingContext2D::GetLineCap(nsAString& capstyle)
 {
   switch (CurrentState().lineCap) {
-  case CAP_BUTT:
+  case CapStyle::BUTT:
     capstyle.AssignLiteral("butt");
     break;
-  case CAP_ROUND:
+  case CapStyle::ROUND:
     capstyle.AssignLiteral("round");
     break;
-  case CAP_SQUARE:
+  case CapStyle::SQUARE:
     capstyle.AssignLiteral("square");
     break;
   }
 }
 
 void
 CanvasRenderingContext2D::SetLineJoin(const nsAString& joinstyle)
 {
   JoinStyle j;
 
   if (joinstyle.EqualsLiteral("round")) {
-    j = JOIN_ROUND;
+    j = JoinStyle::ROUND;
   } else if (joinstyle.EqualsLiteral("bevel")) {
-    j = JOIN_BEVEL;
+    j = JoinStyle::BEVEL;
   } else if (joinstyle.EqualsLiteral("miter")) {
-    j = JOIN_MITER_OR_BEVEL;
+    j = JoinStyle::MITER_OR_BEVEL;
   } else {
     // XXX ERRMSG we need to report an error to developers here! (bug 329026)
     return;
   }
 
   CurrentState().lineJoin = j;
 }
 
 void
 CanvasRenderingContext2D::GetLineJoin(nsAString& joinstyle, ErrorResult& error)
 {
   switch (CurrentState().lineJoin) {
-  case JOIN_ROUND:
+  case JoinStyle::ROUND:
     joinstyle.AssignLiteral("round");
     break;
-  case JOIN_BEVEL:
+  case JoinStyle::BEVEL:
     joinstyle.AssignLiteral("bevel");
     break;
-  case JOIN_MITER_OR_BEVEL:
+  case JoinStyle::MITER_OR_BEVEL:
     joinstyle.AssignLiteral("miter");
     break;
   default:
     error.Throw(NS_ERROR_FAILURE);
   }
 }
 
 void
@@ -3162,19 +3162,19 @@ CanvasRenderingContext2D::DrawImage(cons
     // XXX - Unresolved spec issues here, for now return error.
     error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
 
   Filter filter;
 
   if (CurrentState().imageSmoothingEnabled)
-    filter = mgfx::FILTER_LINEAR;
+    filter = mgfx::Filter::LINEAR;
   else
-    filter = mgfx::FILTER_POINT;
+    filter = mgfx::Filter::POINT;
 
   mgfx::Rect bounds;
 
   if (NeedToDrawShadow()) {
     bounds = mgfx::Rect(dx, dy, dw, dh);
     bounds = mTarget->GetTransform().TransformBounds(bounds);
   }
 
@@ -3187,39 +3187,39 @@ CanvasRenderingContext2D::DrawImage(cons
 
   RedrawUser(gfxRect(dx, dy, dw, dh));
 }
 
 #ifdef USE_SKIA_GPU
 static bool
 IsStandardCompositeOp(CompositionOp op)
 {
-    return (op == OP_SOURCE ||
-            op == OP_ATOP ||
-            op == OP_IN ||
-            op == OP_OUT ||
-            op == OP_OVER ||
-            op == OP_DEST_IN ||
-            op == OP_DEST_OUT ||
-            op == OP_DEST_OVER ||
-            op == OP_DEST_ATOP ||
-            op == OP_ADD ||
-            op == OP_XOR);
+    return (op == CompositionOp::OP_SOURCE ||
+            op == CompositionOp::OP_ATOP ||
+            op == CompositionOp::OP_IN ||
+            op == CompositionOp::OP_OUT ||
+            op == CompositionOp::OP_OVER ||
+            op == CompositionOp::OP_DEST_IN ||
+            op == CompositionOp::OP_DEST_OUT ||
+            op == CompositionOp::OP_DEST_OVER ||
+            op == CompositionOp::OP_DEST_ATOP ||
+            op == CompositionOp::OP_ADD ||
+            op == CompositionOp::OP_XOR);
 }
 #endif
 
 void
 CanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op,
                                                       ErrorResult& error)
 {
   CompositionOp comp_op;
 
 #define CANVAS_OP_TO_GFX_OP(cvsop, op2d) \
   if (op.EqualsLiteral(cvsop))   \
-    comp_op = OP_##op2d;
+    comp_op = CompositionOp::OP_##op2d;
 
   CANVAS_OP_TO_GFX_OP("copy", SOURCE)
   else CANVAS_OP_TO_GFX_OP("source-atop", ATOP)
   else CANVAS_OP_TO_GFX_OP("source-in", IN)
   else CANVAS_OP_TO_GFX_OP("source-out", OUT)
   else CANVAS_OP_TO_GFX_OP("source-over", OVER)
   else CANVAS_OP_TO_GFX_OP("destination-in", DEST_IN)
   else CANVAS_OP_TO_GFX_OP("destination-out", DEST_OUT)
@@ -3257,17 +3257,17 @@ CanvasRenderingContext2D::SetGlobalCompo
 
 void
 CanvasRenderingContext2D::GetGlobalCompositeOperation(nsAString& op,
                                                       ErrorResult& error)
 {
   CompositionOp comp_op = CurrentState().op;
 
 #define CANVAS_OP_TO_GFX_OP(cvsop, op2d) \
-  if (comp_op == OP_##op2d) \
+  if (comp_op == CompositionOp::OP_##op2d) \
     op.AssignLiteral(cvsop);
 
   CANVAS_OP_TO_GFX_OP("copy", SOURCE)
   else CANVAS_OP_TO_GFX_OP("destination-atop", DEST_ATOP)
   else CANVAS_OP_TO_GFX_OP("destination-in", DEST_IN)
   else CANVAS_OP_TO_GFX_OP("destination-out", DEST_OUT)
   else CANVAS_OP_TO_GFX_OP("destination-over", DEST_OVER)
   else CANVAS_OP_TO_GFX_OP("lighter", ADD)
@@ -3449,18 +3449,18 @@ CanvasRenderingContext2D::DrawWindow(nsG
     if (!source) {
       error.Throw(NS_ERROR_FAILURE);
       return;
     }
 
     mgfx::Rect destRect(0, 0, w, h);
     mgfx::Rect sourceRect(0, 0, sw, sh);
     mTarget->DrawSurface(source, destRect, sourceRect,
-                         DrawSurfaceOptions(mgfx::FILTER_POINT),
-                         DrawOptions(1.0f, OP_SOURCE, AA_NONE));
+                         DrawSurfaceOptions(mgfx::Filter::POINT),
+                         DrawOptions(1.0f, CompositionOp::OP_SOURCE, AntialiasMode::NONE));
     mTarget->Flush();
   } else {
     mTarget->SetTransform(matrix);
   }
 
   // note that x and y are coordinates in the document that
   // we're drawing; x and y are drawn to 0,0 in current user
   // space.
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -688,17 +688,17 @@ protected:
     return NS_GET_A(state.shadowColor) != 0 && 
       (state.shadowBlur != 0 || state.shadowOffset.x != 0 || state.shadowOffset.y != 0);
   }
 
   mozilla::gfx::CompositionOp UsedOperation()
   {
     if (NeedToDrawShadow()) {
       // In this case the shadow rendering will use the operator.
-      return mozilla::gfx::OP_OVER;
+      return mozilla::gfx::CompositionOp::OP_OVER;
     }
 
     return CurrentState().op;
   }
 
   /**
     * Gets the pres shell from either the canvas element or the doc shell
     */
@@ -754,20 +754,20 @@ protected:
   public:
     ContextState() : textAlign(TEXT_ALIGN_START),
                      textBaseline(TEXT_BASELINE_ALPHABETIC),
                      lineWidth(1.0f),
                      miterLimit(10.0f),
                      globalAlpha(1.0f),
                      shadowBlur(0.0),
                      dashOffset(0.0f),
-                     op(mozilla::gfx::OP_OVER),
-                     fillRule(mozilla::gfx::FILL_WINDING),
-                     lineCap(mozilla::gfx::CAP_BUTT),
-                     lineJoin(mozilla::gfx::JOIN_MITER_OR_BEVEL),
+                     op(mozilla::gfx::CompositionOp::OP_OVER),
+                     fillRule(mozilla::gfx::FillRule::FILL_WINDING),
+                     lineCap(mozilla::gfx::CapStyle::BUTT),
+                     lineJoin(mozilla::gfx::JoinStyle::MITER_OR_BEVEL),
                      imageSmoothingEnabled(true)
     { }
 
     ContextState(const ContextState& other)
         : fontGroup(other.fontGroup),
           font(other.font),
           textAlign(other.textAlign),
           textBaseline(other.textBaseline),
--- a/content/svg/content/src/SVGPathData.cpp
+++ b/content/svg/content/src/SVGPathData.cpp
@@ -812,17 +812,17 @@ SVGPathData::ToPathForLengthOrPositionMe
   // Since the path that we return will not be used for painting it doesn't
   // matter what we pass to BuildPath as aFillRule. Hawever, we do want to
   // pass something other than NS_STYLE_STROKE_LINECAP_SQUARE as aStrokeLineCap
   // to avoid the insertion of extra little lines (by
   // ApproximateZeroLengthSubpathSquareCaps), in which case the value that we
   // pass as aStrokeWidth doesn't matter (since it's only used to determine the
   // length of those extra little lines).
 
-  return BuildPath(FILL_WINDING, NS_STYLE_STROKE_LINECAP_BUTT, 0);
+  return BuildPath(FillRule::FILL_WINDING, NS_STYLE_STROKE_LINECAP_BUTT, 0);
 }
 
 static double
 AngleOfVector(const gfxPoint& aVector)
 {
   // C99 says about atan2 "A domain error may occur if both arguments are
   // zero" and "On a domain error, the function returns an implementation-
   // defined value". In the case of atan2 the implementation-defined value
--- a/content/svg/content/src/nsSVGPathGeometryElement.cpp
+++ b/content/svg/content/src/nsSVGPathGeometryElement.cpp
@@ -84,30 +84,30 @@ nsSVGPathGeometryElement::CreatePathBuil
   // with the path that we return.
 
   return drawTarget->CreatePathBuilder(GetFillRule());
 }
 
 FillRule
 nsSVGPathGeometryElement::GetFillRule()
 {
-  FillRule fillRule = FILL_WINDING; // Equivalent to NS_STYLE_FILL_RULE_NONZERO
+  FillRule fillRule = FillRule::FILL_WINDING; // Equivalent to NS_STYLE_FILL_RULE_NONZERO
 
   nsRefPtr<nsStyleContext> styleContext =
     nsComputedDOMStyle::GetStyleContextForElementNoFlush(this, nullptr,
                                                          nullptr);
   
   if (styleContext) {
     MOZ_ASSERT(styleContext->StyleSVG()->mFillRule ==
                                            NS_STYLE_FILL_RULE_NONZERO ||
                styleContext->StyleSVG()->mFillRule ==
                                            NS_STYLE_FILL_RULE_EVENODD);
 
     if (styleContext->StyleSVG()->mFillRule == NS_STYLE_FILL_RULE_EVENODD) {
-      fillRule = FILL_EVEN_ODD;
+      fillRule = FillRule::FILL_EVEN_ODD;
     }
   } else {
     // ReportToConsole
     NS_WARNING("Couldn't get style context for content in GetFillRule");
   }
 
   return fillRule;
 }
--- a/gfx/2d/2D.h
+++ b/gfx/2d/2D.h
@@ -73,26 +73,26 @@ struct NativeFont {
  * mAlpha         - Alpha value by which the mask generated by this operation is
  *                  multiplied.
  * mCompositionOp - The operator that indicates how the source and destination
  *                  patterns are blended.
  * mAntiAliasMode - The AntiAlias mode used for this drawing operation.
  */
 struct DrawOptions {
   DrawOptions(Float aAlpha = 1.0f,
-              CompositionOp aCompositionOp = OP_OVER,
-              AntialiasMode aAntialiasMode = AA_DEFAULT)
+              CompositionOp aCompositionOp = CompositionOp::OP_OVER,
+              AntialiasMode aAntialiasMode = AntialiasMode::DEFAULT)
     : mAlpha(aAlpha)
     , mCompositionOp(aCompositionOp)
     , mAntialiasMode(aAntialiasMode)
   {}
 
   Float mAlpha;
-  CompositionOp mCompositionOp : 8;
-  AntialiasMode mAntialiasMode : 3;
+  CompositionOp mCompositionOp;
+  AntialiasMode mAntialiasMode;
 };
 
 /*
  * This structure is used to send stroke options that are used in stroking
  * operations. It consists of the following:
  *
  * mLineWidth    - Width of the stroke in userspace.
  * mLineJoin     - Join style used for joining lines.
@@ -103,18 +103,18 @@ struct DrawOptions {
  *                 this StrokeOptions.
  *                 mDashPattern != null <=> mDashLength > 0.
  * mDashLength   - Number of on/off lengths in mDashPattern.
  * mDashOffset   - Userspace offset within mDashPattern at which stroking
  *                 begins.
  */
 struct StrokeOptions {
   StrokeOptions(Float aLineWidth = 1.0f,
-                JoinStyle aLineJoin = JOIN_MITER_OR_BEVEL,
-                CapStyle aLineCap = CAP_BUTT,
+                JoinStyle aLineJoin = JoinStyle::MITER_OR_BEVEL,
+                CapStyle aLineCap = CapStyle::BUTT,
                 Float aMiterLimit = 10.0f,
                 size_t aDashLength = 0,
                 const Float* aDashPattern = 0,
                 Float aDashOffset = 0.f)
     : mLineWidth(aLineWidth)
     , mMiterLimit(aMiterLimit)
     , mDashPattern(aDashLength > 0 ? aDashPattern : 0)
     , mDashLength(aDashLength)
@@ -125,38 +125,38 @@ struct StrokeOptions {
     MOZ_ASSERT(aDashLength == 0 || aDashPattern);
   }
 
   Float mLineWidth;
   Float mMiterLimit;
   const Float* mDashPattern;
   size_t mDashLength;
   Float mDashOffset;
-  JoinStyle mLineJoin : 4;
-  CapStyle mLineCap : 3;
+  JoinStyle mLineJoin;
+  CapStyle mLineCap;
 };
 
 /*
  * This structure supplies additional options for calls to DrawSurface.
  *
  * mFilter - Filter used when resampling source surface region to the
  *           destination region.
  * aSamplingBounds - This indicates whether the implementation is allowed
  *                   to sample pixels outside the source rectangle as
  *                   specified in DrawSurface on the surface.
  */
 struct DrawSurfaceOptions {
-  DrawSurfaceOptions(Filter aFilter = FILTER_LINEAR,
-                     SamplingBounds aSamplingBounds = SAMPLING_UNBOUNDED)
+  DrawSurfaceOptions(Filter aFilter = Filter::LINEAR,
+                     SamplingBounds aSamplingBounds = SamplingBounds::UNBOUNDED)
     : mFilter(aFilter)
     , mSamplingBounds(aSamplingBounds)
   { }
 
-  Filter mFilter : 3;
-  SamplingBounds mSamplingBounds : 1;
+  Filter mFilter;
+  SamplingBounds mSamplingBounds;
 };
 
 /*
  * This class is used to store gradient stops, it can only be used with a
  * matching DrawTarget. Not adhering to this condition will make a draw call
  * fail.
  */
 class GradientStops : public RefCounted<GradientStops>
@@ -189,17 +189,17 @@ protected:
 
 class ColorPattern : public Pattern
 {
 public:
   ColorPattern(const Color &aColor)
     : mColor(aColor)
   {}
 
-  virtual PatternType GetType() const { return PATTERN_COLOR; }
+  virtual PatternType GetType() const { return PatternType::COLOR; }
 
   Color mColor;
 };
 
 /*
  * This class is used for Linear Gradient Patterns, the gradient stops are
  * stored in a separate object and are backend dependent. This class itself
  * may be used on the stack.
@@ -221,17 +221,17 @@ public:
                         const Matrix &aMatrix = Matrix())
     : mBegin(aBegin)
     , mEnd(aEnd)
     , mStops(aStops)
     , mMatrix(aMatrix)
   {
   }
 
-  virtual PatternType GetType() const { return PATTERN_LINEAR_GRADIENT; }
+  virtual PatternType GetType() const { return PatternType::LINEAR_GRADIENT; }
 
   Point mBegin;
   Point mEnd;
   RefPtr<GradientStops> mStops;
   Matrix mMatrix;
 };
 
 /*
@@ -261,17 +261,17 @@ public:
     , mCenter2(aCenter2)
     , mRadius1(aRadius1)
     , mRadius2(aRadius2)
     , mStops(aStops)
     , mMatrix(aMatrix)
   {
   }
 
-  virtual PatternType GetType() const { return PATTERN_RADIAL_GRADIENT; }
+  virtual PatternType GetType() const { return PatternType::RADIAL_GRADIENT; }
 
   Point mCenter1;
   Point mCenter2;
   Float mRadius1;
   Float mRadius2;
   RefPtr<GradientStops> mStops;
   Matrix mMatrix;
 };
@@ -286,24 +286,24 @@ public:
   /*
    * aSourceSurface Surface to use for drawing
    * aExtendMode This determines how the image is extended outside the bounds
    *             of the image.
    * aMatrix A matrix that transforms the pattern into user space
    * aFilter Resampling filter used for resampling the image.
    */
   SurfacePattern(SourceSurface *aSourceSurface, ExtendMode aExtendMode,
-                 const Matrix &aMatrix = Matrix(), Filter aFilter = FILTER_GOOD)
+                 const Matrix &aMatrix = Matrix(), Filter aFilter = Filter::GOOD)
     : mSurface(aSourceSurface)
     , mExtendMode(aExtendMode)
     , mFilter(aFilter)
     , mMatrix(aMatrix)
   {}
 
-  virtual PatternType GetType() const { return PATTERN_SURFACE; }
+  virtual PatternType GetType() const { return PatternType::SURFACE; }
 
   RefPtr<SourceSurface> mSurface;
   ExtendMode mExtendMode;
   Filter mFilter;
   Matrix mMatrix;
 };
 
 /*
@@ -408,19 +408,19 @@ class Path : public RefCounted<Path>
 public:
   virtual ~Path();
   
   virtual BackendType GetBackendType() const = 0;
 
   /* This returns a PathBuilder object that contains a copy of the contents of
    * this path and is still writable.
    */
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const = 0;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const = 0;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
 
   /* This function checks if a point lies within a path. It allows passing a
    * transform that will transform the path to the coordinate space in which
    * aPoint is given.
    */
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const = 0;
 
 
@@ -858,32 +858,32 @@ public:
 
   /*
    * Create a path builder with the specified fillmode.
    *
    * We need the fill mode up front because of Direct2D.
    * ID2D1SimplifiedGeometrySink requires the fill mode
    * to be set before calling BeginFigure().
    */
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const = 0;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const = 0;
 
   /*
    * Create a GradientStops object that holds information about a set of
    * gradient stops, this object is required for linear or radial gradient
    * patterns to represent the color stops in the gradient.
    *
    * aStops An array of gradient stops
    * aNumStops Number of stops in the array aStops
    * aExtendNone This describes how to extend the stop color outside of the
    *             gradient area.
    */
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const = 0;
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const = 0;
 
   /*
    * Create a FilterNode object that can be used to apply a filter to various
    * inputs.
    *
    * aType Type of filter node to be created.
    */
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType) = 0;
--- a/gfx/2d/BaseMargin.h
+++ b/gfx/2d/BaseMargin.h
@@ -33,21 +33,21 @@ struct BaseMargin {
     top = aTop; right = aRight; bottom = aBottom; left = aLeft;
   }
 
   T LeftRight() const { return left + right; }
   T TopBottom() const { return top + bottom; }
 
   T& Side(SideT aSide) {
     // This is ugly!
-    return *(&top + aSide);
+    return *(&top + T(aSide));
   }
   T Side(SideT aSide) const {
     // This is ugly!
-    return *(&top + aSide);
+    return *(&top + T(aSide));
   }
 
   // Overloaded operators. Note that '=' isn't defined so we'll get the
   // compiler generated default assignment operator
   bool operator==(const Sub& aMargin) const {
     return top == aMargin.top && right == aMargin.right &&
            bottom == aMargin.bottom && left == aMargin.left;
   }
--- a/gfx/2d/DrawTargetCG.cpp
+++ b/gfx/2d/DrawTargetCG.cpp
@@ -32,92 +32,92 @@ static CGRect IntRectToCGRect(IntRect r)
 {
   return CGRectMake(r.x, r.y, r.width, r.height);
 }
 
 CGBlendMode ToBlendMode(CompositionOp op)
 {
   CGBlendMode mode;
   switch (op) {
-    case OP_OVER:
+    case CompositionOp::OP_OVER:
       mode = kCGBlendModeNormal;
       break;
-    case OP_ADD:
+    case CompositionOp::OP_ADD:
       mode = kCGBlendModePlusLighter;
       break;
-    case OP_ATOP:
+    case CompositionOp::OP_ATOP:
       mode = kCGBlendModeSourceAtop;
       break;
-    case OP_OUT:
+    case CompositionOp::OP_OUT:
       mode = kCGBlendModeSourceOut;
       break;
-    case OP_IN:
+    case CompositionOp::OP_IN:
       mode = kCGBlendModeSourceIn;
       break;
-    case OP_SOURCE:
+    case CompositionOp::OP_SOURCE:
       mode = kCGBlendModeCopy;
       break;
-    case OP_DEST_IN:
+    case CompositionOp::OP_DEST_IN:
       mode = kCGBlendModeDestinationIn;
       break;
-    case OP_DEST_OUT:
+    case CompositionOp::OP_DEST_OUT:
       mode = kCGBlendModeDestinationOut;
       break;
-    case OP_DEST_OVER:
+    case CompositionOp::OP_DEST_OVER:
       mode = kCGBlendModeDestinationOver;
       break;
-    case OP_DEST_ATOP:
+    case CompositionOp::OP_DEST_ATOP:
       mode = kCGBlendModeDestinationAtop;
       break;
-    case OP_XOR:
+    case CompositionOp::OP_XOR:
       mode = kCGBlendModeXOR;
       break;
-    case OP_MULTIPLY:
+    case CompositionOp::OP_MULTIPLY:
       mode = kCGBlendModeMultiply;
       break;
-    case OP_SCREEN:
+    case CompositionOp::OP_SCREEN:
       mode = kCGBlendModeScreen;
       break;
-    case OP_OVERLAY:
+    case CompositionOp::OP_OVERLAY:
       mode = kCGBlendModeOverlay;
       break;
-    case OP_DARKEN:
+    case CompositionOp::OP_DARKEN:
       mode = kCGBlendModeDarken;
       break;
-    case OP_LIGHTEN:
+    case CompositionOp::OP_LIGHTEN:
       mode = kCGBlendModeLighten;
       break;
-    case OP_COLOR_DODGE:
+    case CompositionOp::OP_COLOR_DODGE:
       mode = kCGBlendModeColorDodge;
       break;
-    case OP_COLOR_BURN:
+    case CompositionOp::OP_COLOR_BURN:
       mode = kCGBlendModeColorBurn;
       break;
-    case OP_HARD_LIGHT:
+    case CompositionOp::OP_HARD_LIGHT:
       mode = kCGBlendModeHardLight;
       break;
-    case OP_SOFT_LIGHT:
+    case CompositionOp::OP_SOFT_LIGHT:
       mode = kCGBlendModeSoftLight;
       break;
-    case OP_DIFFERENCE:
+    case CompositionOp::OP_DIFFERENCE:
       mode = kCGBlendModeDifference;
       break;
-    case OP_EXCLUSION:
+    case CompositionOp::OP_EXCLUSION:
       mode = kCGBlendModeExclusion;
       break;
-    case OP_HUE:
+    case CompositionOp::OP_HUE:
       mode = kCGBlendModeHue;
       break;
-    case OP_SATURATION:
+    case CompositionOp::OP_SATURATION:
       mode = kCGBlendModeSaturation;
       break;
-    case OP_COLOR:
+    case CompositionOp::OP_COLOR:
       mode = kCGBlendModeColor;
       break;
-    case OP_LUMINOSITY:
+    case CompositionOp::OP_LUMINOSITY:
       mode = kCGBlendModeLuminosity;
       break;
       /*
     case OP_CLEAR:
       mode = kCGBlendModeClear;
       break;*/
     default:
       mode = kCGBlendModeNormal;
@@ -125,21 +125,21 @@ CGBlendMode ToBlendMode(CompositionOp op
   return mode;
 }
 
 static CGInterpolationQuality
 InterpolationQualityFromFilter(Filter aFilter)
 {
   switch (aFilter) {
     default:
-    case FILTER_LINEAR:
+    case Filter::LINEAR:
       return kCGInterpolationLow;
-    case FILTER_POINT:
+    case Filter::POINT:
       return kCGInterpolationNone;
-    case FILTER_GOOD:
+    case Filter::GOOD:
       return kCGInterpolationDefault;
   }
 }
 
 
 DrawTargetCG::DrawTargetCG() : mCg(nullptr), mSnapshot(nullptr)
 {
 }
@@ -292,17 +292,17 @@ DrawTargetCG::DrawSurface(SourceSurface 
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
   CGImageRef image = GetRetainedImageFromSourceSurface(aSurface);
 
   /* we have two options here:
    *  - create a subimage -- this is slower
    *  - fancy things with clip and different dest rects */
   CGImageRef subimage = CGImageCreateWithImageInRect(image, RectToCGRect(aSource));
@@ -348,17 +348,17 @@ static CGColorRef ColorToCGColor(CGColor
 
 class GradientStopsCG : public GradientStops
 {
   public:
   //XXX: The skia backend uses a vector and passes in aNumStops. It should do better
   GradientStopsCG(GradientStop* aStops, uint32_t aNumStops, ExtendMode aExtendMode)
   {
     mExtend = aExtendMode;
-    if (aExtendMode == EXTEND_CLAMP) {
+    if (aExtendMode == ExtendMode::CLAMP) {
       //XXX: do the stops need to be in any particular order?
       // what should we do about the color space here? we certainly shouldn't be
       // recreating it all the time
       std::vector<CGFloat> colors;
       std::vector<CGFloat> offsets;
       colors.reserve(aNumStops*4);
       offsets.reserve(aNumStops);
 
@@ -600,51 +600,51 @@ DrawRadialRepeatingGradient(CGContextRef
   CGContextDrawRadialGradient(cg, gradient, startCenter, startRadius, endCenter, endRadius,
                               kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
   CGGradientRelease(gradient);
 }
 
 static void
 DrawGradient(CGContextRef cg, const Pattern &aPattern, const CGRect &aExtents)
 {
-  if (aPattern.GetType() == PATTERN_LINEAR_GRADIENT) {
+  if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
     const LinearGradientPattern& pat = static_cast<const LinearGradientPattern&>(aPattern);
     GradientStopsCG *stops = static_cast<GradientStopsCG*>(pat.mStops.get());
     CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(pat.mMatrix));
-    if (stops->mExtend == EXTEND_CLAMP) {
+    if (stops->mExtend == ExtendMode::CLAMP) {
 
       // XXX: we should take the m out of the properties of LinearGradientPatterns
       CGPoint startPoint = { pat.mBegin.x, pat.mBegin.y };
       CGPoint endPoint   = { pat.mEnd.x,   pat.mEnd.y };
 
       // Canvas spec states that we should avoid drawing degenerate gradients (XXX: should this be in common code?)
       //if (startPoint.x == endPoint.x && startPoint.y == endPoint.y)
       //  return;
 
       CGContextDrawLinearGradient(cg, stops->mGradient, startPoint, endPoint,
                                   kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
-    } else if (stops->mExtend == EXTEND_REPEAT) {
+    } else if (stops->mExtend == ExtendMode::REPEAT) {
       DrawLinearRepeatingGradient(cg, pat, aExtents);
     }
-  } else if (aPattern.GetType() == PATTERN_RADIAL_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
     const RadialGradientPattern& pat = static_cast<const RadialGradientPattern&>(aPattern);
     CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(pat.mMatrix));
     GradientStopsCG *stops = static_cast<GradientStopsCG*>(pat.mStops.get());
-    if (stops->mExtend == EXTEND_CLAMP) {
+    if (stops->mExtend == ExtendMode::CLAMP) {
 
       // XXX: we should take the m out of the properties of RadialGradientPatterns
       CGPoint startCenter = { pat.mCenter1.x, pat.mCenter1.y };
       CGFloat startRadius = pat.mRadius1;
       CGPoint endCenter   = { pat.mCenter2.x, pat.mCenter2.y };
       CGFloat endRadius   = pat.mRadius2;
 
       //XXX: are there degenerate radial gradients that we should avoid drawing?
       CGContextDrawRadialGradient(cg, stops->mGradient, startCenter, startRadius, endCenter, endRadius,
                                   kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
-    } else if (stops->mExtend == EXTEND_REPEAT) {
+    } else if (stops->mExtend == ExtendMode::REPEAT) {
       DrawRadialRepeatingGradient(cg, pat, aExtents);
     }
   } else {
     assert(0);
   }
 
 }
 
@@ -669,37 +669,37 @@ CGPatternCallbacks patternCallbacks = {
   0,
   drawPattern,
   releaseInfo
 };
 
 static bool
 isGradient(const Pattern &aPattern)
 {
-  return aPattern.GetType() == PATTERN_LINEAR_GRADIENT || aPattern.GetType() == PATTERN_RADIAL_GRADIENT;
+  return aPattern.GetType() == PatternType::LINEAR_GRADIENT || aPattern.GetType() == PatternType::RADIAL_GRADIENT;
 }
 
 /* CoreGraphics patterns ignore the userspace transform so
  * we need to multiply it in */
 static CGPatternRef
 CreateCGPattern(const Pattern &aPattern, CGAffineTransform aUserSpace)
 {
   const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
   // XXX: is .get correct here?
   CGImageRef image = GetRetainedImageFromSourceSurface(pat.mSurface.get());
   CGFloat xStep, yStep;
   switch (pat.mExtendMode) {
-    case EXTEND_CLAMP:
+    case ExtendMode::CLAMP:
       // The 1 << 22 comes from Webkit see Pattern::createPlatformPattern() in PatternCG.cpp for more info
       xStep = static_cast<CGFloat>(1 << 22);
       yStep = static_cast<CGFloat>(1 << 22);
       break;
-    case EXTEND_REFLECT:
+    case ExtendMode::REFLECT:
       assert(0);
-    case EXTEND_REPEAT:
+    case ExtendMode::REPEAT:
       xStep = static_cast<CGFloat>(CGImageGetWidth(image));
       yStep = static_cast<CGFloat>(CGImageGetHeight(image));
       // webkit uses wkCGPatternCreateWithImageAndTransform a wrapper around CGPatternCreateWithImage2
       // this is done to avoid pixel-cracking along pattern boundaries
       // (see https://bugs.webkit.org/show_bug.cgi?id=53055)
       // typedef enum {
       //    wkPatternTilingNoDistortion,
       //    wkPatternTilingConstantSpacingMinimalDistortion,
@@ -724,24 +724,24 @@ CreateCGPattern(const Pattern &aPattern,
   return CGPatternCreate(image, bounds, transform, xStep, yStep, kCGPatternTilingConstantSpacing,
                          true, &patternCallbacks);
 }
 
 static void
 SetFillFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &aPattern)
 {
   assert(!isGradient(aPattern));
-  if (aPattern.GetType() == PATTERN_COLOR) {
+  if (aPattern.GetType() == PatternType::COLOR) {
 
     const Color& color = static_cast<const ColorPattern&>(aPattern).mColor;
     //XXX: we should cache colors
     CGColorRef cgcolor = ColorToCGColor(aColorSpace, color);
     CGContextSetFillColorWithColor(cg, cgcolor);
     CGColorRelease(cgcolor);
-  } else if (aPattern.GetType() == PATTERN_SURFACE) {
+  } else if (aPattern.GetType() == PatternType::SURFACE) {
 
     CGColorSpaceRef patternSpace;
     patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetFillColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
     const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
@@ -751,23 +751,23 @@ SetFillFromPattern(CGContextRef cg, CGCo
     CGPatternRelease(pattern);
   }
 }
 
 static void
 SetStrokeFromPattern(CGContextRef cg, CGColorSpaceRef aColorSpace, const Pattern &aPattern)
 {
   assert(!isGradient(aPattern));
-  if (aPattern.GetType() == PATTERN_COLOR) {
+  if (aPattern.GetType() == PatternType::COLOR) {
     const Color& color = static_cast<const ColorPattern&>(aPattern).mColor;
     //XXX: we should cache colors
     CGColorRef cgcolor = ColorToCGColor(aColorSpace, color);
     CGContextSetStrokeColorWithColor(cg, cgcolor);
     CGColorRelease(cgcolor);
-  } else if (aPattern.GetType() == PATTERN_SURFACE) {
+  } else if (aPattern.GetType() == PatternType::SURFACE) {
     CGColorSpaceRef patternSpace;
     patternSpace = CGColorSpaceCreatePattern (nullptr);
     CGContextSetStrokeColorSpace(cg, patternSpace);
     CGColorSpaceRelease(patternSpace);
 
     CGPatternRef pattern = CreateCGPattern(aPattern, CGContextGetCTM(cg));
     const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
     CGContextSetInterpolationQuality(cg, InterpolationQualityFromFilter(pat.mFilter));
@@ -787,17 +787,17 @@ DrawTargetCG::MaskSurface(const Pattern 
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
   CGImageRef image = GetRetainedImageFromSourceSurface(aMask);
 
   // use a negative-y so that the mask image draws right ways up
   CGContextScaleCTM(cg, 1, -1);
 
   IntSize size = aMask->GetSize();
@@ -830,26 +830,26 @@ DrawTargetCG::FillRect(const Rect &aRect
 {
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
   if (isGradient(aPattern)) {
     CGContextClipToRect(cg, RectToCGRect(aRect));
     DrawGradient(cg, aPattern, RectToCGRect(aRect));
   } else {
-    if (aPattern.GetType() == PATTERN_SURFACE && static_cast<const SurfacePattern&>(aPattern).mExtendMode != EXTEND_REPEAT) {
+    if (aPattern.GetType() == PatternType::SURFACE && static_cast<const SurfacePattern&>(aPattern).mExtendMode != ExtendMode::REPEAT) {
       // SetFillFromPattern can handle this case but using CGContextDrawImage
       // should give us better performance, better output, smaller PDF and
       // matches what cairo does.
       const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
       CGImageRef image = GetRetainedImageFromSourceSurface(pat.mSurface.get());
       CGContextClipToRect(cg, RectToCGRect(aRect));
       CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(pat.mMatrix));
       CGContextTranslateCTM(cg, 0, CGImageGetHeight(image));
@@ -883,17 +883,17 @@ DrawTargetCG::StrokeLine(const Point &p1
 
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
   CGContextBeginPath(cg);
   CGContextMoveToPoint(cg, p1.x, p1.y);
   CGContextAddLineToPoint(cg, p2.x, p2.y);
 
@@ -926,17 +926,17 @@ DrawTargetCG::StrokeRect(const Rect &aRe
 
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
   SetStrokeOptions(cg, aStrokeOptions);
 
   if (isGradient(aPattern)) {
     // There's no CGContextClipStrokeRect so we do it by hand
@@ -979,17 +979,17 @@ DrawTargetCG::Stroke(const Path *aPath, 
 
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(mCg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
 
   CGContextBeginPath(cg);
 
   assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
@@ -1023,17 +1023,17 @@ DrawTargetCG::Fill(const Path *aPath, co
   assert(aPath->GetBackendType() == BackendType::COREGRAPHICS);
 
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
   CGContextBeginPath(cg);
   // XXX: we could put fill mode into the path fill rule if we wanted
   const PathCG *cgPath = static_cast<const PathCG*>(aPath);
 
   if (isGradient(aPattern)) {
@@ -1042,29 +1042,29 @@ DrawTargetCG::Fill(const Path *aPath, co
     if (CGPathIsEmpty(cgPath->GetPath())) {
       // Adding an empty path will cause us not to clip
       // so clip everything explicitly
       CGContextClipToRect(mCg, CGRectZero);
       extents = CGRectZero;
     } else {
       CGContextAddPath(cg, cgPath->GetPath());
       extents = CGContextGetPathBoundingBox(cg);
-      if (cgPath->GetFillRule() == FILL_EVEN_ODD)
+      if (cgPath->GetFillRule() == FillRule::FILL_EVEN_ODD)
         CGContextEOClip(mCg);
       else
         CGContextClip(mCg);
     }
 
     DrawGradient(cg, aPattern, extents);
   } else {
     CGContextAddPath(cg, cgPath->GetPath());
 
     SetFillFromPattern(cg, mColorSpace, aPattern);
 
-    if (cgPath->GetFillRule() == FILL_EVEN_ODD)
+    if (cgPath->GetFillRule() == FillRule::FILL_EVEN_ODD)
       CGContextEOFillPath(cg);
     else
       CGContextFillPath(cg);
   }
 
   fixer.Fix(mCg);
   CGContextRestoreGState(mCg);
 }
@@ -1101,19 +1101,19 @@ DrawTargetCG::FillGlyphs(ScaledFont *aFo
 
   assert(aBuffer.mNumGlyphs);
   CGContextSaveGState(mCg);
 
   CGContextSetBlendMode(mCg, ToBlendMode(aDrawOptions.mCompositionOp));
   UnboundnessFixer fixer;
   CGContextRef cg = fixer.Check(mCg, aDrawOptions.mCompositionOp);
   CGContextSetAlpha(cg, aDrawOptions.mAlpha);
-  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AA_NONE);
-  if (aDrawOptions.mAntialiasMode != AA_DEFAULT) {
-    CGContextSetShouldSmoothFonts(cg, aDrawOptions.mAntialiasMode == AA_SUBPIXEL);
+  CGContextSetShouldAntialias(cg, aDrawOptions.mAntialiasMode != AntialiasMode::NONE);
+  if (aDrawOptions.mAntialiasMode != AntialiasMode::DEFAULT) {
+    CGContextSetShouldSmoothFonts(cg, aDrawOptions.mAntialiasMode == AntialiasMode::SUBPIXEL);
   }
 
   CGContextConcatCTM(cg, GfxMatrixToCGAffineTransform(mTransform));
 
   ScaledFontMac* macFont = static_cast<ScaledFontMac*>(aFont);
 
   //XXX: we should use a stack vector here when we have a class like that
   std::vector<CGGlyph> glyphs;
@@ -1443,25 +1443,25 @@ DrawTargetCG::Mask(const Pattern &aSourc
 {
   MarkChanged();
 
   CGContextSaveGState(mCg);
 
   if (isGradient(aMask)) {
     assert(0);
   } else {
-    if (aMask.GetType() == PATTERN_COLOR) {
+    if (aMask.GetType() == PatternType::COLOR) {
       DrawOptions drawOptions(aDrawOptions);
       const Color& color = static_cast<const ColorPattern&>(aMask).mColor;
       drawOptions.mAlpha *= color.a;
       assert(0);
       // XXX: we need to get a rect that when transformed covers the entire surface
       //Rect
       //FillRect(rect, aSource, drawOptions);
-    } else if (aMask.GetType() == PATTERN_SURFACE) {
+    } else if (aMask.GetType() == PatternType::SURFACE) {
       const SurfacePattern& pat = static_cast<const SurfacePattern&>(aMask);
       CGImageRef mask = GetRetainedImageFromSourceSurface(pat.mSurface.get());
       Rect rect(0,0, CGImageGetWidth(mask), CGImageGetHeight(mask));
       // XXX: probably we need to do some flipping of the image or something
       CGContextClipToMask(mCg, RectToCGRect(rect), mask);
       FillRect(rect, aSource, aDrawOptions);
       CGImageRelease(mask);
     }
@@ -1506,17 +1506,17 @@ DrawTargetCG::PushClip(const Path *aPath
   /* We go through a bit of trouble to temporarilly set the transform
    * while we add the path. XXX: this could be improved if we keep
    * the CTM as resident state on the DrawTarget. */
   CGContextSaveGState(mCg);
   CGContextConcatCTM(mCg, GfxMatrixToCGAffineTransform(mTransform));
   CGContextAddPath(mCg, cgPath->GetPath());
   CGContextRestoreGState(mCg);
 
-  if (cgPath->GetFillRule() == FILL_EVEN_ODD)
+  if (cgPath->GetFillRule() == FillRule::FILL_EVEN_ODD)
     CGContextEOClip(mCg);
   else
     CGContextClip(mCg);
 }
 
 void
 DrawTargetCG::PopClip()
 {
--- a/gfx/2d/DrawTargetCG.h
+++ b/gfx/2d/DrawTargetCG.h
@@ -46,37 +46,37 @@ CGPointToPoint(CGPoint point)
   return Point(point.x, point.y);
 }
 
 static inline void
 SetStrokeOptions(CGContextRef cg, const StrokeOptions &aStrokeOptions)
 {
   switch (aStrokeOptions.mLineCap)
   {
-    case CAP_BUTT:
+    case CapStyle::BUTT:
       CGContextSetLineCap(cg, kCGLineCapButt);
       break;
-    case CAP_ROUND:
+    case CapStyle::ROUND:
       CGContextSetLineCap(cg, kCGLineCapRound);
       break;
-    case CAP_SQUARE:
+    case CapStyle::SQUARE:
       CGContextSetLineCap(cg, kCGLineCapSquare);
       break;
   }
 
   switch (aStrokeOptions.mLineJoin)
   {
-    case JOIN_BEVEL:
+    case JoinStyle::BEVEL:
       CGContextSetLineJoin(cg, kCGLineJoinBevel);
       break;
-    case JOIN_ROUND:
+    case JoinStyle::ROUND:
       CGContextSetLineJoin(cg, kCGLineJoinRound);
       break;
-    case JOIN_MITER:
-    case JOIN_MITER_OR_BEVEL:
+    case JoinStyle::MITER:
+    case JoinStyle::MITER_OR_BEVEL:
       CGContextSetLineJoin(cg, kCGLineJoinMiter);
       break;
   }
 
   CGContextSetLineWidth(cg, aStrokeOptions.mLineWidth);
   CGContextSetMiterLimit(cg, aStrokeOptions.mMiterLimit);
 
   // XXX: rename mDashLength to dashLength
@@ -142,17 +142,17 @@ public:
                     const DrawOptions &aOptions = DrawOptions());
   virtual void PushClip(const Path *);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromNativeSurface(const NativeSurface&) const { return nullptr;}
   virtual TemporaryRef<DrawTarget> CreateSimilarDrawTarget(const IntSize &, SurfaceFormat) const;
   virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule) const;
   virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *, uint32_t,
-                                                          ExtendMode aExtendMode = EXTEND_CLAMP) const;
+                                                          ExtendMode aExtendMode = ExtendMode::CLAMP) const;
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
 
   virtual void *GetNativeSurface(NativeSurfaceType);
 
   virtual IntSize GetSize() { return mSize; }
 
   virtual void SetPermitSubpixelAA(bool aPermitSubpixelAA) MOZ_OVERRIDE;
 
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -164,22 +164,22 @@ SupportsSelfCopy(cairo_surface_t* surfac
   }
 }
 
 static bool
 PatternIsCompatible(const Pattern& aPattern)
 {
   switch (aPattern.GetType())
   {
-    case PATTERN_LINEAR_GRADIENT:
+    case PatternType::LINEAR_GRADIENT:
     {
       const LinearGradientPattern& pattern = static_cast<const LinearGradientPattern&>(aPattern);
       return pattern.mStops->GetBackendType() == BackendType::CAIRO;
     }
-    case PATTERN_RADIAL_GRADIENT:
+    case PatternType::RADIAL_GRADIENT:
     {
       const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
       return pattern.mStops->GetBackendType() == BackendType::CAIRO;
     }
     default:
       return true;
   }
 }
@@ -256,17 +256,17 @@ public:
     : mSurface(nullptr)
   {
     Init(aSurface);
   }
 
   AutoClearDeviceOffset(const Pattern& aPattern)
     : mSurface(nullptr)
   {
-    if (aPattern.GetType() == PATTERN_SURFACE) {
+    if (aPattern.GetType() == PatternType::SURFACE) {
       const SurfacePattern& pattern = static_cast<const SurfacePattern&>(aPattern);
       Init(pattern.mSurface);
     }
   }
 
   ~AutoClearDeviceOffset()
   {
     if (mSurface) {
@@ -306,40 +306,40 @@ private:
 static cairo_pattern_t*
 GfxPatternToCairoPattern(const Pattern& aPattern, Float aAlpha)
 {
   cairo_pattern_t* pat;
   const Matrix* matrix = nullptr;
 
   switch (aPattern.GetType())
   {
-    case PATTERN_COLOR:
+    case PatternType::COLOR:
     {
       Color color = static_cast<const ColorPattern&>(aPattern).mColor;
       pat = cairo_pattern_create_rgba(color.r, color.g, color.b, color.a * aAlpha);
       break;
     }
 
-    case PATTERN_SURFACE:
+    case PatternType::SURFACE:
     {
       const SurfacePattern& pattern = static_cast<const SurfacePattern&>(aPattern);
       cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(pattern.mSurface);
 
       pat = cairo_pattern_create_for_surface(surf);
 
       matrix = &pattern.mMatrix;
 
       cairo_pattern_set_filter(pat, GfxFilterToCairoFilter(pattern.mFilter));
       cairo_pattern_set_extend(pat, GfxExtendToCairoExtend(pattern.mExtendMode));
 
       cairo_surface_destroy(surf);
 
       break;
     }
-    case PATTERN_LINEAR_GRADIENT:
+    case PatternType::LINEAR_GRADIENT:
     {
       const LinearGradientPattern& pattern = static_cast<const LinearGradientPattern&>(aPattern);
 
       pat = cairo_pattern_create_linear(pattern.mBegin.x, pattern.mBegin.y,
                                         pattern.mEnd.x, pattern.mEnd.y);
 
       MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
       GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
@@ -352,17 +352,17 @@ GfxPatternToCairoPattern(const Pattern& 
         const GradientStop& stop = stops[i];
         cairo_pattern_add_color_stop_rgba(pat, stop.offset, stop.color.r,
                                           stop.color.g, stop.color.b,
                                           stop.color.a);
       }
 
       break;
     }
-    case PATTERN_RADIAL_GRADIENT:
+    case PatternType::RADIAL_GRADIENT:
     {
       const RadialGradientPattern& pattern = static_cast<const RadialGradientPattern&>(aPattern);
 
       pat = cairo_pattern_create_radial(pattern.mCenter1.x, pattern.mCenter1.y, pattern.mRadius1,
                                         pattern.mCenter2.x, pattern.mCenter2.y, pattern.mRadius2);
 
       MOZ_ASSERT(pattern.mStops->GetBackendType() == BackendType::CAIRO);
       GradientStopsCairo* cairoStops = static_cast<GradientStopsCairo*>(pattern.mStops.get());
@@ -400,17 +400,17 @@ GfxPatternToCairoPattern(const Pattern& 
   return pat;
 }
 
 static bool
 NeedIntermediateSurface(const Pattern& aPattern, const DrawOptions& aOptions)
 {
   // We pre-multiply colours' alpha by the global alpha, so we don't need to
   // use an intermediate surface for them.
-  if (aPattern.GetType() == PATTERN_COLOR)
+  if (aPattern.GetType() == PatternType::COLOR)
     return false;
 
   if (aOptions.mAlpha == 1.0)
     return false;
 
   return true;
 }
 
@@ -1005,27 +1005,27 @@ DrawTargetCairo::PopClip()
 
   cairo_set_matrix(mContext, &mat);
 
   MOZ_ASSERT(GetTransform() == Matrix(mat.xx, mat.yx, mat.xy, mat.yy, mat.x0, mat.y0),
              "Transforms are out of sync");
 }
 
 TemporaryRef<PathBuilder>
-DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FILL_WINDING */) const
+DrawTargetCairo::CreatePathBuilder(FillRule aFillRule /* = FillRule::FILL_WINDING */) const
 {
   RefPtr<PathBuilderCairo> builder = new PathBuilderCairo(aFillRule);
 
   return builder;
 }
 
 void
 DrawTargetCairo::ClearSurfaceForUnboundedSource(const CompositionOp &aOperator)
 {
-  if (aOperator != OP_SOURCE)
+  if (aOperator != CompositionOp::OP_SOURCE)
     return;
   cairo_set_operator(mContext, CAIRO_OPERATOR_CLEAR);
   // It doesn't really matter what the source is here, since Paint
   // isn't bounded by the source and the mask covers the entire clip
   // region.
   cairo_paint(mContext);
 }
 
--- a/gfx/2d/DrawTargetCairo.h
+++ b/gfx/2d/DrawTargetCairo.h
@@ -125,17 +125,17 @@ public:
                            SourceSurface *aMask,
                            Point aOffset,
                            const DrawOptions &aOptions = DrawOptions());
 
   virtual void PushClip(const Path *aPath);
   virtual void PushClipRect(const Rect &aRect);
   virtual void PopClip();
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual TemporaryRef<SourceSurface> CreateSourceSurfaceFromData(unsigned char *aData,
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const;
   virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
   virtual TemporaryRef<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const;
@@ -143,17 +143,17 @@ public:
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
   virtual TemporaryRef<DrawTarget>
     CreateShadowDrawTarget(const IntSize &aSize, SurfaceFormat aFormat,
                            float aSigma) const;
 
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const;
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
 
   virtual void *GetNativeSurface(NativeSurfaceType aType);
 
   bool Init(cairo_surface_t* aSurface, const IntSize& aSize);
   bool Init(const IntSize& aSize, SurfaceFormat aFormat);
   bool Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
--- a/gfx/2d/DrawTargetD2D.cpp
+++ b/gfx/2d/DrawTargetD2D.cpp
@@ -576,17 +576,17 @@ DrawTargetD2D::DrawSurfaceWithShadow(Sou
     viewport.TopLeftX = 0;
     viewport.TopLeftY = 0;
 
     mDevice->RSSetViewports(1, &viewport);
     mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(srView);
     mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->
       GetPassByIndex(0)->Apply(0);
 
-    mDevice->OMSetBlendState(GetBlendStateForOperator(OP_OVER), nullptr, 0xffffffff);
+    mDevice->OMSetBlendState(GetBlendStateForOperator(CompositionOp::OP_OVER), nullptr, 0xffffffff);
 
     mDevice->Draw(4, 0);
     
     srcSurfSize = dsSize;
 
     srView = dsSRView;
   } else {
     // In this case generate a kernel to draw the blur directly to the temp
@@ -951,17 +951,17 @@ DrawTargetD2D::Fill(const Path *aPath,
 
   RefPtr<ID2D1Brush> brush = CreateBrushForPattern(aPattern, aOptions.mAlpha);
 
   if (brush) {
     rt->FillGeometry(d2dPath->mGeometry, brush);
   }
 
   Rect bounds;
-  if (aOptions.mCompositionOp != OP_OVER) {
+  if (aOptions.mCompositionOp != CompositionOp::OP_OVER) {
     D2D1_RECT_F d2dbounds;
     d2dPath->mGeometry->GetBounds(D2D1::IdentityMatrix(), &d2dbounds);
     bounds = ToRect(d2dbounds);
   }
   FinalizeRTForOperation(aOptions.mCompositionOp, aPattern, bounds);
 }
 
 void
@@ -986,44 +986,44 @@ DrawTargetD2D::FillGlyphs(ScaledFont *aF
       MOZ_ASSERT(false);
     } else {
       params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderOptions)->mParams;
     }
   }
 
   AntialiasMode aaMode = font->GetDefaultAAMode();
 
-  if (aOptions.mAntialiasMode != AA_DEFAULT) {
+  if (aOptions.mAntialiasMode != AntialiasMode::DEFAULT) {
     aaMode = aOptions.mAntialiasMode;
   }
 
   if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
-      aOptions.mCompositionOp == OP_OVER && aPattern.GetType() == PATTERN_COLOR &&
-      aaMode == AA_SUBPIXEL) {
+      aOptions.mCompositionOp == CompositionOp::OP_OVER && aPattern.GetType() == PatternType::COLOR &&
+      aaMode == AntialiasMode::SUBPIXEL) {
     if (FillGlyphsManual(font, aBuffer,
                          static_cast<const ColorPattern*>(&aPattern)->mColor,
                          params, aOptions)) {
       return;
     }
   }
 
   ID2D1RenderTarget *rt = GetRTForOperation(aOptions.mCompositionOp, aPattern);
 
   PrepareForDrawing(rt);
 
   D2D1_TEXT_ANTIALIAS_MODE d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
 
   switch (aaMode) {
-  case AA_NONE:
+  case AntialiasMode::NONE:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
     break;
-  case AA_GRAY:
+  case AntialiasMode::GRAY:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
     break;
-  case AA_SUBPIXEL:
+  case AntialiasMode::SUBPIXEL:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
     break;
   default:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
   }
 
   if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
       mFormat != SurfaceFormat::B8G8R8X8) {
@@ -1238,17 +1238,17 @@ DrawTargetD2D::CreatePathBuilder(FillRul
 
   RefPtr<ID2D1GeometrySink> sink;
   hr = path->Open(byRef(sink));
   if (FAILED(hr)) {
     gfxWarning() << "Failed to access Direct2D Path Geometry. Code: " << hr;
     return nullptr;
   }
 
-  if (aFillRule == FILL_WINDING) {
+  if (aFillRule == FillRule::FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   return new PathBuilderD2D(sink, path, aFillRule);
 }
 
 TemporaryRef<GradientStops>
 DrawTargetD2D::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, ExtendMode aExtendMode) const
@@ -1556,53 +1556,53 @@ DrawTargetD2D::GetBlendStateForOperator(
   memset(&desc, 0, sizeof(D3D10_BLEND_DESC));
 
   desc.AlphaToCoverageEnable = FALSE;
   desc.BlendEnable[0] = TRUE;
   desc.RenderTargetWriteMask[0] = D3D10_COLOR_WRITE_ENABLE_ALL;
   desc.BlendOp = desc.BlendOpAlpha = D3D10_BLEND_OP_ADD;
 
   switch (aOperator) {
-  case OP_ADD:
+  case CompositionOp::OP_ADD:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_ONE;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_ONE;
     break;
-  case OP_IN:
+  case CompositionOp::OP_IN:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_ZERO;
     break;
-  case OP_OUT:
+  case CompositionOp::OP_OUT:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_ZERO;
     break;
-  case OP_ATOP:
+  case CompositionOp::OP_ATOP:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
     break;
-  case OP_DEST_IN:
+  case CompositionOp::OP_DEST_IN:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_ZERO;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_SRC_ALPHA;
     break;
-  case OP_DEST_OUT:
+  case CompositionOp::OP_DEST_OUT:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_ZERO;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
     break;
-  case OP_DEST_ATOP:
+  case CompositionOp::OP_DEST_ATOP:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_SRC_ALPHA;
     break;
-  case OP_DEST_OVER:
+  case CompositionOp::OP_DEST_OVER:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_ONE;
     break;
-  case OP_XOR:
+  case CompositionOp::OP_XOR:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_INV_DEST_ALPHA;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
     break;
-  case OP_SOURCE:
+  case CompositionOp::OP_SOURCE:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_ONE;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_ZERO;
     break;
   default:
     desc.SrcBlend = desc.SrcBlendAlpha = D3D10_BLEND_ONE;
     desc.DestBlend = desc.DestBlendAlpha = D3D10_BLEND_INV_SRC_ALPHA;
   }
   
@@ -1612,35 +1612,35 @@ DrawTargetD2D::GetBlendStateForOperator(
 }
 
 /* This function prepares the temporary RT for drawing and returns it when a
  * drawing operation other than OVER is required.
  */
 ID2D1RenderTarget*
 DrawTargetD2D::GetRTForOperation(CompositionOp aOperator, const Pattern &aPattern)
 {
-  if (aOperator == OP_OVER && IsPatternSupportedByD2D(aPattern)) {
+  if (aOperator == CompositionOp::OP_OVER && IsPatternSupportedByD2D(aPattern)) {
     return mRT;
   }
 
   PopAllClips();
 
-  if (aOperator > OP_XOR) {
+  if (aOperator > CompositionOp::OP_XOR) {
     mRT->Flush();
   }
 
   if (mTempRT) {
     mTempRT->Clear(D2D1::ColorF(0, 0));
     return mTempRT;
   }
 
   EnsureViews();
 
   if (!mRTView || !mSRView) {
-    gfxDebug() << *this << ": Failed to get required views. Defaulting to OP_OVER.";
+    gfxDebug() << *this << ": Failed to get required views. Defaulting to CompositionOp::OP_OVER.";
     return mRT;
   }
 
   mTempRT = CreateRTForTexture(mTempTexture, SurfaceFormat::B8G8R8A8);
 
   if (!mTempRT) {
     return mRT;
   }
@@ -1659,17 +1659,17 @@ DrawTargetD2D::GetRTForOperation(Composi
  * contents) to the rendertarget using the requested composition operation.
  * In order to respect clip for operations which are unbound by their mask,
  * the old content of the surface outside the clipped area may be blended back
  * to the surface.
  */
 void
 DrawTargetD2D::FinalizeRTForOperation(CompositionOp aOperator, const Pattern &aPattern, const Rect &aBounds)
 {
-  if (aOperator == OP_OVER && IsPatternSupportedByD2D(aPattern)) {
+  if (aOperator == CompositionOp::OP_OVER && IsPatternSupportedByD2D(aPattern)) {
     return;
   }
 
   if (!mTempRT) {
     return;
   }
 
   PopClipsFromRT(mTempRT);
@@ -1713,17 +1713,17 @@ DrawTargetD2D::FinalizeRTForOperation(Co
     SetFloatVector(ShaderConstantRectD3D10(-1.0f, 1.0f, 2.0f, -2.0f));
 
   if (IsPatternSupportedByD2D(aPattern)) {
     mPrivateData->mEffect->GetVariableByName("TexCoords")->AsVector()->
       SetFloatVector(ShaderConstantRectD3D10(0, 0, 1.0f, 1.0f));
     mPrivateData->mEffect->GetVariableByName("tex")->AsShaderResource()->SetResource(mSRView);
 
     // Handle the case where we blend with the backdrop
-    if (aOperator > OP_XOR) {
+    if (aOperator > CompositionOp::OP_XOR) {
       IntSize size = mSize;
       SurfaceFormat format = mFormat;
 
       CD3D10_TEXTURE2D_DESC desc(DXGIFormat(format), size.width, size.height, 1, 1);
       desc.BindFlags = D3D10_BIND_RENDER_TARGET | D3D10_BIND_SHADER_RESOURCE;
 
       HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(tmpTexture));
       if (FAILED(hr)) {
@@ -1741,35 +1741,35 @@ DrawTargetD2D::FinalizeRTForOperation(Co
 
       hr = mDevice->CreateShaderResourceView(tmpTexture, nullptr, byRef(mBckSRView));
 
       if (FAILED(hr)) {
         gfxWarning() << *this << "Failed to create shader resource view for temp texture. Code: " << hr;
         return;
       }
 
-      unsigned int compop = (unsigned int)aOperator - (unsigned int)OP_XOR;
+      unsigned int compop = (unsigned int)aOperator - (unsigned int)CompositionOp::OP_XOR;
       mPrivateData->mEffect->GetVariableByName("bcktex")->AsShaderResource()->SetResource(mBckSRView);
       mPrivateData->mEffect->GetVariableByName("blendop")->AsScalar()->SetInt(compop);
 
-      if (aOperator > OP_EXCLUSION)
+      if (aOperator > CompositionOp::OP_EXCLUSION)
         mPrivateData->mEffect->GetTechniqueByName("SampleTextureForNonSeparableBlending")->
           GetPassByIndex(0)->Apply(0);
-      else if (aOperator > OP_COLOR_DODGE)
+      else if (aOperator > CompositionOp::OP_COLOR_DODGE)
         mPrivateData->mEffect->GetTechniqueByName("SampleTextureForSeparableBlending_2")->
           GetPassByIndex(0)->Apply(0);
       else
         mPrivateData->mEffect->GetTechniqueByName("SampleTextureForSeparableBlending_1")->
           GetPassByIndex(0)->Apply(0);
     }
     else {
       mPrivateData->mEffect->GetTechniqueByName("SampleTexture")->GetPassByIndex(0)->Apply(0);
     }
 
-  } else if (aPattern.GetType() == PATTERN_RADIAL_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
     const RadialGradientPattern *pat = static_cast<const RadialGradientPattern*>(&aPattern);
 
     if (pat->mCenter1 == pat->mCenter2 && pat->mRadius1 == pat->mRadius2) {
       // Draw nothing!
       return;
     }
 
     mPrivateData->mEffect->GetVariableByName("mask")->AsShaderResource()->SetResource(mSRView);
@@ -2243,25 +2243,25 @@ TemporaryRef<ID2D1Brush>
 DrawTargetD2D::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
 {
   if (!IsPatternSupportedByD2D(aPattern)) {
     RefPtr<ID2D1SolidColorBrush> colBrush;
     mRT->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
     return colBrush;
   }
 
-  if (aPattern.GetType() == PATTERN_COLOR) {
+  if (aPattern.GetType() == PatternType::COLOR) {
     RefPtr<ID2D1SolidColorBrush> colBrush;
     Color color = static_cast<const ColorPattern*>(&aPattern)->mColor;
     mRT->CreateSolidColorBrush(D2D1::ColorF(color.r, color.g,
                                             color.b, color.a),
                                D2D1::BrushProperties(aAlpha),
                                byRef(colBrush));
     return colBrush;
-  } else if (aPattern.GetType() == PATTERN_LINEAR_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
     RefPtr<ID2D1LinearGradientBrush> gradBrush;
     const LinearGradientPattern *pat =
       static_cast<const LinearGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
@@ -2280,17 +2280,17 @@ DrawTargetD2D::CreateBrushForPattern(con
     }
 
     mRT->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties(D2DPoint(pat->mBegin),
                                                                        D2DPoint(pat->mEnd)),
                                    D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
                                    stops->mStopCollection,
                                    byRef(gradBrush));
     return gradBrush;
-  } else if (aPattern.GetType() == PATTERN_RADIAL_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
     RefPtr<ID2D1RadialGradientBrush> gradBrush;
     const RadialGradientPattern *pat =
       static_cast<const RadialGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
@@ -2302,17 +2302,17 @@ DrawTargetD2D::CreateBrushForPattern(con
       D2D1::RadialGradientBrushProperties(D2DPoint(pat->mCenter2),
                                           D2DPoint(pat->mCenter1 - pat->mCenter2),
                                           pat->mRadius2, pat->mRadius2),
       D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
       stops->mStopCollection,
       byRef(gradBrush));
 
     return gradBrush;
-  } else if (aPattern.GetType() == PATTERN_SURFACE) {
+  } else if (aPattern.GetType() == PatternType::SURFACE) {
     RefPtr<ID2D1BitmapBrush> bmBrush;
     const SurfacePattern *pat =
       static_cast<const SurfacePattern*>(&aPattern);
 
     if (!pat->mSurface) {
       gfxDebug() << "No source surface specified for surface pattern";
       return nullptr;
     }
--- a/gfx/2d/DrawTargetD2D.h
+++ b/gfx/2d/DrawTargetD2D.h
@@ -32,17 +32,17 @@ class ScaledFontDWrite;
 
 const int32_t kLayerCacheSize = 5;
 
 struct PrivateD3D10DataD2D
 {
   RefPtr<ID3D10Effect> mEffect;
   RefPtr<ID3D10InputLayout> mInputLayout;
   RefPtr<ID3D10Buffer> mVB;
-  RefPtr<ID3D10BlendState> mBlendStates[OP_COUNT];
+  RefPtr<ID3D10BlendState> mBlendStates[CompositionOp::OP_COUNT];
 };
 
 class DrawTargetD2D : public DrawTarget
 {
 public:
   DrawTargetD2D();
   virtual ~DrawTargetD2D();
 
@@ -115,22 +115,22 @@ public:
   virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
 
   virtual TemporaryRef<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const;
   
   virtual TemporaryRef<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const;
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
 
   virtual void *GetNativeSurface(NativeSurfaceType aType);
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   bool Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat);
   bool InitD3D10Data();
--- a/gfx/2d/DrawTargetD2D1.cpp
+++ b/gfx/2d/DrawTargetD2D1.cpp
@@ -64,28 +64,28 @@ DrawTargetD2D1::Flush()
 
 void
 DrawTargetD2D1::DrawSurface(SourceSurface *aSurface,
                             const Rect &aDest,
                             const Rect &aSource,
                             const DrawSurfaceOptions &aSurfOptions,
                             const DrawOptions &aOptions)
 {
-  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, EXTEND_CLAMP);
+  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, ExtendMode::CLAMP);
 
   if (!image) {
     gfxWarning() << *this << ": Unable to get D2D image for surface.";
     return;
   }
 
   PrepareForDrawing(aOptions.mCompositionOp, ColorPattern(Color()));
 
   D2D1_RECT_F samplingBounds;
 
-  if (aSurfOptions.mSamplingBounds == SAMPLING_BOUNDED) {
+  if (aSurfOptions.mSamplingBounds == SamplingBounds::BOUNDED) {
     samplingBounds = D2DRect(aSource);
   } else {
     samplingBounds = D2D1::RectF(0, 0, Float(aSurface->GetSize().width), Float(aSurface->GetSize().height));
   }
 
   Float xScale = aDest.width / aSource.width;
   Float yScale = aDest.height / aSource.height;
 
@@ -129,17 +129,17 @@ DrawTargetD2D1::DrawSurfaceWithShadow(So
                                       Float aSigma,
                                       CompositionOp aOperator)
 {
   MarkChanged();
   mDC->SetTransform(D2D1::IdentityMatrix());
   mTransformDirty = true;
 
   Matrix mat;
-  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, EXTEND_CLAMP);
+  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, ExtendMode::CLAMP);
 
   if (!mat.IsIdentity()) {
     gfxDebug() << *this << ": At this point complex partial uploads are not supported for Shadow surfaces.";
     return;
   }
 
   // Step 1, create the shadow effect.
   RefPtr<ID2D1Effect> shadowEffect;
@@ -180,17 +180,17 @@ DrawTargetD2D1::ClearRect(const Rect &aR
 void
 DrawTargetD2D1::MaskSurface(const Pattern &aSource,
                             SourceSurface *aMask,
                             Point aOffset,
                             const DrawOptions &aOptions)
 {
   RefPtr<ID2D1Bitmap> bitmap;
 
-  RefPtr<ID2D1Image> image = GetImageForSurface(aMask, EXTEND_CLAMP);
+  RefPtr<ID2D1Image> image = GetImageForSurface(aMask, ExtendMode::CLAMP);
 
   PrepareForDrawing(aOptions.mCompositionOp, aSource);
 
   // FillOpacityMask only works if the antialias mode is MODE_ALIASED
   mDC->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
 
   IntSize size = aMask->GetSize();
   Rect maskRect = Rect(0.f, 0.f, Float(size.width), Float(size.height));
@@ -215,17 +215,17 @@ DrawTargetD2D1::CopySurface(SourceSurfac
                             const IntPoint &aDestination)
 {
   MarkChanged();
 
   mDC->SetTransform(D2D1::IdentityMatrix());
   mTransformDirty = true;
 
   Matrix mat;
-  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, EXTEND_CLAMP);
+  RefPtr<ID2D1Image> image = GetImageForSurface(aSurface, mat, ExtendMode::CLAMP);
 
   if (!mat.IsIdentity()) {
     gfxDebug() << *this << ": At this point complex partial uploads are not supported for CopySurface.";
     return;
   }
 
   mDC->DrawImage(image, D2D1::Point2F(Float(aDestination.x), Float(aDestination.y)),
                  D2D1::RectF(Float(aSourceRect.x), Float(aSourceRect.y), 
@@ -343,39 +343,39 @@ DrawTargetD2D1::FillGlyphs(ScaledFont *a
       MOZ_ASSERT(false);
     } else {
       params = static_cast<const GlyphRenderingOptionsDWrite*>(aRenderingOptions)->mParams;
     }
   }
 
   AntialiasMode aaMode = font->GetDefaultAAMode();
 
-  if (aOptions.mAntialiasMode != AA_DEFAULT) {
+  if (aOptions.mAntialiasMode != AntialiasMode::DEFAULT) {
     aaMode = aOptions.mAntialiasMode;
   }
 
   PrepareForDrawing(aOptions.mCompositionOp, aPattern);
 
   bool forceClearType = false;
   if (mFormat == SurfaceFormat::B8G8R8A8 && mPermitSubpixelAA &&
-      aOptions.mCompositionOp == OP_OVER && aaMode == AA_SUBPIXEL) {
+      aOptions.mCompositionOp == CompositionOp::OP_OVER && aaMode == AntialiasMode::SUBPIXEL) {
     forceClearType = true;    
   }
 
 
   D2D1_TEXT_ANTIALIAS_MODE d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
 
   switch (aaMode) {
-  case AA_NONE:
+  case AntialiasMode::NONE:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_ALIASED;
     break;
-  case AA_GRAY:
+  case AntialiasMode::GRAY:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE;
     break;
-  case AA_SUBPIXEL:
+  case AntialiasMode::SUBPIXEL:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE;
     break;
   default:
     d2dAAMode = D2D1_TEXT_ANTIALIAS_MODE_DEFAULT;
   }
 
   if (d2dAAMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE &&
       mFormat != SurfaceFormat::B8G8R8X8 && !forceClearType) {
@@ -548,17 +548,17 @@ DrawTargetD2D1::CreatePathBuilder(FillRu
 
   RefPtr<ID2D1GeometrySink> sink;
   hr = path->Open(byRef(sink));
   if (FAILED(hr)) {
     gfxWarning() << *this << ": Failed to access Direct2D Path Geometry. Code: " << hr;
     return nullptr;
   }
 
-  if (aFillRule == FILL_WINDING) {
+  if (aFillRule == FillRule::FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   return new PathBuilderD2D(sink, path, aFillRule);
 }
 
 TemporaryRef<GradientStops>
 DrawTargetD2D1::CreateGradientStops(GradientStop *rawStops, uint32_t aNumStops, ExtendMode aExtendMode) const
@@ -690,30 +690,30 @@ DrawTargetD2D1::PrepareForDrawing(Compos
   // the transform to become dirty.
   if (!mClipsArePushed) {
     mClipsArePushed = true;
     PushClipsToDC(mDC);
   }
 
   FlushTransformToDC();
 
-  if (aOp == OP_OVER && IsPatternSupportedByD2D(aPattern)) {
+  if (aOp == CompositionOp::OP_OVER && IsPatternSupportedByD2D(aPattern)) {
     return;
   }
 
   mDC->SetTarget(mTempBitmap);
   mDC->Clear(D2D1::ColorF(0, 0));
 }
 
 void
 DrawTargetD2D1::FinalizeDrawing(CompositionOp aOp, const Pattern &aPattern)
 {
   bool patternSupported = IsPatternSupportedByD2D(aPattern);
 
-  if (aOp == OP_OVER && patternSupported) {
+  if (aOp == CompositionOp::OP_OVER && patternSupported) {
     return;
   }
 
   RefPtr<ID2D1Image> image;
   mDC->GetTarget(byRef(image));
 
   mDC->SetTarget(mBitmap);
 
@@ -794,25 +794,25 @@ TemporaryRef<ID2D1Brush>
 DrawTargetD2D1::CreateBrushForPattern(const Pattern &aPattern, Float aAlpha)
 {
   if (!IsPatternSupportedByD2D(aPattern)) {
     RefPtr<ID2D1SolidColorBrush> colBrush;
     mDC->CreateSolidColorBrush(D2D1::ColorF(1.0f, 1.0f, 1.0f, 1.0f), byRef(colBrush));
     return colBrush;
   }
 
-  if (aPattern.GetType() == PATTERN_COLOR) {
+  if (aPattern.GetType() == PatternType::COLOR) {
     RefPtr<ID2D1SolidColorBrush> colBrush;
     Color color = static_cast<const ColorPattern*>(&aPattern)->mColor;
     mDC->CreateSolidColorBrush(D2D1::ColorF(color.r, color.g,
                                             color.b, color.a),
                                D2D1::BrushProperties(aAlpha),
                                byRef(colBrush));
     return colBrush;
-  } else if (aPattern.GetType() == PATTERN_LINEAR_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::LINEAR_GRADIENT) {
     RefPtr<ID2D1LinearGradientBrush> gradBrush;
     const LinearGradientPattern *pat =
       static_cast<const LinearGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
@@ -831,17 +831,17 @@ DrawTargetD2D1::CreateBrushForPattern(co
     }
 
     mDC->CreateLinearGradientBrush(D2D1::LinearGradientBrushProperties(D2DPoint(pat->mBegin),
                                                                        D2DPoint(pat->mEnd)),
                                    D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
                                    stops->mStopCollection,
                                    byRef(gradBrush));
     return gradBrush;
-  } else if (aPattern.GetType() == PATTERN_RADIAL_GRADIENT) {
+  } else if (aPattern.GetType() == PatternType::RADIAL_GRADIENT) {
     RefPtr<ID2D1RadialGradientBrush> gradBrush;
     const RadialGradientPattern *pat =
       static_cast<const RadialGradientPattern*>(&aPattern);
 
     GradientStopsD2D *stops = static_cast<GradientStopsD2D*>(pat->mStops.get());
 
     if (!stops) {
       gfxDebug() << "No stops specified for gradient pattern.";
@@ -853,17 +853,17 @@ DrawTargetD2D1::CreateBrushForPattern(co
       D2D1::RadialGradientBrushProperties(D2DPoint(pat->mCenter2),
                                           D2DPoint(pat->mCenter1 - pat->mCenter2),
                                           pat->mRadius2, pat->mRadius2),
       D2D1::BrushProperties(aAlpha, D2DMatrix(pat->mMatrix)),
       stops->mStopCollection,
       byRef(gradBrush));
 
     return gradBrush;
-  } else if (aPattern.GetType() == PATTERN_SURFACE) {
+  } else if (aPattern.GetType() == PatternType::SURFACE) {
     const SurfacePattern *pat =
       static_cast<const SurfacePattern*>(&aPattern);
 
     if (!pat->mSurface) {
       gfxDebug() << "No source surface specified for surface pattern";
       return nullptr;
     }
 
--- a/gfx/2d/DrawTargetD2D1.h
+++ b/gfx/2d/DrawTargetD2D1.h
@@ -106,22 +106,22 @@ public:
   virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const { return nullptr; }
 
   virtual TemporaryRef<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const { return nullptr; }
   
   virtual TemporaryRef<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
 
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const;
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
 
   virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; }
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   uint32_t GetByteSize() const;
 
--- a/gfx/2d/DrawTargetDual.cpp
+++ b/gfx/2d/DrawTargetDual.cpp
@@ -34,17 +34,17 @@ public:
  * we need to pass separate patterns into our destination DrawTargets.
  */
 class DualPattern
 {
 public:
   inline DualPattern(const Pattern &aPattern)
     : mPatternsInitialized(false)
   {
-    if (aPattern.GetType() != PATTERN_SURFACE) {
+    if (aPattern.GetType() != PatternType::SURFACE) {
       mA = mB = &aPattern;
       return;
     }
 
     const SurfacePattern *surfPat =
       static_cast<const SurfacePattern*>(&aPattern);
 
     if (surfPat->mSurface->GetType() != SurfaceType::DUAL_DT) {
--- a/gfx/2d/DrawTargetDual.h
+++ b/gfx/2d/DrawTargetDual.h
@@ -119,25 +119,25 @@ public:
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const
   {
     return mA->CreateSourceSurfaceFromNativeSurface(aSurface);
   }
      
   virtual TemporaryRef<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
      
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const
   {
     return mA->CreatePathBuilder(aFillRule);
   }
      
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const
   {
     return mA->CreateGradientStops(aStops, aNumStops, aExtendMode);
   }
 
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType)
   {
     return mA->CreateFilter(aType);
   }
--- a/gfx/2d/DrawTargetRecording.cpp
+++ b/gfx/2d/DrawTargetRecording.cpp
@@ -164,37 +164,37 @@ struct AdjustedPattern
     if (mPattern) {
       mPattern->~Pattern();
     }
   }
 
   operator Pattern*()
   {
     switch(mOrigPattern->GetType()) {
-    case PATTERN_COLOR:
+    case PatternType::COLOR:
       return mOrigPattern;
-    case PATTERN_SURFACE:
+    case PatternType::SURFACE:
       {
         SurfacePattern *surfPat = static_cast<SurfacePattern*>(mOrigPattern);
         mPattern =
           new (mSurfPat) SurfacePattern(GetSourceSurface(surfPat->mSurface),
                                         surfPat->mExtendMode, surfPat->mMatrix,
                                         surfPat->mFilter);
         return mPattern;
       }
-    case PATTERN_LINEAR_GRADIENT:
+    case PatternType::LINEAR_GRADIENT:
       {
         LinearGradientPattern *linGradPat = static_cast<LinearGradientPattern*>(mOrigPattern);
         mPattern =
           new (mLinGradPat) LinearGradientPattern(linGradPat->mBegin, linGradPat->mEnd,
                                                   GetGradientStops(linGradPat->mStops),
                                                   linGradPat->mMatrix);
         return mPattern;
       }
-    case PATTERN_RADIAL_GRADIENT:
+    case PatternType::RADIAL_GRADIENT:
       {
         RadialGradientPattern *radGradPat = static_cast<RadialGradientPattern*>(mOrigPattern);
         mPattern =
           new (mRadGradPat) RadialGradientPattern(radGradPat->mCenter1, radGradPat->mCenter2,
                                                   radGradPat->mRadius1, radGradPat->mRadius2,
                                                   GetGradientStops(radGradPat->mStops),
                                                   radGradPat->mMatrix);
         return mPattern;
--- a/gfx/2d/DrawTargetRecording.h
+++ b/gfx/2d/DrawTargetRecording.h
@@ -236,32 +236,32 @@ public:
 
   /*
    * Create a path builder with the specified fillmode.
    *
    * We need the fill mode up front because of Direct2D.
    * ID2D1SimplifiedGeometrySink requires the fill mode
    * to be set before calling BeginFigure().
    */
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   /*
    * Create a GradientStops object that holds information about a set of
    * gradient stops, this object is required for linear or radial gradient
    * patterns to represent the color stops in the gradient.
    *
    * aStops An array of gradient stops
    * aNumStops Number of stops in the array aStops
    * aExtendNone This describes how to extend the stop color outside of the
    *             gradient area.
    */
   virtual TemporaryRef<GradientStops>
     CreateGradientStops(GradientStop *aStops,
                         uint32_t aNumStops,
-                        ExtendMode aExtendMode = EXTEND_CLAMP) const;
+                        ExtendMode aExtendMode = ExtendMode::CLAMP) const;
 
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
 
   /*
    * Set a transform on the surface, this transform is applied at drawing time
    * to both the mask and source of the operation.
    */
   virtual void SetTransform(const Matrix &aTransform);
--- a/gfx/2d/DrawTargetSkia.cpp
+++ b/gfx/2d/DrawTargetSkia.cpp
@@ -195,22 +195,22 @@ DrawTargetSkia::Snapshot()
   }
 
   return snapshot;
 }
 
 void SetPaintPattern(SkPaint& aPaint, const Pattern& aPattern, Float aAlpha = 1.0)
 {
   switch (aPattern.GetType()) {
-    case PATTERN_COLOR: {
+    case PatternType::COLOR: {
       Color color = static_cast<const ColorPattern&>(aPattern).mColor;
       aPaint.setColor(ColorToSkColor(color, aAlpha));
       break;
     }
-    case PATTERN_LINEAR_GRADIENT: {
+    case PatternType::LINEAR_GRADIENT: {
       const LinearGradientPattern& pat = static_cast<const LinearGradientPattern&>(aPattern);
       GradientStopsSkia *stops = static_cast<GradientStopsSkia*>(pat.mStops.get());
       SkShader::TileMode mode = ExtendModeToTileMode(stops->mExtendMode);
 
       if (stops->mCount >= 2) {
         SkPoint points[2];
         points[0] = SkPoint::Make(SkFloatToScalar(pat.mBegin.x), SkFloatToScalar(pat.mBegin.y));
         points[1] = SkPoint::Make(SkFloatToScalar(pat.mEnd.x), SkFloatToScalar(pat.mEnd.y));
@@ -228,17 +228,17 @@ void SetPaintPattern(SkPaint& aPaint, co
             SkSafeUnref(aPaint.setShader(shader));
         }
 
       } else {
         aPaint.setColor(SkColorSetARGB(0, 0, 0, 0));
       }
       break;
     }
-    case PATTERN_RADIAL_GRADIENT: {
+    case PatternType::RADIAL_GRADIENT: {
       const RadialGradientPattern& pat = static_cast<const RadialGradientPattern&>(aPattern);
       GradientStopsSkia *stops = static_cast<GradientStopsSkia*>(pat.mStops.get());
       SkShader::TileMode mode = ExtendModeToTileMode(stops->mExtendMode);
 
       if (stops->mCount >= 2) {
         SkPoint points[2];
         points[0] = SkPoint::Make(SkFloatToScalar(pat.mCenter1.x), SkFloatToScalar(pat.mCenter1.y));
         points[1] = SkPoint::Make(SkFloatToScalar(pat.mCenter2.x), SkFloatToScalar(pat.mCenter2.y));
@@ -258,27 +258,27 @@ void SetPaintPattern(SkPaint& aPaint, co
             SkSafeUnref(aPaint.setShader(shader));
         }
 
       } else {
         aPaint.setColor(SkColorSetARGB(0, 0, 0, 0));
       }
       break;
     }
-    case PATTERN_SURFACE: {
+    case PatternType::SURFACE: {
       const SurfacePattern& pat = static_cast<const SurfacePattern&>(aPattern);
       const SkBitmap& bitmap = GetBitmapForSurface(pat.mSurface);
 
       SkShader::TileMode mode = ExtendModeToTileMode(pat.mExtendMode);
       SkShader* shader = SkShader::CreateBitmapShader(bitmap, mode, mode);
       SkMatrix mat;
       GfxMatrixToSkiaMatrix(pat.mMatrix, mat);
       shader->setLocalMatrix(mat);
       SkSafeUnref(aPaint.setShader(shader));
-      if (pat.mFilter == FILTER_POINT) {
+      if (pat.mFilter == Filter::POINT) {
         aPaint.setFilterBitmap(false);
       }
       break;
     }
   }
 }
 
 struct AutoPaintSetup {
@@ -303,17 +303,17 @@ struct AutoPaintSetup {
   }
 
   void Init(SkCanvas *aCanvas, const DrawOptions& aOptions)
   {
     mPaint.setXfermodeMode(GfxOpToSkiaOp(aOptions.mCompositionOp));
     mCanvas = aCanvas;
 
     //TODO: Can we set greyscale somehow?
-    if (aOptions.mAntialiasMode != AA_NONE) {
+    if (aOptions.mAntialiasMode != AntialiasMode::NONE) {
       mPaint.setAntiAlias(true);
     } else {
       mPaint.setAntiAlias(false);
     }
 
     // TODO: We could skip the temporary for operator_source and just
     // clear the clip rect. The other operators would be harder
     // but could be worth it to skip pushing a group.
@@ -372,17 +372,17 @@ DrawTargetSkia::DrawSurface(SourceSurfac
   boundingSource.RoundOut();
 
   SkRect sourceBoundingRect = RectToSkRect(boundingSource);
   SkIRect sourceBoundingIRect = RectToSkIRect(boundingSource);
 
   const SkBitmap& bitmap = GetBitmapForSurface(aSurface);
  
   AutoPaintSetup paint(mCanvas.get(), aOptions);
-  if (aSurfOptions.mFilter == FILTER_POINT) {
+  if (aSurfOptions.mFilter == Filter::POINT) {
     paint.mPaint.setFilterBitmap(false);
   }
 
   if (!integerAligned) {
     // We need to inflate our destRect by the same amount we inflated sourceRect
     // by when we rounded up to the nearest integer size to ensure we interpolate
     // the edge pixels properly, but clip to the true destination rect first so
     // we don't draw outside our designated area.
@@ -642,17 +642,17 @@ DrawTargetSkia::MaskSurface(const Patter
                             SourceSurface *aMask,
                             Point aOffset,
                             const DrawOptions &aOptions)
 {
   MarkChanged();
   AutoPaintSetup paint(mCanvas.get(), aOptions, aSource);
 
   SkPaint maskPaint;
-  SetPaintPattern(maskPaint, SurfacePattern(aMask, EXTEND_CLAMP));
+  SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP));
 
   SkMatrix transform = maskPaint.getShader()->getLocalMatrix();
   transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y));
   maskPaint.getShader()->setLocalMatrix(transform);
 
   SkLayerRasterizer *raster = new SkLayerRasterizer();
   raster->addLayer(maskPaint);
   SkSafeUnref(paint.mPaint.setRasterizer(raster));
--- a/gfx/2d/DrawTargetSkia.h
+++ b/gfx/2d/DrawTargetSkia.h
@@ -90,18 +90,18 @@ public:
                                                             const IntSize &aSize,
                                                             int32_t aStride,
                                                             SurfaceFormat aFormat) const;
   virtual TemporaryRef<SourceSurface> OptimizeSourceSurface(SourceSurface *aSurface) const;
   virtual TemporaryRef<SourceSurface>
     CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const;
   virtual TemporaryRef<DrawTarget>
     CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const;
-  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FILL_WINDING) const;
-  virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode = EXTEND_CLAMP) const;
+  virtual TemporaryRef<PathBuilder> CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
+  virtual TemporaryRef<GradientStops> CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, ExtendMode aExtendMode = ExtendMode::CLAMP) const;
   virtual TemporaryRef<FilterNode> CreateFilter(FilterType aType);
   virtual void SetTransform(const Matrix &aTransform);
 
   bool Init(const IntSize &aSize, SurfaceFormat aFormat);
   void Init(unsigned char* aData, const IntSize &aSize, int32_t aStride, SurfaceFormat aFormat);
 
 #ifdef USE_SKIA_GPU
   virtual GenericRefCountedBase* GetGLContext() const MOZ_OVERRIDE { return mGLContext; }
--- a/gfx/2d/FilterNodeD2D1.cpp
+++ b/gfx/2d/FilterNodeD2D1.cpp
@@ -28,21 +28,21 @@ D2D1_COLORMATRIX_ALPHA_MODE D2DAlphaMode
   }
 
   return D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED;
 }
 
 D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE D2DAffineTransformInterpolationMode(uint32_t aFilter)
 {
   switch (aFilter) {
-  case FILTER_GOOD:
+  case Filter::GOOD:
     return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR;
-  case FILTER_LINEAR:
+  case Filter::LINEAR:
     return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR;
-  case FILTER_POINT:
+  case Filter::POINT:
     return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
   default:
     MOZ_CRASH("Unknown enum value!");
   }
 
   return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR;
 }
 
@@ -124,17 +124,17 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector
 
   MOZ_CRASH("Unknown enum value!");
   return D2D1_CHANNEL_SELECTOR_R;
 }
 
 TemporaryRef<ID2D1Image> GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface)
 {
   if (aDT->GetType() == BackendType::DIRECT2D1_1) {
-    return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, EXTEND_CLAMP);
+    return static_cast<DrawTargetD2D1*>(aDT)->GetImageForSurface(aSurface, ExtendMode::CLAMP);
   }
   RefPtr<ID2D1Image> image;
   switch (aSurface->GetType()) {
   case SurfaceType::D2D1_1_IMAGE:
     image = static_cast<SourceSurfaceD2D1*>(aSurface)->GetImage();
     static_cast<SourceSurfaceD2D1*>(aSurface)->EnsureIndependent();
     break;
   case SurfaceType::D2D1_BITMAP:
--- a/gfx/2d/FilterNodeSoftware.cpp
+++ b/gfx/2d/FilterNodeSoftware.cpp
@@ -919,17 +919,17 @@ FilterNodeBlendSoftware::RequestFromInpu
 IntRect
 FilterNodeBlendSoftware::GetOutputRectInRect(const IntRect& aRect)
 {
   return GetInputRectInRect(IN_BLEND_IN, aRect).Union(
     GetInputRectInRect(IN_BLEND_IN2, aRect)).Intersect(aRect);
 }
 
 FilterNodeTransformSoftware::FilterNodeTransformSoftware()
- : mFilter(FILTER_GOOD)
+ : mFilter(Filter::GOOD)
 {}
 
 int32_t
 FilterNodeTransformSoftware::InputIndex(uint32_t aInputEnumIndex)
 {
   switch (aInputEnumIndex) {
     case IN_TRANSFORM_IN: return 0;
     default: return -1;
--- a/gfx/2d/HelpersCairo.h
+++ b/gfx/2d/HelpersCairo.h
@@ -13,118 +13,118 @@
 namespace mozilla {
 namespace gfx {
 
 static inline cairo_operator_t
 GfxOpToCairoOp(CompositionOp op)
 {
   switch (op)
   {
-    case OP_OVER:
+    case CompositionOp::OP_OVER:
       return CAIRO_OPERATOR_OVER;
-    case OP_ADD:
+    case CompositionOp::OP_ADD:
       return CAIRO_OPERATOR_ADD;
-    case OP_ATOP:
+    case CompositionOp::OP_ATOP:
       return CAIRO_OPERATOR_ATOP;
-    case OP_OUT:
+    case CompositionOp::OP_OUT:
       return CAIRO_OPERATOR_OUT;
-    case OP_IN:
+    case CompositionOp::OP_IN:
       return CAIRO_OPERATOR_IN;
-    case OP_SOURCE:
+    case CompositionOp::OP_SOURCE:
       return CAIRO_OPERATOR_SOURCE;
-    case OP_DEST_IN:
+    case CompositionOp::OP_DEST_IN:
       return CAIRO_OPERATOR_DEST_IN;
-    case OP_DEST_OUT:
+    case CompositionOp::OP_DEST_OUT:
       return CAIRO_OPERATOR_DEST_OUT;
-    case OP_DEST_OVER:
+    case CompositionOp::OP_DEST_OVER:
       return CAIRO_OPERATOR_DEST_OVER;
-    case OP_DEST_ATOP:
+    case CompositionOp::OP_DEST_ATOP:
       return CAIRO_OPERATOR_DEST_ATOP;
-    case OP_XOR:
+    case CompositionOp::OP_XOR:
       return CAIRO_OPERATOR_XOR;
-    case OP_MULTIPLY:
+    case CompositionOp::OP_MULTIPLY:
       return CAIRO_OPERATOR_MULTIPLY;
-    case OP_SCREEN:
+    case CompositionOp::OP_SCREEN:
       return CAIRO_OPERATOR_SCREEN;
-    case OP_OVERLAY:
+    case CompositionOp::OP_OVERLAY:
       return CAIRO_OPERATOR_OVERLAY;
-    case OP_DARKEN:
+    case CompositionOp::OP_DARKEN:
       return CAIRO_OPERATOR_DARKEN;
-    case OP_LIGHTEN:
+    case CompositionOp::OP_LIGHTEN:
       return CAIRO_OPERATOR_LIGHTEN;
-    case OP_COLOR_DODGE:
+    case CompositionOp::OP_COLOR_DODGE:
       return CAIRO_OPERATOR_COLOR_DODGE;
-    case OP_COLOR_BURN:
+    case CompositionOp::OP_COLOR_BURN:
       return CAIRO_OPERATOR_COLOR_BURN;
-    case OP_HARD_LIGHT:
+    case CompositionOp::OP_HARD_LIGHT:
       return CAIRO_OPERATOR_HARD_LIGHT;
-    case OP_SOFT_LIGHT:
+    case CompositionOp::OP_SOFT_LIGHT:
       return CAIRO_OPERATOR_SOFT_LIGHT;
-    case OP_DIFFERENCE:
+    case CompositionOp::OP_DIFFERENCE:
       return CAIRO_OPERATOR_DIFFERENCE;
-    case OP_EXCLUSION:
+    case CompositionOp::OP_EXCLUSION:
       return CAIRO_OPERATOR_EXCLUSION;
-    case OP_HUE:
+    case CompositionOp::OP_HUE:
       return CAIRO_OPERATOR_HSL_HUE;
-    case OP_SATURATION:
+    case CompositionOp::OP_SATURATION:
       return CAIRO_OPERATOR_HSL_SATURATION;
-    case OP_COLOR:
+    case CompositionOp::OP_COLOR:
       return CAIRO_OPERATOR_HSL_COLOR;
-    case OP_LUMINOSITY:
+    case CompositionOp::OP_LUMINOSITY:
       return CAIRO_OPERATOR_HSL_LUMINOSITY;
-    case OP_COUNT:
+    case CompositionOp::OP_COUNT:
       break;
   }
 
   return CAIRO_OPERATOR_OVER;
 }
 
 static inline cairo_antialias_t
 GfxAntialiasToCairoAntialias(AntialiasMode antialias)
 {
   switch (antialias)
   {
-    case AA_NONE:
+    case AntialiasMode::NONE:
       return CAIRO_ANTIALIAS_NONE;
-    case AA_GRAY:
+    case AntialiasMode::GRAY:
       return CAIRO_ANTIALIAS_GRAY;
-    case AA_SUBPIXEL:
+    case AntialiasMode::SUBPIXEL:
       return CAIRO_ANTIALIAS_SUBPIXEL;
-    case AA_DEFAULT:
+    case AntialiasMode::DEFAULT:
       return CAIRO_ANTIALIAS_DEFAULT;
   }
   return CAIRO_ANTIALIAS_DEFAULT;
 }
 
 static inline cairo_filter_t
 GfxFilterToCairoFilter(Filter filter)
 {
   switch (filter)
   {
-    case FILTER_GOOD:
+    case Filter::GOOD:
       return CAIRO_FILTER_GOOD;
-    case FILTER_LINEAR:
+    case Filter::LINEAR:
       return CAIRO_FILTER_BILINEAR;
-    case FILTER_POINT:
+    case Filter::POINT:
       return CAIRO_FILTER_NEAREST;
   }
 
   return CAIRO_FILTER_BILINEAR;
 }
 
 static inline cairo_extend_t
 GfxExtendToCairoExtend(ExtendMode extend)
 {
   switch (extend)
   {
-    case EXTEND_CLAMP:
+    case ExtendMode::CLAMP:
       return CAIRO_EXTEND_PAD;
-    case EXTEND_REPEAT:
+    case ExtendMode::REPEAT:
       return CAIRO_EXTEND_REPEAT;
-    case EXTEND_REFLECT:
+    case ExtendMode::REFLECT:
       return CAIRO_EXTEND_REFLECT;
   }
 
   return CAIRO_EXTEND_PAD;
 }
 
 static inline cairo_format_t
 GfxFormatToCairoFormat(SurfaceFormat format)
@@ -163,39 +163,39 @@ GfxFormatToCairoContent(SurfaceFormat fo
   }
 }
 
 static inline cairo_line_join_t
 GfxLineJoinToCairoLineJoin(JoinStyle style)
 {
   switch (style)
   {
-    case JOIN_BEVEL:
+    case JoinStyle::BEVEL:
       return CAIRO_LINE_JOIN_BEVEL;
-    case JOIN_ROUND:
+    case JoinStyle::ROUND:
       return CAIRO_LINE_JOIN_ROUND;
-    case JOIN_MITER:
+    case JoinStyle::MITER:
       return CAIRO_LINE_JOIN_MITER;
-    case JOIN_MITER_OR_BEVEL:
+    case JoinStyle::MITER_OR_BEVEL:
       return CAIRO_LINE_JOIN_MITER;
   }
 
   return CAIRO_LINE_JOIN_MITER;
 }
 
 static inline cairo_line_cap_t
 GfxLineCapToCairoLineCap(CapStyle style)
 {
   switch (style)
   {
-    case CAP_BUTT:
+    case CapStyle::BUTT:
       return CAIRO_LINE_CAP_BUTT;
-    case CAP_ROUND:
+    case CapStyle::ROUND:
       return CAIRO_LINE_CAP_ROUND;
-    case CAP_SQUARE:
+    case CapStyle::SQUARE:
       return CAIRO_LINE_CAP_SQUARE;
   }
 
   return CAIRO_LINE_CAP_BUTT;
 }
 
 static inline SurfaceFormat
 CairoContentToGfxFormat(cairo_content_t content)
@@ -242,19 +242,19 @@ SetCairoStrokeOptions(cairo_t* aCtx, con
   cairo_set_line_cap(aCtx, GfxLineCapToCairoLineCap(aStrokeOptions.mLineCap));
 }
 
 static inline cairo_fill_rule_t
 GfxFillRuleToCairoFillRule(FillRule rule)
 {
   switch (rule)
   {
-    case FILL_WINDING:
+    case FillRule::FILL_WINDING:
       return CAIRO_FILL_RULE_WINDING;
-    case FILL_EVEN_ODD:
+    case FillRule::FILL_EVEN_ODD:
       return CAIRO_FILL_RULE_EVEN_ODD;
   }
 
   return CAIRO_FILL_RULE_WINDING;
 }
 
 // RAII class for temporarily changing the cairo matrix transform. It will use
 // the given matrix transform while it is in scope. When it goes out of scope
--- a/gfx/2d/HelpersD2D.h
+++ b/gfx/2d/HelpersD2D.h
@@ -48,44 +48,44 @@ static inline D2D1_RECT_F D2DRect(const 
 {
   return D2D1::RectF(aRect.x, aRect.y, aRect.XMost(), aRect.YMost());
 }
 
 static inline D2D1_EXTEND_MODE D2DExtend(ExtendMode aExtendMode)
 {
   D2D1_EXTEND_MODE extend;
   switch (aExtendMode) {
-  case EXTEND_REPEAT:
+  case ExtendMode::REPEAT:
     extend = D2D1_EXTEND_MODE_WRAP;
     break;
-  case EXTEND_REFLECT:
+  case ExtendMode::REFLECT:
     extend = D2D1_EXTEND_MODE_MIRROR;
     break;
   default:
     extend = D2D1_EXTEND_MODE_CLAMP;
   }
 
   return extend;
 }
 
 static inline D2D1_BITMAP_INTERPOLATION_MODE D2DFilter(const Filter &aFilter)
 {
   switch (aFilter) {
-  case FILTER_POINT:
+  case Filter::POINT:
     return D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
   default:
     return D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
   }
 }
 
 #ifdef USE_D2D1_1
 static inline D2D1_INTERPOLATION_MODE D2DInterpolationMode(const Filter &aFilter)
 {
   switch (aFilter) {
-  case FILTER_POINT:
+  case Filter::POINT:
     return D2D1_INTERPOLATION_MODE_NEAREST_NEIGHBOR;
   default:
     return D2D1_INTERPOLATION_MODE_LINEAR;
   }
 }
 
 static inline D2D1_MATRIX_5X4_F D2DMatrix5x4(const Matrix5x4 &aMatrix)
 {
@@ -101,17 +101,17 @@ static inline D2D1_VECTOR_3F D2DVector3D
   return D2D1::Vector3F(aPoint.x, aPoint.y, aPoint.z);
 }
 
 #endif
 
 static inline D2D1_ANTIALIAS_MODE D2DAAMode(AntialiasMode aMode)
 {
   switch (aMode) {
-  case AA_NONE:
+  case AntialiasMode::NONE:
     return D2D1_ANTIALIAS_MODE_ALIASED;
   default:
     return D2D1_ANTIALIAS_MODE_PER_PRIMITIVE;
   }
 }
 
 static inline D2D1_MATRIX_3X2_F D2DMatrix(const Matrix &aTransform)
 {
@@ -191,47 +191,47 @@ static inline D2D1_PIXEL_FORMAT D2DPixel
 {
   return D2D1::PixelFormat(DXGIFormat(aFormat), D2DAlphaModeForFormat(aFormat));
 }
 
 #ifdef USE_D2D1_1
 static inline D2D1_COMPOSITE_MODE D2DCompositionMode(CompositionOp aOp)
 {
   switch(aOp) {
-  case OP_OVER:
+  case CompositionOp::OP_OVER:
     return D2D1_COMPOSITE_MODE_SOURCE_OVER;
-  case OP_ADD:
+  case CompositionOp::OP_ADD:
     return D2D1_COMPOSITE_MODE_PLUS;
-  case OP_ATOP:
+  case CompositionOp::OP_ATOP:
     return D2D1_COMPOSITE_MODE_SOURCE_ATOP;
-  case OP_OUT:
+  case CompositionOp::OP_OUT:
     return D2D1_COMPOSITE_MODE_SOURCE_OUT;
-  case OP_IN:
+  case CompositionOp::OP_IN:
     return D2D1_COMPOSITE_MODE_SOURCE_IN;
-  case OP_SOURCE:
+  case CompositionOp::OP_SOURCE:
     return D2D1_COMPOSITE_MODE_SOURCE_COPY;
-  case OP_DEST_IN:
+  case CompositionOp::OP_DEST_IN:
     return D2D1_COMPOSITE_MODE_DESTINATION_IN;
-  case OP_DEST_OUT:
+  case CompositionOp::OP_DEST_OUT:
     return D2D1_COMPOSITE_MODE_DESTINATION_OUT;
-  case OP_DEST_OVER:
+  case CompositionOp::OP_DEST_OVER:
     return D2D1_COMPOSITE_MODE_DESTINATION_OVER;
-  case OP_DEST_ATOP:
+  case CompositionOp::OP_DEST_ATOP:
     return D2D1_COMPOSITE_MODE_DESTINATION_ATOP;
-  case OP_XOR:
+  case CompositionOp::OP_XOR:
     return D2D1_COMPOSITE_MODE_XOR;
   default:
     return D2D1_COMPOSITE_MODE_SOURCE_OVER;
   }
 }
 #endif
 
 static inline bool IsPatternSupportedByD2D(const Pattern &aPattern)
 {
-  if (aPattern.GetType() != PATTERN_RADIAL_GRADIENT) {
+  if (aPattern.GetType() != PatternType::RADIAL_GRADIENT) {
     return true;
   }
 
   const RadialGradientPattern *pat =
     static_cast<const RadialGradientPattern*>(&aPattern);
   
   if (pat->mRadius1 != 0) {
     return false;
@@ -375,38 +375,38 @@ static TemporaryRef<ID2D1StrokeStyle>
 CreateStrokeStyleForOptions(const StrokeOptions &aStrokeOptions)
 {
   RefPtr<ID2D1StrokeStyle> style;
 
   D2D1_CAP_STYLE capStyle;
   D2D1_LINE_JOIN joinStyle;
 
   switch (aStrokeOptions.mLineCap) {
-  case CAP_BUTT:
+  case CapStyle::BUTT:
     capStyle = D2D1_CAP_STYLE_FLAT;
     break;
-  case CAP_ROUND:
+  case CapStyle::ROUND:
     capStyle = D2D1_CAP_STYLE_ROUND;
     break;
-  case CAP_SQUARE:
+  case CapStyle::SQUARE:
     capStyle = D2D1_CAP_STYLE_SQUARE;
     break;
   }
 
   switch (aStrokeOptions.mLineJoin) {
-  case JOIN_MITER:
+  case JoinStyle::MITER:
     joinStyle = D2D1_LINE_JOIN_MITER;
     break;
-  case JOIN_MITER_OR_BEVEL:
+  case JoinStyle::MITER_OR_BEVEL:
     joinStyle = D2D1_LINE_JOIN_MITER_OR_BEVEL;
     break;
-  case JOIN_ROUND:
+  case JoinStyle::ROUND:
     joinStyle = D2D1_LINE_JOIN_ROUND;
     break;
-  case JOIN_BEVEL:
+  case JoinStyle::BEVEL:
     joinStyle = D2D1_LINE_JOIN_BEVEL;
     break;
   }
 
 
   HRESULT hr;
   if (aStrokeOptions.mDashPattern) {
     typedef std::vector<Float> FloatVector;
@@ -489,19 +489,19 @@ CreatePartialBitmapForSurface(DataSource
   //   '---------------'              '---------------'
   //
   //
 
   if (uploadRect.Contains(rect)) {
     // Extend mode is irrelevant, the displayed rect is completely contained
     // by the source bitmap.
     uploadRect = rect;
-  } else if (aExtendMode == EXTEND_CLAMP && uploadRect.Intersects(rect)) {
+  } else if (aExtendMode == ExtendMode::CLAMP && uploadRect.Intersects(rect)) {
     // Calculate the rectangle on the source bitmap that touches our
-    // surface, and upload that, for EXTEND_CLAMP we can actually guarantee
+    // surface, and upload that, for ExtendMode::CLAMP we can actually guarantee
     // correct behaviour in this case.
     uploadRect = uploadRect.Intersect(rect);
 
     // We now proceed to check if we can limit at least one dimension of the
     // upload rect safely without looking at extend mode.
   } else if (rect.x >= 0 && rect.XMost() < size.width) {
     uploadRect.x = rect.x;
     uploadRect.width = rect.width;
--- a/gfx/2d/HelpersSkia.h
+++ b/gfx/2d/HelpersSkia.h
@@ -83,37 +83,37 @@ GfxMatrixToSkiaMatrix(const Matrix& mat,
                   0, 0, SK_Scalar1);
 }
 
 static inline SkPaint::Cap
 CapStyleToSkiaCap(CapStyle aCap)
 {
   switch (aCap)
   {
-    case CAP_BUTT:
+    case CapStyle::BUTT:
       return SkPaint::kButt_Cap;
-    case CAP_ROUND:
+    case CapStyle::ROUND:
       return SkPaint::kRound_Cap;
-    case CAP_SQUARE:
+    case CapStyle::SQUARE:
       return SkPaint::kSquare_Cap;
   }
   return SkPaint::kDefault_Cap;
 }
 
 static inline SkPaint::Join
 JoinStyleToSkiaJoin(JoinStyle aJoin)
 {
   switch (aJoin)
   {
-    case JOIN_BEVEL:
+    case JoinStyle::BEVEL:
       return SkPaint::kBevel_Join;
-    case JOIN_ROUND:
+    case JoinStyle::ROUND:
       return SkPaint::kRound_Join;
-    case JOIN_MITER:
-    case JOIN_MITER_OR_BEVEL:
+    case JoinStyle::MITER:
+    case JoinStyle::MITER_OR_BEVEL:
       return SkPaint::kMiter_Join;
   }
   return SkPaint::kDefault_Join;
 }
 
 static inline bool
 StrokeOptionsToPaint(SkPaint& aPaint, const StrokeOptions &aOptions)
 {
@@ -154,67 +154,67 @@ StrokeOptionsToPaint(SkPaint& aPaint, co
   return true;
 }
 
 static inline SkXfermode::Mode
 GfxOpToSkiaOp(CompositionOp op)
 {
   switch (op)
   {
-    case OP_OVER:
+    case CompositionOp::OP_OVER:
       return SkXfermode::kSrcOver_Mode;
-    case OP_ADD:
+    case CompositionOp::OP_ADD:
       return SkXfermode::kPlus_Mode;
-    case OP_ATOP:
+    case CompositionOp::OP_ATOP:
       return SkXfermode::kSrcATop_Mode;
-    case OP_OUT:
+    case CompositionOp::OP_OUT:
       return SkXfermode::kSrcOut_Mode;
-    case OP_IN:
+    case CompositionOp::OP_IN:
       return SkXfermode::kSrcIn_Mode;
-    case OP_SOURCE:
+    case CompositionOp::OP_SOURCE:
       return SkXfermode::kSrc_Mode;
-    case OP_DEST_IN:
+    case CompositionOp::OP_DEST_IN:
       return SkXfermode::kDstIn_Mode;
-    case OP_DEST_OUT:
+    case CompositionOp::OP_DEST_OUT:
       return SkXfermode::kDstOut_Mode;
-    case OP_DEST_OVER:
+    case CompositionOp::OP_DEST_OVER:
       return SkXfermode::kDstOver_Mode;
-    case OP_DEST_ATOP:
+    case CompositionOp::OP_DEST_ATOP:
       return SkXfermode::kDstATop_Mode;
-    case OP_XOR:
+    case CompositionOp::OP_XOR:
       return SkXfermode::kXor_Mode;
-    case OP_MULTIPLY:
+    case CompositionOp::OP_MULTIPLY:
       return SkXfermode::kMultiply_Mode;
-    case OP_SCREEN:
+    case CompositionOp::OP_SCREEN:
       return SkXfermode::kScreen_Mode;
-    case OP_OVERLAY:
+    case CompositionOp::OP_OVERLAY:
       return SkXfermode::kOverlay_Mode;
-    case OP_DARKEN:
+    case CompositionOp::OP_DARKEN:
       return SkXfermode::kDarken_Mode;
-    case OP_LIGHTEN:
+    case CompositionOp::OP_LIGHTEN:
       return SkXfermode::kLighten_Mode;
-    case OP_COLOR_DODGE:
+    case CompositionOp::OP_COLOR_DODGE:
       return SkXfermode::kColorDodge_Mode;
-    case OP_COLOR_BURN:
+    case CompositionOp::OP_COLOR_BURN:
       return SkXfermode::kColorBurn_Mode;
-    case OP_HARD_LIGHT:
+    case CompositionOp::OP_HARD_LIGHT:
       return SkXfermode::kHardLight_Mode;
-    case OP_SOFT_LIGHT:
+    case CompositionOp::OP_SOFT_LIGHT:
       return SkXfermode::kSoftLight_Mode;
-    case OP_DIFFERENCE:
+    case CompositionOp::OP_DIFFERENCE:
       return SkXfermode::kDifference_Mode;
-    case OP_EXCLUSION:
+    case CompositionOp::OP_EXCLUSION:
       return SkXfermode::kExclusion_Mode;
-    case OP_HUE:
+    case CompositionOp::OP_HUE:
       return SkXfermode::kHue_Mode;
-    case OP_SATURATION:
+    case CompositionOp::OP_SATURATION:
       return SkXfermode::kSaturation_Mode;
-    case OP_COLOR:
+    case CompositionOp::OP_COLOR:
       return SkXfermode::kColor_Mode;
-    case OP_LUMINOSITY:
+    case CompositionOp::OP_LUMINOSITY:
       return SkXfermode::kLuminosity_Mode;
     default:
       return SkXfermode::kSrcOver_Mode;
   }
 }
 
 static inline SkColor ColorToSkColor(const Color &color, Float aAlpha)
 {
@@ -256,21 +256,21 @@ SkPointToPoint(const SkPoint &aPoint)
   return Point(SkScalarToFloat(aPoint.x()), SkScalarToFloat(aPoint.y()));
 }
 
 static inline SkShader::TileMode
 ExtendModeToTileMode(ExtendMode aMode)
 {
   switch (aMode)
   {
-    case EXTEND_CLAMP:
+    case ExtendMode::CLAMP:
       return SkShader::kClamp_TileMode;
-    case EXTEND_REPEAT:
+    case ExtendMode::REPEAT:
       return SkShader::kRepeat_TileMode;
-    case EXTEND_REFLECT:
+    case ExtendMode::REFLECT:
       return SkShader::kMirror_TileMode;
   }
   return SkShader::kClamp_TileMode;
 }
 
 }
 }
 
--- a/gfx/2d/PathCG.cpp
+++ b/gfx/2d/PathCG.cpp
@@ -228,17 +228,17 @@ PathCG::ContainsPoint(const Point &aPoin
   Matrix inverse = aTransform;
   inverse.Invert();
   Point transformedPoint = inverse*aPoint;
   // We could probably drop the input transform and just transform the point at the caller?
   CGPoint point = {transformedPoint.x, transformedPoint.y};
 
   // The transform parameter of CGPathContainsPoint doesn't seem to work properly on OS X 10.5
   // so we transform aPoint ourselves.
-  return CGPathContainsPoint(mPath, nullptr, point, mFillRule == FILL_EVEN_ODD);
+  return CGPathContainsPoint(mPath, nullptr, point, mFillRule == FillRule::FILL_EVEN_ODD);
 }
 
 static size_t
 PutBytesNull(void *info, const void *buffer, size_t count)
 {
   return count;
 }
 
--- a/gfx/2d/PathCG.h
+++ b/gfx/2d/PathCG.h
@@ -68,19 +68,19 @@ public:
     CGPathRetain(mPath);
   }
   virtual ~PathCG() { CGPathRelease(mPath); }
 
   // Paths will always return BackendType::COREGRAPHICS, but note that they
   // are compatible with BackendType::COREGRAPHICS_ACCELERATED backend.
   virtual BackendType GetBackendType() const { return BackendType::COREGRAPHICS; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
   virtual Rect GetStrokedBounds(const StrokeOptions &aStrokeOptions,
                                 const Matrix &aTransform = Matrix()) const;
--- a/gfx/2d/PathCairo.cpp
+++ b/gfx/2d/PathCairo.cpp
@@ -132,17 +132,17 @@ PathCairo::PathCairo(FillRule aFillRule,
   : mFillRule(aFillRule)
   , mContainingContext(nullptr)
   , mCurrentPoint(aCurrentPoint)
 {
   mPathData.swap(aPathData);
 }
 
 PathCairo::PathCairo(cairo_t *aContext)
-  : mFillRule(FILL_WINDING)
+  : mFillRule(FillRule::FILL_WINDING)
   , mContainingContext(nullptr)
 {
   cairo_path_t *path = cairo_copy_path(aContext);
 
   // XXX - mCurrentPoint is not properly set here, the same is true for the
   // D2D Path code, we never require current point when hitting this codepath
   // but this should be fixed.
   for (int i = 0; i < path->num_data; i++) {
--- a/gfx/2d/PathCairo.h
+++ b/gfx/2d/PathCairo.h
@@ -49,19 +49,19 @@ class PathCairo : public Path
 {
 public:
   PathCairo(FillRule aFillRule, std::vector<cairo_path_data_t> &aPathData, const Point &aCurrentPoint);
   PathCairo(cairo_t *aContext);
   ~PathCairo();
 
   virtual BackendType GetBackendType() const { return BackendType::CAIRO; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
--- a/gfx/2d/PathD2D.cpp
+++ b/gfx/2d/PathD2D.cpp
@@ -325,17 +325,17 @@ PathD2D::TransformedCopyToBuilder(const 
 
   RefPtr<ID2D1GeometrySink> sink;
   hr = path->Open(byRef(sink));
   if (FAILED(hr)) {
     gfxWarning() << "Failed to open Geometry for writing. Code: " << hr;
     return nullptr;
   }
 
-  if (aFillRule == FILL_WINDING) {
+  if (aFillRule == FillRule::FILL_WINDING) {
     sink->SetFillMode(D2D1_FILL_MODE_WINDING);
   }
 
   if (mEndedActive) {
     OpeningGeometrySink wrapSink(sink);
     mGeometry->Simplify(D2D1_GEOMETRY_SIMPLIFICATION_OPTION_CUBICS_AND_LINES,
                         D2DMatrix(aTransform),
                         &wrapSink);
--- a/gfx/2d/PathD2D.h
+++ b/gfx/2d/PathD2D.h
@@ -65,19 +65,19 @@ public:
     : mGeometry(aGeometry)
     , mEndedActive(aEndedActive)
     , mEndPoint(aEndPoint)
     , mFillRule(aFillRule)
   {}
   
   virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
 
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
--- a/gfx/2d/PathRecording.h
+++ b/gfx/2d/PathRecording.h
@@ -85,19 +85,19 @@ public:
   PathRecording(Path *aPath, const std::vector<PathOp> aOps, FillRule aFillRule)
     : mPath(aPath), mPathOps(aOps), mFillRule(aFillRule)
   {
   }
 
   ~PathRecording();
 
   virtual BackendType GetBackendType() const { return BackendType::RECORDING; }
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
   { return mPath->ContainsPoint(aPoint, aTransform); }
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const
   { return mPath->StrokeContainsPoint(aStrokeOptions, aPoint, aTransform); }
   
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const
--- a/gfx/2d/PathSkia.cpp
+++ b/gfx/2d/PathSkia.cpp
@@ -26,17 +26,17 @@ PathBuilderSkia::PathBuilderSkia(FillRul
 {
   SetFillRule(aFillRule);
 }
 
 void
 PathBuilderSkia::SetFillRule(FillRule aFillRule)
 {
   mFillRule = aFillRule;
-  if (mFillRule == FILL_WINDING) {
+  if (mFillRule == FillRule::FILL_WINDING) {
     mPath.setFillType(SkPath::kWinding_FillType);
   } else {
     mPath.setFillType(SkPath::kEvenOdd_FillType);
   }
 }
 
 void
 PathBuilderSkia::MoveTo(const Point &aPoint)
--- a/gfx/2d/PathSkia.h
+++ b/gfx/2d/PathSkia.h
@@ -49,19 +49,19 @@ public:
   PathSkia(SkPath& aPath, FillRule aFillRule)
     : mFillRule(aFillRule)
   {
     mPath.swap(aPath);
   }
   
   virtual BackendType GetBackendType() const { return BackendType::SKIA; }
 
-  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FILL_WINDING) const;
+  virtual TemporaryRef<PathBuilder> CopyToBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const;
   virtual TemporaryRef<PathBuilder> TransformedCopyToBuilder(const Matrix &aTransform,
-                                                             FillRule aFillRule = FILL_WINDING) const;
+                                                             FillRule aFillRule = FillRule::FILL_WINDING) const;
 
   virtual bool ContainsPoint(const Point &aPoint, const Matrix &aTransform) const;
   
   virtual bool StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                                    const Point &aPoint,
                                    const Matrix &aTransform) const;
 
   virtual Rect GetBounds(const Matrix &aTransform = Matrix()) const;
--- a/gfx/2d/RecordedEvent.cpp
+++ b/gfx/2d/RecordedEvent.cpp
@@ -144,111 +144,111 @@ RecordedEvent::GetEventName(EventType aT
 }
 
 void
 RecordedEvent::RecordPatternData(std::ostream &aStream, const PatternStorage &aPattern) const
 {
   WriteElement(aStream, aPattern.mType);
 
   switch (aPattern.mType) {
-  case PATTERN_COLOR:
+  case PatternType::COLOR:
     {
       WriteElement(aStream, *reinterpret_cast<const ColorPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_LINEAR_GRADIENT:
+  case PatternType::LINEAR_GRADIENT:
     {
       WriteElement(aStream, *reinterpret_cast<const LinearGradientPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_RADIAL_GRADIENT:
+  case PatternType::RADIAL_GRADIENT:
     {
       WriteElement(aStream, *reinterpret_cast<const RadialGradientPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_SURFACE:
+  case PatternType::SURFACE:
     {
       WriteElement(aStream, *reinterpret_cast<const SurfacePatternStorage*>(&aPattern.mStorage));
       return;
     }
   default:
     return;
   }
 }
 
 void
 RecordedEvent::ReadPatternData(std::istream &aStream, PatternStorage &aPattern) const
 {
   ReadElement(aStream, aPattern.mType);
 
   switch (aPattern.mType) {
-  case PATTERN_COLOR:
+  case PatternType::COLOR:
     {
       ReadElement(aStream, *reinterpret_cast<ColorPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_LINEAR_GRADIENT:
+  case PatternType::LINEAR_GRADIENT:
     {
       ReadElement(aStream, *reinterpret_cast<LinearGradientPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_RADIAL_GRADIENT:
+  case PatternType::RADIAL_GRADIENT:
     {
       ReadElement(aStream, *reinterpret_cast<RadialGradientPatternStorage*>(&aPattern.mStorage));
       return;
     }
-  case PATTERN_SURFACE:
+  case PatternType::SURFACE:
     {
       ReadElement(aStream, *reinterpret_cast<SurfacePatternStorage*>(&aPattern.mStorage));
       return;
     }
   default:
     return;
   }
 }
 
 void
 RecordedEvent::StorePattern(PatternStorage &aDestination, const Pattern &aSource) const
 {
   aDestination.mType = aSource.GetType();
   
   switch (aSource.GetType()) {
-  case PATTERN_COLOR:
+  case PatternType::COLOR:
     {
       reinterpret_cast<ColorPatternStorage*>(&aDestination.mStorage)->mColor =
         static_cast<const ColorPattern*>(&aSource)->mColor;
       return;
     }
-  case PATTERN_LINEAR_GRADIENT:
+  case PatternType::LINEAR_GRADIENT:
     {
       LinearGradientPatternStorage *store =
         reinterpret_cast<LinearGradientPatternStorage*>(&aDestination.mStorage);
       const LinearGradientPattern *pat =
         static_cast<const LinearGradientPattern*>(&aSource);
       store->mBegin = pat->mBegin;
       store->mEnd = pat->mEnd;
       store->mMatrix = pat->mMatrix;
       store->mStops = pat->mStops.get();
       return;
     }
-  case PATTERN_RADIAL_GRADIENT:
+  case PatternType::RADIAL_GRADIENT:
     {
       RadialGradientPatternStorage *store =
         reinterpret_cast<RadialGradientPatternStorage*>(&aDestination.mStorage);
       const RadialGradientPattern *pat =
         static_cast<const RadialGradientPattern*>(&aSource);
       store->mCenter1 = pat->mCenter1;
       store->mCenter2 = pat->mCenter2;
       store->mRadius1 = pat->mRadius1;
       store->mRadius2 = pat->mRadius2;
       store->mMatrix = pat->mMatrix;
       store->mStops = pat->mStops.get();
       return;
     }
-  case PATTERN_SURFACE:
+  case PatternType::SURFACE:
     {
       SurfacePatternStorage *store =
         reinterpret_cast<SurfacePatternStorage*>(&aDestination.mStorage);
       const SurfacePattern *pat =
         static_cast<const SurfacePattern*>(&aSource);
       store->mExtend = pat->mExtendMode;
       store->mFilter = pat->mFilter;
       store->mMatrix = pat->mMatrix;
@@ -305,40 +305,40 @@ RecordedEvent::ReadStrokeOptions(std::is
   aStrokeOptions.mDashPattern = &mDashPatternStorage.front();
   aStream.read((char*)aStrokeOptions.mDashPattern, sizeof(Float) * aStrokeOptions.mDashLength);
 }
 
 void
 RecordedEvent::OutputSimplePatternInfo(const PatternStorage &aStorage, std::stringstream &aOutput) const
 {
   switch (aStorage.mType) {
-  case PATTERN_COLOR:
+  case PatternType::COLOR:
     {
       const Color color = reinterpret_cast<const ColorPatternStorage*>(&aStorage.mStorage)->mColor;
       aOutput << "Color: (" << color.r << ", " << color.g << ", " << color.b << ", " << color.a << ")";
       return;
     }
-  case PATTERN_LINEAR_GRADIENT:
+  case PatternType::LINEAR_GRADIENT:
     {
       const LinearGradientPatternStorage *store =
         reinterpret_cast<const LinearGradientPatternStorage*>(&aStorage.mStorage);
 
       aOutput << "LinearGradient (" << store->mBegin.x << ", " << store->mBegin.y <<
         ") - (" << store->mEnd.x << ", " << store->mEnd.y << ") Stops: " << store->mStops;
       return;
     }
-  case PATTERN_RADIAL_GRADIENT:
+  case PatternType::RADIAL_GRADIENT:
     {
       const RadialGradientPatternStorage *store =
         reinterpret_cast<const RadialGradientPatternStorage*>(&aStorage.mStorage);
       aOutput << "RadialGradient (Center 1: (" << store->mCenter1.x << ", " <<
         store->mCenter2.y << ") Radius 2: " << store->mRadius2;
       return;
     }
-  case PATTERN_SURFACE:
+  case PatternType::SURFACE:
     {
       const SurfacePatternStorage *store =
         reinterpret_cast<const SurfacePatternStorage*>(&aStorage.mStorage);
       aOutput << "Surface (0x" << store->mSurface << ")";
       return;
     }
   }
 }
@@ -456,36 +456,36 @@ struct GenericPattern
     if (mPattern) {
       mPattern->~Pattern();
     }
   }
 
   operator Pattern*()
   {
     switch(mStorage->mType) {
-    case PATTERN_COLOR:
+    case PatternType::COLOR:
       return new (mColPat) ColorPattern(reinterpret_cast<ColorPatternStorage*>(&mStorage->mStorage)->mColor);
-    case PATTERN_SURFACE:
+    case PatternType::SURFACE:
       {
         SurfacePatternStorage *storage = reinterpret_cast<SurfacePatternStorage*>(&mStorage->mStorage);
         mPattern =
           new (mSurfPat) SurfacePattern(mTranslator->LookupSourceSurface(storage->mSurface),
                                         storage->mExtend, storage->mMatrix, storage->mFilter);
         return mPattern;
       }
-    case PATTERN_LINEAR_GRADIENT:
+    case PatternType::LINEAR_GRADIENT:
       {
         LinearGradientPatternStorage *storage = reinterpret_cast<LinearGradientPatternStorage*>(&mStorage->mStorage);
         mPattern =
           new (mLinGradPat) LinearGradientPattern(storage->mBegin, storage->mEnd,
                                                   mTranslator->LookupGradientStops(storage->mStops),
                                                   storage->mMatrix);
         return mPattern;
       }
-    case PATTERN_RADIAL_GRADIENT:
+    case PatternType::RADIAL_GRADIENT:
       {
         RadialGradientPatternStorage *storage = reinterpret_cast<RadialGradientPatternStorage*>(&mStorage->mStorage);
         mPattern =
           new (mRadGradPat) RadialGradientPattern(storage->mCenter1, storage->mCenter2,
                                                   storage->mRadius1, storage->mRadius2,
                                                   mTranslator->LookupGradientStops(storage->mStops),
                                                   storage->mMatrix);
         return mPattern;
--- a/gfx/2d/ScaledFontBase.cpp
+++ b/gfx/2d/ScaledFontBase.cpp
@@ -76,17 +76,17 @@ ScaledFontBase::GetSkiaPathForGlyphs(con
 #endif
 
 TemporaryRef<Path>
 ScaledFontBase::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aTarget)
 {
 #ifdef USE_SKIA
   if (aTarget->GetType() == BackendType::SKIA) {
     SkPath path = GetSkiaPathForGlyphs(aBuffer);
-    return new PathSkia(path, FILL_WINDING);
+    return new PathSkia(path, FillRule::FILL_WINDING);
   }
 #endif
 #ifdef USE_CAIRO
   if (aTarget->GetType() == BackendType::CAIRO) {
     MOZ_ASSERT(mScaledFont);
 
     DrawTarget *dt = const_cast<DrawTarget*>(aTarget);
     cairo_t *ctx = static_cast<cairo_t*>(dt->GetNativeSurface(NativeSurfaceType::CAIRO_CONTEXT));
--- a/gfx/2d/ScaledFontDWrite.cpp
+++ b/gfx/2d/ScaledFontDWrite.cpp
@@ -404,32 +404,32 @@ ScaledFontDWrite::GetFontFileData(FontFi
   stream->ReleaseFileFragment(context);
 
   return true;
 }
 
 AntialiasMode
 ScaledFontDWrite::GetDefaultAAMode()
 {
-  AntialiasMode defaultMode = AA_SUBPIXEL;
+  AntialiasMode defaultMode = AntialiasMode::SUBPIXEL;
 
   switch (GetSystemTextQuality()) {
   case CLEARTYPE_QUALITY:
-    defaultMode = AA_SUBPIXEL;
+    defaultMode = AntialiasMode::SUBPIXEL;
     break;
   case ANTIALIASED_QUALITY:
-    defaultMode = AA_GRAY;
+    defaultMode = AntialiasMode::GRAY;
     break;
   case DEFAULT_QUALITY:
-    defaultMode = AA_NONE;
+    defaultMode = AntialiasMode::NONE;
     break;
   }
 
-  if (defaultMode == AA_GRAY) {
+  if (defaultMode == AntialiasMode::GRAY) {
     if (!DoGrayscale(mFontFace, mSize)) {
-      defaultMode = AA_NONE;
+      defaultMode = AntialiasMode::NONE;
     }
   }
   return defaultMode;
 }
 
 }
 }
--- a/gfx/2d/ScaledFontMac.cpp
+++ b/gfx/2d/ScaledFontMac.cpp
@@ -88,17 +88,17 @@ ScaledFontMac::GetPathForGlyphs(const Gl
           CGPathRef glyphPath = ::CGFontGetGlyphPath(mFont, &flip, 0, aBuffer.mGlyphs[i].mIndex);
 
           CGAffineTransform matrix = CGAffineTransformMake(mSize, 0, 0, mSize,
                                                            aBuffer.mGlyphs[i].mPosition.x,
                                                            aBuffer.mGlyphs[i].mPosition.y);
           CGPathAddPath(path, &matrix, glyphPath);
           CGPathRelease(glyphPath);
       }
-      TemporaryRef<Path> ret = new PathCG(path, FILL_WINDING);
+      TemporaryRef<Path> ret = new PathCG(path, FillRule::FILL_WINDING);
       CGPathRelease(path);
       return ret;
   } else {
       return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget);
   }
 }
 
 void
--- a/gfx/2d/Tools.h
+++ b/gfx/2d/Tools.h
@@ -14,21 +14,21 @@
 #endif
 
 namespace mozilla {
 namespace gfx {
 
 static inline bool
 IsOperatorBoundByMask(CompositionOp aOp) {
   switch (aOp) {
-  case OP_IN:
-  case OP_OUT:
-  case OP_DEST_IN:
-  case OP_DEST_ATOP:
-  case OP_SOURCE:
+  case CompositionOp::OP_IN:
+  case CompositionOp::OP_OUT:
+  case CompositionOp::OP_DEST_IN:
+  case CompositionOp::OP_DEST_ATOP:
+  case CompositionOp::OP_SOURCE:
     return false;
   default:
     return true;
   }
 }
 
 template <class T>
 struct ClassStorage
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -12,42 +12,42 @@
 #include <stddef.h>
 #include <stdint.h>
 
 namespace mozilla {
 namespace gfx {
 
 typedef float Float;
 
-MOZ_BEGIN_ENUM_CLASS(SurfaceType)
+MOZ_BEGIN_ENUM_CLASS(SurfaceType, int8_t)
   DATA, /* Data surface - bitmap in memory */
   D2D1_BITMAP, /* Surface wrapping a ID2D1Bitmap */
   D2D1_DRAWTARGET, /* Surface made from a D2D draw target */
   CAIRO, /* Surface wrapping a cairo surface */
   CAIRO_IMAGE, /* Data surface wrapping a cairo image surface */
   COREGRAPHICS_IMAGE, /* Surface wrapping a CoreGraphics Image */
   COREGRAPHICS_CGCONTEXT, /* Surface wrapping a CG context */
   SKIA, /* Surface wrapping a Skia bitmap */
   DUAL_DT, /* Snapshot of a dual drawtarget */
   D2D1_1_IMAGE, /* A D2D 1.1 ID2D1Image SourceSurface */
   RECORDING /* Surface used for recording */
 MOZ_END_ENUM_CLASS(SurfaceType)
 
-MOZ_BEGIN_ENUM_CLASS(SurfaceFormat)
+MOZ_BEGIN_ENUM_CLASS(SurfaceFormat, int8_t)
   B8G8R8A8,
   B8G8R8X8,
   R8G8B8A8,
   R8G8B8X8,
   R5G6B5,
   A8,
   YUV,
   UNKNOWN
 MOZ_END_ENUM_CLASS(SurfaceFormat)
 
-MOZ_BEGIN_ENUM_CLASS(FilterType)
+MOZ_BEGIN_ENUM_CLASS(FilterType, int8_t)
   BLEND = 0,
   TRANSFORM,
   MORPHOLOGY,
   COLOR_MATRIX,
   FLOOD,
   TILE,
   TABLE_TRANSFER,
   DISCRETE_TRANSFER,
@@ -66,76 +66,144 @@ MOZ_BEGIN_ENUM_CLASS(FilterType)
   SPOT_SPECULAR,
   DISTANT_DIFFUSE,
   DISTANT_SPECULAR,
   CROP,
   PREMULTIPLY,
   UNPREMULTIPLY
 MOZ_END_ENUM_CLASS(FilterType)
 
-MOZ_BEGIN_ENUM_CLASS(BackendType)
+MOZ_BEGIN_ENUM_CLASS(BackendType, int8_t)
   NONE = 0,
   DIRECT2D,
   COREGRAPHICS,
   COREGRAPHICS_ACCELERATED,
   CAIRO,
   SKIA,
   RECORDING,
   DIRECT2D1_1
 MOZ_END_ENUM_CLASS(BackendType)
 
-MOZ_BEGIN_ENUM_CLASS(FontType)
+MOZ_BEGIN_ENUM_CLASS(FontType, int8_t)
   DWRITE,
   GDI,
   MAC,
   SKIA,
   CAIRO,
   COREGRAPHICS
 MOZ_END_ENUM_CLASS(FontType)
 
-MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType)
+MOZ_BEGIN_ENUM_CLASS(NativeSurfaceType, int8_t)
   D3D10_TEXTURE,
   CAIRO_SURFACE,
   CAIRO_CONTEXT,
   CGCONTEXT,
   CGCONTEXT_ACCELERATED
 MOZ_END_ENUM_CLASS(NativeSurfaceType)
 
-MOZ_BEGIN_ENUM_CLASS(NativeFontType)
+MOZ_BEGIN_ENUM_CLASS(NativeFontType, int8_t)
   DWRITE_FONT_FACE,
   GDI_FONT_FACE,
   MAC_FONT_FACE,
   SKIA_FONT_FACE,
   CAIRO_FONT_FACE
 MOZ_END_ENUM_CLASS(NativeFontType)
 
-MOZ_BEGIN_ENUM_CLASS(FontStyle)
+MOZ_BEGIN_ENUM_CLASS(FontStyle, int8_t)
   NORMAL,
   ITALIC,
   BOLD,
   BOLD_ITALIC
 MOZ_END_ENUM_CLASS(FontStyle)
 
-MOZ_BEGIN_ENUM_CLASS(FontHinting)
+MOZ_BEGIN_ENUM_CLASS(FontHinting, int8_t)
   NONE,
   LIGHT,
   NORMAL,
   FULL
 MOZ_END_ENUM_CLASS(FontHinting)
 
-enum CompositionOp { OP_OVER, OP_ADD, OP_ATOP, OP_OUT, OP_IN, OP_SOURCE, OP_DEST_IN, OP_DEST_OUT, OP_DEST_OVER, OP_DEST_ATOP, OP_XOR, 
-  OP_MULTIPLY, OP_SCREEN, OP_OVERLAY, OP_DARKEN, OP_LIGHTEN, OP_COLOR_DODGE, OP_COLOR_BURN, OP_HARD_LIGHT, OP_SOFT_LIGHT,  OP_DIFFERENCE, OP_EXCLUSION, OP_HUE, OP_SATURATION, OP_COLOR, OP_LUMINOSITY, OP_COUNT };
-enum ExtendMode { EXTEND_CLAMP, EXTEND_REPEAT, EXTEND_REFLECT };
-enum FillRule { FILL_WINDING, FILL_EVEN_ODD };
-enum AntialiasMode { AA_NONE, AA_GRAY, AA_SUBPIXEL, AA_DEFAULT };
-enum Filter { FILTER_GOOD, FILTER_LINEAR, FILTER_POINT };
-enum PatternType { PATTERN_COLOR, PATTERN_SURFACE, PATTERN_LINEAR_GRADIENT, PATTERN_RADIAL_GRADIENT };
-enum JoinStyle { JOIN_BEVEL, JOIN_ROUND, JOIN_MITER, JOIN_MITER_OR_BEVEL };
-enum CapStyle { CAP_BUTT, CAP_ROUND, CAP_SQUARE };
-enum SamplingBounds { SAMPLING_UNBOUNDED, SAMPLING_BOUNDED };
+MOZ_BEGIN_ENUM_CLASS(CompositionOp, int8_t)
+  OP_OVER,
+  OP_ADD,
+  OP_ATOP,
+  OP_OUT,
+  OP_IN,
+  OP_SOURCE,
+  OP_DEST_IN,
+  OP_DEST_OUT,
+  OP_DEST_OVER,
+  OP_DEST_ATOP,
+  OP_XOR,
+  OP_MULTIPLY,
+  OP_SCREEN,
+  OP_OVERLAY,
+  OP_DARKEN,
+  OP_LIGHTEN,
+  OP_COLOR_DODGE,
+  OP_COLOR_BURN,
+  OP_HARD_LIGHT,
+  OP_SOFT_LIGHT,
+  OP_DIFFERENCE,
+  OP_EXCLUSION,
+  OP_HUE,
+  OP_SATURATION,
+  OP_COLOR,
+  OP_LUMINOSITY,
+  OP_COUNT
+MOZ_END_ENUM_CLASS(CompositionOp)
+
+MOZ_BEGIN_ENUM_CLASS(ExtendMode, int8_t)
+  CLAMP,
+  REPEAT,
+  REFLECT
+MOZ_END_ENUM_CLASS(ExtendMode)
+
+MOZ_BEGIN_ENUM_CLASS(FillRule, int8_t)
+  FILL_WINDING,
+  FILL_EVEN_ODD
+MOZ_END_ENUM_CLASS(FillRule)
+
+MOZ_BEGIN_ENUM_CLASS(AntialiasMode, int8_t)
+  NONE,
+  GRAY,
+  SUBPIXEL,
+  DEFAULT
+MOZ_END_ENUM_CLASS(AntialiasMode)
+
+MOZ_BEGIN_ENUM_CLASS(Filter, int8_t)
+  GOOD,
+  LINEAR,
+  POINT
+MOZ_END_ENUM_CLASS(Filter)
+
+MOZ_BEGIN_ENUM_CLASS(PatternType, int8_t)
+  COLOR,
+  SURFACE,
+  LINEAR_GRADIENT,
+  RADIAL_GRADIENT
+MOZ_END_ENUM_CLASS(PatternType)
+
+MOZ_BEGIN_ENUM_CLASS(JoinStyle, int8_t)
+  BEVEL,
+  ROUND,
+  MITER,
+  MITER_OR_BEVEL
+MOZ_END_ENUM_CLASS(JoinStyle)
+
+MOZ_BEGIN_ENUM_CLASS(CapStyle, int8_t)
+  BUTT,
+  ROUND,
+  SQUARE
+MOZ_END_ENUM_CLASS(CapStyle)
+
+MOZ_BEGIN_ENUM_CLASS(SamplingBounds, int8_t)
+  UNBOUNDED,
+  BOUNDED
+MOZ_END_ENUM_CLASS(SamplingBounds)
 
 /* Color is stored in non-premultiplied form */
 struct Color
 {
 public:
   Color()
     : r(0.0f), g(0.0f), b(0.0f), a(0.0f)
   {}
--- a/gfx/cairo/cairo/NEWS
+++ b/gfx/cairo/cairo/NEWS
@@ -1069,17 +1069,17 @@ Fix gradients.
 
 Fix EXTEND_NONE mode for patterns.
 
 Fix cairo_quartz_surface_create to properly clear the new surface
 in cairo_quartz_surface_create.
 
 Fix to correctly handle 0x0 sized surfaces.
 
-Optimize drawing of EXTEND_REPEAT patterns for OS X 10.5.
+Optimize drawing of ExtendMode::REPEAT patterns for OS X 10.5.
 
 Snapshot 1.5.2 (2007-10-30 Carl Worth <cworth@cworth.org>)
 ==========================================================
 This is the first snapshot in cairo's unstable 1.5 series. It comes 4
 months after the 1.4.10 release. This snapshot includes significant
 improvements to PDF and PostScript output, which is one of the things
 in which we're most interested in getting feedback. There are a couple
 of minor API additions, and several optimizations, (primarily in the
@@ -3106,17 +3106,17 @@ And at least the following bugs have bee
  * PS: Fix to not draw BUTT-capped zero-length dash segments
  * Do device offset before float->fixed conversion
    http://bugzilla.gnome.org/show_bug.cgi?id=332266
  * PS: Fix source surfaces with transformations
  * PS: Fix to not draw BUTT-capped degnerate sub-paths
  * PS: Don't walk off end of array when printing "~>"
  * Fix some memory leaks in the test suite rig
  * SVG: Fix memory leak when using cairo_mask
- * Fix EXTEND_REFLECT and EXTEND_PAD to not crash (though these are
+ * Fix ExtendMode::REFLECT and EXTEND_PAD to not crash (though these are
    still not yet fully implemented for surface patterns).
 
 This has been a tremendous effort by everyone, and I'm proud to have
 been a part of it. Congratulations to all contributors to cairo!
 
 Snapshot 1.1.10 (2006-06-16 Carl Worth <cworth@cworth.org>)
 ===========================================================
 This is the fifth in a series of snapshots working toward the 1.2
--- a/gfx/cairo/cairo/src/cairo-qt-surface.cpp
+++ b/gfx/cairo/cairo/src/cairo-qt-surface.cpp
@@ -1728,19 +1728,19 @@ cairo_qt_surface_get_image (cairo_surfac
     return qs->image_equiv;
 }
 
 /*
  * TODO:
  *
  * - Figure out why QBrush isn't working with non-repeated images
  *
- * - Correct repeat mode; right now, every surface source is EXTEND_REPEAT
+ * - Correct repeat mode; right now, every surface source is ExtendMode::REPEAT
  *   - implement EXTEND_NONE (?? probably need to clip to the extents of the source)
- *   - implement EXTEND_REFLECT (create temporary and copy 4x, then EXTEND_REPEAT that)
+ *   - implement ExtendMode::REFLECT (create temporary and copy 4x, then ExtendMode::REPEAT that)
  *
  * - stroke-image failure
  *
  * - Implement mask() with non-solid masks (probably will need to use a temporary and use IN)
  *
  * - Implement gradient sources
  *
  * - Make create_similar smarter -- create QPixmaps in more circumstances
--- a/gfx/cairo/cairo/src/cairo-script-surface.c
+++ b/gfx/cairo/cairo/src/cairo-script-surface.c
@@ -312,30 +312,30 @@ static const char *
     return names[op];
 }
 
 static const char *
 _extend_to_string (cairo_extend_t extend)
 {
     static const char *names[] = {
 	"EXTEND_NONE",		/* CAIRO_EXTEND_NONE */
-	"EXTEND_REPEAT",	/* CAIRO_EXTEND_REPEAT */
-	"EXTEND_REFLECT",	/* CAIRO_EXTEND_REFLECT */
+	"ExtendMode::REPEAT",	/* CAIRO_EXTEND_REPEAT */
+	"ExtendMode::REFLECT",	/* CAIRO_EXTEND_REFLECT */
 	"EXTEND_PAD"		/* CAIRO_EXTEND_PAD */
     };
     assert (extend < ARRAY_LENGTH (names));
     return names[extend];
 }
 
 static const char *
 _filter_to_string (cairo_filter_t filter)
 {
     static const char *names[] = {
 	"FILTER_FAST",		/* CAIRO_FILTER_FAST */
-	"FILTER_GOOD",		/* CAIRO_FILTER_GOOD */
+	"Filter::GOOD",		/* CAIRO_FILTER_GOOD */
 	"FILTER_BEST",		/* CAIRO_FILTER_BEST */
 	"FILTER_NEAREST",	/* CAIRO_FILTER_NEAREST */
 	"FILTER_BILINEAR",	/* CAIRO_FILTER_BILINEAR */
 	"FILTER_GAUSSIAN",	/* CAIRO_FILTER_GAUSSIAN */
     };
     assert (filter < ARRAY_LENGTH (names));
     return names[filter];
 }
--- a/gfx/cairo/cairo/src/cairo-xml-surface.c
+++ b/gfx/cairo/cairo/src/cairo-xml-surface.c
@@ -113,30 +113,30 @@ static const char *
     return names[op];
 }
 
 static const char *
 _extend_to_string (cairo_extend_t extend)
 {
     static const char *names[] = {
 	"EXTEND_NONE",		/* CAIRO_EXTEND_NONE */
-	"EXTEND_REPEAT",	/* CAIRO_EXTEND_REPEAT */
-	"EXTEND_REFLECT",	/* CAIRO_EXTEND_REFLECT */
+	"ExtendMode::REPEAT",	/* CAIRO_EXTEND_REPEAT */
+	"ExtendMode::REFLECT",	/* CAIRO_EXTEND_REFLECT */
 	"EXTEND_PAD"		/* CAIRO_EXTEND_PAD */
     };
     assert (extend < ARRAY_LENGTH (names));
     return names[extend];
 }
 
 static const char *
 _filter_to_string (cairo_filter_t filter)
 {
     static const char *names[] = {
 	"FILTER_FAST",		/* CAIRO_FILTER_FAST */
-	"FILTER_GOOD",		/* CAIRO_FILTER_GOOD */
+	"Filter::GOOD",		/* CAIRO_FILTER_GOOD */
 	"FILTER_BEST",		/* CAIRO_FILTER_BEST */
 	"FILTER_NEAREST",	/* CAIRO_FILTER_NEAREST */
 	"FILTER_BILINEAR",	/* CAIRO_FILTER_BILINEAR */
 	"FILTER_GAUSSIAN",	/* CAIRO_FILTER_GAUSSIAN */
     };
     assert (filter < ARRAY_LENGTH (names));
     return names[filter];
 }
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -90,17 +90,17 @@ struct EffectMask : public Effect
   gfx::IntSize mSize;
   gfx::Matrix4x4 mMaskTransform;
 };
 
 // Render to a render target rather than the screen.
 struct EffectRenderTarget : public TexturedEffect
 {
   EffectRenderTarget(CompositingRenderTarget *aRenderTarget)
-    : TexturedEffect(EFFECT_RENDER_TARGET, aRenderTarget, true, gfx::FILTER_LINEAR)
+    : TexturedEffect(EFFECT_RENDER_TARGET, aRenderTarget, true, gfx::Filter::LINEAR)
     , mRenderTarget(aRenderTarget)
   {}
 
   virtual const char* Name() { return "EffectRenderTarget"; }
   virtual void PrintInfo(nsACString& aTo, const char* aPrefix);
 
   RefPtr<CompositingRenderTarget> mRenderTarget;
 };
--- a/gfx/layers/LayersLogging.cpp
+++ b/gfx/layers/LayersLogging.cpp
@@ -188,19 +188,19 @@ AppendToString(nsACString& s, const Matr
 
 nsACString&
 AppendToString(nsACString& s, const Filter filter,
                const char* pfx, const char* sfx)
 {
   s += pfx;
 
   switch (filter) {
-    case FILTER_GOOD: s += "FILTER_GOOD"; break;
-    case FILTER_LINEAR: s += "FILTER_LINEAR"; break;
-    case FILTER_POINT: s += "FILTER_POINT"; break;
+    case Filter::GOOD: s += "Filter::GOOD"; break;
+    case Filter::LINEAR: s += "Filter::LINEAR"; break;
+    case Filter::POINT: s += "Filter::POINT"; break;
   }
   return s += sfx;
 }
 
 nsACString&
 AppendToString(nsACString& s, TextureFlags flags,
                const char* pfx, const char* sfx)
 {
--- a/gfx/layers/RotatedBuffer.cpp
+++ b/gfx/layers/RotatedBuffer.cpp
@@ -16,17 +16,17 @@
 #include "gfxUtils.h"                   // for gfxUtils
 #include "mozilla/ArrayUtils.h"         // for ArrayLength
 #include "mozilla/gfx/BasePoint.h"      // for BasePoint
 #include "mozilla/gfx/BaseRect.h"       // for BaseRect
 #include "mozilla/gfx/BaseSize.h"       // for BaseSize
 #include "mozilla/gfx/Matrix.h"         // for Matrix
 #include "mozilla/gfx/Point.h"          // for Point, IntPoint
 #include "mozilla/gfx/Rect.h"           // for Rect, IntRect
-#include "mozilla/gfx/Types.h"          // for ExtendMode::EXTEND_CLAMP, etc
+#include "mozilla/gfx/Types.h"          // for ExtendMode::ExtendMode::CLAMP, etc
 #include "mozilla/layers/ShadowLayers.h"  // for ShadowableLayer
 #include "mozilla/layers/TextureClient.h"  // for DeprecatedTextureClient
 #include "nsSize.h"                     // for nsIntSize
 #include "gfx2DGlue.h"
 
 namespace mozilla {
 
 using namespace gfx;
@@ -90,73 +90,73 @@ RotatedBuffer::DrawBufferQuadrant(gfx::D
   // mBufferRect
   nsIntRect quadrantRect = GetQuadrantRectangle(aXSide, aYSide);
   nsIntRect fillRect;
   if (!fillRect.IntersectRect(mBufferRect, quadrantRect))
     return;
 
   gfx::Point quadrantTranslation(quadrantRect.x, quadrantRect.y);
 
-  MOZ_ASSERT(aOperator == OP_OVER || aOperator == OP_SOURCE);
+  MOZ_ASSERT(aOperator == CompositionOp::OP_OVER || aOperator == CompositionOp::OP_SOURCE);
   // direct2d is much slower when using OP_SOURCE so use OP_OVER and
   // (maybe) a clear instead. Normally we need to draw in a single operation
   // (to avoid flickering) but direct2d is ok since it defers rendering.
   // We should try abstract this logic in a helper when we have other use
   // cases.
-  if (aTarget->GetType() == BackendType::DIRECT2D && aOperator == OP_SOURCE) {
-    aOperator = OP_OVER;
+  if (aTarget->GetType() == BackendType::DIRECT2D && aOperator == CompositionOp::OP_SOURCE) {
+    aOperator = CompositionOp::OP_OVER;
     if (mDTBuffer->GetFormat() == SurfaceFormat::B8G8R8A8) {
       aTarget->ClearRect(ToRect(fillRect));
     }
   }
 
   RefPtr<gfx::SourceSurface> snapshot;
   if (aSource == BUFFER_BLACK) {
     snapshot = mDTBuffer->Snapshot();
   } else {
     MOZ_ASSERT(aSource == BUFFER_WHITE);
     snapshot = mDTBufferOnWhite->Snapshot();
   }
 
-  if (aOperator == OP_SOURCE) {
+  if (aOperator == CompositionOp::OP_SOURCE) {
     // OP_SOURCE is unbounded in Azure, and we really don't want that behaviour here.
     // We also can't do a ClearRect+FillRect since we need the drawing to happen
     // as an atomic operation (to prevent flickering).
     aTarget->PushClipRect(gfx::Rect(fillRect.x, fillRect.y,
                                     fillRect.width, fillRect.height));
   }
 
   if (aMask) {
     // Transform from user -> buffer space.
     Matrix transform;
     transform.Translate(quadrantTranslation.x, quadrantTranslation.y);
 
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
-    SurfacePattern source(snapshot, EXTEND_CLAMP, transform, FILTER_POINT);
+    SurfacePattern source(snapshot, ExtendMode::CLAMP, transform, Filter::POINT);
 #else
-    SurfacePattern source(snapshot, EXTEND_CLAMP, transform);
+    SurfacePattern source(snapshot, ExtendMode::CLAMP, transform);
 #endif
 
     Matrix oldTransform = aTarget->GetTransform();
     aTarget->SetTransform(*aMaskTransform);
     aTarget->MaskSurface(source, aMask, Point(0, 0), DrawOptions(aOpacity, aOperator));
     aTarget->SetTransform(oldTransform);
   } else {
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
-    DrawSurfaceOptions options(FILTER_POINT);
+    DrawSurfaceOptions options(Filter::POINT);
 #else
     DrawSurfaceOptions options;
 #endif
     aTarget->DrawSurface(snapshot, ToRect(fillRect),
                          GetSourceRectangle(aXSide, aYSide),
                          options,
                          DrawOptions(aOpacity, aOperator));
   }
 
-  if (aOperator == OP_SOURCE) {
+  if (aOperator == CompositionOp::OP_SOURCE) {
     aTarget->PopClip();
   }
 }
 
 void
 RotatedBuffer::DrawBufferWithRotation(gfx::DrawTarget *aTarget, ContextSource aSource,
                                       float aOpacity,
                                       gfx::CompositionOp aOperator,
@@ -626,27 +626,27 @@ RotatedContentBuffer::BeginPaint(ThebesL
       nsIntPoint offset = -destBufferRect.TopLeft();
       Matrix mat;
       mat.Translate(offset.x, offset.y);
       destDTBuffer->SetTransform(mat);
       if (!EnsureBuffer()) {
         return result;
       }
        MOZ_ASSERT(mDTBuffer, "Have we got a Thebes buffer for some reason?");
-      DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, OP_SOURCE);
+      DrawBufferWithRotation(destDTBuffer, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
       destDTBuffer->SetTransform(Matrix());
 
       if (mode == Layer::SURFACE_COMPONENT_ALPHA) {
         NS_ASSERTION(destDTBufferOnWhite, "Must have a white buffer!");
         destDTBufferOnWhite->SetTransform(mat);
         if (!EnsureBufferOnWhite()) {
           return result;
         }
         MOZ_ASSERT(mDTBufferOnWhite, "Have we got a Thebes buffer for some reason?");
-        DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE, 1.0, OP_SOURCE);
+        DrawBufferWithRotation(destDTBufferOnWhite, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
         destDTBufferOnWhite->SetTransform(Matrix());
       }
     }
 
     mDTBuffer = destDTBuffer.forget();
     mDTBufferOnWhite = destDTBufferOnWhite.forget();
     mBufferRect = destBufferRect;
     mBufferRotation = nsIntPoint(0,0);
--- a/gfx/layers/RotatedBuffer.h
+++ b/gfx/layers/RotatedBuffer.h
@@ -74,17 +74,17 @@ public:
     BUFFER_BLACK, // The normal buffer, or buffer with black background when using component alpha.
     BUFFER_WHITE, // The buffer with white background, only valid with component alpha.
     BUFFER_BOTH // The combined black/white buffers, only valid for writing operations, not reading.
   };
   // It is the callers repsonsibility to ensure aTarget is flushed after calling
   // this method.
   void DrawBufferWithRotation(gfx::DrawTarget* aTarget, ContextSource aSource,
                               float aOpacity = 1.0,
-                              gfx::CompositionOp aOperator = gfx::OP_OVER,
+                              gfx::CompositionOp aOperator = gfx::CompositionOp::OP_OVER,
                               gfx::SourceSurface* aMask = nullptr,
                               const gfx::Matrix* aMaskTransform = nullptr) const;
 
   /**
    * |BufferRect()| is the rect of device pixels that this
    * RotatedBuffer covers.  That is what DrawBufferWithRotation()
    * will paint when it's called.
    */
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -302,23 +302,23 @@ DrawSurfaceWithTextureCoords(DrawTarget 
   Matrix matrix = ToMatrix(transform);
   if (aMask) {
     aDest->PushClipRect(aDestRect);
     Matrix maskTransformInverse = aMaskTransform;
     maskTransformInverse.Invert();
     Matrix dtTransform = aDest->GetTransform();
     aDest->SetTransform(aMaskTransform);
     Matrix patternMatrix = maskTransformInverse * dtTransform * matrix;
-    aDest->MaskSurface(SurfacePattern(aSource, EXTEND_REPEAT, patternMatrix),
+    aDest->MaskSurface(SurfacePattern(aSource, ExtendMode::REPEAT, patternMatrix),
                        aMask, Point(), DrawOptions(aOpacity));
     aDest->SetTransform(dtTransform);
     aDest->PopClip();
   } else {
     aDest->FillRect(aDestRect,
-                    SurfacePattern(aSource, EXTEND_REPEAT, matrix),
+                    SurfacePattern(aSource, ExtendMode::REPEAT, matrix),
                     DrawOptions(aOpacity));
   }
 }
 
 static pixman_transform
 Matrix3DToPixman(const gfx3DMatrix& aMatrix)
 {
   pixman_f_transform transform;
--- a/gfx/layers/client/ContentClient.cpp
+++ b/gfx/layers/client/ContentClient.cpp
@@ -613,33 +613,33 @@ ContentClientDoubleBuffered::UpdateDesti
   DrawTarget* destDT =
     BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_BLACK);
 
   bool isClippingCheap = IsClippingCheap(destDT, aUpdateRegion);
   if (isClippingCheap) {
     gfxUtils::ClipToRegion(destDT, aUpdateRegion);
   }
 
-  aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, OP_SOURCE);
+  aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
   if (isClippingCheap) {
     destDT->PopClip();
   }
   ReturnDrawTarget(destDT);
 
   if (aSource.HaveBufferOnWhite()) {
     MOZ_ASSERT(HaveBufferOnWhite());
     DrawTarget* destDT =
       BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_WHITE);
 
     bool isClippingCheap = IsClippingCheap(destDT, aUpdateRegion);
     if (isClippingCheap) {
       gfxUtils::ClipToRegion(destDT, aUpdateRegion);
     }
 
-    aSource.DrawBufferWithRotation(destDT, BUFFER_WHITE, 1.0, OP_SOURCE);
+    aSource.DrawBufferWithRotation(destDT, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
     if (isClippingCheap) {
       destDT->PopClip();
     }
     ReturnDrawTarget(destDT);
   }
 }
 
 DeprecatedContentClientDoubleBuffered::~DeprecatedContentClientDoubleBuffered()
@@ -834,33 +834,33 @@ DeprecatedContentClientDoubleBuffered::U
     return;
   }
 
   bool isClippingCheap = IsClippingCheap(destDT, aUpdateRegion);
   if (isClippingCheap) {
     gfxUtils::ClipToRegion(destDT, aUpdateRegion);
   }
 
-  aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, OP_SOURCE);
+  aSource.DrawBufferWithRotation(destDT, BUFFER_BLACK, 1.0, CompositionOp::OP_SOURCE);
   if (isClippingCheap) {
     destDT->PopClip();
   }
   ReturnDrawTarget(destDT);
 
   if (aSource.HaveBufferOnWhite()) {
     MOZ_ASSERT(HaveBufferOnWhite());
     DrawTarget* destDT =
       BorrowDrawTargetForQuadrantUpdate(aUpdateRegion.GetBounds(), BUFFER_WHITE);
 
     bool isClippingCheap = IsClippingCheap(destDT, aUpdateRegion);
     if (isClippingCheap) {
       gfxUtils::ClipToRegion(destDT, aUpdateRegion);
     }
 
-    aSource.DrawBufferWithRotation(destDT, BUFFER_WHITE, 1.0, OP_SOURCE);
+    aSource.DrawBufferWithRotation(destDT, BUFFER_WHITE, 1.0, CompositionOp::OP_SOURCE);
     if (isClippingCheap) {
       destDT->PopClip();
     }
     ReturnDrawTarget(destDT);
   }
 }
 
 void
--- a/gfx/layers/composite/ThebesLayerComposite.cpp
+++ b/gfx/layers/composite/ThebesLayerComposite.cpp
@@ -9,17 +9,17 @@
 #include "Units.h"                      // for CSSRect, LayerPixel, etc
 #include "gfx2DGlue.h"                  // for ToMatrix4x4
 #include "gfx3DMatrix.h"                // for gfx3DMatrix
 #include "gfxUtils.h"                   // for gfxUtils, etc
 #include "mozilla/Assertions.h"         // for MOZ_ASSERT, etc
 #include "mozilla/gfx/Matrix.h"         // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for Point
 #include "mozilla/gfx/Rect.h"           // for RoundedToInt, Rect
-#include "mozilla/gfx/Types.h"          // for Filter::FILTER_LINEAR
+#include "mozilla/gfx/Types.h"          // for Filter::Filter::LINEAR
 #include "mozilla/layers/Compositor.h"  // for Compositor
 #include "mozilla/layers/ContentHost.h"  // for ContentHost
 #include "mozilla/layers/Effects.h"     // for EffectChain
 #include "mozilla/mozalloc.h"           // for operator delete
 #include "nsAString.h"
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsMathUtils.h"                // for NS_lround
 #include "nsPoint.h"                    // for nsIntPoint
@@ -130,17 +130,17 @@ ThebesLayerComposite::RenderLayer(const 
     tiledLayerProps.mValidRegion = mValidRegion;
   }
 
   mBuffer->SetPaintWillResample(MayResample());
 
   mBuffer->Composite(effectChain,
                      GetEffectiveOpacity(),
                      transform,
-                     gfx::FILTER_LINEAR,
+                     gfx::Filter::LINEAR,
                      clipRect,
                      &visibleRegion,
                      mRequiresTiledProperties ? &tiledLayerProps
                                               : nullptr);
 
 
   if (mRequiresTiledProperties) {
     mValidRegion = tiledLayerProps.mValidRegion;
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -587,17 +587,17 @@ CompositorD3D11::DrawQuad(const gfx::Rec
 
       SetSamplerForFilter(texturedEffect->mFilter);
     }
     break;
   case EFFECT_YCBCR: {
       EffectYCbCr* ycbcrEffect =
         static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
 
-      SetSamplerForFilter(FILTER_LINEAR);
+      SetSamplerForFilter(Filter::LINEAR);
 
       mVSConstants.textureCoords = ycbcrEffect->mTextureCoords;
 
       const int Y = 0, Cb = 1, Cr = 2;
       TextureSource* source = ycbcrEffect->mTexture;
 
       if (!source) {
         NS_WARNING("No texture to composite");
@@ -914,20 +914,20 @@ CompositorD3D11::UpdateConstantBuffers()
 }
 
 void
 CompositorD3D11::SetSamplerForFilter(Filter aFilter)
 {
   ID3D11SamplerState *sampler;
   switch (aFilter) {
   default:
-  case FILTER_LINEAR:
+  case Filter::LINEAR:
     sampler = mAttachments->mLinearSamplerState;
     break;
-  case FILTER_POINT:
+  case Filter::POINT:
     sampler = mAttachments->mPointSamplerState;
     break;
   }
 
   mContext->PSSetSamplers(0, 1, &sampler);
 }
 
 void
--- a/gfx/layers/d3d9/CompositorD3D9.cpp
+++ b/gfx/layers/d3d9/CompositorD3D9.cpp
@@ -315,17 +315,17 @@ CompositorD3D9::DrawQuad(const gfx::Rect
       isPremultiplied = texturedEffect->mPremultiplied;
     }
     break;
   case EFFECT_YCBCR:
     {
       EffectYCbCr* ycbcrEffect =
         static_cast<EffectYCbCr*>(aEffectChain.mPrimaryEffect.get());
 
-      SetSamplerForFilter(FILTER_LINEAR);
+      SetSamplerForFilter(Filter::LINEAR);
 
       Rect textureCoords = ycbcrEffect->mTextureCoords;
       d3d9Device->SetVertexShaderConstantF(CBvTextureCoords,
                                            ShaderConstantRect(
                                              textureCoords.x,
                                              textureCoords.y,
                                              textureCoords.width,
                                              textureCoords.height),
@@ -679,21 +679,21 @@ CompositorD3D9::EnsureSize()
 
   mSize = rect.Size();
 }
 
 void
 CompositorD3D9::SetSamplerForFilter(Filter aFilter)
 {
   switch (aFilter) {
-  case FILTER_LINEAR:
+  case Filter::LINEAR:
     device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
     device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
     return;
-  case FILTER_POINT:
+  case Filter::POINT:
     device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
     device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
     return;
   default:
     device()->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
     device()->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
   }
 }
--- a/gfx/layers/opengl/CompositorOGL.cpp
+++ b/gfx/layers/opengl/CompositorOGL.cpp
@@ -1500,17 +1500,17 @@ CompositorOGL::CopyToTarget(DrawTarget *
   Matrix glToCairoTransform = ToMatrix(aTransform);
   glToCairoTransform.Invert();
   glToCairoTransform.Scale(1.0, -1.0);
   glToCairoTransform.Translate(0.0, -height);
 
   Matrix oldMatrix = aTarget->GetTransform();
   aTarget->SetTransform(glToCairoTransform);
   Rect floatRect = Rect(rect.x, rect.y, rect.width, rect.height);
-  aTarget->DrawSurface(source, floatRect, floatRect, DrawSurfaceOptions(), DrawOptions(1.0f, OP_SOURCE));
+  aTarget->DrawSurface(source, floatRect, floatRect, DrawSurfaceOptions(), DrawOptions(1.0f, CompositionOp::OP_SOURCE));
   aTarget->SetTransform(oldMatrix);
   aTarget->Flush();
 }
 
 double
 CompositorOGL::AddFrameAndGetFps(const TimeStamp& timestamp)
 {
   if (sDrawFPS) {
--- a/gfx/src/nsRect.cpp
+++ b/gfx/src/nsRect.cpp
@@ -4,17 +4,20 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsRect.h"
 #include "mozilla/gfx/Types.h"          // for NS_SIDE_BOTTOM, etc
 #include "nsDeviceContext.h"            // for nsDeviceContext
 #include "nsString.h"               // for nsAutoString, etc
 #include "nsMargin.h"                   // for nsMargin
 
-static_assert((NS_SIDE_TOP == 0) && (NS_SIDE_RIGHT == 1) && (NS_SIDE_BOTTOM == 2) && (NS_SIDE_LEFT == 3),
+static_assert((int(NS_SIDE_TOP) == 0) &&
+              (int(NS_SIDE_RIGHT) == 1) &&
+              (int(NS_SIDE_BOTTOM) == 2) &&
+              (int(NS_SIDE_LEFT) == 3),
               "The mozilla::css::Side sequence must match the nsMargin nscoord sequence");
 
 #ifdef DEBUG
 // Diagnostics
 
 FILE* operator<<(FILE* out, const nsRect& rect)
 {
   nsAutoString tmp;
--- a/gfx/thebes/gfx2DGlue.h
+++ b/gfx/thebes/gfx2DGlue.h
@@ -75,52 +75,52 @@ inline IntSize ToIntSize(const gfxIntSiz
 {
   return IntSize(aSize.width, aSize.height);
 }
 
 inline Filter ToFilter(GraphicsFilter aFilter)
 {
   switch (aFilter) {
   case GraphicsFilter::FILTER_NEAREST:
-    return FILTER_POINT;
+    return Filter::POINT;
   case GraphicsFilter::FILTER_GOOD:
-    return FILTER_GOOD;
+    return Filter::GOOD;
   default:
-    return FILTER_LINEAR;
+    return Filter::LINEAR;
   }
 }
 
 inline GraphicsFilter ThebesFilter(Filter aFilter)
 {
   switch (aFilter) {
-  case FILTER_POINT:
+  case Filter::POINT:
     return GraphicsFilter::FILTER_NEAREST;
   default:
     return GraphicsFilter::FILTER_BEST;
   }
 }
 
 inline ExtendMode ToExtendMode(gfxPattern::GraphicsExtend aExtend)
 {
   switch (aExtend) {
   case gfxPattern::EXTEND_REPEAT:
-    return EXTEND_REPEAT;
+    return ExtendMode::REPEAT;
   case gfxPattern::EXTEND_REFLECT:
-    return EXTEND_REFLECT;
+    return ExtendMode::REFLECT;
   default:
-    return EXTEND_CLAMP;
+    return ExtendMode::CLAMP;
   }
 }
 
 inline gfxPattern::GraphicsExtend ThebesExtend(ExtendMode aExtend)
 {
   switch (aExtend) {
-  case EXTEND_REPEAT:
+  case ExtendMode::REPEAT:
     return gfxPattern::EXTEND_REPEAT;
-  case EXTEND_REFLECT:
+  case ExtendMode::REFLECT:
     return gfxPattern::EXTEND_REFLECT;
   default:
     return gfxPattern::EXTEND_PAD;
   }
 }
 
 inline gfxPoint ThebesPoint(const Point &aPoint)
 {
@@ -150,62 +150,62 @@ inline nsIntRect ThebesIntRect(const Int
 inline gfxRGBA ThebesRGBA(const Color &aColor)
 {
   return gfxRGBA(aColor.r, aColor.g, aColor.b, aColor.a);
 }
 
 inline gfxContext::GraphicsLineCap ThebesLineCap(CapStyle aStyle)
 {
   switch (aStyle) {
-  case CAP_BUTT:
+  case CapStyle::BUTT:
     return gfxContext::LINE_CAP_BUTT;
-  case CAP_ROUND:
+  case CapStyle::ROUND:
     return gfxContext::LINE_CAP_ROUND;
-  case CAP_SQUARE:
+  case CapStyle::SQUARE:
     return gfxContext::LINE_CAP_SQUARE;
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 inline CapStyle ToCapStyle(gfxContext::GraphicsLineCap aStyle)
 {
   switch (aStyle) {
   case gfxContext::LINE_CAP_BUTT:
-    return CAP_BUTT;
+    return CapStyle::BUTT;
   case gfxContext::LINE_CAP_ROUND:
-    return CAP_ROUND;
+    return CapStyle::ROUND;
   case gfxContext::LINE_CAP_SQUARE:
-    return CAP_SQUARE;
+    return CapStyle::SQUARE;
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 inline gfxContext::GraphicsLineJoin ThebesLineJoin(JoinStyle aStyle)
 {
   switch (aStyle) {
-  case JOIN_MITER:
+  case JoinStyle::MITER:
     return gfxContext::LINE_JOIN_MITER;
-  case JOIN_BEVEL:
+  case JoinStyle::BEVEL:
     return gfxContext::LINE_JOIN_BEVEL;
-  case JOIN_ROUND:
+  case JoinStyle::ROUND:
     return gfxContext::LINE_JOIN_ROUND;
   default:
     return gfxContext::LINE_JOIN_MITER;
   }
 }
 
 inline JoinStyle ToJoinStyle(gfxContext::GraphicsLineJoin aStyle)
 {
   switch (aStyle) {
   case gfxContext::LINE_JOIN_MITER:
-    return JOIN_MITER;
+    return JoinStyle::MITER;
   case gfxContext::LINE_JOIN_BEVEL:
-    return JOIN_BEVEL;
+    return JoinStyle::BEVEL;
   case gfxContext::LINE_JOIN_ROUND:
-    return JOIN_ROUND;
+    return JoinStyle::ROUND;
   }
   MOZ_CRASH("Incomplete switch");
 }
 
 inline gfxImageFormat SurfaceFormatToImageFormat(SurfaceFormat aFormat)
 {
   switch (aFormat) {
   case SurfaceFormat::B8G8R8A8:
@@ -253,118 +253,118 @@ inline gfxContentType ContentForFormat(c
     return GFX_CONTENT_COLOR_ALPHA;
   }
 }
 
 inline CompositionOp CompositionOpForOp(gfxContext::GraphicsOperator aOp)
 {
   switch (aOp) {
   case gfxContext::OPERATOR_ADD:
-    return OP_ADD;
+    return CompositionOp::OP_ADD;
   case gfxContext::OPERATOR_ATOP:
-    return OP_ATOP;
+    return CompositionOp::OP_ATOP;
   case gfxContext::OPERATOR_IN:
-    return OP_IN;
+    return CompositionOp::OP_IN;
   case gfxContext::OPERATOR_OUT:
-    return OP_OUT;
+    return CompositionOp::OP_OUT;
   case gfxContext::OPERATOR_SOURCE:
-    return OP_SOURCE;
+    return CompositionOp::OP_SOURCE;
   case gfxContext::OPERATOR_DEST_IN:
-    return OP_DEST_IN;
+    return CompositionOp::OP_DEST_IN;
   case gfxContext::OPERATOR_DEST_OUT:
-    return OP_DEST_OUT;
+    return CompositionOp::OP_DEST_OUT;
   case gfxContext::OPERATOR_DEST_ATOP:
-    return OP_DEST_ATOP;
+    return CompositionOp::OP_DEST_ATOP;
   case gfxContext::OPERATOR_XOR:
-    return OP_XOR;
+    return CompositionOp::OP_XOR;
   case gfxContext::OPERATOR_MULTIPLY:
-    return OP_MULTIPLY;
+    return CompositionOp::OP_MULTIPLY;
   case gfxContext::OPERATOR_SCREEN:
-    return OP_SCREEN;
+    return CompositionOp::OP_SCREEN;
   case gfxContext::OPERATOR_OVERLAY:
-    return OP_OVERLAY;
+    return CompositionOp::OP_OVERLAY;
   case gfxContext::OPERATOR_DARKEN:
-    return OP_DARKEN;
+    return CompositionOp::OP_DARKEN;
   case gfxContext::OPERATOR_LIGHTEN:
-    return OP_LIGHTEN;
+    return CompositionOp::OP_LIGHTEN;
   case gfxContext::OPERATOR_COLOR_DODGE:
-    return OP_COLOR_DODGE;
+    return CompositionOp::OP_COLOR_DODGE;
   case gfxContext::OPERATOR_COLOR_BURN:
-    return OP_COLOR_BURN;
+    return CompositionOp::OP_COLOR_BURN;
   case gfxContext::OPERATOR_HARD_LIGHT:
-    return OP_HARD_LIGHT;
+    return CompositionOp::OP_HARD_LIGHT;
   case gfxContext::OPERATOR_SOFT_LIGHT:
-    return OP_SOFT_LIGHT;
+    return CompositionOp::OP_SOFT_LIGHT;
   case gfxContext::OPERATOR_DIFFERENCE:
-    return OP_DIFFERENCE;
+    return CompositionOp::OP_DIFFERENCE;
   case gfxContext::OPERATOR_EXCLUSION:
-    return OP_EXCLUSION;
+    return CompositionOp::OP_EXCLUSION;
   case gfxContext::OPERATOR_HUE:
-    return OP_HUE;
+    return CompositionOp::OP_HUE;
   case gfxContext::OPERATOR_SATURATION:
-    return OP_SATURATION;
+    return CompositionOp::OP_SATURATION;
   case gfxContext::OPERATOR_COLOR:
-    return OP_COLOR;
+    return CompositionOp::OP_COLOR;
   case gfxContext::OPERATOR_LUMINOSITY:
-    return OP_LUMINOSITY;
+    return CompositionOp::OP_LUMINOSITY;
   default:
-    return OP_OVER;
+    return CompositionOp::OP_OVER;
   }
 }
 
 inline gfxContext::GraphicsOperator ThebesOp(CompositionOp aOp)
 {
   switch (aOp) {
-  case OP_ADD:
+  case CompositionOp::OP_ADD:
     return gfxContext::OPERATOR_ADD;
-  case OP_ATOP:
+  case CompositionOp::OP_ATOP:
     return gfxContext::OPERATOR_ATOP;
-  case OP_IN:
+  case CompositionOp::OP_IN:
     return gfxContext::OPERATOR_IN;
-  case OP_OUT:
+  case CompositionOp::OP_OUT:
     return gfxContext::OPERATOR_OUT;
-  case OP_SOURCE:
+  case CompositionOp::OP_SOURCE:
     return gfxContext::OPERATOR_SOURCE;
-  case OP_DEST_IN:
+  case CompositionOp::OP_DEST_IN:
     return gfxContext::OPERATOR_DEST_IN;
-  case OP_DEST_OUT:
+  case CompositionOp::OP_DEST_OUT:
     return gfxContext::OPERATOR_DEST_OUT;
-  case OP_DEST_ATOP:
+  case CompositionOp::OP_DEST_ATOP:
     return gfxContext::OPERATOR_DEST_ATOP;
-  case OP_XOR:
+  case CompositionOp::OP_XOR:
     return gfxContext::OPERATOR_XOR;
-  case OP_MULTIPLY:
+  case CompositionOp::OP_MULTIPLY:
     return gfxContext::OPERATOR_MULTIPLY;
-  case OP_SCREEN:
+  case CompositionOp::OP_SCREEN:
     return gfxContext::OPERATOR_SCREEN;
-  case OP_OVERLAY:
+  case CompositionOp::OP_OVERLAY:
     return gfxContext::OPERATOR_OVERLAY;
-  case OP_DARKEN:
+  case CompositionOp::OP_DARKEN:
     return gfxContext::OPERATOR_DARKEN;
-  case OP_LIGHTEN:
+  case CompositionOp::OP_LIGHTEN:
     return gfxContext::OPERATOR_LIGHTEN;
-  case OP_COLOR_DODGE:
+  case CompositionOp::OP_COLOR_DODGE:
     return gfxContext::OPERATOR_COLOR_DODGE;
-  case OP_COLOR_BURN:
+  case CompositionOp::OP_COLOR_BURN:
     return gfxContext::OPERATOR_COLOR_BURN;
-  case OP_HARD_LIGHT:
+  case CompositionOp::OP_HARD_LIGHT:
     return gfxContext::OPERATOR_HARD_LIGHT;
-  case OP_SOFT_LIGHT:
+  case CompositionOp::OP_SOFT_LIGHT:
     return gfxContext::OPERATOR_SOFT_LIGHT;
-  case OP_DIFFERENCE:
+  case CompositionOp::OP_DIFFERENCE:
     return gfxContext::OPERATOR_DIFFERENCE;
-  case OP_EXCLUSION:
+  case CompositionOp::OP_EXCLUSION:
     return gfxContext::OPERATOR_EXCLUSION;
-  case OP_HUE:
+  case CompositionOp::OP_HUE:
     return gfxContext::OPERATOR_HUE;
-  case OP_SATURATION:
+  case CompositionOp::OP_SATURATION:
     return gfxContext::OPERATOR_SATURATION;
-  case OP_COLOR:
+  case CompositionOp::OP_COLOR:
     return gfxContext::OPERATOR_COLOR;
-  case OP_LUMINOSITY:
+  case CompositionOp::OP_LUMINOSITY:
     return gfxContext::OPERATOR_LUMINOSITY;
   default:
     return gfxContext::OPERATOR_OVER;
   }
 }
 
 inline void
 ToMatrix4x4(const gfx3DMatrix& aIn, Matrix4x4& aOut)
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -55,17 +55,17 @@ public:
       if (state.patternTransformChanged) {
         Matrix mat = mContext->GetDTTransform();
         mat.Invert();
 
         transform = transform * state.patternTransform * mat;
       }
 
       mPattern = new (mSurfacePattern.addr())
-        SurfacePattern(state.sourceSurface, EXTEND_CLAMP, transform);
+        SurfacePattern(state.sourceSurface, ExtendMode::CLAMP, transform);
       return *mPattern;
     } else {
       mPattern = new (mColorPattern.addr())
         ColorPattern(state.color);
       return *mPattern;
     }
   }
 
@@ -925,33 +925,33 @@ gfxContext::SetAntialiasMode(AntialiasMo
   if (mCairo) {
     if (mode == MODE_ALIASED) {
         cairo_set_antialias(mCairo, CAIRO_ANTIALIAS_NONE);
     } else if (mode == MODE_COVERAGE) {
         cairo_set_antialias(mCairo, CAIRO_ANTIALIAS_DEFAULT);
     }
   } else {
     if (mode == MODE_ALIASED) {
-      CurrentState().aaMode = AA_NONE;
+      CurrentState().aaMode = gfx::AntialiasMode::NONE;
     } else if (mode == MODE_COVERAGE) {
-      CurrentState().aaMode = AA_SUBPIXEL;
+      CurrentState().aaMode = gfx::AntialiasMode::SUBPIXEL;
     }
   }
 }
 
 gfxContext::AntialiasMode
 gfxContext::CurrentAntialiasMode() const
 {
   if (mCairo) {
     cairo_antialias_t aa = cairo_get_antialias(mCairo);
     if (aa == CAIRO_ANTIALIAS_NONE)
         return MODE_ALIASED;
     return MODE_COVERAGE;
   } else {
-    if (CurrentState().aaMode == AA_NONE) {
+    if (CurrentState().aaMode == gfx::AntialiasMode::NONE) {
       return MODE_ALIASED;
     }
     return MODE_COVERAGE;
   }
 }
 
 void
 gfxContext::SetDash(gfxLineType ltype)
@@ -1148,17 +1148,17 @@ gfxContext::CurrentMiterLimit() const
 }
 
 void
 gfxContext::SetFillRule(FillRule rule)
 {
   if (mCairo) {
     cairo_set_fill_rule(mCairo, (cairo_fill_rule_t)rule);
   } else {
-    CurrentState().fillRule = rule == FILL_RULE_WINDING ? FILL_WINDING : FILL_EVEN_ODD;
+    CurrentState().fillRule = rule == FILL_RULE_WINDING ? gfx::FillRule::FILL_WINDING : gfx::FillRule::FILL_EVEN_ODD;
   }
 }
 
 gfxContext::FillRule
 gfxContext::CurrentFillRule() const
 {
   if (mCairo) {
     return (FillRule)cairo_get_fill_rule(mCairo);
@@ -2066,17 +2066,17 @@ gfxContext::FillAzure(Float aOpacity)
 
   CompositionOp op = GetOp();
 
   if (mPathIsRect) {
     MOZ_ASSERT(!mTransformChanged);
 
     if (state.opIsClear) {
       mDT->ClearRect(mRect);
-    } else if (op == OP_SOURCE) {
+    } else if (op == CompositionOp::OP_SOURCE) {
       // Emulate cairo operator source which is bound by mask!
       mDT->ClearRect(mRect);
       mDT->FillRect(mRect, GeneralPattern(this), DrawOptions(aOpacity));
     } else {
       mDT->FillRect(mRect, GeneralPattern(this), DrawOptions(aOpacity, op, state.aaMode));
     }
   } else {
     EnsurePath();
@@ -2115,38 +2115,38 @@ gfxContext::PushClipsToDT(DrawTarget *aD
       }
     }
   }
 }
 
 CompositionOp
 gfxContext::GetOp()
 {
-  if (CurrentState().op != OP_SOURCE) {
+  if (CurrentState().op != CompositionOp::OP_SOURCE) {
     return CurrentState().op;
   }
 
   AzureState &state = CurrentState();
   if (state.pattern) {
     if (state.pattern->IsOpaque()) {
-      return OP_OVER;
+      return CompositionOp::OP_OVER;
     } else {
-      return OP_SOURCE;
+      return CompositionOp::OP_SOURCE;
     }
   } else if (state.sourceSurface) {
     if (state.sourceSurface->GetFormat() == SurfaceFormat::B8G8R8X8) {
-      return OP_OVER;
+      return CompositionOp::OP_OVER;
     } else {
-      return OP_SOURCE;
+      return CompositionOp::OP_SOURCE;
     }
   } else {
     if (state.color.a > 0.999) {
-      return OP_OVER;
+      return CompositionOp::OP_OVER;
     } else {
-      return OP_SOURCE;
+      return CompositionOp::OP_SOURCE;
     }
   }
 }
 
 /* SVG font code can change the transform after having set the pattern on the
  * context. When the pattern is set it is in user space, if the transform is
  * changed after doing so the pattern needs to be converted back into userspace.
  * We just store the old pattern transform here so that we only do the work
--- a/gfx/thebes/gfxContext.h
+++ b/gfx/thebes/gfxContext.h
@@ -726,22 +726,22 @@ private:
   typedef mozilla::gfx::Rect Rect;
   typedef mozilla::gfx::CompositionOp CompositionOp;
   typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::PathBuilder PathBuilder;
   typedef mozilla::gfx::SourceSurface SourceSurface;
   
   struct AzureState {
     AzureState()
-      : op(mozilla::gfx::OP_OVER)
+      : op(mozilla::gfx::CompositionOp::OP_OVER)
       , opIsClear(false)
       , color(0, 0, 0, 1.0f)
       , clipWasReset(false)
-      , fillRule(mozilla::gfx::FILL_WINDING)
-      , aaMode(mozilla::gfx::AA_SUBPIXEL)
+      , fillRule(mozilla::gfx::FillRule::FILL_WINDING)
+      , aaMode(mozilla::gfx::AntialiasMode::SUBPIXEL)
       , patternTransformChanged(false)
     {}
 
     mozilla::gfx::CompositionOp op;
     bool opIsClear;
     Color color;
     nsRefPtr<gfxPattern> pattern;
     nsRefPtr<gfxASurface> sourceSurfCairo;
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -2211,23 +2211,23 @@ private:
     }
 
 #undef GLYPH_BUFFER_SIZE
 };
 
 static AntialiasMode Get2DAAMode(gfxFont::AntialiasOption aAAOption) {
   switch (aAAOption) {
   case gfxFont::kAntialiasSubpixel:
-    return AA_SUBPIXEL;
+    return AntialiasMode::SUBPIXEL;
   case gfxFont::kAntialiasGrayscale:
-    return AA_GRAY;
+    return AntialiasMode::GRAY;
   case gfxFont::kAntialiasNone:
-    return AA_NONE;
+    return AntialiasMode::NONE;
   default:
-    return AA_DEFAULT;
+    return AntialiasMode::DEFAULT;
   }
 }
 
 struct GlyphBufferAzure {
 #define GLYPH_BUFFER_SIZE (2048/sizeof(Glyph))
     Glyph mGlyphBuffer[GLYPH_BUFFER_SIZE];
     unsigned int mNumGlyphs;
 
@@ -2284,21 +2284,21 @@ struct GlyphBufferAzure {
                     Matrix *mat = nullptr;
                     if (aInvFontMatrix) {
                         // The brush matrix needs to be multiplied with the inverted matrix
                         // as well, to move the brush into the space of the glyphs. Before
                         // the render target transformation
 
                         // This relies on the returned Pattern not to be reused by
                         // others, but regenerated on GetPattern calls. This is true!
-                        if (pat->GetType() == PATTERN_LINEAR_GRADIENT) {
+                        if (pat->GetType() == PatternType::LINEAR_GRADIENT) {
                             mat = &static_cast<LinearGradientPattern*>(pat)->mMatrix;
-                        } else if (pat->GetType() == PATTERN_RADIAL_GRADIENT) {
+                        } else if (pat->GetType() == PatternType::RADIAL_GRADIENT) {
                             mat = &static_cast<RadialGradientPattern*>(pat)->mMatrix;
-                        } else if (pat->GetType() == PATTERN_SURFACE) {
+                        } else if (pat->GetType() == PatternType::SURFACE) {
                             mat = &static_cast<SurfacePattern*>(pat)->mMatrix;
                         }
 
                         if (mat) {
                             saved = *mat;
                             *mat = (*mat) * (*aInvFontMatrix);
                         }
                     }
@@ -2307,17 +2307,17 @@ struct GlyphBufferAzure {
                                     aDrawOptions, aOptions);
 
                     if (mat) {
                         *mat = saved;
                     }
                 }
             } else if (state.sourceSurface) {
                 aDT->FillGlyphs(aFont, buf, SurfacePattern(state.sourceSurface,
-                                                           EXTEND_CLAMP,
+                                                           ExtendMode::CLAMP,
                                                            state.surfTransform),
                                 aDrawOptions, aOptions);
             } else {
                 aDT->FillGlyphs(aFont, buf, ColorPattern(state.color),
                                 aDrawOptions, aOptions);
             }
         }
         if (int(aDrawMode) & int(DrawMode::GLYPH_PATH)) {
--- a/gfx/thebes/gfxGradientCache.cpp
+++ b/gfx/thebes/gfxGradientCache.cpp
@@ -40,17 +40,17 @@ struct GradientCacheKey : public PLDHash
   };
 
   static PLDHashNumber
   HashKey(const KeyTypePointer aKey)
   {
     PLDHashNumber hash = 0;
     FloatUint32 convert;
     hash = AddToHash(hash, int(aKey->mBackendType));
-    hash = AddToHash(hash, aKey->mExtend);
+    hash = AddToHash(hash, int(aKey->mExtend));
     for (uint32_t i = 0; i < aKey->mStops.Length(); i++) {
       hash = AddToHash(hash, aKey->mStops[i].color.ToABGR());
       // Use the float bits as hash, except for the cases of 0.0 and -0.0 which both map to 0
       convert.f = aKey->mStops[i].offset;
       hash = AddToHash(hash, convert.f ? convert.u : 0);
     }
     return hash;
   }
--- a/gfx/thebes/gfxPattern.cpp
+++ b/gfx/thebes/gfxPattern.cpp
@@ -116,18 +116,18 @@ gfxPattern::CacheColorStops(mozilla::gfx
       double offset, r, g, b, a;
       cairo_pattern_get_color_stop_rgba(mPattern, n, &offset, &r, &g, &b, &a);
       stops[n].color = mozilla::gfx::Color(r, g, b, a);
       stops[n].offset = offset;
     }
     mStops = gfxGradientCache::GetOrCreateGradientStops(aDT,
                                                         stops,
                                                         (cairo_pattern_get_extend(mPattern) == CAIRO_EXTEND_REPEAT)
-                                                        ? mozilla::gfx::EXTEND_REPEAT
-                                                        : mozilla::gfx::EXTEND_CLAMP);
+                                                        ? mozilla::gfx::ExtendMode::REPEAT
+                                                        : mozilla::gfx::ExtendMode::CLAMP);
   }
 }
 
 void
 gfxPattern::SetMatrix(const gfxMatrix& matrix)
 {
   if (mPattern) {
     cairo_matrix_t mat = *reinterpret_cast<const cairo_matrix_t*>(&matrix);
--- a/gfx/thebes/gfxPlatform.h
+++ b/gfx/thebes/gfxPlatform.h
@@ -49,17 +49,17 @@ namespace gfx {
 class DrawTarget;
 class SourceSurface;
 class ScaledFont;
 class DrawEventRecorder;
 
 inline uint32_t
 BackendTypeBit(BackendType b)
 {
-  return 1 << int(b);
+  return 1 << uint8_t(b);
 }
 }
 }
 
 extern cairo_user_data_key_t kDrawTarget;
 
 // pref lang id's for font prefs
 // !!! needs to match the list of pref font.default.xx entries listed in all.js !!!
--- a/image/src/imgTools.cpp
+++ b/image/src/imgTools.cpp
@@ -151,17 +151,17 @@ NS_IMETHODIMP imgTools::EncodeScaledImag
     RefPtr<DrawTarget> dt =
       gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(dest, IntSize(aScaledWidth, aScaledHeight));
     RefPtr<SourceSurface> source = gfxPlatform::GetPlatform()->GetSourceSurfaceForSurface(dt, frame);
 
     dt->DrawSurface(source,
                     Rect(0, 0, aScaledWidth, aScaledHeight),
                     Rect(0, 0, frameWidth, frameHeight),
                     DrawSurfaceOptions(),
-                    DrawOptions(1.0f, OP_SOURCE));
+                    DrawOptions(1.0f, CompositionOp::OP_SOURCE));
   } else {
     gfxContext ctx(dest);
 
     // Set scaling
     gfxFloat sw = (double) aScaledWidth / frameWidth;
     gfxFloat sh = (double) aScaledHeight / frameHeight;
     ctx.Scale(sw, sh);
 
--- a/layout/base/nsCSSRendering.cpp
+++ b/layout/base/nsCSSRendering.cpp
@@ -2276,17 +2276,17 @@ nsCSSRendering::PaintGradient(nsPresCont
     rawStops.SetLength(stops.Length());
     for(uint32_t i = 0; i < stops.Length(); i++) {
       rawStops[i].color = gfx::Color(stops[i].mColor.r, stops[i].mColor.g, stops[i].mColor.b, stops[i].mColor.a);
       rawStops[i].offset = stopScale * (stops[i].mPosition - stopOrigin);
     }
     mozilla::RefPtr<mozilla::gfx::GradientStops> gs =
       gfxGradientCache::GetOrCreateGradientStops(ctx->GetDrawTarget(),
                                                  rawStops,
-                                                 isRepeat ? gfx::EXTEND_REPEAT : gfx::EXTEND_CLAMP);
+                                                 isRepeat ? gfx::ExtendMode::REPEAT : gfx::ExtendMode::CLAMP);
     gradientPattern->SetColorStops(gs);
   } else {
     for (uint32_t i = 0; i < stops.Length(); i++) {
       double pos = stopScale*(stops[i].mPosition - stopOrigin);
       gradientPattern->AddColorStop(pos, stops[i].mColor);
     }
     // Set repeat mode. Default cairo extend mode is PAD.
     if (isRepeat) {
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -1137,26 +1137,26 @@ nsCSSBorderRenderer::CreateCornerGradien
   // rendering with the Direct2D Azure and Quartz Cairo backends. For other
   // cairo backends it could create un-antialiased border corner transitions
   // since that at least used to be pixman's behaviour for hard stops.
   rawStops[0].color = firstColor;
   rawStops[0].offset = 0.5;
   rawStops[1].color = secondColor;
   rawStops[1].offset = 0.5;
   RefPtr<GradientStops> gs =
-    gfxGradientCache::GetGradientStops(aDT, rawStops, EXTEND_CLAMP);
+    gfxGradientCache::GetGradientStops(aDT, rawStops, ExtendMode::CLAMP);
   if (!gs) {
     // Having two corners, both with reversed color stops is pretty common
     // for certain border types. Let's optimize it!
     rawStops[0].color = secondColor;
     rawStops[1].color = firstColor;
     Point tmp = aPoint1;
     aPoint1 = aPoint2;
     aPoint2 = tmp;
-    gs = gfxGradientCache::GetOrCreateGradientStops(aDT, rawStops, EXTEND_CLAMP);
+    gs = gfxGradientCache::GetOrCreateGradientStops(aDT, rawStops, ExtendMode::CLAMP);
   }
   return gs;
 }
 
 typedef struct { gfxFloat a, b; } twoFloats;
 
 void
 nsCSSBorderRenderer::DrawSingleWidthSolidBorder()
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2401,17 +2401,17 @@ nsChildView::MaybeDrawRoundedCorners(GLM
   nsIntSize size(mDevPixelCornerRadius, mDevPixelCornerRadius);
   mCornerMaskImage->UpdateIfNeeded(size, nsIntRegion(), ^(gfx::DrawTarget* drawTarget, const nsIntRegion& updateRegion) {
     ClearRegion(drawTarget, updateRegion);
     RefPtr<gfx::PathBuilder> builder = drawTarget->CreatePathBuilder();
     builder->Arc(gfx::Point(mDevPixelCornerRadius, mDevPixelCornerRadius), mDevPixelCornerRadius, 0, 2.0f * M_PI);
     RefPtr<gfx::Path> path = builder->Finish();
     drawTarget->Fill(path,
                      gfx::ColorPattern(gfx::Color(1.0, 1.0, 1.0, 1.0)),
-                     gfx::DrawOptions(1.0f, gfx::OP_SOURCE));
+                     gfx::DrawOptions(1.0f, gfx::CompositionOp::OP_SOURCE));
   });
 
   // Use operator destination in: multiply all 4 channels with source alpha.
   aManager->gl()->fBlendFuncSeparate(LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA,
                                      LOCAL_GL_ZERO, LOCAL_GL_SRC_ALPHA);
 
   gfx3DMatrix flipX = gfx3DMatrix::ScalingMatrix(-1, 1, 1);
   gfx3DMatrix flipY = gfx3DMatrix::ScalingMatrix(1, -1, 1);
@@ -2703,17 +2703,17 @@ RectTextureImage::UpdateFromCGContext(co
     gfxUtils::ClipToRegion(dt, GetUpdateRegion());
     RefPtr<gfx::SourceSurface> sourceSurface =
       dt->CreateSourceSurfaceFromData(static_cast<uint8_t *>(CGBitmapContextGetData(aCGContext)),
                                       size,
                                       CGBitmapContextGetBytesPerRow(aCGContext),
                                       gfx::SurfaceFormat::B8G8R8A8);
     dt->DrawSurface(sourceSurface, rect, rect,
                     gfx::DrawSurfaceOptions(),
-                    gfx::DrawOptions(1.0, gfx::OP_SOURCE));
+                    gfx::DrawOptions(1.0, gfx::CompositionOp::OP_SOURCE));
     dt->PopClip();
     EndUpdate();
   }
 }
 
 void
 RectTextureImage::UpdateFromDrawTarget(const nsIntSize& aNewSize,
                                        const nsIntRegion& aDirtyRegion,
@@ -2724,17 +2724,17 @@ RectTextureImage::UpdateFromDrawTarget(c
   RefPtr<gfx::DrawTarget> drawTarget = BeginUpdate(aNewSize, aDirtyRegion);
   if (drawTarget) {
     if (drawTarget != aFromDrawTarget) {
       RefPtr<gfx::SourceSurface> source = aFromDrawTarget->Snapshot();
       gfx::Rect rect(0, 0, aFromDrawTarget->GetSize().width, aFromDrawTarget->GetSize().height);
       gfxUtils::ClipToRegion(drawTarget, GetUpdateRegion());
       drawTarget->DrawSurface(source, rect, rect,
                               gfx::DrawSurfaceOptions(),
-                              gfx::DrawOptions(1.0, gfx::OP_SOURCE));
+                              gfx::DrawOptions(1.0, gfx::CompositionOp::OP_SOURCE));
       drawTarget->PopClip();
     }
     EndUpdate();
   }
   mUpdateDrawTarget = nullptr;
 }
 
 void
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -2279,17 +2279,17 @@ nsWindow::UpdateAlpha(gfxPattern* aPatte
       nsAutoArrayPtr<uint8_t> imageBuffer(new (std::nothrow) uint8_t[bufferSize]);
       RefPtr<DrawTarget> drawTarget = gfxPlatform::GetPlatform()->
           CreateDrawTargetForData(imageBuffer, ToIntSize(aBoundsRect.Size()),
                                   stride, SurfaceFormat::A8);
 
       if (drawTarget) {
           drawTarget->FillRect(Rect(0, 0, aBoundsRect.width, aBoundsRect.height),
                                *aPattern->GetPattern(drawTarget),
-                               DrawOptions(1.0, OP_SOURCE));
+                               DrawOptions(1.0, CompositionOp::OP_SOURCE));
       }
       UpdateTranslucentWindowAlphaInternal(aBoundsRect, imageBuffer, stride);
   } else {
       nsRefPtr<gfxImageSurface> img =
           new gfxImageSurface(aBoundsRect.Size(), gfxImageFormatA8);
       if (img && !img->CairoStatus()) {
           img->SetDeviceOffset(-aBoundsRect.TopLeft());