servo: Merge #15808 - Add remaining keyword values of -moz-user-select (fixes #15197) (from servo:moz-user-select); r=nox,SimonSapin
authorKaran Singh <singhkaran@github.com>
Fri, 03 Mar 2017 08:17:44 -0800
changeset 345866 2ae0da5b22c63f1d1fea0c6d97262d99fe854ad8
parent 345865 55d9a513c90e37af3d2fe22de2f01c1797f97b35
child 345867 4b805bbd9a83d0b3861b55a972c2759e0ceb7a67
push id31451
push usercbook@mozilla.com
push dateMon, 06 Mar 2017 09:52:09 +0000
treeherdermozilla-central@7099e03837e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox, SimonSapin
milestone54.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 #15808 - Add remaining keyword values of -moz-user-select (fixes #15197) (from servo:moz-user-select); r=nox,SimonSapin Source-Repo: https://github.com/servo/servo Source-Revision: 1842b2e25e2ade4c6ec47df871b7e73c3235add7
servo/components/style/properties/data.py
servo/components/style/properties/longhand/ui.mako.rs
servo/tests/unit/style/parsing/mod.rs
servo/tests/unit/style/parsing/ui.rs
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -65,17 +65,17 @@ class Keyword(object):
             return self.servo_values()
         else:
             raise Exception("Bad product: " + product)
 
     def gecko_constant(self, value):
         moz_stripped = value.replace("-moz-", '') if self.gecko_strip_moz_prefix else value.replace("-moz-", 'moz-')
         mapped = self.consts_map.get(value)
         if self.gecko_enum_prefix:
-            parts = moz_stripped.split('-')
+            parts = moz_stripped.replace('-', '_').split('_')
             parts = mapped if mapped else [p.title() for p in parts]
             return self.gecko_enum_prefix + "::" + "".join(parts)
         else:
             suffix = mapped if mapped else moz_stripped.replace("-", "_")
             return self.gecko_constant_prefix + "_" + suffix.upper()
 
     def needs_cast(self):
         return self.gecko_enum_prefix is None
--- a/servo/components/style/properties/longhand/ui.mako.rs
+++ b/servo/components/style/properties/longhand/ui.mako.rs
@@ -11,21 +11,22 @@
 
 // TODO spec says that UAs should not support this
 // we should probably remove from gecko (https://bugzilla.mozilla.org/show_bug.cgi?id=1328331)
 ${helpers.single_keyword("ime-mode", "normal auto active disabled inactive",
                          products="gecko", gecko_ffi_name="mIMEMode",
                          animatable=False,
                          spec="https://drafts.csswg.org/css-ui/#input-method-editor")}
 
-${helpers.single_keyword("-moz-user-select", "auto text none all", products="gecko",
+${helpers.single_keyword("-moz-user-select", "auto text none all element elements" +
+                            " toggle tri_state -moz-all -moz-none -moz-text",
+                         products="gecko",
                          alias="-webkit-user-select",
                          gecko_ffi_name="mUserSelect",
                          gecko_enum_prefix="StyleUserSelect",
-                         gecko_inexhaustive=True,
                          animatable=False,
                          spec="https://drafts.csswg.org/css-ui-4/#propdef-user-select")}
 
 ${helpers.single_keyword("-moz-window-dragging", "default drag no-drag", products="gecko",
                          gecko_ffi_name="mWindowDragging",
                          gecko_enum_prefix="StyleWindowDragging",
                          animatable=False,
                          spec="None (Nonstandard Firefox-only property)")}
--- a/servo/tests/unit/style/parsing/mod.rs
+++ b/servo/tests/unit/style/parsing/mod.rs
@@ -89,8 +89,9 @@ mod inherited_box;
 mod inherited_text;
 mod mask;
 mod outline;
 mod position;
 mod selectors;
 mod supports;
 mod text_overflow;
 mod transition_timing_function;
+mod ui;
new file mode 100644
--- /dev/null
+++ b/servo/tests/unit/style/parsing/ui.rs
@@ -0,0 +1,32 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use cssparser::Parser;
+use media_queries::CSSErrorReporterTest;
+use servo_url::ServoUrl;
+use style::parser::ParserContext;
+use style::stylesheets::Origin;
+use style_traits::ToCss;
+
+#[test]
+fn test_moz_user_select() {
+    use style::properties::longhands::_moz_user_select;
+
+    assert_roundtrip_with_context!(_moz_user_select::parse, "auto");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "text");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "none");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "element");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "elements");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "toggle");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "tri_state");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "-moz-all");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "-moz-none");
+    assert_roundtrip_with_context!(_moz_user_select::parse, "-moz-text");
+
+    let url = ServoUrl::parse("http://localhost").unwrap();
+    let context = ParserContext::new(Origin::Author, &url, Box::new(CSSErrorReporterTest));
+
+    let mut negative = Parser::new("potato");
+    assert!(_moz_user_select::parse(&context, &mut negative).is_err());
+}