servo: Merge #15918 - PropertyDeclaration with CSSWideKeyword is parsed (from munyari:whitespace); r=emilio
authorPanashe M. Fundira <fundirap@gmail.com>
Mon, 20 Mar 2017 04:23:28 -0700
changeset 348411 f713510190c54c2dddcf2b7bd48b1bb560292759
parent 348410 2684ce503c2ebca79205bfc05efddaa5e275388a
child 348412 c98cc6ddb83b92bf592d3c79ab9b929c3f1e30b8
push id39154
push userservo-vcs-sync@mozilla.com
push dateMon, 20 Mar 2017 12:26:15 +0000
treeherderautoland@f713510190c5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs15918, 15401
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 #15918 - PropertyDeclaration with CSSWideKeyword is parsed (from munyari:whitespace); r=emilio Addresses #15401 Source-Repo: https://github.com/servo/servo Source-Revision: 4a63581fadd41f9a1901498e47672c59d44b5fb0
servo/components/style/properties/properties.mako.rs
servo/tests/unit/style/properties/serialization.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -1170,17 +1170,19 @@ impl PropertyDeclaration {
     /// preserving whitespace (as opposed to being parsed into a more abstract
     /// data structure).
     ///
     /// This is the case of custom properties and values that contain
     /// unsubstituted variables.
     pub fn value_is_unparsed(&self) -> bool {
       match *self {
           PropertyDeclaration::WithVariables(..) => true,
-          PropertyDeclaration::Custom(..) => true,
+          PropertyDeclaration::Custom(_, ref value) => {
+            !matches!(value.borrow(), DeclaredValue::CSSWideKeyword(..))
+          }
           _ => false,
       }
     }
 
     /// The shorthands that this longhand is part of.
     pub fn shorthands(&self) -> &'static [ShorthandId] {
         // first generate longhand to shorthands lookup map
         <%
--- a/servo/tests/unit/style/properties/serialization.rs
+++ b/servo/tests/unit/style/properties/serialization.rs
@@ -1125,9 +1125,30 @@ mod shorthand_serialization {
                               transition-timing-function: cubic-bezier(0.2, 5, 0.5, 2), ease;";
             let block = parse_declaration_block(block_text);
 
             let serialization = block.to_css_string();
 
             assert_eq!(serialization, block_text);
         }
     }
+
+    mod keywords {
+        pub use super::*;
+        #[test]
+        fn css_wide_keywords_should_be_parsed() {
+            let block_text = "--a:inherit;";
+            let block = parse_declaration_block(block_text);
+
+            let serialization = block.to_css_string();
+            assert_eq!(serialization, "--a: inherit;");
+        }
+
+        #[test]
+        fn non_keyword_custom_property_should_be_unparsed() {
+            let block_text = "--main-color: #06c;";
+            let block = parse_declaration_block(block_text);
+
+            let serialization = block.to_css_string();
+            assert_eq!(serialization, block_text);
+        }
+    }
 }