aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/values
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2017-05-21 14:54:05 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2017-05-21 17:02:42 +0200
commit911d307f8f37a1f6d1f50ee1c516970cc2876f08 (patch)
tree6e6fc89f28840f57f017dfe7533f49311fe17dbb /components/style/values
parent3d40b516c8ac6e946cadace2378581cbac7b1e1b (diff)
downloadservo-911d307f8f37a1f6d1f50ee1c516970cc2876f08.tar.gz
servo-911d307f8f37a1f6d1f50ee1c516970cc2876f08.zip
Bug 1365629: Respect parsing mode in LengthOrPercentage. r=canaltinova
Diffstat (limited to 'components/style/values')
-rw-r--r--components/style/values/specified/length.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs
index 331901bf8c6..2f74cae4cea 100644
--- a/components/style/values/specified/length.rs
+++ b/components/style/values/specified/length.rs
@@ -620,7 +620,8 @@ impl Length {
Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) =>
Length::parse_dimension(context, value.value, unit),
Token::Number(ref value) if num_context.is_ok(value.value) => {
- if value.value != 0. && !context.parsing_mode.allows_unitless_lengths() &&
+ if value.value != 0. &&
+ !context.parsing_mode.allows_unitless_lengths() &&
!allow_quirks.allowed(context.quirks_mode) {
return Err(())
}
@@ -805,9 +806,14 @@ impl LengthOrPercentage {
NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentage::Length),
Token::Percentage(ref value) if num_context.is_ok(value.unit_value) =>
Ok(LengthOrPercentage::Percentage(Percentage(value.unit_value))),
- Token::Number(value) if value.value == 0. ||
- (num_context.is_ok(value.value) && allow_quirks.allowed(context.quirks_mode)) =>
- Ok(LengthOrPercentage::Length(NoCalcLength::from_px(value.value))),
+ Token::Number(value) if num_context.is_ok(value.value) => {
+ if value.value != 0. &&
+ !context.parsing_mode.allows_unitless_lengths() &&
+ !allow_quirks.allowed(context.quirks_mode) {
+ return Err(())
+ }
+ Ok(LengthOrPercentage::Length(NoCalcLength::from_px(value.value)))
+ }
Token::Function(ref name) if name.eq_ignore_ascii_case("calc") => {
let calc = try!(input.parse_nested_block(|i| {
CalcNode::parse_length_or_percentage(context, i, num_context)
@@ -942,7 +948,8 @@ impl LengthOrPercentageOrAuto {
Token::Percentage(ref value) if num_context.is_ok(value.unit_value) =>
Ok(LengthOrPercentageOrAuto::Percentage(Percentage(value.unit_value))),
Token::Number(ref value) if num_context.is_ok(value.value) => {
- if value.value != 0. && !context.parsing_mode.allows_unitless_lengths() &&
+ if value.value != 0. &&
+ !context.parsing_mode.allows_unitless_lengths() &&
!allow_quirks.allowed(context.quirks_mode) {
return Err(())
}