diff --git a/layout/base/nsBidiPresUtils.cpp b/layout/base/nsBidiPresUtils.cpp index f02bb2aa4cf2..2f0cae7521bc 100644 --- a/layout/base/nsBidiPresUtils.cpp +++ b/layout/base/nsBidiPresUtils.cpp @@ -76,8 +76,8 @@ static bool IsIsolateControl(char16_t aChar) { // Returns 0 if no override control character is implied by this style. 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) && + if ((vis->mWritingMode == StyleWritingModeProperty::VerticalRl || + vis->mWritingMode == StyleWritingModeProperty::VerticalLr) && vis->mTextOrientation == StyleTextOrientation::Upright) { return kLRO; } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index d8b5c6cef852..4c32efaa0383 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -7574,13 +7574,13 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) { /* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunOrientFlagsForStyle( ComputedStyle* aComputedStyle) { - uint8_t writingMode = aComputedStyle->StyleVisibility()->mWritingMode; + auto writingMode = aComputedStyle->StyleVisibility()->mWritingMode; switch (writingMode) { - case NS_STYLE_WRITING_MODE_HORIZONTAL_TB: + case StyleWritingModeProperty::HorizontalTb: return gfx::ShapedTextFlags::TEXT_ORIENT_HORIZONTAL; - case NS_STYLE_WRITING_MODE_VERTICAL_LR: - case NS_STYLE_WRITING_MODE_VERTICAL_RL: + case StyleWritingModeProperty::VerticalLr: + case StyleWritingModeProperty::VerticalRl: switch (aComputedStyle->StyleVisibility()->mTextOrientation) { case StyleTextOrientation::Mixed: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED; @@ -7593,10 +7593,10 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) { return gfx::ShapedTextFlags(); } - case NS_STYLE_WRITING_MODE_SIDEWAYS_LR: + case StyleWritingModeProperty::SidewaysLr: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT; - case NS_STYLE_WRITING_MODE_SIDEWAYS_RL: + case StyleWritingModeProperty::SidewaysRl: return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; default: diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h index 854dab6693eb..59540a519c85 100644 --- a/layout/generic/WritingModes.h +++ b/layout/generic/WritingModes.h @@ -316,9 +316,9 @@ class WritingMode { // orientation and bit 0 of a LogicalAxis value indicating the inline axis, // so that it can correctly form mozilla::PhysicalAxis values using bit // manipulation. - static_assert(NS_STYLE_WRITING_MODE_HORIZONTAL_TB == 0 && - NS_STYLE_WRITING_MODE_VERTICAL_RL == 1 && - NS_STYLE_WRITING_MODE_VERTICAL_LR == 3 && + static_assert(uint8_t(StyleWritingModeProperty::HorizontalTb) == 0 && + uint8_t(StyleWritingModeProperty::VerticalRl) == 1 && + uint8_t(StyleWritingModeProperty::VerticalLr) == 3 && eLogicalAxisBlock == 0 && eLogicalAxisInline == 1 && eAxisVertical == 0 && eAxisHorizontal == 1, "unexpected writing-mode, logical axis or physical axis " @@ -327,8 +327,8 @@ class WritingMode { } mozilla::PhysicalAxis PhysicalAxis(LogicalAxis aAxis) const { - // This will set wm to either NS_STYLE_WRITING_MODE_HORIZONTAL_TB or - // NS_STYLE_WRITING_MODE_VERTICAL_RL, and not the other two (real + // This will set wm to either StyleWritingModel::HorizontalTB or + // StyleWritingModeProperty::VerticalRL, and not the other two (real // and hypothetical) values. But this is fine; we only need to // distinguish between vertical and horizontal in // PhysicalAxisForLogicalAxis. @@ -338,7 +338,7 @@ class WritingMode { static mozilla::Side PhysicalSideForBlockAxis(uint8_t aWritingModeValue, LogicalEdge aEdge) { - // indexes are NS_STYLE_WRITING_MODE_* values, which are the same as these + // indexes are StyleWritingModeProperty values, which are the same as these // two-bit values: // bit 0 = the StyleWritingMode::VERTICAL value // bit 1 = the StyleWritingMode::VERTICAL_LR value @@ -349,9 +349,9 @@ class WritingMode { {eSideLeft, eSideRight}, // vertical-lr }; - // Ignore the SIDEWAYS_MASK bit of the writing-mode value, as this has no + // Ignore the SidewaysMask bit of the writing-mode value, as this has no // effect on the side mappings. - aWritingModeValue &= ~NS_STYLE_WRITING_MODE_SIDEWAYS_MASK; + aWritingModeValue &= ~kWritingModeSidewaysMask; // What's left of the writing-mode should be in the range 0-3: NS_ASSERTION(aWritingModeValue < 4, "invalid aWritingModeValue value"); diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index b40228c0f1a0..369d62ae1a30 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -164,6 +164,7 @@ rusty-enums = [ "mozilla::StyleBlend", "mozilla::StyleMaskComposite", "mozilla::StyleControlCharacterVisibility", + "mozilla::StyleWritingModeProperty", ] whitelist-vars = [ "NS_ATTRVALUE_.*", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index abbb716e9ebc..278fff536f57 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -338,21 +338,21 @@ enum class StyleDirection : uint8_t { Ltr, Rtl }; // See nsStyleVisibility // NOTE: WritingModes.h depends on the particular values used here. -#define NS_STYLE_WRITING_MODE_HORIZONTAL_TB 0 -#define NS_STYLE_WRITING_MODE_VERTICAL_RL 1 -// #define NS_STYLE_WRITING_MODE_HORIZONTAL_BT 2 // hypothetical -#define NS_STYLE_WRITING_MODE_VERTICAL_LR 3 -// Single-bit flag, used in combination with VERTICAL_LR and _RL to specify -// the corresponding SIDEWAYS_* modes. +// Single-bit flag, used in combination with VerticalLR and RL to specify +// the corresponding Sideways* modes. // (To avoid ambiguity, this bit must be high enough such that no other // values here accidentally use it in their binary representation.) -#define NS_STYLE_WRITING_MODE_SIDEWAYS_MASK 4 +static constexpr uint8_t kWritingModeSidewaysMask = 4; -#define NS_STYLE_WRITING_MODE_SIDEWAYS_RL \ - (NS_STYLE_WRITING_MODE_VERTICAL_RL | NS_STYLE_WRITING_MODE_SIDEWAYS_MASK) -#define NS_STYLE_WRITING_MODE_SIDEWAYS_LR \ - (NS_STYLE_WRITING_MODE_VERTICAL_LR | NS_STYLE_WRITING_MODE_SIDEWAYS_MASK) +enum class StyleWritingModeProperty : uint8_t { + HorizontalTb = 0, + VerticalRl = 1, + // HorizontalBT = 2, // hypothetical + VerticalLr = 3, + SidewaysRl = VerticalRl | kWritingModeSidewaysMask, + SidewaysLr = VerticalLr | kWritingModeSidewaysMask, +}; // See nsStylePosition enum class StyleFlexDirection : uint8_t { diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index ca57b756d7ba..175277165a69 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -1286,8 +1286,8 @@ nsChangeHint nsStylePosition::CalcDifference( // It doesn't matter whether we're looking at the old or new visibility // struct, since a change between vertical and horizontal writing-mode will // cause a reframe. - bool isVertical = - aOldStyleVisibility.mWritingMode != NS_STYLE_WRITING_MODE_HORIZONTAL_TB; + bool isVertical = aOldStyleVisibility.mWritingMode != + StyleWritingModeProperty::HorizontalTb; if (isVertical ? widthChanged : heightChanged) { hint |= nsChangeHint_ReflowHintsForBSizeChange; } @@ -2736,7 +2736,7 @@ nsStyleVisibility::nsStyleVisibility(const Document& aDocument) : StyleDirection::Ltr), mVisible(StyleVisibility::Visible), mImageRendering(StyleImageRendering::Auto), - mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB), + mWritingMode(StyleWritingModeProperty::HorizontalTb), mTextOrientation(StyleTextOrientation::Mixed), mColorAdjust(StyleColorAdjust::Economy) { MOZ_COUNT_CTOR(nsStyleVisibility); diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index d586a8a1aadd..69f1cac2c65e 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1067,7 +1067,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility { mozilla::StyleDirection mDirection; mozilla::StyleVisibility mVisible; mozilla::StyleImageRendering mImageRendering; - uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_* + mozilla::StyleWritingModeProperty mWritingMode; mozilla::StyleTextOrientation mTextOrientation; mozilla::StyleColorAdjust mColorAdjust; diff --git a/servo/components/style/properties/longhands/inherited_box.mako.rs b/servo/components/style/properties/longhands/inherited_box.mako.rs index 37d86d62695c..32f9819a42d8 100644 --- a/servo/components/style/properties/longhands/inherited_box.mako.rs +++ b/servo/components/style/properties/longhands/inherited_box.mako.rs @@ -31,6 +31,7 @@ ${helpers.single_keyword( servo_2020_pref="layout.writing-mode.enabled", animation_value_type="none", spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode", + gecko_enum_prefix="StyleWritingModeProperty", servo_restyle_damage="rebuild_and_reflow", )}