mirror of
https://github.com/servo/servo.git
synced 2025-07-05 22:43:40 +01:00
style: Cleanup a bit after bug 1525371.
Differential Revision: https://phabricator.services.mozilla.com/D19001
This commit is contained in:
parent
258217a369
commit
207ff730c2
2 changed files with 22 additions and 42 deletions
|
@ -80,7 +80,6 @@ pub struct ComputedValues(crate::gecko_bindings::structs::mozilla::ComputedStyle
|
||||||
|
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
device: &Device,
|
|
||||||
pseudo: Option<<&PseudoElement>,
|
pseudo: Option<<&PseudoElement>,
|
||||||
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
|
@ -100,10 +99,7 @@ impl ComputedValues {
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
${style_struct.ident},
|
${style_struct.ident},
|
||||||
% endfor
|
% endfor
|
||||||
).to_outer(
|
).to_outer(pseudo)
|
||||||
device.pres_context(),
|
|
||||||
pseudo.map(|p| p.pseudo_info())
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||||
|
@ -116,7 +112,7 @@ impl ComputedValues {
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
style_structs::${style_struct.name}::default(pres_context),
|
style_structs::${style_struct.name}::default(pres_context),
|
||||||
% endfor
|
% endfor
|
||||||
).to_outer(pres_context, None)
|
).to_outer(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pseudo(&self) -> Option<PseudoElement> {
|
pub fn pseudo(&self) -> Option<PseudoElement> {
|
||||||
|
@ -190,10 +186,9 @@ impl Clone for ComputedValuesInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type PseudoInfo = (*mut structs::nsAtom, structs::CSSPseudoElementType);
|
|
||||||
|
|
||||||
impl ComputedValuesInner {
|
impl ComputedValuesInner {
|
||||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
pub fn new(
|
||||||
|
custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
flags: ComputedValueFlags,
|
flags: ComputedValueFlags,
|
||||||
rules: Option<StrongRuleNode>,
|
rules: Option<StrongRuleNode>,
|
||||||
|
@ -202,12 +197,12 @@ impl ComputedValuesInner {
|
||||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||||
% endfor
|
% endfor
|
||||||
) -> Self {
|
) -> Self {
|
||||||
ComputedValuesInner {
|
Self {
|
||||||
custom_properties: custom_properties,
|
custom_properties,
|
||||||
writing_mode: writing_mode,
|
writing_mode,
|
||||||
rules: rules,
|
rules,
|
||||||
visited_style: visited_style.map(|x| Arc::into_raw_offset(x)),
|
visited_style: visited_style.map(Arc::into_raw_offset),
|
||||||
flags: flags,
|
flags,
|
||||||
% for style_struct in data.style_structs:
|
% for style_struct in data.style_structs:
|
||||||
${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
|
${style_struct.gecko_name}: Arc::into_raw_offset(${style_struct.ident}),
|
||||||
% endfor
|
% endfor
|
||||||
|
@ -216,29 +211,16 @@ impl ComputedValuesInner {
|
||||||
|
|
||||||
fn to_outer(
|
fn to_outer(
|
||||||
self,
|
self,
|
||||||
pres_context: RawGeckoPresContextBorrowed,
|
pseudo: Option<<&PseudoElement>,
|
||||||
info: Option<PseudoInfo>
|
|
||||||
) -> Arc<ComputedValues> {
|
) -> Arc<ComputedValues> {
|
||||||
let (tag, ty) = if let Some(info) = info {
|
let (pseudo_tag, pseudo_ty) = match pseudo {
|
||||||
info
|
Some(p) => p.pseudo_info(),
|
||||||
} else {
|
None => (ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo),
|
||||||
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
|
||||||
};
|
};
|
||||||
|
let arc = unsafe {
|
||||||
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: Arc<ComputedValues> = Arc::new(uninitialized());
|
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
||||||
bindings::Gecko_ComputedStyle_Init(
|
bindings::Gecko_ComputedStyle_Init(
|
||||||
&arc.0 as *const _ as *mut _,
|
&arc.0 as *const _ as *mut _,
|
||||||
pres_context,
|
|
||||||
&self,
|
&self,
|
||||||
pseudo_ty,
|
pseudo_ty,
|
||||||
pseudo_tag
|
pseudo_tag
|
||||||
|
|
|
@ -2890,7 +2890,6 @@ impl ComputedValues {
|
||||||
impl ComputedValues {
|
impl ComputedValues {
|
||||||
/// Create a new refcounted `ComputedValues`
|
/// Create a new refcounted `ComputedValues`
|
||||||
pub fn new(
|
pub fn new(
|
||||||
_: &Device,
|
|
||||||
_: Option<<&PseudoElement>,
|
_: Option<<&PseudoElement>,
|
||||||
custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
|
custom_properties: Option<Arc<crate::custom_properties::CustomPropertiesMap>>,
|
||||||
writing_mode: WritingMode,
|
writing_mode: WritingMode,
|
||||||
|
@ -3655,7 +3654,6 @@ impl<'a> StyleBuilder<'a> {
|
||||||
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
||||||
pub fn build(self) -> Arc<ComputedValues> {
|
pub fn build(self) -> Arc<ComputedValues> {
|
||||||
ComputedValues::new(
|
ComputedValues::new(
|
||||||
self.device,
|
|
||||||
self.pseudo,
|
self.pseudo,
|
||||||
self.custom_properties,
|
self.custom_properties,
|
||||||
self.writing_mode,
|
self.writing_mode,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue