mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +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
|
% endif
|
||||||
</%def>
|
</%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) {
|
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||||
v.to_gecko_style_coord(&mut self.gecko.${unit_ffi_name},
|
v.to_gecko_style_coord(&mut self.gecko.${unit_ffi_name},
|
||||||
&mut self.gecko.${union_ffi_name});
|
&mut self.gecko.${union_ffi_name});
|
||||||
|
@ -281,6 +281,10 @@ def set_gecko_property(ffi_name, expr):
|
||||||
}
|
}
|
||||||
</%def>
|
</%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)">
|
<%def name="impl_style_struct(style_struct)">
|
||||||
impl ${style_struct.gecko_struct_name} {
|
impl ${style_struct.gecko_struct_name} {
|
||||||
#[allow(dead_code, unused_variables)]
|
#[allow(dead_code, unused_variables)]
|
||||||
|
@ -354,14 +358,17 @@ impl Debug for ${style_struct.gecko_ffi_name} {
|
||||||
# These are booleans.
|
# These are booleans.
|
||||||
force_stub += ["page-break-after", "page-break-before"]
|
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]
|
keyword_longhands = [x for x in longhands if x.keyword and not x.name in force_stub]
|
||||||
simple_longhands = [x for x in longhands
|
predefined_longhands = [x for x in longhands
|
||||||
if x.predefined_type in simple_types and not x.name in force_stub]
|
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]
|
||||||
autogenerated_longhands = keyword_longhands + simple_longhands
|
|
||||||
stub_longhands = [x for x in longhands if x not in autogenerated_longhands]
|
|
||||||
%>
|
%>
|
||||||
impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
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.
|
* Auto-Generated Methods.
|
||||||
*/
|
*/
|
||||||
% for longhand in keyword_longhands:
|
<%
|
||||||
<%call expr="impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)"></%call>
|
for longhand in keyword_longhands:
|
||||||
% endfor
|
impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone)
|
||||||
% for longhand in simple_longhands:
|
for longhand in predefined_longhands:
|
||||||
<%call expr="impl_simple(longhand.ident, longhand.gecko_ffi_name)"></%call>
|
impl_fn = predefined_types[longhand.predefined_type]
|
||||||
% endfor
|
impl_fn(longhand.ident, longhand.gecko_ffi_name)
|
||||||
|
%>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stubs.
|
* Stubs.
|
||||||
|
@ -461,8 +469,9 @@ fn static_assert() {
|
||||||
skip_longhands="${skip_margin_longhands}">
|
skip_longhands="${skip_margin_longhands}">
|
||||||
|
|
||||||
% for side in SIDES:
|
% for side in SIDES:
|
||||||
<% impl_style_coord("margin_%s" % side.ident,
|
<% impl_split_style_coord("margin_%s" % side.ident,
|
||||||
"mMargin.mUnits[%s]" % side.index, "mMargin.mValues[%s]" % side.index) %>
|
"mMargin.mUnits[%s]" % side.index,
|
||||||
|
"mMargin.mValues[%s]" % side.index) %>
|
||||||
% endfor
|
% endfor
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
@ -471,8 +480,9 @@ fn static_assert() {
|
||||||
skip_longhands="${skip_padding_longhands}">
|
skip_longhands="${skip_padding_longhands}">
|
||||||
|
|
||||||
% for side in SIDES:
|
% for side in SIDES:
|
||||||
<% impl_style_coord("padding_%s" % side.ident,
|
<% impl_split_style_coord("padding_%s" % side.ident,
|
||||||
"mPadding.mUnits[%s]" % side.index, "mPadding.mValues[%s]" % side.index) %>
|
"mPadding.mUnits[%s]" % side.index,
|
||||||
|
"mPadding.mValues[%s]" % side.index) %>
|
||||||
% endfor
|
% endfor
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
@ -481,8 +491,9 @@ fn static_assert() {
|
||||||
skip_longhands="${skip_position_longhands}">
|
skip_longhands="${skip_position_longhands}">
|
||||||
|
|
||||||
% for side in SIDES:
|
% for side in SIDES:
|
||||||
<% impl_style_coord("%s" % side.ident,
|
<% impl_split_style_coord("%s" % side.ident,
|
||||||
"mOffset.mUnits[%s]" % side.index, "mOffset.mValues[%s]" % side.index) %>
|
"mOffset.mUnits[%s]" % side.index,
|
||||||
|
"mOffset.mValues[%s]" % side.index) %>
|
||||||
% endfor
|
% endfor
|
||||||
</%self:impl_trait>
|
</%self:impl_trait>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue