diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index c42f973205c..f73219afe0e 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1275,7 +1275,7 @@ pub trait ComputedValues : Debug + Clone + Send + Sync + 'static { fn initial_values() -> &'static Self; - fn do_cascade_property>)>(f: F); + fn do_cascade_property])>(f: F); % for style_struct in data.active_style_structs(): fn clone_${style_struct.trait_name_lower}(&self) -> @@ -1346,8 +1346,9 @@ impl ComputedValues for ServoComputedValues { fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES } - fn do_cascade_property>)>(f: F) { - CASCADE_PROPERTY.with(|x| f(x)); + #[inline] + fn do_cascade_property])>(f: F) { + f(&CASCADE_PROPERTY) } % for style_struct in data.active_style_structs(): @@ -1747,19 +1748,11 @@ pub type CascadePropertyFn = cacheable: &mut bool, error_reporter: &mut StdBox); -pub fn make_cascade_vec() -> Vec> { - vec![ - % for property in data.longhands: - longhands::${property.ident}::cascade_property, - % endfor - ] -} - -// This is a thread-local rather than a lazy static to avoid atomic operations when cascading -// properties. -thread_local!(static CASCADE_PROPERTY: Vec> = { - make_cascade_vec::() -}); +static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [ + % for property in data.longhands: + longhands::${property.ident}::cascade_property, + % endfor +]; /// Performs the CSS cascade, computing new styles for an element from its parent style and /// optionally a cached related style. The arguments are: diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 6493a399ea9..94e8f794a89 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -33,7 +33,6 @@ use style::custom_properties::ComputedValuesMap; use style::logical_geometry::WritingMode; use style::properties::{CascadePropertyFn, ServoComputedValues, ComputedValues}; use style::properties::longhands; -use style::properties::make_cascade_vec; use style::properties::style_struct_traits::*; use values::{StyleCoordHelpers, ToGeckoStyleCoord, convert_nscolor_to_rgba}; use values::{convert_rgba_to_nscolor, debug_assert_unit_is_safe_to_copy}; @@ -106,8 +105,9 @@ impl ComputedValues for GeckoComputedValues { fn initial_values() -> &'static Self { &*INITIAL_GECKO_VALUES } - fn do_cascade_property>)>(f: F) { - CASCADE_PROPERTY.with(|x| f(x)); + #[inline] + fn do_cascade_property])>(f: F) { + f(&CASCADE_PROPERTY) } % for style_struct in data.style_structs: @@ -1139,8 +1139,8 @@ lazy_static! { }; } -// This is a thread-local rather than a lazy static to avoid atomic operations when cascading -// properties. -thread_local!(static CASCADE_PROPERTY: Vec> = { - make_cascade_vec::() -}); +static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [ + % for property in data.longhands: + longhands::${property.ident}::cascade_property, + % endfor +];