servo: Merge #14366 - move Servo_GetStyleVariables definition from the Gecko side (from heycam:variables); r=Manishearth
authorCameron McCormack <cam@mcc.id.au>
Thu, 24 Nov 2016 16:38:40 -0800
changeset 340220 92421ff0865165fd982558f52ed81e681fda1ad5
parent 340219 8d6170c6ba2edafbc8e19872cde6932cced2415f
child 340221 3d7fba3f53fd3b2ba1fa9a5cb835160720f9aaf1
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersManishearth
servo: Merge #14366 - move Servo_GetStyleVariables definition from the Gecko side (from heycam:variables); r=Manishearth <!-- Please describe your changes on the following line: --> This is the Servo-side part of https://bugzilla.mozilla.org/show_bug.cgi?id=1319982 which has already been reviewed by @Manishearth there. Source-Repo: https://github.com/servo/servo Source-Revision: 4529435f96cadf0a7b32f7417bef885833a7cabc
servo/components/style/properties/gecko.mako.rs
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -14,16 +14,17 @@ use app_units::Au;
 use custom_properties::ComputedValuesMap;
 use gecko_bindings::bindings;
 % for style_struct in data.style_structs:
 use gecko_bindings::structs::${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_Construct_${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_CopyConstruct_${style_struct.gecko_ffi_name};
 use gecko_bindings::bindings::Gecko_Destroy_${style_struct.gecko_ffi_name};
 % endfor
+use gecko_bindings::bindings::Gecko_Construct_nsStyleVariables;
 use gecko_bindings::bindings::Gecko_CopyCursorArrayFrom;
 use gecko_bindings::bindings::Gecko_CopyFontFamilyFrom;
 use gecko_bindings::bindings::Gecko_CopyImageValueFrom;
 use gecko_bindings::bindings::Gecko_CopyListStyleImageFrom;
 use gecko_bindings::bindings::Gecko_CopyListStyleTypeFrom;
 use gecko_bindings::bindings::Gecko_CopyMozBindingFrom;
 use gecko_bindings::bindings::Gecko_EnsureImageLayersLength;
 use gecko_bindings::bindings::Gecko_FontFamilyList_AppendGeneric;
@@ -35,16 +36,17 @@ use gecko_bindings::bindings::Gecko_NewC
 use gecko_bindings::bindings::Gecko_SetListStyleImage;
 use gecko_bindings::bindings::Gecko_SetListStyleImageNone;
 use gecko_bindings::bindings::Gecko_SetListStyleType;
 use gecko_bindings::bindings::Gecko_SetMozBinding;
 use gecko_bindings::bindings::Gecko_SetNullImageValue;
 use gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
 use gecko_bindings::bindings::{Gecko_ResetFilters, Gecko_CopyFiltersFrom};
 use gecko_bindings::structs;
+use gecko_bindings::structs::nsStyleVariables;
 use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
 use gecko_bindings::sugar::ownership::HasArcFFI;
 use gecko::values::convert_nscolor_to_rgba;
 use gecko::values::convert_rgba_to_nscolor;
 use gecko::values::GeckoStyleCoordConvertible;
 use gecko::values::round_border_to_device_pixels;
 use gecko::values::StyleCoordHelpers;
 use logical_geometry::WritingMode;
@@ -2455,16 +2457,33 @@ pub unsafe extern "C" fn Servo_GetStyle$
 ${declare_style_struct(style_struct)}
 ${impl_style_struct(style_struct)}
 % if not style_struct.name in data.manual_style_structs:
 <%self:raw_impl_trait style_struct="${style_struct}"></%self:raw_impl_trait>
 % endif
 ${define_ffi_struct_accessor(style_struct)}
 % endfor
 
+lazy_static! {
+    static ref EMPTY_VARIABLES_STRUCT: nsStyleVariables = {
+        unsafe {
+            let mut variables: nsStyleVariables = unsafe { zeroed() };
+            Gecko_Construct_nsStyleVariables(&mut variables);
+            variables
+        }
+    };
+}
+
+#[no_mangle]
+#[allow(non_snake_case)]
+pub unsafe extern "C" fn Servo_GetStyleVariables(_cv: ServoComputedValuesBorrowedOrNull)
+                                                 -> *const nsStyleVariables {
+    &*EMPTY_VARIABLES_STRUCT
+}
+
 // To avoid UB, we store the initial values as a atomic. It would be nice to
 // store them as AtomicPtr, but we can't have static AtomicPtr without const
 // fns, which aren't in stable Rust.
 static INITIAL_VALUES_STORAGE: AtomicUsize = ATOMIC_USIZE_INIT;
 unsafe fn raw_initial_values() -> *mut ComputedValues {
     INITIAL_VALUES_STORAGE.load(Ordering::Relaxed) as *mut ComputedValues
 }
 unsafe fn set_raw_initial_values(v: *mut ComputedValues) {