mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #12599 - Manishearth:sync, r=heycam
Resync stylo bindings Now at gecko-dev 13b9d03a21091cfcd797ab89decec2dde9114781 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/12599) <!-- Reviewable:end -->
This commit is contained in:
commit
d6266c7cee
9 changed files with 118 additions and 107 deletions
|
@ -18,11 +18,15 @@ def to_camel_case(ident):
|
|||
|
||||
class Keyword(object):
|
||||
def __init__(self, name, values, gecko_constant_prefix=None,
|
||||
gecko_enum_prefix=None,
|
||||
extra_gecko_values=None, extra_servo_values=None):
|
||||
self.name = name
|
||||
self.values = values.split()
|
||||
if gecko_constant_prefix and gecko_enum_prefix:
|
||||
raise TypeError("Only one of gecko_constant_prefix and gecko_enum_prefix can be specified")
|
||||
self.gecko_constant_prefix = gecko_constant_prefix or \
|
||||
"NS_STYLE_" + self.name.upper().replace("-", "_")
|
||||
self.gecko_enum_prefix = gecko_enum_prefix
|
||||
self.extra_gecko_values = (extra_gecko_values or "").split()
|
||||
self.extra_servo_values = (extra_servo_values or "").split()
|
||||
|
||||
|
@ -41,7 +45,18 @@ class Keyword(object):
|
|||
raise Exception("Bad product: " + product)
|
||||
|
||||
def gecko_constant(self, value):
|
||||
return self.gecko_constant_prefix + "_" + value.replace("-moz-", "").replace("-", "_").upper()
|
||||
if self.gecko_enum_prefix:
|
||||
if value == "none":
|
||||
return self.gecko_enum_prefix + "::None_"
|
||||
else:
|
||||
parts = value.replace("-moz-", "").split("-")
|
||||
parts = [p.title() for p in parts]
|
||||
return self.gecko_enum_prefix + "::" + "".join(parts)
|
||||
else:
|
||||
return self.gecko_constant_prefix + "_" + value.replace("-moz-", "").replace("-", "_").upper()
|
||||
|
||||
def needs_cast(self):
|
||||
return self.gecko_enum_prefix is None
|
||||
|
||||
|
||||
class Longhand(object):
|
||||
|
|
|
@ -194,7 +194,11 @@ def set_gecko_property(ffi_name, expr):
|
|||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
|
||||
% if keyword.needs_cast():
|
||||
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)} as u8,
|
||||
% else:
|
||||
Keyword::${to_rust_ident(value)} => structs::${keyword.gecko_constant(value)},
|
||||
% endif
|
||||
% endfor
|
||||
};
|
||||
${set_gecko_property(gecko_ffi_name, "result")}
|
||||
|
|
|
@ -289,7 +289,8 @@
|
|||
<%def name="single_keyword_computed(name, values, **kwargs)">
|
||||
<%
|
||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
||||
'gecko_constant_prefix', 'extra_gecko_values', 'extra_servo_values'
|
||||
'gecko_constant_prefix', 'gecko_enum_prefix',
|
||||
'extra_gecko_values', 'extra_servo_values',
|
||||
]}
|
||||
%>
|
||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
||||
|
@ -317,7 +318,8 @@
|
|||
<%def name="keyword_list(name, values, **kwargs)">
|
||||
<%
|
||||
keyword_kwargs = {a: kwargs.pop(a, None) for a in [
|
||||
'gecko_constant_prefix', 'extra_gecko_values', 'extra_servo_values'
|
||||
'gecko_constant_prefix', 'gecko_enum_prefix',
|
||||
'extra_gecko_values', 'extra_servo_values',
|
||||
]}
|
||||
%>
|
||||
<%call expr="longhand(name, keyword=Keyword(name, values, **keyword_kwargs), **kwargs)">
|
||||
|
|
|
@ -82,6 +82,6 @@ ${helpers.single_keyword("box-decoration-break", "slice clone",
|
|||
|
||||
${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
|
||||
gecko_ffi_name="mFloatEdge",
|
||||
gecko_constant_prefix="NS_STYLE_FLOAT_EDGE",
|
||||
gecko_enum_prefix="StyleFloatEdge",
|
||||
products="gecko",
|
||||
animatable=False)}
|
||||
|
|
|
@ -71,5 +71,5 @@ ${helpers.single_keyword("-moz-user-modify", "read-only read-write write-only",
|
|||
${helpers.single_keyword("-moz-user-focus",
|
||||
"ignore normal select-after select-before select-menu select-same select-all none",
|
||||
products="gecko", gecko_ffi_name="mUserFocus",
|
||||
gecko_constant_prefix="NS_STYLE_USER_FOCUS",
|
||||
gecko_enum_prefix="StyleUserFocus",
|
||||
animatable=False)}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue