layout: Implement word-spacing per CSS 2.1 § 16.4.

This assumes that there are no ligatures that span across multiple
words. Since we have a per-word shape cache, this is a safe assumption
as of now. I have left comments to ensure that, if and when this is
revisted, we make sure to handle it properly.
This commit is contained in:
Patrick Walton 2014-12-12 17:49:37 -08:00
parent ea39b878ac
commit 106fdb1d32
7 changed files with 94 additions and 7 deletions

View file

@ -1111,6 +1111,29 @@ pub mod longhands {
}
</%self:single_component_value>
<%self:single_component_value name="word-spacing">
pub type SpecifiedValue = Option<specified::Length>;
pub mod computed_value {
use super::super::Au;
pub type T = Option<Au>;
}
#[inline]
pub fn get_initial_value() -> computed_value::T {
None
}
#[inline]
pub fn to_computed_value(value: SpecifiedValue, context: &computed::Context)
-> computed_value::T {
value.map(|length| computed::compute_Au(length, context))
}
pub fn from_component_value(input: &ComponentValue, _: &Url) -> Result<SpecifiedValue,()> {
match input {
&Ident(ref value) if value.eq_ignore_ascii_case("normal") => Ok(None),
_ => specified::Length::parse_non_negative(input).map(|length| Some(length)),
}
}
</%self:single_component_value>
${predefined_type("text-indent", "LengthOrPercentage", "computed::LP_Length(Au(0))")}
${new_style_struct("Text", is_inherited=False)}