mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Implements gecko keyword bit type properties animatable
This commit is contained in:
parent
21b7b256c2
commit
f358ec069c
2 changed files with 41 additions and 24 deletions
|
@ -680,17 +680,22 @@ impl Debug for ${style_struct.gecko_struct_name} {
|
|||
%endif
|
||||
</%def>
|
||||
|
||||
<%def name="impl_simple_type_with_conversion(ident)">
|
||||
<%def name="impl_simple_type_with_conversion(ident, gecko_ffi_name=None)">
|
||||
<%
|
||||
if gecko_ffi_name is None:
|
||||
gecko_ffi_name = "m" + to_camel_case(ident)
|
||||
%>
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
|
||||
self.gecko.m${to_camel_case(ident)} = From::from(v)
|
||||
self.gecko.${gecko_ffi_name} = From::from(v)
|
||||
}
|
||||
|
||||
<% impl_simple_copy(ident, "m" + to_camel_case(ident)) %>
|
||||
<% impl_simple_copy(ident, gecko_ffi_name) %>
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
|
||||
From::from(self.gecko.m${to_camel_case(ident)})
|
||||
From::from(self.gecko.${gecko_ffi_name})
|
||||
}
|
||||
</%def>
|
||||
|
||||
|
@ -1851,23 +1856,9 @@ fn static_assert() {
|
|||
// self.gecko.mFont.alternateValues = other.gecko.mFont.alternateValues;
|
||||
}
|
||||
|
||||
pub fn set_font_variant_ligatures(&mut self, v: longhands::font_variant_ligatures::computed_value::T) {
|
||||
self.gecko.mFont.variantLigatures = v.to_gecko_keyword()
|
||||
}
|
||||
|
||||
${impl_simple_copy('font_variant_ligatures', 'mFont.variantLigatures')}
|
||||
|
||||
pub fn set_font_variant_east_asian(&mut self, v: longhands::font_variant_east_asian::computed_value::T) {
|
||||
self.gecko.mFont.variantEastAsian = v.to_gecko_keyword()
|
||||
}
|
||||
|
||||
${impl_simple_copy('font_variant_east_asian', 'mFont.variantEastAsian')}
|
||||
|
||||
pub fn set_font_variant_numeric(&mut self, v: longhands::font_variant_numeric::computed_value::T) {
|
||||
self.gecko.mFont.variantNumeric = v.to_gecko_keyword()
|
||||
}
|
||||
|
||||
${impl_simple_copy('font_variant_numeric', 'mFont.variantNumeric')}
|
||||
${impl_simple_type_with_conversion("font_variant_ligatures", "mFont.variantLigatures")}
|
||||
${impl_simple_type_with_conversion("font_variant_east_asian", "mFont.variantEastAsian")}
|
||||
${impl_simple_type_with_conversion("font_variant_numeric", "mFont.variantNumeric")}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
pub fn set__moz_min_font_size_ratio(&mut self, v: longhands::_moz_min_font_size_ratio::computed_value::T) {
|
||||
|
|
|
@ -16,6 +16,23 @@
|
|||
%endif
|
||||
</%def>
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
macro_rules! impl_gecko_keyword_from_trait {
|
||||
($name: ident, $utype: ty) => {
|
||||
impl From<$utype> for $name {
|
||||
fn from(bits: $utype) -> $name {
|
||||
$name::from_gecko_keyword(bits)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$name> for $utype {
|
||||
fn from(v: $name) -> $utype {
|
||||
v.to_gecko_keyword()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Define ToComputedValue, ToCss, and other boilerplate for a specified value
|
||||
// which is of the form `enum SpecifiedValue {Value(..), System(SystemFont)}`
|
||||
<%def name="simple_system_boilerplate(name)">
|
||||
|
@ -1362,7 +1379,7 @@ macro_rules! exclusive_value {
|
|||
}
|
||||
}
|
||||
|
||||
<%helpers:longhand name="font-variant-east-asian" products="gecko" animation_value_type="none"
|
||||
<%helpers:longhand name="font-variant-east-asian" products="gecko" animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-east-asian">
|
||||
use properties::longhands::system_font::SystemFont;
|
||||
use std::fmt;
|
||||
|
@ -1500,9 +1517,12 @@ macro_rules! exclusive_value {
|
|||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl_gecko_keyword_from_trait!(VariantEastAsian, u16);
|
||||
</%helpers:longhand>
|
||||
|
||||
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="none"
|
||||
<%helpers:longhand name="font-variant-ligatures" products="gecko" animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-ligatures">
|
||||
use properties::longhands::system_font::SystemFont;
|
||||
use std::fmt;
|
||||
|
@ -1650,9 +1670,12 @@ macro_rules! exclusive_value {
|
|||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl_gecko_keyword_from_trait!(VariantLigatures, u16);
|
||||
</%helpers:longhand>
|
||||
|
||||
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="none"
|
||||
<%helpers:longhand name="font-variant-numeric" products="gecko" animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-fonts/#propdef-font-variant-numeric">
|
||||
use properties::longhands::system_font::SystemFont;
|
||||
use std::fmt;
|
||||
|
@ -1793,6 +1816,9 @@ macro_rules! exclusive_value {
|
|||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
impl_gecko_keyword_from_trait!(VariantNumeric, u8);
|
||||
</%helpers:longhand>
|
||||
|
||||
${helpers.single_keyword_system("font-variant-position",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue