mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Add support for font-size relative size keywords. Fix #3423
This commit is contained in:
parent
4c6e64dc7c
commit
eabb8d4f29
3 changed files with 19 additions and 12 deletions
|
@ -908,8 +908,7 @@ pub mod longhands {
|
||||||
// We already computed this element's font size; no need to compute it again.
|
// We already computed this element's font size; no need to compute it again.
|
||||||
return context.font_size
|
return context.font_size
|
||||||
}
|
}
|
||||||
/// <length> | <percentage> | <absolute-size>
|
/// <length> | <percentage> | <absolute-size> | <relative-size>
|
||||||
/// TODO: support <relative-size>
|
|
||||||
pub fn from_component_value(input: &ComponentValue, _base_url: &Url)
|
pub fn from_component_value(input: &ComponentValue, _base_url: &Url)
|
||||||
-> Result<SpecifiedValue, ()> {
|
-> Result<SpecifiedValue, ()> {
|
||||||
match specified::LengthOrPercentage::parse_non_negative(input) {
|
match specified::LengthOrPercentage::parse_non_negative(input) {
|
||||||
|
@ -917,17 +916,21 @@ pub mod longhands {
|
||||||
Ok(specified::LP_Percentage(value)) => return Ok(specified::Em(value)),
|
Ok(specified::LP_Percentage(value)) => return Ok(specified::Em(value)),
|
||||||
Err(()) => (),
|
Err(()) => (),
|
||||||
}
|
}
|
||||||
let au = match try!(get_ident_lower(input)).as_slice() {
|
match try!(get_ident_lower(input)).as_slice() {
|
||||||
"xx-small" => Au::from_px(MEDIUM_PX) * 3 / 5,
|
"xx-small" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 3 / 5)),
|
||||||
"x-small" => Au::from_px(MEDIUM_PX) * 3 / 4,
|
"x-small" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 3 / 4)),
|
||||||
"small" => Au::from_px(MEDIUM_PX) * 8 / 9,
|
"small" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 8 / 9)),
|
||||||
"medium" => Au::from_px(MEDIUM_PX),
|
"medium" => Ok(specified::Au_(Au::from_px(MEDIUM_PX))),
|
||||||
"large" => Au::from_px(MEDIUM_PX) * 6 / 5,
|
"large" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 6 / 5)),
|
||||||
"x-large" => Au::from_px(MEDIUM_PX) * 3 / 2,
|
"x-large" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 3 / 2)),
|
||||||
"xx-large" => Au::from_px(MEDIUM_PX) * 2,
|
"xx-large" => Ok(specified::Au_(Au::from_px(MEDIUM_PX) * 2)),
|
||||||
|
|
||||||
|
// https://github.com/servo/servo/issues/3423#issuecomment-56321664
|
||||||
|
"smaller" => Ok(specified::Em(0.85)),
|
||||||
|
"larger" => Ok(specified::Em(1.2)),
|
||||||
|
|
||||||
_ => return Err(())
|
_ => return Err(())
|
||||||
};
|
}
|
||||||
Ok(specified::Au_(au))
|
|
||||||
}
|
}
|
||||||
</%self:single_component_value>
|
</%self:single_component_value>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
<p style="font-size: 24pt">24pt is 32px.
|
<p style="font-size: 24pt">24pt is 32px.
|
||||||
<p style="font-size: 2em">2em is 40px.
|
<p style="font-size: 2em">2em is 40px.
|
||||||
<p style="font-size: 200%">200% is 40px.
|
<p style="font-size: 200%">200% is 40px.
|
||||||
|
<p style="font-size: smaller">smaller is 17px.
|
||||||
|
<p style="font-size: larger">larger is 24px.
|
||||||
<p style="font-size: xx-small">xx-small is 9.6px.
|
<p style="font-size: xx-small">xx-small is 9.6px.
|
||||||
<p style="font-size: x-small">x-small is 12px.
|
<p style="font-size: x-small">x-small is 12px.
|
||||||
<p style="font-size: small">small is 14.2222…px.
|
<p style="font-size: small">small is 14.2222…px.
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
<p style="font-size: 32px">24pt is 32px.
|
<p style="font-size: 32px">24pt is 32px.
|
||||||
<p style="font-size: 40px">2em is 40px.
|
<p style="font-size: 40px">2em is 40px.
|
||||||
<p style="font-size: 40px">200% is 40px.
|
<p style="font-size: 40px">200% is 40px.
|
||||||
|
<p style="font-size: 17px">smaller is 17px.
|
||||||
|
<p style="font-size: 24px">larger is 24px.
|
||||||
<p style="font-size: 9.6px">xx-small is 9.6px.
|
<p style="font-size: 9.6px">xx-small is 9.6px.
|
||||||
<p style="font-size: 12px">x-small is 12px.
|
<p style="font-size: 12px">x-small is 12px.
|
||||||
<p style="font-size: 14.2222222222222222222222222222px">small is 14.2222…px.
|
<p style="font-size: 14.2222222222222222222222222222px">small is 14.2222…px.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue