diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 9b0608930965..65ef6bb8bcf2 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7567,10 +7567,10 @@ nsLayoutUtils::GetTextRunFlagsForStyle(ComputedStyle* aComputedStyle, 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; } diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 4fb56f546cec..c081b59f9cd9 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -139,6 +139,7 @@ rusty-enums = [ "mozilla::StyleOverscrollBehavior", "mozilla::StyleScrollbarWidth", "mozilla::StyleWhiteSpace", + "mozilla::StyleTextRendering", "nsStyleImageType", "nsStyleSVGPaintType", "nsStyleSVGFallbackType", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 0e07c8bcff95..77245f846cb2 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -976,10 +976,12 @@ enum class StyleWhiteSpace : uint8_t { #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 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 37d243abbdc6..4cbee5f66ae0 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -4260,7 +4260,7 @@ nsStyleText::nsStyleText(const nsPresContext* aContext) , 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()) diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index f3925bad9494..af87e095681e 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1587,7 +1587,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText 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; diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 2ed02eba9413..2149703dd488 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -2926,7 +2926,7 @@ SVGTextDrawPathCallbacks::SetupContext() // 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: @@ -5550,7 +5550,7 @@ SVGTextFrame::UpdateFontSizeScaleFactor() // 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) { diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/nsSVGUtils.h index 45d1dab2b7b5..fbab0b682bd8 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/nsSVGUtils.h @@ -550,8 +550,8 @@ public: 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; } diff --git a/servo/components/style/properties/longhands/inherited_text.mako.rs b/servo/components/style/properties/longhands/inherited_text.mako.rs index e8c5629c3009..24797de3d869 100644 --- a/servo/components/style/properties/longhands/inherited_text.mako.rs +++ b/servo/components/style/properties/longhands/inherited_text.mako.rs @@ -337,6 +337,7 @@ ${helpers.single_keyword( ${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",