Bug 1611041 - Convert image-rendering #defines to an enum class. r=emilio
authorThomas Dolezal <thomas.dolezal@mail.utoronto.ca>
Thu, 30 Jan 2020 04:34:32 +0100
changeset 512086 c06f42caa50864b4388a89673ae0b12c82c3a5ca
parent 512085 485e623584d63bbaba3a8b8267bb1d6e55c68042
child 512087 4277d047f5b7b05a1a7e12a0067fc91b0b0e3183
push id37071
push usercsabou@mozilla.com
push dateThu, 30 Jan 2020 09:53:03 +0000
treeherdermozilla-central@7b794b53736c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1611041
milestone74.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 1611041 - Convert image-rendering #defines to an enum class. r=emilio MANUAL PUSH: Contributor didn't use Phabricator and I don't want patch to rot
layout/base/nsLayoutUtils.cpp
layout/style/ServoBindings.toml
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
servo/components/style/properties/longhands/inherited_box.mako.rs
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -6545,21 +6545,21 @@ SamplingFilter nsLayoutUtils::GetSamplin
   ComputedStyle* sc;
   if (nsCSSRendering::IsCanvasFrame(aForFrame)) {
     nsCSSRendering::FindBackground(aForFrame, &sc);
   } else {
     sc = aForFrame->Style();
   }
 
   switch (sc->StyleVisibility()->mImageRendering) {
-    case NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED:
+    case StyleImageRendering::Optimizespeed:
       return SamplingFilter::POINT;
-    case NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY:
+    case StyleImageRendering::Optimizequality:
       return SamplingFilter::LINEAR;
-    case NS_STYLE_IMAGE_RENDERING_CRISP_EDGES:
+    case StyleImageRendering::CrispEdges:
       return SamplingFilter::POINT;
     default:
       return defaultFilter;
   }
 }
 
 /**
  * Given an image being drawn into an appunit coordinate system, and
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -94,16 +94,17 @@ rusty-enums = [
     "mozilla::StyleOrient",
     "mozilla::StyleBoxSizing",
     "mozilla::StyleClear",
     "mozilla::StyleColumnFill",
     "mozilla::StyleColumnSpan",
     "mozilla::StyleDirection",
     "mozilla::StyleFloat",
     "mozilla::StyleImageOrientation",
+    "mozilla::StyleImageRendering",
     "mozilla::StyleUserModify",
     "mozilla::StyleUserInput",
     "mozilla::StyleBoxDirection",
     "mozilla::StyleTextJustify",
     "mozilla::StyleRubyAlign",
     "mozilla::StyleTextSizeAdjust",
     "mozilla::StyleHyphens",
     "mozilla::StyleRubyPosition",
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -740,20 +740,22 @@ enum class StyleDominantBaseline : uint8
   Mathematical,
   Central,
   Middle,
   TextAfterEdge,
   TextBeforeEdge,
 };
 
 // image-rendering
-#define NS_STYLE_IMAGE_RENDERING_AUTO 0
-#define NS_STYLE_IMAGE_RENDERING_OPTIMIZESPEED 1
-#define NS_STYLE_IMAGE_RENDERING_OPTIMIZEQUALITY 2
-#define NS_STYLE_IMAGE_RENDERING_CRISP_EDGES 3
+enum class StyleImageRendering : uint8_t {
+  Auto,
+  Optimizespeed,
+  Optimizequality,
+  CrispEdges,
+};
 
 // mask-type
 enum class StyleMaskType : uint8_t {
   Luminance,
   Alpha,
 };
 
 // shape-rendering
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -3125,17 +3125,17 @@ nsChangeHint nsStyleDisplay::CalcDiffere
 // nsStyleVisibility
 //
 
 nsStyleVisibility::nsStyleVisibility(const Document& aDocument)
     : mDirection(aDocument.GetBidiOptions() == IBMBIDI_TEXTDIRECTION_RTL
                      ? StyleDirection::Rtl
                      : StyleDirection::Ltr),
       mVisible(StyleVisibility::Visible),
-      mImageRendering(NS_STYLE_IMAGE_RENDERING_AUTO),
+      mImageRendering(StyleImageRendering::Auto),
       mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB),
       mTextOrientation(StyleTextOrientation::Mixed),
       mColorAdjust(StyleColorAdjust::Economy) {
   MOZ_COUNT_CTOR(nsStyleVisibility);
 }
 
 nsStyleVisibility::nsStyleVisibility(const nsStyleVisibility& aSource)
     : mImageOrientation(aSource.mImageOrientation),
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1256,17 +1256,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   ~nsStyleVisibility() { MOZ_COUNT_DTOR(nsStyleVisibility); }
   static constexpr bool kHasTriggerImageLoads = false;
 
   nsChangeHint CalcDifference(const nsStyleVisibility& aNewData) const;
 
   mozilla::StyleImageOrientation mImageOrientation;
   mozilla::StyleDirection mDirection;
   mozilla::StyleVisibility mVisible;
-  uint8_t mImageRendering;  // NS_STYLE_IMAGE_RENDERING_*
+  mozilla::StyleImageRendering mImageRendering;
   uint8_t mWritingMode;     // NS_STYLE_WRITING_MODE_*
   mozilla::StyleTextOrientation mTextOrientation;
   mozilla::StyleColorAdjust mColorAdjust;
 
   bool IsVisible() const {
     return mVisible == mozilla::StyleVisibility::Visible;
   }
 
--- a/servo/components/style/properties/longhands/inherited_box.mako.rs
+++ b/servo/components/style/properties/longhands/inherited_box.mako.rs
@@ -73,16 +73,17 @@
 ${helpers.single_keyword(
     "image-rendering",
     "auto crisp-edges",
     engines="gecko servo-2013 servo-2020",
     extra_gecko_values="optimizespeed optimizequality",
     extra_servo_2013_values="pixelated",
     extra_servo_2020_values="pixelated",
     gecko_aliases="-moz-crisp-edges=crisp-edges",
+    gecko_enum_prefix="StyleImageRendering",
     animation_value_type="discrete",
     spec="https://drafts.csswg.org/css-images/#propdef-image-rendering",
 )}
 
 ${helpers.single_keyword(
     "image-orientation",
     "none from-image",
     engines="gecko",