mirror of
https://github.com/servo/servo.git
synced 2025-08-26 23:58:20 +01:00
Auto merge of #10957 - heycam:number, r=bholley
Support plain number-typed properties in geckolib r? @bholley <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10957) <!-- Reviewable:end -->
This commit is contained in:
commit
ddada69acb
9 changed files with 119 additions and 43 deletions
|
@ -128,6 +128,12 @@ pub struct ${style_struct.gecko_struct_name} {
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_simple_setter(ident, gecko_ffi_name)">
|
||||
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
${set_gecko_property(gecko_ffi_name, "v")}
|
||||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_simple_copy(ident, gecko_ffi_name)">
|
||||
fn copy_${ident}_from(&mut self, other: &Self) {
|
||||
self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name};
|
||||
|
@ -186,6 +192,11 @@ def set_gecko_property(ffi_name, expr):
|
|||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="impl_simple(ident, gecko_ffi_name)">
|
||||
<%call expr="impl_simple_setter(ident, gecko_ffi_name)"></%call>
|
||||
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
|
||||
</%def>
|
||||
|
||||
<%def name="impl_app_units(ident, gecko_ffi_name, need_clone)">
|
||||
fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
self.gecko.${gecko_ffi_name} = v.0;
|
||||
|
@ -284,8 +295,14 @@ impl Debug for ${style_struct.gecko_ffi_name} {
|
|||
# These are booleans.
|
||||
force_stub += ["page-break-after", "page-break-before"]
|
||||
|
||||
simple_types = ["Number", "Opacity"]
|
||||
|
||||
keyword_longhands = [x for x in longhands if x.keyword and not x.name in force_stub]
|
||||
stub_longhands = [x for x in longhands if x not in keyword_longhands]
|
||||
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]
|
||||
%>
|
||||
impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
||||
/*
|
||||
|
@ -299,6 +316,9 @@ impl ${style_struct.trait_name} for ${style_struct.gecko_struct_name} {
|
|||
% 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
|
||||
|
||||
/*
|
||||
* Stubs.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue