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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2018-11-20 04:39:36 +00:00
parent c76f00a8ad
commit cd451a8c96
2 changed files with 24 additions and 9 deletions

View File

@ -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;

View File

@ -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