From e9711f487b335bf22e8e52fff26ee91fbed6ee41 Mon Sep 17 00:00:00 2001 From: jeffin143 Date: Tue, 26 Nov 2019 04:50:04 +0000 Subject: [PATCH] Bug 1598528 : convert NS_STYLE_TEXT_ORIENTATION_* to an enum class in nsStyleConsts.h r=emilio Differential Revision: https://phabricator.services.mozilla.com/D54252 --HG-- extra : moz-landing-system : lando --- gfx/src/nsFontMetrics.cpp | 16 ++++++++-------- gfx/src/nsFontMetrics.h | 8 +++++--- layout/base/nsBidiPresUtils.cpp | 2 +- layout/base/nsLayoutUtils.cpp | 6 +++--- layout/style/ServoBindings.toml | 1 + layout/style/nsStyleConsts.h | 8 +++++--- layout/style/nsStyleStruct.cpp | 2 +- layout/style/nsStyleStruct.h | 10 +++++----- .../properties/longhands/inherited_box.mako.rs | 1 + 9 files changed, 30 insertions(+), 24 deletions(-) diff --git a/gfx/src/nsFontMetrics.cpp b/gfx/src/nsFontMetrics.cpp index 3a5b41d68426..d364d2d5ea66 100644 --- a/gfx/src/nsFontMetrics.cpp +++ b/gfx/src/nsFontMetrics.cpp @@ -58,13 +58,13 @@ class AutoTextRun { } if (aMetrics->GetVertical()) { switch (aMetrics->GetTextOrientation()) { - case NS_STYLE_TEXT_ORIENTATION_MIXED: + case StyleTextOrientation::Mixed: flags |= gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED; break; - case NS_STYLE_TEXT_ORIENTATION_UPRIGHT: + case StyleTextOrientation::Upright: flags |= gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT; break; - case NS_STYLE_TEXT_ORIENTATION_SIDEWAYS: + case StyleTextOrientation::Sideways: flags |= gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; break; } @@ -116,7 +116,7 @@ nsFontMetrics::nsFontMetrics(const nsFont& aFont, const Params& aParams, mOrientation(aParams.orientation), mTextRunRTL(false), mVertical(false), - mTextOrientation(0) { + mTextOrientation(mozilla::StyleTextOrientation::Mixed) { gfxFontStyle style( aFont.style, aFont.weight, aFont.stretch, gfxFloat(aFont.size) / mP2A, aParams.language, aParams.explicitLanguage, aFont.sizeAdjust, @@ -251,10 +251,10 @@ nscoord nsFontMetrics::SpaceWidth() { // width of a horizontal space (even if we're using vertical line-spacing // metrics, as with "writing-mode:vertical-*;text-orientation:mixed"). return CEIL_TO_TWIPS( - GetMetrics(this, mVertical && mTextOrientation == - NS_STYLE_TEXT_ORIENTATION_UPRIGHT - ? eVertical - : eHorizontal) + GetMetrics(this, + mVertical && mTextOrientation == StyleTextOrientation::Upright + ? eVertical + : eHorizontal) .spaceWidth); } diff --git a/gfx/src/nsFontMetrics.h b/gfx/src/nsFontMetrics.h index 4cb6bc0f403b..4480a9545021 100644 --- a/gfx/src/nsFontMetrics.h +++ b/gfx/src/nsFontMetrics.h @@ -226,10 +226,12 @@ class nsFontMetrics final { void SetVertical(bool aVertical) { mVertical = aVertical; } bool GetVertical() const { return mVertical; } - void SetTextOrientation(uint8_t aTextOrientation) { + void SetTextOrientation(mozilla::StyleTextOrientation aTextOrientation) { mTextOrientation = aTextOrientation; } - uint8_t GetTextOrientation() const { return mTextOrientation; } + mozilla::StyleTextOrientation GetTextOrientation() const { + return mTextOrientation; + } gfxFontGroup* GetThebesFontGroup() const { return mFontGroup; } gfxUserFontSet* GetUserFontSet() const; @@ -258,7 +260,7 @@ class nsFontMetrics final { // and text-orientation desired. bool mTextRunRTL; bool mVertical; - uint8_t mTextOrientation; + mozilla::StyleTextOrientation mTextOrientation; }; #endif /* NSFONTMETRICS__H__ */ diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index e8082f2202f5..5b1025da16b4 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -78,7 +78,7 @@ static char16_t GetBidiOverride(ComputedStyle* aComputedStyle) { const nsStyleVisibility* vis = aComputedStyle->StyleVisibility(); if ((vis->mWritingMode == NS_STYLE_WRITING_MODE_VERTICAL_RL || vis->mWritingMode == NS_STYLE_WRITING_MODE_VERTICAL_LR) && - vis->mTextOrientation == NS_STYLE_TEXT_ORIENTATION_UPRIGHT) { + vis->mTextOrientation == StyleTextOrientation::Upright) { return kLRO; } const nsStyleTextReset* text = aComputedStyle->StyleTextReset(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index db2b358c56b0..4d9cd37e0300 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7361,11 +7361,11 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) { case NS_STYLE_WRITING_MODE_VERTICAL_LR: case NS_STYLE_WRITING_MODE_VERTICAL_RL: switch (aComputedStyle->StyleVisibility()->mTextOrientation) { - case NS_STYLE_TEXT_ORIENTATION_MIXED: + case StyleTextOrientation::Mixed: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED; - case NS_STYLE_TEXT_ORIENTATION_UPRIGHT: + case StyleTextOrientation::Upright: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_UPRIGHT; - case NS_STYLE_TEXT_ORIENTATION_SIDEWAYS: + case StyleTextOrientation::Sideways: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; default: MOZ_ASSERT_UNREACHABLE("unknown text-orientation"); diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 860ca737c9a3..db1ec1f9caec 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -134,6 +134,7 @@ rusty-enums = [ "mozilla::StyleShapeRendering", "mozilla::StyleTextAnchor", "mozilla::StyleObjectFit", + "mozilla::StyleTextOrientation", "nsStyleImageType", "nsINode_BooleanFlag", "mozilla::PseudoStyleType", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 9fa46673ca15..56e5bfa631c5 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -667,9 +667,11 @@ enum class StyleWhiteSpace : uint8_t { #define NS_STYLE_TEXT_SIZE_ADJUST_AUTO 1 // See nsStyleText -#define NS_STYLE_TEXT_ORIENTATION_MIXED 0 -#define NS_STYLE_TEXT_ORIENTATION_UPRIGHT 1 -#define NS_STYLE_TEXT_ORIENTATION_SIDEWAYS 2 +enum class StyleTextOrientation : uint8_t { + Mixed, + Upright, + Sideways, +}; // See nsStyleText #define NS_STYLE_TEXT_COMBINE_UPRIGHT_NONE 0 diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 730ea2a91fad..b5377cd4b695 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -3132,7 +3132,7 @@ nsStyleVisibility::nsStyleVisibility(const Document& aDocument) mVisible(NS_STYLE_VISIBILITY_VISIBLE), mImageRendering(NS_STYLE_IMAGE_RENDERING_AUTO), mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB), - mTextOrientation(NS_STYLE_TEXT_ORIENTATION_MIXED), + mTextOrientation(StyleTextOrientation::Mixed), mColorAdjust(StyleColorAdjust::Economy) { MOZ_COUNT_CTOR(nsStyleVisibility); } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index bf27e80b7850..1a94c8703313 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1266,11 +1266,11 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility { nsChangeHint CalcDifference(const nsStyleVisibility& aNewData) const; mozilla::StyleImageOrientation mImageOrientation; - uint8_t mDirection; // NS_STYLE_DIRECTION_* - uint8_t mVisible; // NS_STYLE_VISIBILITY_VISIBLE_* - uint8_t mImageRendering; // NS_STYLE_IMAGE_RENDERING_* - uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_* - uint8_t mTextOrientation; // NS_STYLE_TEXT_ORIENTATION_MIXED_* + uint8_t mDirection; // NS_STYLE_DIRECTION_* + uint8_t mVisible; // NS_STYLE_VISIBILITY_VISIBLE_* + uint8_t mImageRendering; // NS_STYLE_IMAGE_RENDERING_* + uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_* + mozilla::StyleTextOrientation mTextOrientation; mozilla::StyleColorAdjust mColorAdjust; bool IsVisible() const { return (mVisible == NS_STYLE_VISIBILITY_VISIBLE); } diff --git a/servo/components/style/properties/longhands/inherited_box.mako.rs b/servo/components/style/properties/longhands/inherited_box.mako.rs index 8db62bf56d64..2542ee5e3764 100644 --- a/servo/components/style/properties/longhands/inherited_box.mako.rs +++ b/servo/components/style/properties/longhands/inherited_box.mako.rs @@ -51,6 +51,7 @@ ${helpers.single_keyword( "mixed upright sideways", engines="gecko", gecko_aliases="sideways-right=sideways", + gecko_enum_prefix="StyleTextOrientation", animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-text-orientation", )}