Bug 1520229 - [css-logical] Implement the inset-block/inline shorthands. r=emilio
authorMats Palmgren <mats@mozilla.com>
Wed, 16 Jan 2019 19:26:14 +0100
changeset 514195 30dc251e2657b65838bb037e527c9552b3040a34
parent 514194 cbda9c487dca2695f4cb419ce5b2d3555342602e
child 514196 009cf5f885ba2406585a572c2281791d99a77521
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1520229
milestone66.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
Bug 1520229 - [css-logical] Implement the inset-block/inline shorthands. r=emilio
devtools/shared/css/generated/properties-db.js
layout/style/test/property_database.js
servo/components/style/properties/shorthands/position.mako.rs
--- a/devtools/shared/css/generated/properties-db.js
+++ b/devtools/shared/css/generated/properties-db.js
@@ -6440,16 +6440,30 @@ exports.CSS_PROPERTIES = {
       "auto",
       "inherit",
       "initial",
       "max-content",
       "min-content",
       "unset"
     ]
   },
+  "inset-block": {
+    "isInherited": false,
+    "subproperties": [
+      "inset-block-start",
+      "inset-block-end"
+    ],
+    "supports": [],
+    "values": [
+      "auto",
+      "inherit",
+      "initial",
+      "unset"
+    ]
+  },
   "inset-block-end": {
     "isInherited": false,
     "subproperties": [
       "inset-block-end"
     ],
     "supports": [],
     "values": [
       "auto",
@@ -6466,16 +6480,30 @@ exports.CSS_PROPERTIES = {
     "supports": [],
     "values": [
       "auto",
       "inherit",
       "initial",
       "unset"
     ]
   },
+  "inset-inline": {
+    "isInherited": false,
+    "subproperties": [
+      "inset-inline-start",
+      "inset-inline-end"
+    ],
+    "supports": [],
+    "values": [
+      "auto",
+      "inherit",
+      "initial",
+      "unset"
+    ]
+  },
   "inset-inline-end": {
     "isInherited": false,
     "subproperties": [
       "inset-inline-end"
     ],
     "supports": [],
     "values": [
       "auto",
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -6381,16 +6381,34 @@ var gCSSProperties = {
       "calc(2px)",
       "calc(50%)",
       "calc(3*25px)",
       "calc(25px*3)",
       "calc(3*25px + 50%)",
     ],
     invalid_values: [ "none", "5" ]
   },
+  "inset-block": {
+    domProp: "insetBlock",
+    inherited: false,
+    type: CSS_TYPE_TRUE_SHORTHAND,
+    subproperties: [ "inset-block-start", "inset-block-end" ],
+    /* FIXME: run tests with multiple prerequisites */
+    prerequisites: { "position": "relative" },
+    initial_values: [ "auto", "auto auto" ],
+    other_values: [ "32px", "-3em", "12%", "32px auto", "auto -3em", "12% auto",
+      "calc(2px)", "calc(2px) auto",
+      "calc(-2px)", "auto calc(-2px)",
+      "calc(50%)", "auto calc(50%)",
+      "calc(3*25px)", "calc(3*25px) auto",
+      "calc(25px*3)", "auto calc(25px*3)",
+      "calc(3*25px + 50%)", "auto calc(3*25px + 50%)",
+    ],
+    invalid_values: [ "none" ]
+  },
   "inset-block-end": {
     domProp: "insetBlockEnd",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     logical: true,
     /* FIXME: run tests with multiple prerequisites */
     prerequisites: { "position": "relative" },
     /* XXX 0 may or may not be equal to auto */
@@ -6419,16 +6437,34 @@ var gCSSProperties = {
       "calc(-2px)",
       "calc(50%)",
       "calc(3*25px)",
       "calc(25px*3)",
       "calc(3*25px + 50%)",
     ],
     invalid_values: []
   },
+  "inset-inline": {
+    domProp: "insetInline",
+    inherited: false,
+    type: CSS_TYPE_TRUE_SHORTHAND,
+    subproperties: [ "inset-inline-start", "inset-inline-end" ],
+    /* FIXME: run tests with multiple prerequisites */
+    prerequisites: { "position": "relative" },
+    initial_values: [ "auto", "auto auto" ],
+    other_values: [ "32px", "-3em", "12%", "32px auto", "auto -3em", "12% auto",
+      "calc(2px)", "calc(2px) auto",
+      "calc(-2px)", "auto calc(-2px)",
+      "calc(50%)", "auto calc(50%)",
+      "calc(3*25px)", "calc(3*25px) auto",
+      "calc(25px*3)", "auto calc(25px*3)",
+      "calc(3*25px + 50%)", "auto calc(3*25px + 50%)",
+    ],
+    invalid_values: [ "none" ]
+  },
   "inset-inline-end": {
     domProp: "insetInlineEnd",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     logical: true,
     /* FIXME: run tests with multiple prerequisites */
     prerequisites: { "position": "relative" },
     /* XXX 0 may or may not be equal to auto */
--- a/servo/components/style/properties/shorthands/position.mako.rs
+++ b/servo/components/style/properties/shorthands/position.mako.rs
@@ -757,8 +757,51 @@
                 dest.write_str(" ")?;
                 self.justify_items.to_css(dest)?;
             }
 
             Ok(())
         }
     }
 </%helpers:shorthand>
+
+% for axis in ["block", "inline"]:
+    <%
+        spec = "https://drafts.csswg.org/css-logical/#propdef-inset-%s" % axis
+    %>
+    <%helpers:shorthand
+        name="inset-${axis}"
+        sub_properties="${' '.join(
+            'inset-%s-%s' % (axis, side)
+            for side in ['start', 'end']
+        )}"
+        spec="${spec}">
+
+        use crate::parser::Parse;
+        use crate::values::specified::length::LengthPercentageOrAuto;
+        pub fn parse_value<'i, 't>(
+            context: &ParserContext,
+            input: &mut Parser<'i, 't>,
+        ) -> Result<Longhands, ParseError<'i>> {
+            let start_value = LengthPercentageOrAuto::parse(context, input)?;
+            let end_value =
+                input.try(|input| LengthPercentageOrAuto::parse(context, input)).unwrap_or_else(|_| start_value.clone());
+
+            Ok(expanded! {
+                inset_${axis}_start: start_value,
+                inset_${axis}_end: end_value,
+            })
+        }
+
+        impl<'a> ToCss for LonghandsToSerialize<'a>  {
+            fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
+                self.inset_${axis}_start.to_css(dest)?;
+
+                if self.inset_${axis}_end != self.inset_${axis}_start {
+                    dest.write_str(" ")?;
+                    self.inset_${axis}_end.to_css(dest)?;
+                }
+
+                Ok(())
+            }
+        }
+    </%helpers:shorthand>
+% endfor