Bug 1525955 - Cleanup a bit after bug 1525371. r=jwatt

Differential Revision: https://phabricator.services.mozilla.com/D19001

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-02-08 22:40:26 +00:00
parent 39bdbdd823
commit 286396f97a
6 changed files with 29 additions and 54 deletions

View File

@ -42,7 +42,7 @@ namespace mozilla {
//----------------------------------------------------------------------
ComputedStyle::ComputedStyle(nsPresContext* aPresContext, nsAtom* aPseudoTag,
ComputedStyle::ComputedStyle(nsAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
ServoComputedDataForgotten aComputedValues)
: mSource(aComputedValues),

View File

@ -79,8 +79,7 @@ class ComputedStyle {
using Bit = ComputedStyleBit;
public:
ComputedStyle(nsPresContext* aPresContext, nsAtom* aPseudoTag,
CSSPseudoElementType aPseudoType,
ComputedStyle(nsAtom* aPseudoTag, CSSPseudoElementType aPseudoType,
ServoComputedDataForgotten aComputedValues);
void AddRef() { Servo_ComputedStyle_AddRef(this); }

View File

@ -183,15 +183,12 @@ const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(
return &static_cast<const HTMLSlotElement*>(aElement)->AssignedNodes();
}
void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* aStyle,
RawGeckoPresContextBorrowed aPresContext,
void Gecko_ComputedStyle_Init(ComputedStyle* aStyle,
const ServoComputedData* aValues,
mozilla::CSSPseudoElementType aPseudoType,
CSSPseudoElementType aPseudoType,
nsAtom* aPseudoTag) {
auto* presContext = const_cast<nsPresContext*>(aPresContext);
new (KnownNotNull, aStyle)
mozilla::ComputedStyle(presContext, aPseudoTag, aPseudoType,
ServoComputedDataForgotten(aValues));
new (KnownNotNull, aStyle) ComputedStyle(aPseudoTag, aPseudoType,
ServoComputedDataForgotten(aValues));
}
ServoComputedData::ServoComputedData(const ServoComputedDataForgotten aValue) {
@ -230,7 +227,7 @@ void ServoComputedData::AddSizeOfExcludingThis(nsWindowSizes& aSizes) const {
// - font_computation_data
}
void Gecko_ComputedStyle_Destroy(mozilla::ComputedStyle* aStyle) {
void Gecko_ComputedStyle_Destroy(ComputedStyle* aStyle) {
aStyle->~ComputedStyle();
}

View File

@ -88,7 +88,6 @@ const nsTArray<RefPtr<nsINode>>* Gecko_GetAssignedNodes(
void Gecko_DestroyAnonymousContentList(nsTArray<nsIContent*>* anon_content);
void Gecko_ComputedStyle_Init(mozilla::ComputedStyle* context,
RawGeckoPresContextBorrowed pres_context,
ServoComputedDataBorrowed values,
mozilla::CSSPseudoElementType pseudo_type,
nsAtom* pseudo_tag);

View File

@ -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<Arc<CustomPropertiesMap>>,
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<Self> {
@ -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<PseudoElement> {
@ -190,24 +186,23 @@ impl Clone for ComputedValuesInner {
}
}
type PseudoInfo = (*mut structs::nsAtom, structs::CSSPseudoElementType);
impl ComputedValuesInner {
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
% for style_struct in data.style_structs:
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% endfor
pub fn new(
custom_properties: Option<Arc<CustomPropertiesMap>>,
writing_mode: WritingMode,
flags: ComputedValueFlags,
rules: Option<StrongRuleNode>,
visited_style: Option<Arc<ComputedValues>>,
% for style_struct in data.style_structs:
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
% 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<PseudoInfo>
pseudo: Option<<&PseudoElement>,
) -> Arc<ComputedValues> {
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<ComputedValues> {
let arc = {
let arc = unsafe {
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
bindings::Gecko_ComputedStyle_Init(
&arc.0 as *const _ as *mut _,
pres_context,
&self,
pseudo_ty,
pseudo_tag

View File

@ -2890,7 +2890,6 @@ impl ComputedValues {
impl ComputedValues {
/// Create a new refcounted `ComputedValues`
pub fn new(
_: &Device,
_: Option<<&PseudoElement>,
custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
writing_mode: WritingMode,
@ -3654,7 +3653,6 @@ impl<'a> StyleBuilder<'a> {
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
pub fn build(self) -> Arc<ComputedValues> {
ComputedValues::new(
self.device,
self.pseudo,
self.custom_properties,
self.writing_mode,