Bug 1509664 - Change Text Rendering constants to enum classes in nsStyleConsts.h. r=heycam
authorShubham Kumaram <shubhamkumaram@gmail.com>
Fri, 30 Nov 2018 05:08:46 +0000
changeset 508133 b5e141f4ca9b59ae61e778c54536bf7aadff0dfc
parent 508132 7e99dc45f560afd931870bd24f3ec60578a3c82b
child 508134 46c936ce7efed56027d7770690f94ee31f415d7a
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1509664
milestone65.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 1509664 - Change Text Rendering constants to enum classes in nsStyleConsts.h. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D12839
layout/base/nsLayoutUtils.cpp
layout/style/ServoBindings.toml
layout/style/nsStyleConsts.h
layout/style/nsStyleStruct.cpp
layout/style/nsStyleStruct.h
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGUtils.h
servo/components/style/properties/longhands/inherited_text.mako.rs
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7562,20 +7562,20 @@ nsLayoutUtils::GetTextRunFlagsForStyle(C
   if (aLetterSpacing != 0 ||
       aStyleText->mTextJustify == StyleTextJustify::InterCharacter) {
     result |= gfx::ShapedTextFlags::TEXT_DISABLE_OPTIONAL_LIGATURES;
   }
   if (aStyleText->mControlCharacterVisibility == NS_STYLE_CONTROL_CHARACTER_VISIBILITY_HIDDEN) {
     result |= gfx::ShapedTextFlags::TEXT_HIDE_CONTROL_CHARACTERS;
   }
   switch (aComputedStyle->StyleText()->mTextRendering) {
-  case NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED:
+  case StyleTextRendering::Optimizespeed:
     result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
     break;
-  case NS_STYLE_TEXT_RENDERING_AUTO:
+  case StyleTextRendering::Auto:
     if (aStyleFont->mFont.size < aPresContext->GetAutoQualityMinFontSize()) {
       result |= gfx::ShapedTextFlags::TEXT_OPTIMIZE_SPEED;
     }
     break;
   default:
     break;
   }
   return result | GetTextRunOrientFlagsForStyle(aComputedStyle);
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -134,16 +134,17 @@ rusty-enums = [
     "mozilla::StyleImageLayerAttachment",
     "mozilla::StyleBoxDecorationBreak",
     "mozilla::StyleBorderStyle",
     "mozilla::StyleRuleInclusion",
     "mozilla::StyleGridTrackBreadth",
     "mozilla::StyleOverscrollBehavior",
     "mozilla::StyleScrollbarWidth",
     "mozilla::StyleWhiteSpace",
+    "mozilla::StyleTextRendering",
     "nsStyleImageType",
     "nsStyleSVGPaintType",
     "nsStyleSVGFallbackType",
     "nsINode_BooleanFlag",
     "mozilla::CSSPseudoElementType",
     "mozilla::LookAndFeel_ColorID",
     "mozilla::LookAndFeel_FontID",
     "nsStyleTransformMatrix::MatrixTransformOperator",
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -971,20 +971,22 @@ enum class StyleWhiteSpace : uint8_t {
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_DOT            1
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_CIRCLE         2
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_DOUBLE_CIRCLE  3
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_TRIANGLE       4
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_SESAME         5
 #define NS_STYLE_TEXT_EMPHASIS_STYLE_STRING         255
 
 // text-rendering
-#define NS_STYLE_TEXT_RENDERING_AUTO               0
-#define NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED      1
-#define NS_STYLE_TEXT_RENDERING_OPTIMIZELEGIBILITY 2
-#define NS_STYLE_TEXT_RENDERING_GEOMETRICPRECISION 3
+enum class StyleTextRendering : uint8_t {
+  Auto,
+  Optimizespeed,
+  Optimizelegibility,
+  Geometricprecision,
+};
 
 // color-adjust
 #define NS_STYLE_COLOR_ADJUST_ECONOMY               0
 #define NS_STYLE_COLOR_ADJUST_EXACT                 1
 
 // color-interpolation and color-interpolation-filters
 #define NS_STYLE_COLOR_INTERPOLATION_AUTO           0
 #define NS_STYLE_COLOR_INTERPOLATION_SRGB           1
--- a/layout/style/nsStyleStruct.cpp
+++ b/layout/style/nsStyleStruct.cpp
@@ -4255,17 +4255,17 @@ nsStyleText::nsStyleText(const nsPresCon
   , mOverflowWrap(StyleOverflowWrap::Normal)
   , mHyphens(StyleHyphens::Manual)
   , mRubyAlign(NS_STYLE_RUBY_ALIGN_SPACE_AROUND)
   , mRubyPosition(NS_STYLE_RUBY_POSITION_OVER)
   , mTextSizeAdjust(NS_STYLE_TEXT_SIZE_ADJUST_AUTO)
   , mTextCombineUpright(NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE)
   , mControlCharacterVisibility(nsLayoutUtils::ControlCharVisibilityDefault())
   , mTextEmphasisStyle(NS_STYLE_TEXT_EMPHASIS_STYLE_NONE)
-  , mTextRendering(NS_STYLE_TEXT_RENDERING_AUTO)
+  , mTextRendering(StyleTextRendering::Auto)
   , mTextEmphasisColor(StyleComplexColor::CurrentColor())
   , mWebkitTextFillColor(StyleComplexColor::CurrentColor())
   , mWebkitTextStrokeColor(StyleComplexColor::CurrentColor())
   , mTabSize(float(NS_STYLE_TABSIZE_INITIAL), eStyleUnit_Factor)
   , mWordSpacing(0, nsStyleCoord::CoordConstructor)
   , mLetterSpacing(eStyleUnit_Normal)
   , mLineHeight(eStyleUnit_Normal)
   , mTextIndent(0, nsStyleCoord::CoordConstructor)
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -1582,17 +1582,17 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt
   mozilla::StyleHyphens mHyphens;
   uint8_t mRubyAlign;                   // NS_STYLE_RUBY_ALIGN_*
   uint8_t mRubyPosition;                // NS_STYLE_RUBY_POSITION_*
   uint8_t mTextSizeAdjust;              // NS_STYLE_TEXT_SIZE_ADJUST_*
   uint8_t mTextCombineUpright;          // NS_STYLE_TEXT_COMBINE_UPRIGHT_*
   uint8_t mControlCharacterVisibility;  // NS_STYLE_CONTROL_CHARACTER_VISIBILITY_*
   uint8_t mTextEmphasisPosition;        // NS_STYLE_TEXT_EMPHASIS_POSITION_*
   uint8_t mTextEmphasisStyle;           // NS_STYLE_TEXT_EMPHASIS_STYLE_*
-  uint8_t mTextRendering;               // NS_STYLE_TEXT_RENDERING_*
+  mozilla::StyleTextRendering mTextRendering;
   mozilla::StyleComplexColor mTextEmphasisColor;
   mozilla::StyleComplexColor mWebkitTextFillColor;
   mozilla::StyleComplexColor mWebkitTextStrokeColor;
 
   nsStyleCoord mTabSize;                // coord, factor, calc
   nsStyleCoord mWordSpacing;            // coord, percent, calc
   nsStyleCoord mLetterSpacing;          // coord, normal
   nsStyleCoord mLineHeight;             // coord, factor, normal
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -2921,17 +2921,17 @@ void
 SVGTextDrawPathCallbacks::SetupContext()
 {
   mContext.Save();
 
   // XXX This is copied from nsSVGGlyphFrame::Render, but cairo doesn't actually
   // seem to do anything with the antialias mode.  So we can perhaps remove it,
   // or make SetAntialiasMode set cairo text antialiasing too.
   switch (mFrame->StyleText()->mTextRendering) {
-  case NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED:
+  case StyleTextRendering::Optimizespeed:
     mContext.SetAntialiasMode(AntialiasMode::NONE);
     break;
   default:
     mContext.SetAntialiasMode(AntialiasMode::SUBPIXEL);
     break;
   }
 }
 
@@ -5545,17 +5545,17 @@ SVGTextFrame::UpdateFontSizeScaleFactor(
   // nsTextFrames.
   TextFrameIterator it(this);
   nsTextFrame* f = it.Current();
   while (f) {
     if (!geometricPrecision) {
       // Unfortunately we can't treat text-rendering:geometricPrecision
       // separately for each text frame.
       geometricPrecision = f->StyleText()->mTextRendering ==
-                             NS_STYLE_TEXT_RENDERING_GEOMETRICPRECISION;
+                             StyleTextRendering::Geometricprecision;
     }
     nscoord size = f->StyleFont()->mFont.size;
     if (size) {
       min = std::min(min, size);
       max = std::max(max, size);
     }
     f = it.Next();
   }
--- a/layout/svg/nsSVGUtils.h
+++ b/layout/svg/nsSVGUtils.h
@@ -545,18 +545,18 @@ public:
    */
   static uint16_t GetGeometryHitTestFlags(nsIFrame* aFrame);
 
   static FillRule ToFillRule(mozilla::StyleFillRule aFillRule) {
     return aFillRule == mozilla::StyleFillRule::Evenodd ?
              FillRule::FILL_EVEN_ODD : FillRule::FILL_WINDING;
   }
 
-  static AntialiasMode ToAntialiasMode(uint8_t aTextRendering) {
-    return aTextRendering == NS_STYLE_TEXT_RENDERING_OPTIMIZESPEED ?
+  static AntialiasMode ToAntialiasMode(mozilla::StyleTextRendering aTextRendering) {
+    return aTextRendering == mozilla::StyleTextRendering::Optimizespeed ?
              AntialiasMode::NONE : AntialiasMode::SUBPIXEL;
   }
 
   /**
    * Render a SVG glyph.
    * @param aElement the SVG glyph element to render
    * @param aContext the thebes aContext to draw to
    * @return true if rendering succeeded
--- a/servo/components/style/properties/longhands/inherited_text.mako.rs
+++ b/servo/components/style/properties/longhands/inherited_text.mako.rs
@@ -332,16 +332,17 @@
     animation_value_type="discrete",
     spec="https://drafts.csswg.org/css-writing-modes-3/#text-combine-upright",
 )}
 
 // SVG 1.1: Section 11 - Painting: Filling, Stroking and Marker Symbols
 ${helpers.single_keyword(
     "text-rendering",
     "auto optimizespeed optimizelegibility geometricprecision",
+    gecko_enum_prefix="StyleTextRendering",
     animation_value_type="discrete",
     spec="https://www.w3.org/TR/SVG11/painting.html#TextRenderingProperty",
     servo_restyle_damage="rebuild_and_reflow",
 )}
 
 // FIXME Firefox expects the initial value of this property to change depending
 // on the value of the layout.css.control-characters.visible pref.
 ${helpers.single_keyword(