Bug 1410028: Ensure logical longhands appear before their physical counter-part. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 23 Oct 2017 07:00:57 +0200
changeset 684587 0a7906e773f22628c9810392f8c25e0eecaeea3c
parent 684431 3a41ce3212450f28c95b0d76adfc3c5bc4bac529
child 736902 7909c294241425ee457fb69ba853223901eefb93
push id85657
push userbmo:emilio@crisal.io
push dateMon, 23 Oct 2017 06:17:15 +0000
reviewersxidorn
bugs1410028
milestone58.0a1
Bug 1410028: Ensure logical longhands appear before their physical counter-part. r?xidorn MozReview-Commit-ID: KPIbt1e2Eq
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -168,21 +168,47 @@ pub mod shorthands {
     <%include file="/shorthand/outline.mako.rs" />
     <%include file="/shorthand/padding.mako.rs" />
     <%include file="/shorthand/position.mako.rs" />
     <%include file="/shorthand/inherited_svg.mako.rs" />
     <%include file="/shorthand/text.mako.rs" />
 
     // We don't defined the 'all' shorthand using the regular helpers:shorthand
     // mechanism, since it causes some very large types to be generated.
-    <% data.declare_shorthand("all",
-                              [p.name for p in data.longhands
-                                if p.name not in ['direction', 'unicode-bidi']
-                                      and not p.internal],
-                              spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand") %>
+    //
+    // Also, make sure logical properties appear before its physical
+    // counter-parts, in order to prevent bugs like:
+    //
+    //   https://bugzilla.mozilla.org/show_bug.cgi?id=1410028
+    //
+    // FIXME(emilio): Adopt the resolution from:
+    //
+    //   https://github.com/w3c/csswg-drafts/issues/1898
+    //
+    // when there is one, whatever that is.
+    <%
+        logical_longhands = []
+        other_longhands = []
+
+        for p in data.longhands:
+            if p.name in ['direction', 'unicode-bidi']:
+                continue;
+            if p.internal:
+                continue;
+            if p.logical:
+                logical_longhands.append(p.name)
+            else:
+                other_longhands.append(p.name)
+
+        data.declare_shorthand(
+            "all",
+            logical_longhands + other_longhands,
+            spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand"
+        )
+    %>
 }
 
 /// A module with all the code related to animated properties.
 ///
 /// This needs to be "included" by mako at least after all longhand modules,
 /// given they populate the global data.
 pub mod animated_properties {
     <%include file="/helpers/animated_properties.mako.rs" />