mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1635160 - Convert style-font #defines to an enum class. r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D73728
This commit is contained in:
parent
46cce048ef
commit
46da657360
@ -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])) {
|
||||
|
@ -166,6 +166,7 @@ rusty-enums = [
|
||||
"mozilla::StyleBlend",
|
||||
"mozilla::StyleMaskComposite",
|
||||
"mozilla::StyleControlCharacterVisibility",
|
||||
"mozilla::StyleFontSize",
|
||||
]
|
||||
whitelist-vars = [
|
||||
"NS_ATTRVALUE_.*",
|
||||
|
@ -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 <font size="7">. 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)
|
||||
|
@ -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),
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user