mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
fix to ensure all font-weight keywords are preserved
This commit is contained in:
parent
c48a326fb3
commit
17c74cf967
3 changed files with 26 additions and 6 deletions
|
@ -230,6 +230,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum SpecifiedValue {
|
||||
Normal,
|
||||
Bold,
|
||||
Bolder,
|
||||
Lighter,
|
||||
% for weight in range(100, 901, 100):
|
||||
|
@ -240,6 +242,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::Normal => dest.write_str("normal"),
|
||||
SpecifiedValue::Bold => dest.write_str("bold"),
|
||||
SpecifiedValue::Bolder => dest.write_str("bolder"),
|
||||
SpecifiedValue::Lighter => dest.write_str("lighter"),
|
||||
% for weight in range(100, 901, 100):
|
||||
|
@ -252,8 +256,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
input.try(|input| {
|
||||
match_ignore_ascii_case! { try!(input.expect_ident()),
|
||||
"bold" => Ok(SpecifiedValue::Weight700),
|
||||
"normal" => Ok(SpecifiedValue::Weight400),
|
||||
"normal" => Ok(SpecifiedValue::Normal),
|
||||
"bold" => Ok(SpecifiedValue::Bold),
|
||||
"bolder" => Ok(SpecifiedValue::Bolder),
|
||||
"lighter" => Ok(SpecifiedValue::Lighter),
|
||||
_ => Err(())
|
||||
|
@ -281,6 +285,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
% for weight in range(100, 901, 100):
|
||||
SpecifiedValue::Weight${weight} => Ok(computed_value::T::Weight${weight}),
|
||||
% endfor
|
||||
SpecifiedValue::Normal => Ok(computed_value::T::Weight400),
|
||||
SpecifiedValue::Bold => Ok(computed_value::T::Weight700),
|
||||
SpecifiedValue::Bolder |
|
||||
SpecifiedValue::Lighter => Err(())
|
||||
}
|
||||
|
@ -331,6 +337,8 @@ ${helpers.single_keyword("font-variant-caps",
|
|||
% for weight in range(100, 901, 100):
|
||||
SpecifiedValue::Weight${weight} => computed_value::T::Weight${weight},
|
||||
% endfor
|
||||
SpecifiedValue::Normal => computed_value::T::Weight400,
|
||||
SpecifiedValue::Bold => computed_value::T::Weight700,
|
||||
SpecifiedValue::Bolder => match context.inherited_style().get_font().clone_font_weight() {
|
||||
computed_value::T::Weight100 => computed_value::T::Weight400,
|
||||
computed_value::T::Weight200 => computed_value::T::Weight400,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue