mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Remove StyleFontSize enum from nsStyleConsts.h.
Differential Revision: https://phabricator.services.mozilla.com/D77511
This commit is contained in:
parent
60f4fedcbf
commit
5af0d7ca7c
6 changed files with 56 additions and 79 deletions
|
@ -854,12 +854,13 @@ impl<'a, 'b: 'a> Cascade<'a, 'b> {
|
|||
|
||||
let new_size = {
|
||||
let font = self.context.builder.get_font();
|
||||
let new_size = match font.clone_font_size().keyword_info {
|
||||
Some(info) => {
|
||||
let info = font.clone_font_size().keyword_info;
|
||||
let new_size = match info.kw {
|
||||
specified::FontSizeKeyword::None => return,
|
||||
_ => {
|
||||
self.context.for_non_inherited_property = None;
|
||||
specified::FontSize::Keyword(info).to_computed_value(self.context)
|
||||
}
|
||||
None => return,
|
||||
};
|
||||
|
||||
if font.gecko().mScriptUnconstrainedSize == Au::from(new_size.size()).0 {
|
||||
|
|
|
@ -942,62 +942,26 @@ fn static_assert() {
|
|||
}
|
||||
|
||||
pub fn set_font_size(&mut self, v: FontSize) {
|
||||
use crate::values::specified::font::KeywordSize;
|
||||
|
||||
let size = Au::from(v.size());
|
||||
self.gecko.mScriptUnconstrainedSize = size.0;
|
||||
|
||||
// These two may be changed from Cascade::fixup_font_stuff.
|
||||
self.gecko.mSize = size.0;
|
||||
self.gecko.mFont.size = size.0;
|
||||
|
||||
if let Some(info) = v.keyword_info {
|
||||
self.gecko.mFontSizeKeyword = match info.kw {
|
||||
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::StyleFontSize::NoKeyword;
|
||||
self.gecko.mFontSizeFactor = 1.;
|
||||
self.gecko.mFontSizeOffset = 0;
|
||||
}
|
||||
self.gecko.mFontSizeKeyword = v.keyword_info.kw;
|
||||
self.gecko.mFontSizeFactor = v.keyword_info.factor;
|
||||
self.gecko.mFontSizeOffset = v.keyword_info.offset.to_i32_au();
|
||||
}
|
||||
|
||||
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 {
|
||||
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,
|
||||
}
|
||||
}
|
||||
_ => unreachable!("mFontSizeKeyword should be an absolute keyword or NO_KEYWORD")
|
||||
};
|
||||
use crate::values::specified::font::KeywordInfo;
|
||||
FontSize {
|
||||
size,
|
||||
keyword_info: Some(KeywordInfo {
|
||||
kw,
|
||||
size: Au(self.gecko.mSize).into(),
|
||||
keyword_info: KeywordInfo {
|
||||
kw: self.gecko.mFontSizeKeyword,
|
||||
factor: self.gecko.mFontSizeFactor,
|
||||
offset: Au(self.gecko.mFontSizeOffset).into()
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -362,6 +362,7 @@ ${helpers.predefined_type(
|
|||
use crate::gecko_bindings::structs::{LookAndFeel_FontID, nsFont};
|
||||
use std::mem;
|
||||
use crate::values::computed::Percentage;
|
||||
use crate::values::specified::font::KeywordInfo;
|
||||
use crate::values::computed::font::{FontFamily, FontSize, FontStretch, FontStyle, FontFamilyList};
|
||||
use crate::values::generics::NonNegative;
|
||||
|
||||
|
@ -397,7 +398,7 @@ ${helpers.predefined_type(
|
|||
},
|
||||
font_size: FontSize {
|
||||
size: NonNegative(cx.maybe_zoom_text(Au(system.size).into())),
|
||||
keyword_info: None
|
||||
keyword_info: KeywordInfo::none()
|
||||
},
|
||||
font_weight,
|
||||
font_stretch,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue