diff --git a/components/style/properties/mod.rs.mako b/components/style/properties/mod.rs.mako index f65e9b35280..c6b4cec4028 100644 --- a/components/style/properties/mod.rs.mako +++ b/components/style/properties/mod.rs.mako @@ -904,8 +904,9 @@ pub mod longhands { use super::super::Au; pub type T = Au; } + static MEDIUM_PX: int = 16; #[inline] pub fn get_initial_value() -> computed_value::T { - Au::from_px(16) // medium + Au::from_px(MEDIUM_PX) } #[inline] pub fn to_computed_value(_value: SpecifiedValue, context: &computed::Context) @@ -913,16 +914,26 @@ pub mod longhands { // We already computed this element's font size; no need to compute it again. return context.font_size } - /// | - /// TODO: support and + /// | | + /// TODO: support pub fn from_component_value(input: &ComponentValue, _base_url: &Url) -> Result { - specified::LengthOrPercentage::parse_non_negative(input).map(|value| { - match value { - specified::LP_Length(value) => value, - specified::LP_Percentage(value) => specified::Em(value), - } - }) + match specified::LengthOrPercentage::parse_non_negative(input) { + Ok(specified::LP_Length(value)) => return Ok(value), + Ok(specified::LP_Percentage(value)) => return Ok(specified::Em(value)), + Err(()) => (), + } + let au = match try!(get_ident_lower(input)).as_slice() { + "xx-small" => Au::from_px(MEDIUM_PX) * 3 / 5, + "x-small" => Au::from_px(MEDIUM_PX) * 3 / 4, + "small" => Au::from_px(MEDIUM_PX) * 8 / 9, + "medium" => Au::from_px(MEDIUM_PX), + "large" => Au::from_px(MEDIUM_PX) * 6 / 5, + "x-large" => Au::from_px(MEDIUM_PX) * 3 / 2, + "xx-large" => Au::from_px(MEDIUM_PX) * 2, + _ => return Err(()) + }; + Ok(specified::Au_(au)) } diff --git a/tests/ref/basic.list b/tests/ref/basic.list index 7f5a9ee7fa6..71120311643 100644 --- a/tests/ref/basic.list +++ b/tests/ref/basic.list @@ -23,8 +23,7 @@ == text_decoration_cached.html text_decoration_cached_ref.html # text_decoration_propagation_a.html text_decoration_propagation_b.html # inline_text_align_a.html inline_text_align_b.html -== font_size_em.html font_size_em_ref.html -== font_size_percentage.html font_size_em_ref.html +== font_size.html font_size_ref.html == img_size_a.html img_size_b.html == img_dynamic_remove.html img_dynamic_remove_ref.html == upper_id_attr.html upper_id_attr_ref.html diff --git a/tests/ref/font_size.html b/tests/ref/font_size.html new file mode 100644 index 00000000000..868a6f4b3d3 --- /dev/null +++ b/tests/ref/font_size.html @@ -0,0 +1,13 @@ + +font-size (issues #1435, #3417) + +

24pt is 32px. +

2em is 40px. +

200% is 40px. +

xx-small is 9.6px. +

x-small is 12px. +

small is 14.2222…px. +

medium is 16px. +

large is 19.2px. +

x-large is 24px. +

xx-large is 32px. diff --git a/tests/ref/font_size_em.html b/tests/ref/font_size_em.html deleted file mode 100644 index 5f1983d12c0..00000000000 --- a/tests/ref/font_size_em.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - font-size: 2em (Bug #1435) - - - -

This text should be 40px high.

- - diff --git a/tests/ref/font_size_em_ref.html b/tests/ref/font_size_em_ref.html deleted file mode 100644 index 3697fdb0e6d..00000000000 --- a/tests/ref/font_size_em_ref.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - font-size: 2em (Bug #1435) - - - -

This text should be 40px high.

- - diff --git a/tests/ref/font_size_percentage.html b/tests/ref/font_size_percentage.html deleted file mode 100644 index d344ea782e9..00000000000 --- a/tests/ref/font_size_percentage.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - font-size: 200% (Bug #1435) - - - -

This text should be 40px high.

- - diff --git a/tests/ref/font_size_ref.html b/tests/ref/font_size_ref.html new file mode 100644 index 00000000000..d85c120b822 --- /dev/null +++ b/tests/ref/font_size_ref.html @@ -0,0 +1,13 @@ + +font-size (issues #1435, #3417) + +

24pt is 32px. +

2em is 40px. +

200% is 40px. +

xx-small is 9.6px. +

x-small is 12px. +

small is 14.2222…px. +

medium is 16px. +

large is 19.2px. +

x-large is 24px. +

xx-large is 32px.