From a427e4f76308890582fa2d68ab4d77c01ba7af40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 20 Nov 2018 04:39:36 +0000 Subject: [PATCH] style: Introduce the concept of legacy shorthands. 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 --- .../style/properties/declaration_block.rs | 4 +++ .../style/properties/properties.mako.rs | 29 +++++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index fce6faeca77..d7058d99635 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -917,6 +917,10 @@ impl PropertyDeclarationBlock { } 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; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 16fad869427..494bdc7706d 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -948,6 +948,10 @@ bitflags! { /// 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 @@ -1461,17 +1465,24 @@ impl ShorthandId { 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