зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648938 - Convert writing-modes #defines to an enum class. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D84016
This commit is contained in:
Родитель
977d27e7b7
Коммит
3d4be168ae
|
@ -76,8 +76,8 @@ static bool IsIsolateControl(char16_t aChar) {
|
||||||
// Returns 0 if no override control character is implied by this style.
|
// Returns 0 if no override control character is implied by this style.
|
||||||
static char16_t GetBidiOverride(ComputedStyle* aComputedStyle) {
|
static char16_t GetBidiOverride(ComputedStyle* aComputedStyle) {
|
||||||
const nsStyleVisibility* vis = aComputedStyle->StyleVisibility();
|
const nsStyleVisibility* vis = aComputedStyle->StyleVisibility();
|
||||||
if ((vis->mWritingMode == NS_STYLE_WRITING_MODE_VERTICAL_RL ||
|
if ((vis->mWritingMode == StyleWritingModeProperty::VerticalRl ||
|
||||||
vis->mWritingMode == NS_STYLE_WRITING_MODE_VERTICAL_LR) &&
|
vis->mWritingMode == StyleWritingModeProperty::VerticalLr) &&
|
||||||
vis->mTextOrientation == StyleTextOrientation::Upright) {
|
vis->mTextOrientation == StyleTextOrientation::Upright) {
|
||||||
return kLRO;
|
return kLRO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7574,13 +7574,13 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) {
|
||||||
|
|
||||||
/* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunOrientFlagsForStyle(
|
/* static */ gfx::ShapedTextFlags nsLayoutUtils::GetTextRunOrientFlagsForStyle(
|
||||||
ComputedStyle* aComputedStyle) {
|
ComputedStyle* aComputedStyle) {
|
||||||
uint8_t writingMode = aComputedStyle->StyleVisibility()->mWritingMode;
|
auto writingMode = aComputedStyle->StyleVisibility()->mWritingMode;
|
||||||
switch (writingMode) {
|
switch (writingMode) {
|
||||||
case NS_STYLE_WRITING_MODE_HORIZONTAL_TB:
|
case StyleWritingModeProperty::HorizontalTb:
|
||||||
return gfx::ShapedTextFlags::TEXT_ORIENT_HORIZONTAL;
|
return gfx::ShapedTextFlags::TEXT_ORIENT_HORIZONTAL;
|
||||||
|
|
||||||
case NS_STYLE_WRITING_MODE_VERTICAL_LR:
|
case StyleWritingModeProperty::VerticalLr:
|
||||||
case NS_STYLE_WRITING_MODE_VERTICAL_RL:
|
case StyleWritingModeProperty::VerticalRl:
|
||||||
switch (aComputedStyle->StyleVisibility()->mTextOrientation) {
|
switch (aComputedStyle->StyleVisibility()->mTextOrientation) {
|
||||||
case StyleTextOrientation::Mixed:
|
case StyleTextOrientation::Mixed:
|
||||||
return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED;
|
return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_MIXED;
|
||||||
|
@ -7593,10 +7593,10 @@ nsIFrame* nsLayoutUtils::GetReferenceFrame(nsIFrame* aFrame) {
|
||||||
return gfx::ShapedTextFlags();
|
return gfx::ShapedTextFlags();
|
||||||
}
|
}
|
||||||
|
|
||||||
case NS_STYLE_WRITING_MODE_SIDEWAYS_LR:
|
case StyleWritingModeProperty::SidewaysLr:
|
||||||
return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT;
|
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;
|
return gfx::ShapedTextFlags::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -316,9 +316,9 @@ class WritingMode {
|
||||||
// orientation and bit 0 of a LogicalAxis value indicating the inline axis,
|
// orientation and bit 0 of a LogicalAxis value indicating the inline axis,
|
||||||
// so that it can correctly form mozilla::PhysicalAxis values using bit
|
// so that it can correctly form mozilla::PhysicalAxis values using bit
|
||||||
// manipulation.
|
// manipulation.
|
||||||
static_assert(NS_STYLE_WRITING_MODE_HORIZONTAL_TB == 0 &&
|
static_assert(uint8_t(StyleWritingModeProperty::HorizontalTb) == 0 &&
|
||||||
NS_STYLE_WRITING_MODE_VERTICAL_RL == 1 &&
|
uint8_t(StyleWritingModeProperty::VerticalRl) == 1 &&
|
||||||
NS_STYLE_WRITING_MODE_VERTICAL_LR == 3 &&
|
uint8_t(StyleWritingModeProperty::VerticalLr) == 3 &&
|
||||||
eLogicalAxisBlock == 0 && eLogicalAxisInline == 1 &&
|
eLogicalAxisBlock == 0 && eLogicalAxisInline == 1 &&
|
||||||
eAxisVertical == 0 && eAxisHorizontal == 1,
|
eAxisVertical == 0 && eAxisHorizontal == 1,
|
||||||
"unexpected writing-mode, logical axis or physical axis "
|
"unexpected writing-mode, logical axis or physical axis "
|
||||||
|
@ -327,8 +327,8 @@ class WritingMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
mozilla::PhysicalAxis PhysicalAxis(LogicalAxis aAxis) const {
|
mozilla::PhysicalAxis PhysicalAxis(LogicalAxis aAxis) const {
|
||||||
// This will set wm to either NS_STYLE_WRITING_MODE_HORIZONTAL_TB or
|
// This will set wm to either StyleWritingModel::HorizontalTB or
|
||||||
// NS_STYLE_WRITING_MODE_VERTICAL_RL, and not the other two (real
|
// StyleWritingModeProperty::VerticalRL, and not the other two (real
|
||||||
// and hypothetical) values. But this is fine; we only need to
|
// and hypothetical) values. But this is fine; we only need to
|
||||||
// distinguish between vertical and horizontal in
|
// distinguish between vertical and horizontal in
|
||||||
// PhysicalAxisForLogicalAxis.
|
// PhysicalAxisForLogicalAxis.
|
||||||
|
@ -338,7 +338,7 @@ class WritingMode {
|
||||||
|
|
||||||
static mozilla::Side PhysicalSideForBlockAxis(uint8_t aWritingModeValue,
|
static mozilla::Side PhysicalSideForBlockAxis(uint8_t aWritingModeValue,
|
||||||
LogicalEdge aEdge) {
|
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:
|
// two-bit values:
|
||||||
// bit 0 = the StyleWritingMode::VERTICAL value
|
// bit 0 = the StyleWritingMode::VERTICAL value
|
||||||
// bit 1 = the StyleWritingMode::VERTICAL_LR value
|
// bit 1 = the StyleWritingMode::VERTICAL_LR value
|
||||||
|
@ -349,9 +349,9 @@ class WritingMode {
|
||||||
{eSideLeft, eSideRight}, // vertical-lr
|
{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.
|
// 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:
|
// What's left of the writing-mode should be in the range 0-3:
|
||||||
NS_ASSERTION(aWritingModeValue < 4, "invalid aWritingModeValue value");
|
NS_ASSERTION(aWritingModeValue < 4, "invalid aWritingModeValue value");
|
||||||
|
|
|
@ -164,6 +164,7 @@ rusty-enums = [
|
||||||
"mozilla::StyleBlend",
|
"mozilla::StyleBlend",
|
||||||
"mozilla::StyleMaskComposite",
|
"mozilla::StyleMaskComposite",
|
||||||
"mozilla::StyleControlCharacterVisibility",
|
"mozilla::StyleControlCharacterVisibility",
|
||||||
|
"mozilla::StyleWritingModeProperty",
|
||||||
]
|
]
|
||||||
whitelist-vars = [
|
whitelist-vars = [
|
||||||
"NS_ATTRVALUE_.*",
|
"NS_ATTRVALUE_.*",
|
||||||
|
|
|
@ -338,21 +338,21 @@ enum class StyleDirection : uint8_t { Ltr, Rtl };
|
||||||
|
|
||||||
// See nsStyleVisibility
|
// See nsStyleVisibility
|
||||||
// NOTE: WritingModes.h depends on the particular values used here.
|
// 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
|
// Single-bit flag, used in combination with VerticalLR and RL to specify
|
||||||
// the corresponding SIDEWAYS_* modes.
|
// the corresponding Sideways* modes.
|
||||||
// (To avoid ambiguity, this bit must be high enough such that no other
|
// (To avoid ambiguity, this bit must be high enough such that no other
|
||||||
// values here accidentally use it in their binary representation.)
|
// 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 \
|
enum class StyleWritingModeProperty : uint8_t {
|
||||||
(NS_STYLE_WRITING_MODE_VERTICAL_RL | NS_STYLE_WRITING_MODE_SIDEWAYS_MASK)
|
HorizontalTb = 0,
|
||||||
#define NS_STYLE_WRITING_MODE_SIDEWAYS_LR \
|
VerticalRl = 1,
|
||||||
(NS_STYLE_WRITING_MODE_VERTICAL_LR | NS_STYLE_WRITING_MODE_SIDEWAYS_MASK)
|
// HorizontalBT = 2, // hypothetical
|
||||||
|
VerticalLr = 3,
|
||||||
|
SidewaysRl = VerticalRl | kWritingModeSidewaysMask,
|
||||||
|
SidewaysLr = VerticalLr | kWritingModeSidewaysMask,
|
||||||
|
};
|
||||||
|
|
||||||
// See nsStylePosition
|
// See nsStylePosition
|
||||||
enum class StyleFlexDirection : uint8_t {
|
enum class StyleFlexDirection : uint8_t {
|
||||||
|
|
|
@ -1286,8 +1286,8 @@ nsChangeHint nsStylePosition::CalcDifference(
|
||||||
// It doesn't matter whether we're looking at the old or new visibility
|
// 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
|
// struct, since a change between vertical and horizontal writing-mode will
|
||||||
// cause a reframe.
|
// cause a reframe.
|
||||||
bool isVertical =
|
bool isVertical = aOldStyleVisibility.mWritingMode !=
|
||||||
aOldStyleVisibility.mWritingMode != NS_STYLE_WRITING_MODE_HORIZONTAL_TB;
|
StyleWritingModeProperty::HorizontalTb;
|
||||||
if (isVertical ? widthChanged : heightChanged) {
|
if (isVertical ? widthChanged : heightChanged) {
|
||||||
hint |= nsChangeHint_ReflowHintsForBSizeChange;
|
hint |= nsChangeHint_ReflowHintsForBSizeChange;
|
||||||
}
|
}
|
||||||
|
@ -2736,7 +2736,7 @@ nsStyleVisibility::nsStyleVisibility(const Document& aDocument)
|
||||||
: StyleDirection::Ltr),
|
: StyleDirection::Ltr),
|
||||||
mVisible(StyleVisibility::Visible),
|
mVisible(StyleVisibility::Visible),
|
||||||
mImageRendering(StyleImageRendering::Auto),
|
mImageRendering(StyleImageRendering::Auto),
|
||||||
mWritingMode(NS_STYLE_WRITING_MODE_HORIZONTAL_TB),
|
mWritingMode(StyleWritingModeProperty::HorizontalTb),
|
||||||
mTextOrientation(StyleTextOrientation::Mixed),
|
mTextOrientation(StyleTextOrientation::Mixed),
|
||||||
mColorAdjust(StyleColorAdjust::Economy) {
|
mColorAdjust(StyleColorAdjust::Economy) {
|
||||||
MOZ_COUNT_CTOR(nsStyleVisibility);
|
MOZ_COUNT_CTOR(nsStyleVisibility);
|
||||||
|
|
|
@ -1067,7 +1067,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleVisibility {
|
||||||
mozilla::StyleDirection mDirection;
|
mozilla::StyleDirection mDirection;
|
||||||
mozilla::StyleVisibility mVisible;
|
mozilla::StyleVisibility mVisible;
|
||||||
mozilla::StyleImageRendering mImageRendering;
|
mozilla::StyleImageRendering mImageRendering;
|
||||||
uint8_t mWritingMode; // NS_STYLE_WRITING_MODE_*
|
mozilla::StyleWritingModeProperty mWritingMode;
|
||||||
mozilla::StyleTextOrientation mTextOrientation;
|
mozilla::StyleTextOrientation mTextOrientation;
|
||||||
mozilla::StyleColorAdjust mColorAdjust;
|
mozilla::StyleColorAdjust mColorAdjust;
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ ${helpers.single_keyword(
|
||||||
servo_2020_pref="layout.writing-mode.enabled",
|
servo_2020_pref="layout.writing-mode.enabled",
|
||||||
animation_value_type="none",
|
animation_value_type="none",
|
||||||
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode",
|
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode",
|
||||||
|
gecko_enum_prefix="StyleWritingModeProperty",
|
||||||
servo_restyle_damage="rebuild_and_reflow",
|
servo_restyle_damage="rebuild_and_reflow",
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче