Extend whitespace::T with additional helper methods

This commit is contained in:
Keith Yeung 2015-11-16 01:32:27 -08:00
parent a5babb89a0
commit 7de7cb4786
5 changed files with 47 additions and 48 deletions

View file

@ -2331,7 +2331,42 @@ pub mod longhands {
}
</%self:longhand>
${single_keyword("white-space", "normal pre nowrap pre-wrap pre-line")}
<%self:single_keyword_computed name="white-space" values="normal pre nowrap pre-wrap pre-line">
use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {}
impl SpecifiedValue {
pub fn allow_wrap(&self) -> bool {
match *self {
SpecifiedValue::nowrap |
SpecifiedValue::pre => false,
SpecifiedValue::normal |
SpecifiedValue::pre_wrap |
SpecifiedValue::pre_line => true,
}
}
pub fn preserve_newlines(&self) -> bool {
match *self {
SpecifiedValue::normal |
SpecifiedValue::nowrap => false,
SpecifiedValue::pre |
SpecifiedValue::pre_wrap |
SpecifiedValue::pre_line => true,
}
}
pub fn preserve_spaces(&self) -> bool {
match *self {
SpecifiedValue::normal |
SpecifiedValue::nowrap |
SpecifiedValue::pre_line => false,
SpecifiedValue::pre |
SpecifiedValue::pre_wrap => true,
}
}
}
</%self:single_keyword_computed>
// TODO(pcwalton): `full-width`
${single_keyword("text-transform", "none capitalize uppercase lowercase")}