Create a generic flag system for properties

This commit is contained in:
Nazım Can Altınova 2017-04-01 01:57:47 +03:00
parent 355d5f89da
commit 67799f9445
No known key found for this signature in database
GPG key ID: AF9BCD7CE6449954
6 changed files with 36 additions and 35 deletions

View file

@ -469,13 +469,13 @@ bitflags! {
/// A set of flags for properties.
pub flags PropertyFlags: u8 {
/// This property requires a stacking context.
const CREATES_STACKING_CONTEXT = 0x01,
const CREATES_STACKING_CONTEXT = 1 << 0,
/// This property has values that can establish a containing block for
/// fixed positioned and absolutely positioned elements.
const FIXPOS_CB = 0x02,
const FIXPOS_CB = 1 << 1,
/// This property has values that can establish a containing block for
/// absolutely positioned elements.
const ABSPOS_CB = 0x04,
const ABSPOS_CB = 1 << 2,
}
}
@ -518,20 +518,14 @@ impl LonghandId {
}
}
/// Returns PropertyFlags for given property.
/// Returns PropertyFlags for given longhand property.
pub fn flags(&self) -> PropertyFlags {
match *self {
% for property in data.longhands:
LonghandId::${property.camel_case} =>
%if property.creates_stacking_context:
CREATES_STACKING_CONTEXT |
%endif
%if property.fixpos_cb:
FIXPOS_CB |
%endif
%if property.abspos_cb:
ABSPOS_CB |
%endif
% for flag in property.flags:
${flag} |
% endfor
PropertyFlags::empty(),
% endfor
}
@ -658,6 +652,19 @@ impl ShorthandId {
None
}
/// Returns PropertyFlags for given shorthand property.
pub fn flags(&self) -> PropertyFlags {
match *self {
% for property in data.shorthands:
ShorthandId::${property.camel_case} =>
% for flag in property.flags:
${flag} |
% endfor
PropertyFlags::empty(),
% endfor
}
}
}
/// Servo's representation of a declared value for a given `T`, which is the