Bug 1501116 - Part 2: Use alias for StyleAppearance. r=emilio
authorBoris Chiou <boris.chiou@gmail.com>
Wed, 31 Oct 2018 06:20:00 +0000
changeset 443788 288229844b584c2c707d31f61e68d021c36f4cc4
parent 443787 fd02ae8fbc9bc1135907ca32cacc3483cd151553
child 443789 a01b320f6684c1124253ff10a2479a5935019820
push id34969
push usercbrindusan@mozilla.com
push dateWed, 31 Oct 2018 21:39:53 +0000
treeherdermozilla-central@814414676c25 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1501116
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1501116 - Part 2: Use alias for StyleAppearance. r=emilio So we could avoid generating it in rust-bindgen and drop transmute. Differential Revision: https://phabricator.services.mozilla.com/D10304
layout/style/ServoBindings.toml
servo/components/style/properties/gecko.mako.rs
--- a/layout/style/ServoBindings.toml
+++ b/layout/style/ServoBindings.toml
@@ -386,16 +386,17 @@ opaque-types = [
     "StyleAnimationValue", # pulls in a whole bunch of stuff we don't need in the bindings
     "mozilla::dom::.*Callback", # Pulls in ErrorResult and other things that
                                 # don't align properly on Linux 32-bit
     "mozilla::SchedulerGroup", # Non-standard-layout packing of field into superclass
 ]
 
 # All cbindgen-types are in mod "structs::root::mozilla".
 cbindgen-types = [
+    { gecko = "mozilla::StyleAppearance", servo = "values::specified::Appearance" },
     { gecko = "mozilla::StyleComputedTimingFunction", servo = "values::computed::easing::TimingFunction" },
 ]
 
 mapped-generic-types = [
     { generic = true, gecko = "mozilla::RustCell", servo = "::std::cell::Cell" },
     { generic = false, gecko = "ServoNodeData", servo = "AtomicRefCell<ElementData>" },
     { generic = false, gecko = "mozilla::ServoWritingMode", servo = "::logical_geometry::WritingMode" },
     { generic = false, gecko = "mozilla::ServoCustomPropertiesMap", servo = "Option<::servo_arc::Arc<::custom_properties::CustomPropertiesMap>>" },
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -363,44 +363,16 @@ impl ${style_struct.gecko_struct_name} {
 <%!
 def get_gecko_property(ffi_name, self_param = "self"):
     return "%s.gecko.%s" % (self_param, ffi_name)
 
 def set_gecko_property(ffi_name, expr):
     return "self.gecko.%s = %s;" % (ffi_name, expr)
 %>
 
-<%def name="impl_cbindgen_keyword(ident, gecko_ffi_name)">
-    #[allow(non_snake_case)]
-    #[inline]
-    pub fn set_${ident}(&mut self, v: longhands::${ident}::computed_value::T) {
-        // unsafe: cbindgen ensures the representations match.
-        ${set_gecko_property(gecko_ffi_name, "unsafe { transmute(v) }")}
-    }
-
-    #[allow(non_snake_case)]
-    #[inline]
-    pub fn clone_${ident}(&self) -> longhands::${ident}::computed_value::T {
-        // unsafe: cbindgen ensures the representations match.
-        unsafe { transmute(${get_gecko_property(gecko_ffi_name)}) }
-    }
-
-    #[allow(non_snake_case)]
-    #[inline]
-    pub fn copy_${ident}_from(&mut self, other: &Self) {
-        self.gecko.${gecko_ffi_name} = other.gecko.${gecko_ffi_name};
-    }
-
-    #[allow(non_snake_case)]
-    #[inline]
-    pub fn reset_${ident}(&mut self, other: &Self) {
-        self.copy_${ident}_from(other)
-    }
-</%def>
-
 <%def name="impl_keyword_setter(ident, gecko_ffi_name, keyword, cast_type='u8', on_set=None)">
     #[allow(non_snake_case)]
     pub fn set_${ident}(&mut self, v: 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
         let result = match v {
             % for value in keyword.values_for('gecko'):
                 Keyword::${to_camel_case(value)} =>
@@ -3086,17 +3058,17 @@ fn static_assert() {
     }
 
     #[inline]
     pub fn clone_display(&self) -> longhands::display::computed_value::T {
         // unsafe: cbindgen ensures the representation is the same.
         unsafe { transmute(self.gecko.mDisplay) }
     }
 
-    ${impl_cbindgen_keyword('_moz_appearance', 'mAppearance')}
+    ${impl_simple('_moz_appearance', 'mAppearance')}
 
     <% float_keyword = Keyword("float", "Left Right None", gecko_enum_prefix="StyleFloat") %>
     ${impl_keyword('float', 'mFloat', float_keyword)}
 
     <% clear_keyword = Keyword(
         "clear",
         "Left Right None Both",
         gecko_enum_prefix="StyleClear",