aboutsummaryrefslogtreecommitdiffstats
path: root/src/servo/parser/parser_util.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/servo/parser/parser_util.rs')
-rw-r--r--src/servo/parser/parser_util.rs56
1 files changed, 28 insertions, 28 deletions
diff --git a/src/servo/parser/parser_util.rs b/src/servo/parser/parser_util.rs
index 5d7813ca569..2cfc2e328b5 100644
--- a/src/servo/parser/parser_util.rs
+++ b/src/servo/parser/parser_util.rs
@@ -11,16 +11,16 @@ export parse_display_type;
fn parse_unit(str : ~str) -> option<Unit> {
alt str {
- s if s.ends_with(~"%") { from_str(str.substr(0, str.len() - 1)).map(|f| Percent(f)) }
- s if s.ends_with(~"in") { from_str(str.substr(0, str.len() - 2)).map(|f| In(f)) }
- s if s.ends_with(~"cm") { from_str(str.substr(0, str.len() - 2)).map(|f| Cm(f)) }
- s if s.ends_with(~"mm") { from_str(str.substr(0, str.len() - 2)).map(|f| Mm(f)) }
- s if s.ends_with(~"pt") { from_str(str.substr(0, str.len() - 2)).map(|f| Pt(f)) }
- s if s.ends_with(~"pc") { from_str(str.substr(0, str.len() - 2)).map(|f| Pc(f)) }
- s if s.ends_with(~"px") { from_str(str.substr(0, str.len() - 2)).map(|f| Px(f)) }
- s if s.ends_with(~"em") { from_str(str.substr(0, str.len() - 2)).map(|f| Em(f)) }
- s if s.ends_with(~"ex") { from_str(str.substr(0, str.len() - 2)).map(|f| Ex(f)) }
- _ { none }
+ s if s.ends_with(~"%") => from_str(str.substr(0, str.len() - 1)).map(|f| Percent(f)),
+ s if s.ends_with(~"in") => from_str(str.substr(0, str.len() - 2)).map(|f| In(f)),
+ s if s.ends_with(~"cm") => from_str(str.substr(0, str.len() - 2)).map(|f| Cm(f)),
+ s if s.ends_with(~"mm") => from_str(str.substr(0, str.len() - 2)).map(|f| Mm(f)),
+ s if s.ends_with(~"pt") => from_str(str.substr(0, str.len() - 2)).map(|f| Pt(f)),
+ s if s.ends_with(~"pc") => from_str(str.substr(0, str.len() - 2)).map(|f| Pc(f)),
+ s if s.ends_with(~"px") => from_str(str.substr(0, str.len() - 2)).map(|f| Px(f)),
+ s if s.ends_with(~"em") => from_str(str.substr(0, str.len() - 2)).map(|f| Em(f)),
+ s if s.ends_with(~"ex") => from_str(str.substr(0, str.len() - 2)).map(|f| Ex(f)),
+ _ => none,
}
}
@@ -29,35 +29,35 @@ fn parse_font_size(str : ~str) -> option<Unit> {
let default = 16.0;
alt str {
- ~"xx-small" { some(Px(0.6*default)) }
- ~"x-small" { some(Px(0.75*default)) }
- ~"small" { some(Px(8.0/9.0*default)) }
- ~"medium" { some(Px(default)) }
- ~"large" { some(Px(1.2*default)) }
- ~"x-large" { some(Px(1.5*default)) }
- ~"xx-large" { some(Px(2.0*default)) }
- ~"smaller" { some(Em(0.8)) }
- ~"larger" { some(Em(1.25)) }
- ~"inherit" { some(Em(1.0)) }
- _ { parse_unit(str) }
+ ~"xx-small" => some(Px(0.6*default)),
+ ~"x-small" => some(Px(0.75*default)),
+ ~"small" => some(Px(8.0/9.0*default)),
+ ~"medium" => some(Px(default)),
+ ~"large" => some(Px(1.2*default)),
+ ~"x-large" => some(Px(1.5*default)),
+ ~"xx-large" => some(Px(2.0*default)),
+ ~"smaller" => some(Em(0.8)),
+ ~"larger" => some(Em(1.25)),
+ ~"inherit" => some(Em(1.0)),
+ _ => parse_unit(str),
}
}
// For width / height, and anything else with the same attribute values
fn parse_size(str : ~str) -> option<Unit> {
alt str {
- ~"auto" { some(Auto) }
- ~"inherit" { some(Em(1.0)) }
- _ { parse_unit(str) }
+ ~"auto" => some(Auto),
+ ~"inherit" => some(Em(1.0)),
+ _ => parse_unit(str),
}
}
fn parse_display_type(str : ~str) -> option<DisplayType> {
alt str {
- ~"inline" { some(DisInline) }
- ~"block" { some(DisBlock) }
- ~"none" { some(DisNone) }
- _ { #debug["Recieved unknown display value '%s'", str]; none }
+ ~"inline" => some(DisInline),
+ ~"block" => some(DisBlock),
+ ~"none" => some(DisNone),
+ _ => { #debug["Recieved unknown display value '%s'", str]; none }
}
}