Bug 1597979 : convert NS_STYLE_TEXT_ANCHOR_* to an enum class in nsStyleConsts.h r=emilio
authorjeffin143 <jeffinsam@karunya.edu.in>
Thu, 21 Nov 2019 08:48:19 +0000
changeset 503157 d68f192a42e5742e1b18a4c57d495b4182bed77a
parent 503156 fd6c0265761ec7fc6c3cf220f9fc44dd235692a2
child 503158 a63f4be757ec28b4362f900f910ff3b21f5accdd
push id36828
push userccoroiu@mozilla.com
push dateThu, 21 Nov 2019 21:44:22 +0000
treeherdermozilla-central@76e20a306bc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1597979
milestone72.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 1597979 : convert NS_STYLE_TEXT_ANCHOR_* to an enum class in nsStyleConsts.h r=emilio Differential Revision: https://phabricator.services.mozilla.com/D53956
layout/style/ServoBindings.toml
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/svg/SVGTextFrame.cpp
servo/components/style/properties/longhands/inherited_svg.mako.rs
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -125,16 +125,17 @@ rusty-enums = [
     "mozilla::StyleTextRendering",
     "mozilla::StyleColorAdjust",
     "mozilla::StyleFlexDirection",
     "mozilla::StyleStrokeLinecap",
     "mozilla::StyleFlexWrap",
     "mozilla::StyleTextDecorationSkipInk",
     "mozilla::StyleTextDecorationLength",
     "mozilla::StyleShapeRendering",
+    "mozilla::StyleTextAnchor",
     "nsStyleImageType",
     "nsINode_BooleanFlag",
     "mozilla::PseudoStyleType",
     "mozilla::LookAndFeel_ColorID",
     "mozilla::LookAndFeel_FontID",
     "nsStyleTransformMatrix::MatrixTransformOperator",
     "mozilla::StyleGeometryBox",
     "mozilla::SystemColor",
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -778,19 +778,21 @@ enum class StyleStrokeLinecap : uint8_t 
 };
 
 // stroke-linejoin
 #define NS_STYLE_STROKE_LINEJOIN_MITER 0
 #define NS_STYLE_STROKE_LINEJOIN_ROUND 1
 #define NS_STYLE_STROKE_LINEJOIN_BEVEL 2
 
 // text-anchor
-#define NS_STYLE_TEXT_ANCHOR_START 0
-#define NS_STYLE_TEXT_ANCHOR_MIDDLE 1
-#define NS_STYLE_TEXT_ANCHOR_END 2
+enum class StyleTextAnchor : uint8_t {
+  Start,
+  Middle,
+  End,
+};
 
 // text-emphasis-position
 #define NS_STYLE_TEXT_EMPHASIS_POSITION_OVER (1 << 0)
 #define NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER (1 << 1)
 #define NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT (1 << 2)
 #define NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT (1 << 3)
 #define NS_STYLE_TEXT_EMPHASIS_POSITION_DEFAULT \
   (NS_STYLE_TEXT_EMPHASIS_POSITION_OVER | NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT)
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -741,17 +741,17 @@ nsStyleSVG::nsStyleSVG(const Document& a
       mColorInterpolation(NS_STYLE_COLOR_INTERPOLATION_SRGB),
       mColorInterpolationFilters(NS_STYLE_COLOR_INTERPOLATION_LINEARRGB),
       mFillRule(StyleFillRule::Nonzero),
       mPaintOrder(0),
       mShapeRendering(StyleShapeRendering::Auto),
       mStrokeLinecap(StyleStrokeLinecap::Butt),
       mStrokeLinejoin(NS_STYLE_STROKE_LINEJOIN_MITER),
       mDominantBaseline(NS_STYLE_DOMINANT_BASELINE_AUTO),
-      mTextAnchor(NS_STYLE_TEXT_ANCHOR_START),
+      mTextAnchor(StyleTextAnchor::Start),
       mContextFlags(
           (eStyleSVGOpacitySource_Normal << FILL_OPACITY_SOURCE_SHIFT) |
           (eStyleSVGOpacitySource_Normal << STROKE_OPACITY_SOURCE_SHIFT)) {
   MOZ_COUNT_CTOR(nsStyleSVG);
 }
 
 nsStyleSVG::~nsStyleSVG() { MOZ_COUNT_DTOR(nsStyleSVG); }
 
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2218,17 +2218,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   uint8_t mColorInterpolation;         // NS_STYLE_COLOR_INTERPOLATION_*
   uint8_t mColorInterpolationFilters;  // NS_STYLE_COLOR_INTERPOLATION_*
   mozilla::StyleFillRule mFillRule;
   mozilla::StyleSVGPaintOrder mPaintOrder;
   mozilla::StyleShapeRendering mShapeRendering;
   mozilla::StyleStrokeLinecap mStrokeLinecap;
   uint8_t mStrokeLinejoin;    // NS_STYLE_STROKE_LINEJOIN_*
   uint8_t mDominantBaseline;  // NS_STYLE_DOMINANT_BASELINE_*
-  uint8_t mTextAnchor;        // NS_STYLE_TEXT_ANCHOR_*
+  mozilla::StyleTextAnchor mTextAnchor;
 
   /// Returns true if style has been set to expose the computed values of
   /// certain properties (such as 'fill') to the contents of any linked images.
   bool ExposesContextProperties() const {
     return bool(mMozContextProperties.bits);
   }
 
   nsStyleSVGOpacitySource FillOpacitySource() const {
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -4441,23 +4441,23 @@ void SVGTextFrame::DetermineCharPosition
  * Physical text-anchor values.
  */
 enum TextAnchorSide { eAnchorLeft, eAnchorMiddle, eAnchorRight };
 
 /**
  * Converts a logical text-anchor value to its physical value, based on whether
  * it is for an RTL frame.
  */
-static TextAnchorSide ConvertLogicalTextAnchorToPhysical(uint8_t aTextAnchor,
-                                                         bool aIsRightToLeft) {
-  NS_ASSERTION(aTextAnchor <= 3, "unexpected value for aTextAnchor");
+static TextAnchorSide ConvertLogicalTextAnchorToPhysical(
+    StyleTextAnchor aTextAnchor, bool aIsRightToLeft) {
+  NS_ASSERTION(uint8_t(aTextAnchor) <= 3, "unexpected value for aTextAnchor");
   if (!aIsRightToLeft) {
-    return TextAnchorSide(aTextAnchor);
-  }
-  return TextAnchorSide(2 - aTextAnchor);
+    return TextAnchorSide(uint8_t(aTextAnchor));
+  }
+  return TextAnchorSide(2 - uint8_t(aTextAnchor));
 }
 
 /**
  * Shifts the recorded character positions for an anchored chunk.
  *
  * @param aCharPositions The recorded character positions.
  * @param aChunkStart The character index the starts the anchored chunk.  This
  *   character's initial position is the anchor point.
--- a/servo/components/style/properties/longhands/inherited_svg.mako.rs
+++ b/servo/components/style/properties/longhands/inherited_svg.mako.rs
@@ -20,16 +20,17 @@
 )}
 
 ${helpers.single_keyword(
     "text-anchor",
     "start middle end",
     engines="gecko",
     animation_value_type="discrete",
     spec="https://www.w3.org/TR/SVG/text.html#TextAnchorProperty",
+    gecko_enum_prefix="StyleTextAnchor",
 )}
 
 // Section 11 - Painting: Filling, Stroking and Marker Symbols
 ${helpers.single_keyword(
     "color-interpolation",
     "srgb auto linearrgb",
     engines="gecko",
     animation_value_type="discrete",