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) &&
|
if (!ParseNumericValue(str, fontSize, flags, nullptr) &&
|
||||||
parseSizeKeywords) {
|
parseSizeKeywords) {
|
||||||
static const char sizes[3][7] = {"small", "normal", "big"};
|
static const char sizes[3][7] = {"small", "normal", "big"};
|
||||||
static const int32_t values[MOZ_ARRAY_LENGTH(sizes)] = {
|
static const StyleFontSize values[MOZ_ARRAY_LENGTH(sizes)] = {
|
||||||
NS_STYLE_FONT_SIZE_SMALL, NS_STYLE_FONT_SIZE_MEDIUM,
|
StyleFontSize::Small, StyleFontSize::Medium, StyleFontSize::Large};
|
||||||
NS_STYLE_FONT_SIZE_LARGE};
|
|
||||||
str.CompressWhitespace();
|
str.CompressWhitespace();
|
||||||
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
|
for (uint32_t i = 0; i < ArrayLength(sizes); ++i) {
|
||||||
if (str.EqualsASCII(sizes[i])) {
|
if (str.EqualsASCII(sizes[i])) {
|
||||||
|
@ -166,6 +166,7 @@ rusty-enums = [
|
|||||||
"mozilla::StyleBlend",
|
"mozilla::StyleBlend",
|
||||||
"mozilla::StyleMaskComposite",
|
"mozilla::StyleMaskComposite",
|
||||||
"mozilla::StyleControlCharacterVisibility",
|
"mozilla::StyleControlCharacterVisibility",
|
||||||
|
"mozilla::StyleFontSize",
|
||||||
]
|
]
|
||||||
whitelist-vars = [
|
whitelist-vars = [
|
||||||
"NS_ATTRVALUE_.*",
|
"NS_ATTRVALUE_.*",
|
||||||
|
@ -375,19 +375,19 @@ enum class StyleFlexWrap : uint8_t {
|
|||||||
#define NS_STYLE_ORDER_INITIAL 0
|
#define NS_STYLE_ORDER_INITIAL 0
|
||||||
|
|
||||||
// See nsStyleFont
|
// See nsStyleFont
|
||||||
#define NS_STYLE_FONT_SIZE_XXSMALL 0
|
enum class StyleFontSize : uint8_t {
|
||||||
#define NS_STYLE_FONT_SIZE_XSMALL 1
|
Xxsmall = 0,
|
||||||
#define NS_STYLE_FONT_SIZE_SMALL 2
|
Xsmall,
|
||||||
#define NS_STYLE_FONT_SIZE_MEDIUM 3
|
Small,
|
||||||
#define NS_STYLE_FONT_SIZE_LARGE 4
|
Medium,
|
||||||
#define NS_STYLE_FONT_SIZE_XLARGE 5
|
Large,
|
||||||
#define NS_STYLE_FONT_SIZE_XXLARGE 6
|
Xlarge,
|
||||||
#define NS_STYLE_FONT_SIZE_XXXLARGE \
|
Xxlarge,
|
||||||
7 // Only used by <font size="7">. Not specifiable in CSS.
|
Xxxlarge,
|
||||||
#define NS_STYLE_FONT_SIZE_LARGER 8
|
Larger,
|
||||||
#define NS_STYLE_FONT_SIZE_SMALLER 9
|
Smaller,
|
||||||
#define NS_STYLE_FONT_SIZE_NO_KEYWORD \
|
NoKeyword // Used by Servo to track the "no keyword" case
|
||||||
10 // Used by Servo to track the "no keyword" case
|
};
|
||||||
|
|
||||||
#define NS_STYLE_MASONRY_PLACEMENT_PACK (1 << 0)
|
#define NS_STYLE_MASONRY_PLACEMENT_PACK (1 << 0)
|
||||||
#define NS_STYLE_MASONRY_ORDER_DEFINITE_FIRST (1 << 1)
|
#define NS_STYLE_MASONRY_ORDER_DEFINITE_FIRST (1 << 1)
|
||||||
|
@ -245,7 +245,7 @@ nsStyleFont::nsStyleFont(const Document& aDocument)
|
|||||||
mSize(ZoomText(aDocument, mFont.size)),
|
mSize(ZoomText(aDocument, mFont.size)),
|
||||||
mFontSizeFactor(1.0),
|
mFontSizeFactor(1.0),
|
||||||
mFontSizeOffset(0),
|
mFontSizeOffset(0),
|
||||||
mFontSizeKeyword(NS_STYLE_FONT_SIZE_MEDIUM),
|
mFontSizeKeyword(StyleFontSize::Medium),
|
||||||
mGenericID(StyleGenericFontFamily::None),
|
mGenericID(StyleGenericFontFamily::None),
|
||||||
mScriptLevel(0),
|
mScriptLevel(0),
|
||||||
mMathVariant(NS_MATHML_MATHVARIANT_NONE),
|
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
|
// and if so if it has been modified by a factor/offset
|
||||||
float mFontSizeFactor;
|
float mFontSizeFactor;
|
||||||
nscoord mFontSizeOffset;
|
nscoord mFontSizeOffset;
|
||||||
uint8_t mFontSizeKeyword; // NS_STYLE_FONT_SIZE_*, is
|
mozilla::StyleFontSize mFontSizeKeyword; // StyleFontSize is Nokeyword when
|
||||||
// NS_STYLE_FONT_SIZE_NO_KEYWORD when not
|
// not keyword-derived
|
||||||
// keyword-derived
|
|
||||||
|
|
||||||
mozilla::StyleGenericFontFamily mGenericID;
|
mozilla::StyleGenericFontFamily mGenericID;
|
||||||
|
|
||||||
|
@ -953,19 +953,19 @@ fn static_assert() {
|
|||||||
|
|
||||||
if let Some(info) = v.keyword_info {
|
if let Some(info) = v.keyword_info {
|
||||||
self.gecko.mFontSizeKeyword = match info.kw {
|
self.gecko.mFontSizeKeyword = match info.kw {
|
||||||
KeywordSize::XXSmall => structs::NS_STYLE_FONT_SIZE_XXSMALL,
|
KeywordSize::XXSmall => structs::StyleFontSize::Xxsmall,
|
||||||
KeywordSize::XSmall => structs::NS_STYLE_FONT_SIZE_XSMALL,
|
KeywordSize::XSmall => structs::StyleFontSize::Xsmall,
|
||||||
KeywordSize::Small => structs::NS_STYLE_FONT_SIZE_SMALL,
|
KeywordSize::Small => structs::StyleFontSize::Small,
|
||||||
KeywordSize::Medium => structs::NS_STYLE_FONT_SIZE_MEDIUM,
|
KeywordSize::Medium => structs::StyleFontSize::Medium,
|
||||||
KeywordSize::Large => structs::NS_STYLE_FONT_SIZE_LARGE,
|
KeywordSize::Large => structs::StyleFontSize::Large,
|
||||||
KeywordSize::XLarge => structs::NS_STYLE_FONT_SIZE_XLARGE,
|
KeywordSize::XLarge => structs::StyleFontSize::Xxlarge,
|
||||||
KeywordSize::XXLarge => structs::NS_STYLE_FONT_SIZE_XXLARGE,
|
KeywordSize::XXLarge => structs::StyleFontSize::Xxlarge,
|
||||||
KeywordSize::XXXLarge => structs::NS_STYLE_FONT_SIZE_XXXLARGE,
|
KeywordSize::XXXLarge => structs::StyleFontSize::Xxxlarge,
|
||||||
} as u8;
|
};
|
||||||
self.gecko.mFontSizeFactor = info.factor;
|
self.gecko.mFontSizeFactor = info.factor;
|
||||||
self.gecko.mFontSizeOffset = info.offset.to_i32_au();
|
self.gecko.mFontSizeOffset = info.offset.to_i32_au();
|
||||||
} else {
|
} 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.mFontSizeFactor = 1.;
|
||||||
self.gecko.mFontSizeOffset = 0;
|
self.gecko.mFontSizeOffset = 0;
|
||||||
}
|
}
|
||||||
@ -974,16 +974,16 @@ fn static_assert() {
|
|||||||
pub fn clone_font_size(&self) -> FontSize {
|
pub fn clone_font_size(&self) -> FontSize {
|
||||||
use crate::values::specified::font::{KeywordInfo, KeywordSize};
|
use crate::values::specified::font::{KeywordInfo, KeywordSize};
|
||||||
let size = Au(self.gecko.mSize).into();
|
let size = Au(self.gecko.mSize).into();
|
||||||
let kw = match self.gecko.mFontSizeKeyword as u32 {
|
let kw = match self.gecko.mFontSizeKeyword {
|
||||||
structs::NS_STYLE_FONT_SIZE_XXSMALL => KeywordSize::XXSmall,
|
structs::StyleFontSize::Xxsmall => KeywordSize::XXSmall,
|
||||||
structs::NS_STYLE_FONT_SIZE_XSMALL => KeywordSize::XSmall,
|
structs::StyleFontSize::Xsmall => KeywordSize::XSmall,
|
||||||
structs::NS_STYLE_FONT_SIZE_SMALL => KeywordSize::Small,
|
structs::StyleFontSize::Small => KeywordSize::Small,
|
||||||
structs::NS_STYLE_FONT_SIZE_MEDIUM => KeywordSize::Medium,
|
structs::StyleFontSize::Medium => KeywordSize::Medium,
|
||||||
structs::NS_STYLE_FONT_SIZE_LARGE => KeywordSize::Large,
|
structs::StyleFontSize::Large => KeywordSize::Large,
|
||||||
structs::NS_STYLE_FONT_SIZE_XLARGE => KeywordSize::XLarge,
|
structs::StyleFontSize::Xlarge => KeywordSize::XLarge,
|
||||||
structs::NS_STYLE_FONT_SIZE_XXLARGE => KeywordSize::XXLarge,
|
structs::StyleFontSize::Xxlarge => KeywordSize::XXLarge,
|
||||||
structs::NS_STYLE_FONT_SIZE_XXXLARGE => KeywordSize::XXXLarge,
|
structs::StyleFontSize::Xxxlarge => KeywordSize::XXXLarge,
|
||||||
structs::NS_STYLE_FONT_SIZE_NO_KEYWORD => {
|
structs::StyleFontSize::NoKeyword => {
|
||||||
return FontSize {
|
return FontSize {
|
||||||
size,
|
size,
|
||||||
keyword_info: None,
|
keyword_info: None,
|
||||||
|
Loading…
Reference in New Issue
Block a user