Bug 775618 - Introduce the concept of legacy shorthands. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 20 Nov 2018 04:39:36 +0000
changeset 505368 f97f45821194fd28be1282d3a854ed129498d187
parent 505367 c228095e647e155d3638a667341f867774c07a81
child 505369 b4c0c0fecdba68979d41609d3978fe596078d0cd
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs775618
milestone65.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 775618 - Introduce the concept of legacy shorthands. r=heycam We need this because there's a weird mapping between these properties' values ('always' maps to 'page'). See https://drafts.csswg.org/css-cascade-4/#legacy-shorthand. Differential Revision: https://phabricator.services.mozilla.com/D12213
servo/components/style/properties/declaration_block.rs
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/properties/declaration_block.rs
+++ b/servo/components/style/properties/declaration_block.rs
@@ -912,16 +912,20 @@ impl PropertyDeclarationBlock {
             // Step 3.3.2
             for shorthand in longhand_id.shorthands() {
                 // We already attempted to serialize this shorthand before.
                 if already_serialized.contains(shorthand.into()) {
                     continue;
                 }
                 already_serialized.insert(shorthand.into());
 
+                if shorthand.is_legacy_shorthand() {
+                    continue;
+                }
+
                 // Substep 2 & 3
                 let mut current_longhands = SmallVec::<[_; 10]>::new();
                 let mut important_count = 0;
                 let mut found_system = None;
 
                 let is_system_font =
                     shorthand == ShorthandId::Font &&
                     self.declarations.iter().any(|l| {
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -943,16 +943,20 @@ bitflags! {
         const APPLIES_TO_FIRST_LETTER = 1 << 3;
         /// This longhand property applies to ::first-line.
         const APPLIES_TO_FIRST_LINE = 1 << 4;
         /// This longhand property applies to ::placeholder.
         const APPLIES_TO_PLACEHOLDER = 1 << 5;
         /// This property's getComputedStyle implementation requires layout
         /// to be flushed.
         const GETCS_NEEDS_LAYOUT_FLUSH = 1 << 6;
+        /// This property is a legacy shorthand.
+        ///
+        /// https://drafts.csswg.org/css-cascade/#legacy-shorthand
+        const IS_LEGACY_SHORTHAND = 1 << 7;
 
         /* The following flags are currently not used in Rust code, they
          * only need to be listed in corresponding properties so that
          * they can be checked in the C++ side via ServoCSSPropList.h. */
         /// This property can be animated on the compositor.
         const CAN_ANIMATE_ON_COMPOSITOR = 0;
         /// This shorthand property is accessible from getComputedStyle.
         const SHORTHAND_IN_GETCS = 0;
@@ -1456,27 +1460,34 @@ impl ShorthandId {
         // Check whether all declarations can be serialized as part of shorthand.
         if declarations3.all(|d| d.may_serialize_as_part_of_shorthand()) {
             return Some(AppendableValue::DeclarationsForShorthand(self, declarations));
         }
 
         None
     }
 
-    /// Returns PropertyFlags for given shorthand property.
-    pub fn flags(&self) -> PropertyFlags {
-        match *self {
+    /// Returns PropertyFlags for the given shorthand property.
+    #[inline]
+    pub fn flags(self) -> PropertyFlags {
+        const FLAGS: [u8; ${len(data.shorthands)}] = [
             % for property in data.shorthands:
-                ShorthandId::${property.camel_case} =>
-                    % for flag in property.flags:
-                        PropertyFlags::${flag} |
-                    % endfor
-                    PropertyFlags::empty(),
+                % for flag in property.flags:
+                    PropertyFlags::${flag}.bits |
+                % endfor
+                0,
             % endfor
-        }
+        ];
+        PropertyFlags::from_bits_truncate(FLAGS[self as usize])
+    }
+
+    /// Returns whether this property is a legacy shorthand.
+    #[inline]
+    pub fn is_legacy_shorthand(self) -> bool {
+        self.flags().contains(PropertyFlags::IS_LEGACY_SHORTHAND)
     }
 
     /// Returns the order in which this property appears relative to other
     /// shorthands in idl-name-sorting order.
     #[inline]
     pub fn idl_name_sort_order(self) -> u32 {
         <%
             from data import to_idl_name