mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Support width and height in geckolib.
This commit is contained in:
parent
580f58c146
commit
8d6a99b46e
1 changed files with 30 additions and 19 deletions
|
@ -267,7 +267,7 @@ def set_gecko_property(ffi_name, expr):
|
|||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="impl_style_coord(ident, unit_ffi_name, union_ffi_name)">
|
||||
<%def name="impl_split_style_coord(ident, unit_ffi_name, union_ffi_name)">
|
||||
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
v.to_gecko_style_coord(&mut self.gecko.${unit_ffi_name},
|
||||
&mut self.gecko.${union_ffi_name});
|
||||
|
@ -281,6 +281,10 @@ def set_gecko_property(ffi_name, expr):
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_style_coord(ident, gecko_ffi_name)">
|
||||
<%call expr="impl_split_style_coord(ident, '%s.mUnit' % gecko_ffi_name, '%s.mValue' % gecko_ffi_name)"></%call>
|
||||
</%def>
|
||||
|
||||
<%def name="impl_style_struct(style_struct)">
|
||||
impl ${style_struct.gecko_struct_name} {
|
||||
#[allow(dead_code, unused_variables)]
|
||||
|
@ -354,14 +358,17 @@ impl Debug for ${style_struct.gecko_ffi_name} {
|
|||
# These are booleans.
|
||||
force_stub += ["page-break-after", "page-break-before"]
|
||||
|
||||
simple_types = ["Number", "Opacity"]
|
||||
# Types used with predefined_type()-defined properties that we can auto-generate.
|
||||
predefined_types = {
|
||||
"LengthOrPercentageOrAuto": impl_style_coord,
|
||||
"Number": impl_simple,
|
||||
"Opacity": impl_simple,
|
||||
}
|
||||
|
||||
keyword_longhands = [x for x in longhands if x.keyword and not x.name in force_stub]
|
||||
simple_longhands = [x for x in longhands
|
||||
if x.predefined_type in simple_types and not x.name in force_stub]
|
||||
|
||||
autogenerated_longhands = keyword_longhands + simple_longhands
|
||||
stub_longhands = [x for x in longhands if x not in autogenerated_longhands]
|
||||
predefined_longhands = [x for x in longhands
|
||||
if x.predefined_type in predefined_types and not x.name in force_stub]
|
||||
stub_longhands = [x for x in longhands if x not in keyword_longhands + predefined_longhands]
|
||||
%>
|
||||
impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
||||
/*
|
||||
|
@ -372,12 +379,13 @@ impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
|||
/*
|
||||
* Auto-Generated Methods.
|
||||
*/
|
||||
% for longhand in keyword_longhands:
|
||||
<%call expr="impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)"></%call>
|
||||
% endfor
|
||||
% for longhand in simple_longhands:
|
||||
<%call expr="impl_simple(longhand.ident, longhand.gecko_ffi_name)"></%call>
|
||||
% endfor
|
||||
<%
|
||||
for longhand in keyword_longhands:
|
||||
impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)
|
||||
for longhand in predefined_longhands:
|
||||
impl_fn = predefined_types[longhand.predefined_type]
|
||||
impl_fn(longhand.ident, longhand.gecko_ffi_name)
|
||||
%>
|
||||
|
||||
/*
|
||||
* Stubs.
|
||||
|
@ -461,8 +469,9 @@ fn static_assert() {
|
|||
skip_longhands="${skip_margin_longhands}">
|
||||
|
||||
% for side in SIDES:
|
||||
<% impl_style_coord("margin_%s" % side.ident,
|
||||
"mMargin.mUnits[%s]" % side.index, "mMargin.mValues[%s]" % side.index) %>
|
||||
<% impl_split_style_coord("margin_%s" % side.ident,
|
||||
"mMargin.mUnits[%s]" % side.index,
|
||||
"mMargin.mValues[%s]" % side.index) %>
|
||||
% endfor
|
||||
</%self:impl_trait>
|
||||
|
||||
|
@ -471,8 +480,9 @@ fn static_assert() {
|
|||
skip_longhands="${skip_padding_longhands}">
|
||||
|
||||
% for side in SIDES:
|
||||
<% impl_style_coord("padding_%s" % side.ident,
|
||||
"mPadding.mUnits[%s]" % side.index, "mPadding.mValues[%s]" % side.index) %>
|
||||
<% impl_split_style_coord("padding_%s" % side.ident,
|
||||
"mPadding.mUnits[%s]" % side.index,
|
||||
"mPadding.mValues[%s]" % side.index) %>
|
||||
% endfor
|
||||
</%self:impl_trait>
|
||||
|
||||
|
@ -481,8 +491,9 @@ fn static_assert() {
|
|||
skip_longhands="${skip_position_longhands}">
|
||||
|
||||
% for side in SIDES:
|
||||
<% impl_style_coord("%s" % side.ident,
|
||||
"mOffset.mUnits[%s]" % side.index, "mOffset.mValues[%s]" % side.index) %>
|
||||
<% impl_split_style_coord("%s" % side.ident,
|
||||
"mOffset.mUnits[%s]" % side.index,
|
||||
"mOffset.mValues[%s]" % side.index) %>
|
||||
% endfor
|
||||
</%self:impl_trait>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue