From 207ff730c2c48fc626638de182ea11d57cf9f54c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 8 Feb 2019 22:40:26 +0000 Subject: [PATCH] style: Cleanup a bit after bug 1525371. Differential Revision: https://phabricator.services.mozilla.com/D19001 --- components/style/properties/gecko.mako.rs | 62 +++++++------------ .../style/properties/properties.mako.rs | 2 - 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 5dc8a0f6619..2c25a2095af 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -80,7 +80,6 @@ pub struct ComputedValues(crate::gecko_bindings::structs::mozilla::ComputedStyle impl ComputedValues { pub fn new( - device: &Device, pseudo: Option<<&PseudoElement>, custom_properties: Option>, writing_mode: WritingMode, @@ -100,10 +99,7 @@ impl ComputedValues { % for style_struct in data.style_structs: ${style_struct.ident}, % endfor - ).to_outer( - device.pres_context(), - pseudo.map(|p| p.pseudo_info()) - ) + ).to_outer(pseudo) } pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc { @@ -116,7 +112,7 @@ impl ComputedValues { % for style_struct in data.style_structs: style_structs::${style_struct.name}::default(pres_context), % endfor - ).to_outer(pres_context, None) + ).to_outer(None) } pub fn pseudo(&self) -> Option { @@ -190,24 +186,23 @@ impl Clone for ComputedValuesInner { } } -type PseudoInfo = (*mut structs::nsAtom, structs::CSSPseudoElementType); - impl ComputedValuesInner { - pub fn new(custom_properties: Option>, - writing_mode: WritingMode, - flags: ComputedValueFlags, - rules: Option, - visited_style: Option>, - % for style_struct in data.style_structs: - ${style_struct.ident}: Arc, - % endfor + pub fn new( + custom_properties: Option>, + writing_mode: WritingMode, + flags: ComputedValueFlags, + rules: Option, + visited_style: Option>, + % for style_struct in data.style_structs: + ${style_struct.ident}: Arc, + % endfor ) -> Self { - ComputedValuesInner { - custom_properties: custom_properties, - writing_mode: writing_mode, - rules: rules, - visited_style: visited_style.map(|x| Arc::into_raw_offset(x)), - flags: flags, + Self { + custom_properties, + writing_mode, + rules, + visited_style: visited_style.map(Arc::into_raw_offset), + flags, % for style_struct in data.style_structs: ${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}), % endfor @@ -216,29 +211,16 @@ impl ComputedValuesInner { fn to_outer( self, - pres_context: RawGeckoPresContextBorrowed, - info: Option + pseudo: Option<<&PseudoElement>, ) -> Arc { - let (tag, ty) = if let Some(info) = info { - info - } else { - (ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo) + let (pseudo_tag, pseudo_ty) = match pseudo { + Some(p) => p.pseudo_info(), + None => (ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo), }; - - unsafe { self.to_outer_helper(pres_context, ty, tag) } - } - - unsafe fn to_outer_helper( - self, - pres_context: bindings::RawGeckoPresContextBorrowed, - pseudo_ty: structs::CSSPseudoElementType, - pseudo_tag: *mut structs::nsAtom - ) -> Arc { - let arc = { + let arc = unsafe { let arc: Arc = Arc::new(uninitialized()); bindings::Gecko_ComputedStyle_Init( &arc.0 as *const _ as *mut _, - pres_context, &self, pseudo_ty, pseudo_tag diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 6a263c8ca35..0e7364d445c 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -2890,7 +2890,6 @@ impl ComputedValues { impl ComputedValues { /// Create a new refcounted `ComputedValues` pub fn new( - _: &Device, _: Option<<&PseudoElement>, custom_properties: Option>, writing_mode: WritingMode, @@ -3655,7 +3654,6 @@ impl<'a> StyleBuilder<'a> { /// Turns this `StyleBuilder` into a proper `ComputedValues` instance. pub fn build(self) -> Arc { ComputedValues::new( - self.device, self.pseudo, self.custom_properties, self.writing_mode,