Bug 1391432 - stylo: Handle single X keyword value in LegacyPosition r?jdm draft
authorNazım Can Altınova <canaltinova@gmail.com>
Thu, 17 Aug 2017 15:57:25 -0700
changeset 648591 2561cfa08552e5ef8281001cae5109335a9ceeea
parent 648384 e365137fa61bfd729617ba1ebf9f1ed79facd1f2
child 726868 19245eb505afdf406761df3fa584dd41fe1480df
push id74805
push userbmo:canaltinova@gmail.com
push dateFri, 18 Aug 2017 00:41:31 +0000
reviewersjdm
bugs1391432
milestone57.0a1
Bug 1391432 - stylo: Handle single X keyword value in LegacyPosition r?jdm MozReview-Commit-ID: EohV57mnQKy
layout/style/test/property_database.js
servo/components/style/values/specified/position.rs
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -655,16 +655,18 @@ if (IsCSSPropertyPrefEnabled("layout.css
 
     "-moz-linear-gradient(top left, red, blue)",
     "-moz-linear-gradient(0 0, red, blue)",
     "-moz-linear-gradient(20% bottom, red, blue)",
     "-moz-linear-gradient(center 20%, red, blue)",
     "-moz-linear-gradient(left 35px, red, blue)",
     "-moz-linear-gradient(10% 10em, red, blue)",
     "-moz-linear-gradient(44px top, red, blue)",
+    "-moz-linear-gradient(left, red, blue)",
+    "-moz-linear-gradient(bottom, red, blue)",
 
     "-moz-linear-gradient(0px, red, blue)",
     "-moz-linear-gradient(0, red, blue)",
     "-moz-linear-gradient(top left 45deg, red, blue)",
     "-moz-linear-gradient(20% bottom -300deg, red, blue)",
     "-moz-linear-gradient(center 20% 1.95929rad, red, blue)",
     "-moz-linear-gradient(left 35px 30grad, red, blue)",
     "-moz-linear-gradient(left 35px 0.1turn, red, blue)",
--- a/servo/components/style/values/specified/position.rs
+++ b/servo/components/style/values/specified/position.rs
@@ -315,30 +315,27 @@ impl LegacyPosition {
                 }
                 let x_pos = input
                     .try(|i| OriginComponent::parse(context, i))
                     .unwrap_or(x_pos);
                 let y_pos = OriginComponent::Center;
                 return Ok(Self::new(x_pos, y_pos));
             },
             Ok(OriginComponent::Side(x_keyword)) => {
-                if input.try(|i| i.expect_ident_matching("center")).is_ok() {
-                    let x_pos = OriginComponent::Side(x_keyword);
-                    let y_pos = OriginComponent::Center;
-                    return Ok(Self::new(x_pos, y_pos));
-                }
                 if let Ok(y_keyword) = input.try(Y::parse) {
                     let x_pos = OriginComponent::Side(x_keyword);
                     let y_pos = OriginComponent::Side(y_keyword);
                     return Ok(Self::new(x_pos, y_pos));
                 }
                 let x_pos = OriginComponent::Side(x_keyword);
                 if let Ok(y_lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) {
                     return Ok(Self::new(x_pos, OriginComponent::Length(y_lop)))
                 }
+                let _ = input.try(|i| i.expect_ident_matching("center"));
+                return Ok(Self::new(x_pos, OriginComponent::Center));
             },
             Ok(x_pos @ OriginComponent::Length(_)) => {
                 if let Ok(y_keyword) = input.try(Y::parse) {
                     let y_pos = OriginComponent::Side(y_keyword);
                     return Ok(Self::new(x_pos, y_pos));
                 }
                 if let Ok(y_lop) = input.try(|i| LengthOrPercentage::parse_quirky(context, i, allow_quirks)) {
                     let y_pos = OriginComponent::Length(y_lop);