Bug 1519847 - [css-logical] Implement the padding-block/inline shorthands. r=emilio
authorMats Palmgren <mats@mozilla.com>
Mon, 14 Jan 2019 19:22:03 +0100
changeset 453847 c15d04c80f5b966cd0cb5bee952eb28b7c96d9ee
parent 453846 c5f982e028923c2465f2d47303a9e9769912ea77
child 453848 43022e5e375774afce6db2316028e16bb09a9ec9
push id76039
push usercbrindusan@mozilla.com
push dateMon, 14 Jan 2019 21:54:07 +0000
treeherderautoland@7f08c65a8bd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1519847
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 1519847 - [css-logical] Implement the padding-block/inline shorthands. r=emilio
devtools/shared/css/generated/properties-db.js
layout/style/test/property_database.js
servo/components/style/properties/shorthands/padding.mako.rs
testing/web-platform/meta/css/css-logical/logical-box-padding.html.ini
--- a/devtools/shared/css/generated/properties-db.js
+++ b/devtools/shared/css/generated/properties-db.js
@@ -7763,16 +7763,29 @@ exports.CSS_PROPERTIES = {
     ],
     "supports": [],
     "values": [
       "inherit",
       "initial",
       "unset"
     ]
   },
+  "padding-block": {
+    "isInherited": false,
+    "subproperties": [
+      "padding-block-start",
+      "padding-block-end"
+    ],
+    "supports": [],
+    "values": [
+      "inherit",
+      "initial",
+      "unset"
+    ]
+  },
   "padding-block-end": {
     "isInherited": false,
     "subproperties": [
       "padding-block-end"
     ],
     "supports": [],
     "values": [
       "inherit",
@@ -7799,16 +7812,29 @@ exports.CSS_PROPERTIES = {
     ],
     "supports": [],
     "values": [
       "inherit",
       "initial",
       "unset"
     ]
   },
+  "padding-inline": {
+    "isInherited": false,
+    "subproperties": [
+      "padding-inline-start",
+      "padding-inline-end"
+    ],
+    "supports": [],
+    "values": [
+      "inherit",
+      "initial",
+      "unset"
+    ]
+  },
   "padding-inline-end": {
     "isInherited": false,
     "subproperties": [
       "padding-inline-end"
     ],
     "supports": [],
     "values": [
       "inherit",
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -4265,16 +4265,36 @@ var gCSSProperties = {
     type: CSS_TYPE_TRUE_SHORTHAND,
     subproperties: [ "padding-top", "padding-right", "padding-bottom", "padding-left" ],
     initial_values: [ "0", "0px 0 0em", "0% 0px 0em 0pt", "calc(0px) calc(0em) calc(-2px) calc(-1%)" ],
     other_values: [ "3px 0", "2em 4px 2pt", "1em 2em 3px 4px" ],
     invalid_values: [ "1px calc(nonsense)", "1px red", "-1px" ],
     unbalanced_values: [ "1px calc(" ],
     quirks_values: { "5": "5px", "3px 6px 2 5px": "3px 6px 2px 5px" },
   },
+  "padding-block": {
+    domProp: "paddingBlock",
+    inherited: false,
+    type: CSS_TYPE_TRUE_SHORTHAND,
+    subproperties: [ "padding-block-start", "padding-block-end" ],
+    initial_values: [ "0", "0px 0em" ],
+    other_values: [ "3px 0", "2% 4px", "1em", "calc(1px) calc(-1%)" ],
+    invalid_values: [ "1px calc(nonsense)", "1px red", "-1px", "auto", "none" ],
+    unbalanced_values: [ "1px calc(" ],
+  },
+  "padding-inline": {
+    domProp: "paddingInline",
+    inherited: false,
+    type: CSS_TYPE_TRUE_SHORTHAND,
+    subproperties: [ "padding-inline-start", "padding-inline-end" ],
+    initial_values: [ "0", "0px 0em" ],
+    other_values: [ "3px 0", "2% 4px", "1em", "calc(1px) calc(-1%)" ],
+    invalid_values: [ "1px calc(nonsense)", "1px red", "-1px", "auto", "none" ],
+    unbalanced_values: [ "1px calc(" ],
+  },
   "padding-bottom": {
     domProp: "paddingBottom",
     inherited: false,
     type: CSS_TYPE_LONGHAND,
     applies_to_first_letter: true,
     // No applies_to_placeholder because we have a !important rule in forms.css.
     initial_values: [ "0", "0px", "0%", "calc(0pt)", "calc(0% + 0px)", "calc(-3px)", "calc(-1%)" ],
     other_values: [ "1px", "2em", "5%",
--- a/servo/components/style/properties/shorthands/padding.mako.rs
+++ b/servo/components/style/properties/shorthands/padding.mako.rs
@@ -2,8 +2,51 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
 <%namespace name="helpers" file="/helpers.mako.rs" />
 
 ${helpers.four_sides_shorthand("padding", "padding-%s", "specified::NonNegativeLengthPercentage::parse",
                                spec="https://drafts.csswg.org/css-box-3/#propdef-padding",
                                allow_quirks=True)}
+
+% for axis in ["block", "inline"]:
+    <%
+        spec = "https://drafts.csswg.org/css-logical/#propdef-padding-%s" % axis
+    %>
+    <%helpers:shorthand
+        name="padding-${axis}"
+        sub_properties="${' '.join(
+            'padding-%s-%s' % (axis, side)
+            for side in ['start', 'end']
+        )}"
+        spec="${spec}">
+
+        use crate::parser::Parse;
+        use crate::values::specified::length::NonNegativeLengthPercentage;
+        pub fn parse_value<'i, 't>(
+            context: &ParserContext,
+            input: &mut Parser<'i, 't>,
+        ) -> Result<Longhands, ParseError<'i>> {
+            let start_value = NonNegativeLengthPercentage::parse(context, input)?;
+            let end_value =
+                input.try(|input| NonNegativeLengthPercentage::parse(context, input)).unwrap_or_else(|_| start_value.clone());
+
+            Ok(expanded! {
+                padding_${axis}_start: start_value,
+                padding_${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.padding_${axis}_start.to_css(dest)?;
+
+                if self.padding_${axis}_end != self.padding_${axis}_start {
+                    dest.write_str(" ")?;
+                    self.padding_${axis}_end.to_css(dest)?;
+                }
+
+                Ok(())
+            }
+        }
+    </%helpers:shorthand>
+% endfor
--- a/testing/web-platform/meta/css/css-logical/logical-box-padding.html.ini
+++ b/testing/web-platform/meta/css/css-logical/logical-box-padding.html.ini
@@ -1,40 +1,13 @@
 [logical-box-padding.html]
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: horizontal-tb; direction: ltr; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: horizontal-tb; direction: rtl; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: vertical-rl; direction: rtl; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: sideways-rl; direction: rtl; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: vertical-rl; direction: ltr; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: sideways-rl; direction: ltr; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: vertical-lr; direction: rtl; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: sideways-lr; direction: ltr; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: vertical-lr; direction: ltr; '.]
-    expected: FAIL
-
-  [Test that padding-* shorthands set the computed value of both logical and physical longhands, with 'writing-mode: sideways-lr; direction: rtl; '.]
-    expected: FAIL
-
   [Test that padding shorthand sets longhands and serializes correctly.]
     expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=137688
 
   [Test that padding-inline shorthand sets longhands and serializes correctly.]
     expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=137688
 
   [Test that padding-block shorthand sets longhands and serializes correctly.]
     expected: FAIL
+    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=137688