mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Make nscssproperty a method of longhand/shorthand/alias class.
This commit is contained in:
parent
2aee174b6d
commit
1599357cff
4 changed files with 22 additions and 30 deletions
|
@ -299,6 +299,12 @@ class Longhand(object):
|
||||||
return computed
|
return computed
|
||||||
return "<{} as ToAnimatedValue>::AnimatedValue".format(computed)
|
return "<{} as ToAnimatedValue>::AnimatedValue".format(computed)
|
||||||
|
|
||||||
|
def nscsspropertyid(self):
|
||||||
|
ident = self.ident
|
||||||
|
if ident == "float":
|
||||||
|
ident = "float_"
|
||||||
|
return "nsCSSPropertyID::eCSSProperty_%s" % ident
|
||||||
|
|
||||||
|
|
||||||
class Shorthand(object):
|
class Shorthand(object):
|
||||||
def __init__(self, name, sub_properties, spec=None, servo_pref=None, gecko_pref=None,
|
def __init__(self, name, sub_properties, spec=None, servo_pref=None, gecko_pref=None,
|
||||||
|
@ -362,6 +368,9 @@ class Shorthand(object):
|
||||||
def enabled_in_content(self):
|
def enabled_in_content(self):
|
||||||
return self.enabled_in == "content"
|
return self.enabled_in == "content"
|
||||||
|
|
||||||
|
def nscsspropertyid(self):
|
||||||
|
return "nsCSSPropertyID::eCSSProperty_%s" % self.ident
|
||||||
|
|
||||||
|
|
||||||
class Alias(object):
|
class Alias(object):
|
||||||
def __init__(self, name, original):
|
def __init__(self, name, original):
|
||||||
|
@ -388,6 +397,9 @@ class Alias(object):
|
||||||
def enabled_in_content(self):
|
def enabled_in_content(self):
|
||||||
return self.enabled_in == "content"
|
return self.enabled_in == "content"
|
||||||
|
|
||||||
|
def nscsspropertyid(self):
|
||||||
|
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % self.camel_case
|
||||||
|
|
||||||
|
|
||||||
class Method(object):
|
class Method(object):
|
||||||
def __init__(self, name, return_type=None, arg_types=None, is_mut=False):
|
def __init__(self, name, return_type=None, arg_types=None, is_mut=False):
|
||||||
|
|
|
@ -872,17 +872,3 @@
|
||||||
</%self:logical_setter_helper>
|
</%self:logical_setter_helper>
|
||||||
}
|
}
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
<%def name="alias_to_nscsspropertyid(alias)">
|
|
||||||
<%
|
|
||||||
return "nsCSSPropertyID::eCSSPropertyAlias_%s" % to_camel_case(alias)
|
|
||||||
%>
|
|
||||||
</%def>
|
|
||||||
|
|
||||||
<%def name="to_nscsspropertyid(ident)">
|
|
||||||
<%
|
|
||||||
if ident == "float":
|
|
||||||
ident = "float_"
|
|
||||||
return "nsCSSPropertyID::eCSSProperty_%s" % ident
|
|
||||||
%>
|
|
||||||
</%def>
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ pub fn nscsspropertyid_is_animatable(property: nsCSSPropertyID) -> bool {
|
||||||
match property {
|
match property {
|
||||||
% for prop in data.longhands + data.shorthands_except_all():
|
% for prop in data.longhands + data.shorthands_except_all():
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
${helpers.to_nscsspropertyid(prop.ident)} => true,
|
${prop.nscsspropertyid()} => true,
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -154,12 +154,12 @@ impl From<nsCSSPropertyID> for TransitionProperty {
|
||||||
fn from(property: nsCSSPropertyID) -> TransitionProperty {
|
fn from(property: nsCSSPropertyID) -> TransitionProperty {
|
||||||
match property {
|
match property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
${helpers.to_nscsspropertyid(prop.ident)} => {
|
${prop.nscsspropertyid()} => {
|
||||||
TransitionProperty::Longhand(LonghandId::${prop.camel_case})
|
TransitionProperty::Longhand(LonghandId::${prop.camel_case})
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
% for prop in data.shorthands_except_all():
|
% for prop in data.shorthands_except_all():
|
||||||
${helpers.to_nscsspropertyid(prop.ident)} => {
|
${prop.nscsspropertyid()} => {
|
||||||
TransitionProperty::Shorthand(ShorthandId::${prop.camel_case})
|
TransitionProperty::Shorthand(ShorthandId::${prop.camel_case})
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -179,7 +179,7 @@ pub fn nscsspropertyid_is_transitionable(property: nsCSSPropertyID) -> bool {
|
||||||
match property {
|
match property {
|
||||||
% for prop in data.longhands + data.shorthands_except_all():
|
% for prop in data.longhands + data.shorthands_except_all():
|
||||||
% if prop.transitionable:
|
% if prop.transitionable:
|
||||||
${helpers.to_nscsspropertyid(prop.ident)} => true,
|
${prop.nscsspropertyid()} => true,
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
_ => false
|
_ => false
|
||||||
|
|
|
@ -424,14 +424,8 @@ impl NonCustomPropertyId {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
fn to_nscsspropertyid(self) -> nsCSSPropertyID {
|
fn to_nscsspropertyid(self) -> nsCSSPropertyID {
|
||||||
static MAP: [nsCSSPropertyID; ${len(data.longhands) + len(data.shorthands) + len(data.all_aliases())}] = [
|
static MAP: [nsCSSPropertyID; ${len(data.longhands) + len(data.shorthands) + len(data.all_aliases())}] = [
|
||||||
% for property in data.longhands:
|
% for property in data.longhands + data.shorthands + data.all_aliases():
|
||||||
${helpers.to_nscsspropertyid(property.ident)},
|
${property.nscsspropertyid()},
|
||||||
% endfor
|
|
||||||
% for property in data.shorthands:
|
|
||||||
${helpers.to_nscsspropertyid(property.ident)},
|
|
||||||
% endfor
|
|
||||||
% for property in data.all_aliases():
|
|
||||||
${helpers.alias_to_nscsspropertyid(property.ident)},
|
|
||||||
% endfor
|
% endfor
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -1617,11 +1611,11 @@ impl PropertyId {
|
||||||
use gecko_bindings::structs::*;
|
use gecko_bindings::structs::*;
|
||||||
match id {
|
match id {
|
||||||
% for property in data.longhands:
|
% for property in data.longhands:
|
||||||
${helpers.to_nscsspropertyid(property.ident)} => {
|
${property.nscsspropertyid()} => {
|
||||||
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
Ok(PropertyId::Longhand(LonghandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% for alias in property.alias:
|
% for alias in property.alias:
|
||||||
${helpers.alias_to_nscsspropertyid(alias.name)} => {
|
${alias.nscsspropertyid()} => {
|
||||||
Ok(PropertyId::LonghandAlias(
|
Ok(PropertyId::LonghandAlias(
|
||||||
LonghandId::${property.camel_case},
|
LonghandId::${property.camel_case},
|
||||||
AliasId::${alias.camel_case}
|
AliasId::${alias.camel_case}
|
||||||
|
@ -1630,11 +1624,11 @@ impl PropertyId {
|
||||||
% endfor
|
% endfor
|
||||||
% endfor
|
% endfor
|
||||||
% for property in data.shorthands:
|
% for property in data.shorthands:
|
||||||
${helpers.to_nscsspropertyid(property.ident)} => {
|
${property.nscsspropertyid()} => {
|
||||||
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
Ok(PropertyId::Shorthand(ShorthandId::${property.camel_case}))
|
||||||
}
|
}
|
||||||
% for alias in property.alias:
|
% for alias in property.alias:
|
||||||
${helpers.alias_to_nscsspropertyid(alias.name)} => {
|
${alias.nscsspropertyid()} => {
|
||||||
Ok(PropertyId::ShorthandAlias(
|
Ok(PropertyId::ShorthandAlias(
|
||||||
ShorthandId::${property.camel_case},
|
ShorthandId::${property.camel_case},
|
||||||
AliasId::${alias.camel_case}
|
AliasId::${alias.camel_case}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue