mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make font-stretch animatable.
This commit is contained in:
parent
0b3fd8de76
commit
c71abc0c28
4 changed files with 78 additions and 9 deletions
|
@ -274,14 +274,25 @@ def set_gecko_property(ffi_name, expr):
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_keyword_clone(ident, gecko_ffi_name, keyword)">
|
||||
<%def name="impl_keyword_clone(ident, gecko_ffi_name, keyword, cast_type='u8')">
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
use properties::longhands::${ident}::computed_value::T as Keyword;
|
||||
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
|
||||
match ${get_gecko_property(gecko_ffi_name)} ${keyword.maybe_cast("u32")} {
|
||||
|
||||
// Some constant macros in the gecko are defined as negative integer(e.g. font-stretch).
|
||||
// And they are convert to signed integer in Rust bindings. We need to cast then
|
||||
// as signed type when we have both signed/unsigned integer in order to use them
|
||||
// as match's arms.
|
||||
// Also, to use same implementation here we use casted constant if we have only singed values.
|
||||
% for value in keyword.values_for('gecko'):
|
||||
const ${keyword.casted_constant_name(value, cast_type)} : ${cast_type} =
|
||||
structs::${keyword.gecko_constant(value)} as ${cast_type};
|
||||
% endfor
|
||||
|
||||
match ${get_gecko_property(gecko_ffi_name)} as ${cast_type} {
|
||||
% for value in keyword.values_for('gecko'):
|
||||
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)},
|
||||
${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_rust_ident(value)},
|
||||
% endfor
|
||||
% if keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
|
||||
|
@ -334,11 +345,11 @@ fn color_to_nscolor_zero_currentcolor(color: Color) -> structs::nscolor {
|
|||
}
|
||||
</%def>
|
||||
|
||||
<%def name="impl_keyword(ident, gecko_ffi_name, keyword, need_clone, **kwargs)">
|
||||
<%call expr="impl_keyword_setter(ident, gecko_ffi_name, keyword, **kwargs)"></%call>
|
||||
<%def name="impl_keyword(ident, gecko_ffi_name, keyword, need_clone, cast_type='u8', **kwargs)">
|
||||
<%call expr="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type, **kwargs)"></%call>
|
||||
<%call expr="impl_simple_copy(ident, gecko_ffi_name)"></%call>
|
||||
%if need_clone:
|
||||
<%call expr="impl_keyword_clone(ident, gecko_ffi_name, keyword)"></%call>
|
||||
<%call expr="impl_keyword_clone(ident, gecko_ffi_name, keyword, cast_type)"></%call>
|
||||
% endif
|
||||
</%def>
|
||||
|
||||
|
@ -2010,6 +2021,7 @@ fn static_assert() {
|
|||
"-moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck " +
|
||||
"-moz-popup -moz-groupbox",
|
||||
gecko_enum_prefix="StyleDisplay",
|
||||
gecko_inexhaustive="True",
|
||||
gecko_strip_moz_prefix=False) %>
|
||||
|
||||
pub fn set_display(&mut self, v: longhands::display::computed_value::T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue