servo: Merge #16984 - Bug 1365629: Respect parsing mode in LengthOrPercentage. r=canaltinova (from emilio:lop-parsing-mode); r=canaltinova
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 21 May 2017 10:36:54 -0500
changeset 359828 3342de3cb3762de6e1a3a70b963aae24af650c8f
parent 359827 07630be9df220071ba54238fbb765226ae7f5ea1
child 359829 1ec7b0cb2bfdd8c270c4d51060c98004ebd6e3cf
push id31859
push userihsiao@mozilla.com
push dateMon, 22 May 2017 03:28:26 +0000
treeherdermozilla-central@367944041b55 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscanaltinova, canaltinova
bugs1365629
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16984 - Bug 1365629: Respect parsing mode in LengthOrPercentage. r=canaltinova (from emilio:lop-parsing-mode); r=canaltinova Source-Repo: https://github.com/servo/servo Source-Revision: 0566c601570bc5367db0b9696cb3616405c6a8ca
servo/components/style/values/specified/length.rs
--- a/servo/components/style/values/specified/length.rs
+++ b/servo/components/style/values/specified/length.rs
@@ -615,17 +615,18 @@ impl Length {
                       input: &mut Parser,
                       num_context: AllowedLengthType,
                       allow_quirks: AllowQuirks)
                       -> Result<Length, ()> {
         match try!(input.next()) {
             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(())
                 }
                 Ok(Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(value.value))))
             },
             Token::Function(ref name) if name.eq_ignore_ascii_case("calc") =>
                 input.parse_nested_block(|input| {
                     CalcNode::parse_length(context, input, num_context).map(|calc| Length::Calc(Box::new(calc)))
@@ -800,19 +801,24 @@ impl LengthOrPercentage {
                       allow_quirks: AllowQuirks)
                       -> Result<LengthOrPercentage, ()>
     {
         match try!(input.next()) {
             Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) =>
                 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)
                 }));
                 Ok(LengthOrPercentage::Calc(Box::new(calc)))
             },
             _ => Err(())
         }
@@ -937,17 +943,18 @@ impl LengthOrPercentageOrAuto {
                       allow_quirks: AllowQuirks)
                       -> Result<Self, ()> {
         match try!(input.next()) {
             Token::Dimension(ref value, ref unit) if num_context.is_ok(value.value) =>
                 NoCalcLength::parse_dimension(context, value.value, unit).map(LengthOrPercentageOrAuto::Length),
             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(())
                 }
                 Ok(LengthOrPercentageOrAuto::Length(
                     NoCalcLength::Absolute(AbsoluteLength::Px(value.value))
                 ))
             }
             Token::Ident(ref value) if value.eq_ignore_ascii_case("auto") =>