Auto merge of #8542 - KiChjang:style-whitespace-methods, r=SimonSapin

Extend whitespace::T with additional helper methods

Fixes #8128.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8542)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-11-23 23:39:07 +05:30
commit 6449cd09eb
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")}