diff --git a/dom/mathml/MathMLElement.cpp b/dom/mathml/MathMLElement.cpp index 0ceade64a3e7..d58930bc834d 100644 --- a/dom/mathml/MathMLElement.cpp +++ b/dom/mathml/MathMLElement.cpp @@ -528,9 +528,8 @@ void MathMLElement::MapMathMLAttributesInto( if (!ParseNumericValue(str, fontSize, flags, nullptr) && parseSizeKeywords) { static const char sizes[3][7] = {"small", "normal", "big"}; - static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = { - NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM, - NS_STYLE_FONT_SIZE_LARGE}; + static const StyleFontSize values[MOZ_ARRAY_LENGTH(sizes)] = { + StyleFontSize::Small, StyleFontSize::Medium, StyleFontSize::Large}; str.CompressWhitespace(); for (uint32_t i = 0; i < ArrayLength(sizes); ++i) { if (str.EqualsASCII(sizes[i])) { diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index b8e1788a9f56..d7cf1b4df061 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -166,6 +166,7 @@ rusty-enums = [ "mozilla::StyleBlend", "mozilla::StyleMaskComposite", "mozilla::StyleControlCharacterVisibility", + "mozilla::StyleFontSize", ] whitelist-vars = [ "NS_ATTRVALUE_.*", diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index fc7bc25f69f3..693e37bc0e41 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -375,19 +375,19 @@ enum class StyleFlexWrap : uint8_t { #define NS_STYLE_ORDER_INITIAL 0 // See nsStyleFont -#define NS_STYLE_FONT_SIZE_XXSMALL 0 -#define NS_STYLE_FONT_SIZE_XSMALL 1 -#define NS_STYLE_FONT_SIZE_SMALL 2 -#define NS_STYLE_FONT_SIZE_MEDIUM 3 -#define NS_STYLE_FONT_SIZE_LARGE 4 -#define NS_STYLE_FONT_SIZE_XLARGE 5 -#define NS_STYLE_FONT_SIZE_XXLARGE 6 -#define NS_STYLE_FONT_SIZE_XXXLARGE \ - 7 // Only used by . Not specifiable in CSS. -#define NS_STYLE_FONT_SIZE_LARGER 8 -#define NS_STYLE_FONT_SIZE_SMALLER 9 -#define NS_STYLE_FONT_SIZE_NO_KEYWORD \ - 10 // Used by Servo to track the "no keyword" case +enum class StyleFontSize : uint8_t { + Xxsmall = 0, + Xsmall, + Small, + Medium, + Large, + Xlarge, + Xxlarge, + Xxxlarge, + Larger, + Smaller, + NoKeyword // Used by Servo to track the "no keyword" case +}; #define NS_STYLE_MASONRY_PLACEMENT_PACK (1 << 0) #define NS_STYLE_MASONRY_ORDER_DEFINITE_FIRST (1 << 1) diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index ac1c7c5f9d84..f5f03b4888f5 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -245,7 +245,7 @@ nsStyleFont::nsStyleFont(const Document& aDocument) mSize(ZoomText(aDocument, mFont.size)), mFontSizeFactor(1.0), mFontSizeOffset(0), - mFontSizeKeyword(NS_STYLE_FONT_SIZE_MEDIUM), + mFontSizeKeyword(StyleFontSize::Medium), mGenericID(StyleGenericFontFamily::None), mScriptLevel(0), mMathVariant(NS_MATHML_MATHVARIANT_NONE), diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index c50087f745c9..066d1b47510f 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -102,9 +102,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleFont { // and if so if it has been modified by a factor/offset float mFontSizeFactor; nscoord mFontSizeOffset; - uint8_t mFontSizeKeyword; // NS_STYLE_FONT_SIZE_*, is - // NS_STYLE_FONT_SIZE_NO_KEYWORD when not - // keyword-derived + mozilla::StyleFontSize mFontSizeKeyword; // StyleFontSize is Nokeyword when + // not keyword-derived mozilla::StyleGenericFontFamily mGenericID; diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index 545e8cc77b54..8b10d71c1466 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -953,19 +953,19 @@ fn static_assert() { if let Some(info) = v.keyword_info { self.gecko.mFontSizeKeyword = match info.kw { - KeywordSize::XXSmall => structs::NS_STYLE_FONT_SIZE_XXSMALL, - KeywordSize::XSmall => structs::NS_STYLE_FONT_SIZE_XSMALL, - KeywordSize::Small => structs::NS_STYLE_FONT_SIZE_SMALL, - KeywordSize::Medium => structs::NS_STYLE_FONT_SIZE_MEDIUM, - KeywordSize::Large => structs::NS_STYLE_FONT_SIZE_LARGE, - KeywordSize::XLarge => structs::NS_STYLE_FONT_SIZE_XLARGE, - KeywordSize::XXLarge => structs::NS_STYLE_FONT_SIZE_XXLARGE, - KeywordSize::XXXLarge => structs::NS_STYLE_FONT_SIZE_XXXLARGE, - } as u8; + KeywordSize::XXSmall => structs::StyleFontSize::Xxsmall, + KeywordSize::XSmall => structs::StyleFontSize::Xsmall, + KeywordSize::Small => structs::StyleFontSize::Small, + KeywordSize::Medium => structs::StyleFontSize::Medium, + KeywordSize::Large => structs::StyleFontSize::Large, + KeywordSize::XLarge => structs::StyleFontSize::Xxlarge, + KeywordSize::XXLarge => structs::StyleFontSize::Xxlarge, + KeywordSize::XXXLarge => structs::StyleFontSize::Xxxlarge, + }; self.gecko.mFontSizeFactor = info.factor; self.gecko.mFontSizeOffset = info.offset.to_i32_au(); } else { - self.gecko.mFontSizeKeyword = structs::NS_STYLE_FONT_SIZE_NO_KEYWORD as u8; + self.gecko.mFontSizeKeyword = structs::StyleFontSize::NoKeyword; self.gecko.mFontSizeFactor = 1.; self.gecko.mFontSizeOffset = 0; } @@ -974,16 +974,16 @@ fn static_assert() { pub fn clone_font_size(&self) -> FontSize { use crate::values::specified::font::{KeywordInfo, KeywordSize}; let size = Au(self.gecko.mSize).into(); - let kw = match self.gecko.mFontSizeKeyword as u32 { - structs::NS_STYLE_FONT_SIZE_XXSMALL => KeywordSize::XXSmall, - structs::NS_STYLE_FONT_SIZE_XSMALL => KeywordSize::XSmall, - structs::NS_STYLE_FONT_SIZE_SMALL => KeywordSize::Small, - structs::NS_STYLE_FONT_SIZE_MEDIUM => KeywordSize::Medium, - structs::NS_STYLE_FONT_SIZE_LARGE => KeywordSize::Large, - structs::NS_STYLE_FONT_SIZE_XLARGE => KeywordSize::XLarge, - structs::NS_STYLE_FONT_SIZE_XXLARGE => KeywordSize::XXLarge, - structs::NS_STYLE_FONT_SIZE_XXXLARGE => KeywordSize::XXXLarge, - structs::NS_STYLE_FONT_SIZE_NO_KEYWORD => { + let kw = match self.gecko.mFontSizeKeyword { + structs::StyleFontSize::Xxsmall => KeywordSize::XXSmall, + structs::StyleFontSize::Xsmall => KeywordSize::XSmall, + structs::StyleFontSize::Small => KeywordSize::Small, + structs::StyleFontSize::Medium => KeywordSize::Medium, + structs::StyleFontSize::Large => KeywordSize::Large, + structs::StyleFontSize::Xlarge => KeywordSize::XLarge, + structs::StyleFontSize::Xxlarge => KeywordSize::XXLarge, + structs::StyleFontSize::Xxxlarge => KeywordSize::XXXLarge, + structs::StyleFontSize::NoKeyword => { return FontSize { size, keyword_info: None,