mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
stylo: Cleanup the Gecko bits.
MozReview-Commit-ID: dbVDy1u4vp
This commit is contained in:
parent
655c842d2e
commit
07e1c6e75a
8 changed files with 148 additions and 111 deletions
|
@ -16,7 +16,7 @@ use gecko_bindings::structs::nsIDocument;
|
|||
use gecko_bindings::sugar::ownership::{HasArcFFI, HasBoxFFI, HasFFI, HasSimpleFFI};
|
||||
use invalidation::media_queries::{MediaListKey, ToMediaListKey};
|
||||
use media_queries::{Device, MediaList};
|
||||
use properties::ComputedValuesInner;
|
||||
use properties::ComputedValues;
|
||||
use shared_lock::{Locked, StylesheetGuards, SharedRwLockReadGuard};
|
||||
use stylearc::Arc;
|
||||
use stylesheet_set::StylesheetSet;
|
||||
|
@ -188,8 +188,8 @@ impl PerDocumentStyleDataImpl {
|
|||
}
|
||||
|
||||
/// Get the default computed values for this document.
|
||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
||||
self.stylist.device().default_computed_values()
|
||||
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
|
||||
self.stylist.device().default_computed_values_arc()
|
||||
}
|
||||
|
||||
/// Clear the stylist. This will be a no-op if the stylist is
|
||||
|
|
|
@ -17,9 +17,10 @@ use gecko_bindings::structs::{nsMediaFeature_ValueType, nsMediaFeature_RangeType
|
|||
use gecko_bindings::structs::{nsPresContext, RawGeckoPresContextOwned};
|
||||
use media_queries::MediaType;
|
||||
use parser::ParserContext;
|
||||
use properties::{ComputedValuesInner, StyleBuilder};
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::longhands::font_size;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use servo_arc::Arc;
|
||||
use std::fmt::{self, Write};
|
||||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||
use str::starts_with_ignore_ascii_case;
|
||||
|
@ -36,7 +37,7 @@ pub struct Device {
|
|||
/// stylist, and thus the `Device`, so having a raw pres context pointer
|
||||
/// here is fine.
|
||||
pres_context: RawGeckoPresContextOwned,
|
||||
default_values: ComputedValuesInner,
|
||||
default_values: Arc<ComputedValues>,
|
||||
viewport_override: Option<ViewportConstraints>,
|
||||
/// The font size of the root element
|
||||
/// This is set when computing the style of the root
|
||||
|
@ -61,7 +62,7 @@ impl Device {
|
|||
assert!(!pres_context.is_null());
|
||||
Device {
|
||||
pres_context: pres_context,
|
||||
default_values: ComputedValuesInner::default_values(unsafe { &*pres_context }),
|
||||
default_values: ComputedValues::default_values(unsafe { &*pres_context }),
|
||||
viewport_override: None,
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
||||
used_root_font_size: AtomicBool::new(false),
|
||||
|
@ -77,7 +78,12 @@ impl Device {
|
|||
|
||||
/// Returns the default computed values as a reference, in order to match
|
||||
/// Servo.
|
||||
pub fn default_computed_values(&self) -> &ComputedValuesInner {
|
||||
pub fn default_computed_values(&self) -> &ComputedValues {
|
||||
&self.default_values
|
||||
}
|
||||
|
||||
/// Returns the default computed values as an `Arc`.
|
||||
pub fn default_computed_values_arc(&self) -> &Arc<ComputedValues> {
|
||||
&self.default_values
|
||||
}
|
||||
|
||||
|
@ -101,7 +107,7 @@ impl Device {
|
|||
pub fn reset_computed_values(&mut self) {
|
||||
// NB: A following stylesheet flush will populate this if appropriate.
|
||||
self.viewport_override = None;
|
||||
self.default_values = ComputedValuesInner::default_values(self.pres_context());
|
||||
self.default_values = ComputedValues::default_values(self.pres_context());
|
||||
self.used_root_font_size.store(false, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
|
@ -620,8 +626,7 @@ impl Expression {
|
|||
is_root_element: false,
|
||||
device: device,
|
||||
inherited_style: default_values,
|
||||
layout_parent_style: default_values,
|
||||
style: StyleBuilder::for_derived_style(default_values),
|
||||
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||
font_metrics_provider: &provider,
|
||||
cached_system_font: None,
|
||||
in_media_query: true,
|
||||
|
|
|
@ -107,7 +107,6 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Construct a `CSSPseudoElementType` from a pseudo-element
|
||||
#[inline]
|
||||
pub fn pseudo_type(&self) -> CSSPseudoElementType {
|
||||
|
@ -133,6 +132,21 @@ impl PseudoElement {
|
|||
(self.atom().as_ptr(), self.pseudo_type())
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an `Atom`.
|
||||
#[inline]
|
||||
pub fn from_atom(atom: &Atom) -> Option<Self> {
|
||||
% for pseudo in PSEUDOS:
|
||||
% if pseudo.is_tree_pseudo_element():
|
||||
// We cannot generate ${pseudo_element_variant(pseudo)} from just an atom.
|
||||
% else:
|
||||
if atom == &atom!("${pseudo.value}") {
|
||||
return Some(${pseudo_element_variant(pseudo)});
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
None
|
||||
}
|
||||
|
||||
/// Construct a pseudo-element from an anonymous box `Atom`.
|
||||
#[inline]
|
||||
pub fn from_anon_box_atom(atom: &Atom) -> Option<Self> {
|
||||
|
|
|
@ -57,6 +57,7 @@ use properties::computed_value_flags::ComputedValueFlags;
|
|||
use properties::{longhands, FontComputationData, Importance, LonghandId};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
|
||||
use rule_tree::StrongRuleNode;
|
||||
use selector_parser::PseudoElement;
|
||||
use std::mem::{forget, uninitialized, transmute, zeroed};
|
||||
use std::{cmp, ops, ptr};
|
||||
use stylearc::{Arc, RawOffsetArc};
|
||||
|
@ -105,11 +106,37 @@ impl ComputedValues {
|
|||
${style_struct.ident},
|
||||
% endfor
|
||||
).to_outer(
|
||||
device,
|
||||
device.pres_context(),
|
||||
parent,
|
||||
pseudo.map(|p| p.pseudo_info())
|
||||
)
|
||||
}
|
||||
|
||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Arc<Self> {
|
||||
ComputedValuesInner::new(
|
||||
/* custom_properties = */ None,
|
||||
/* writing_mode = */ WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
FontComputationData::default_font_size_keyword(),
|
||||
ComputedValueFlags::empty(),
|
||||
/* rules = */ None,
|
||||
/* visited_style = */ None,
|
||||
% for style_struct in data.style_structs:
|
||||
style_structs::${style_struct.name}::default(pres_context),
|
||||
% endfor
|
||||
).to_outer(pres_context, None, None)
|
||||
}
|
||||
|
||||
pub fn pseudo(&self) -> Option<PseudoElement> {
|
||||
use string_cache::Atom;
|
||||
|
||||
let atom = (self.0)._base.mPseudoTag.raw::<structs::nsIAtom>();
|
||||
if atom.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let atom = Atom::from(atom);
|
||||
PseudoElement::from_atom(&atom)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ComputedValues {
|
||||
|
@ -145,8 +172,8 @@ impl Clone for ComputedValuesInner {
|
|||
}
|
||||
}
|
||||
|
||||
pub type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
||||
pub type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
||||
type PseudoInfo = (*mut structs::nsIAtom, structs::CSSPseudoElementType);
|
||||
type ParentStyleContextInfo<'a> = Option< &'a ComputedValues>;
|
||||
|
||||
impl ComputedValuesInner {
|
||||
pub fn new(custom_properties: Option<Arc<CustomPropertiesMap>>,
|
||||
|
@ -172,37 +199,28 @@ impl ComputedValuesInner {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn default_values(pres_context: RawGeckoPresContextBorrowed) -> Self {
|
||||
ComputedValuesInner {
|
||||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
flags: ComputedValueFlags::empty(),
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.gecko_name}: Arc::into_raw_offset(
|
||||
style_structs::${style_struct.name}::default(pres_context)
|
||||
),
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_outer(self, device: &Device, parent: ParentStyleContextInfo,
|
||||
info: Option<PseudoInfo>) -> Arc<ComputedValues> {
|
||||
fn to_outer(
|
||||
self,
|
||||
pres_context: RawGeckoPresContextBorrowed,
|
||||
parent: ParentStyleContextInfo,
|
||||
info: Option<PseudoInfo>
|
||||
) -> Arc<ComputedValues> {
|
||||
let (tag, ty) = if let Some(info) = info {
|
||||
info
|
||||
} else {
|
||||
(ptr::null_mut(), structs::CSSPseudoElementType::NotPseudo)
|
||||
};
|
||||
|
||||
unsafe { self.to_outer_helper(device.pres_context(), parent, ty, tag) }
|
||||
unsafe { self.to_outer_helper(pres_context, parent, ty, tag) }
|
||||
}
|
||||
|
||||
unsafe fn to_outer_helper(self, pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||
parent: ParentStyleContextInfo,
|
||||
pseudo_ty: structs::CSSPseudoElementType,
|
||||
pseudo_tag: *mut structs::nsIAtom) -> Arc<ComputedValues> {
|
||||
unsafe fn to_outer_helper(
|
||||
self,
|
||||
pres_context: bindings::RawGeckoPresContextBorrowed,
|
||||
parent: ParentStyleContextInfo,
|
||||
pseudo_ty: structs::CSSPseudoElementType,
|
||||
pseudo_tag: *mut structs::nsIAtom
|
||||
) -> Arc<ComputedValues> {
|
||||
let arc = unsafe {
|
||||
let arc: Arc<ComputedValues> = Arc::new(uninitialized());
|
||||
bindings::Gecko_ServoStyleContext_Init(&arc.0 as *const _ as *mut _, parent, pres_context,
|
||||
|
|
|
@ -121,10 +121,8 @@ impl FontComputationData {
|
|||
}
|
||||
|
||||
/// Assigns default values for variables in struct FontComputationData
|
||||
pub fn default_values() -> Self {
|
||||
FontComputationData{
|
||||
font_size_keyword: Some((Default::default(), 1.))
|
||||
}
|
||||
pub fn default_font_size_keyword() -> Option<(longhands::font_size::KeywordSize, f32)> {
|
||||
Some((Default::default(), 1.))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1873,7 +1871,7 @@ pub mod style_structs {
|
|||
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko_properties::{ComputedValues, ComputedValuesInner, ParentStyleContextInfo, PseudoInfo};
|
||||
pub use gecko_properties::{ComputedValues, ComputedValuesInner};
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[cfg_attr(feature = "servo", derive(Clone, Debug))]
|
||||
|
@ -1921,6 +1919,7 @@ pub struct ComputedValues {
|
|||
inner: ComputedValuesInner,
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl ComputedValues {
|
||||
/// Create a new refcounted `ComputedValues`
|
||||
pub fn new(
|
||||
|
@ -2521,8 +2520,12 @@ impl<'a> StyleBuilder<'a> {
|
|||
|
||||
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
||||
/// order to create a derived style.
|
||||
pub fn for_derived_style(device: &'a Device, s: &'a ComputedValues) -> Self {
|
||||
Self::for_inheritance(device, s, s, s.pseudo())
|
||||
pub fn for_derived_style(
|
||||
device: &'a Device,
|
||||
s: &'a ComputedValues,
|
||||
pseudo: Option<<&'a PseudoElement>,
|
||||
) -> Self {
|
||||
Self::for_inheritance(device, s, s, pseudo)
|
||||
}
|
||||
|
||||
/// Inherits style from the parent element, accounting for the default
|
||||
|
|
|
@ -231,7 +231,7 @@ impl Range<specified::Length> {
|
|||
is_root_element: false,
|
||||
device: device,
|
||||
inherited_style: default_values,
|
||||
style: StyleBuilder::for_derived_style(device, default_values),
|
||||
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||
// Servo doesn't support font metrics
|
||||
// A real provider will be needed here once we do; since
|
||||
// ch units can exist in media queries.
|
||||
|
|
|
@ -706,7 +706,7 @@ impl MaybeNew for ViewportConstraints {
|
|||
is_root_element: false,
|
||||
device: device,
|
||||
inherited_style: default_values,
|
||||
style: StyleBuilder::for_derived_style(device, default_values),
|
||||
style: StyleBuilder::for_derived_style(device, default_values, None),
|
||||
font_metrics_provider: &provider,
|
||||
cached_system_font: None,
|
||||
in_media_query: false,
|
||||
|
|
|
@ -60,7 +60,6 @@ use style::gecko_bindings::bindings::RawServoAnimationValueBorrowed;
|
|||
use style::gecko_bindings::bindings::RawServoAnimationValueMapBorrowedMut;
|
||||
use style::gecko_bindings::bindings::RawServoAnimationValueStrong;
|
||||
use style::gecko_bindings::bindings::RawServoStyleRuleBorrowed;
|
||||
use style::gecko_bindings::bindings::ServoComputedValuesBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::ServoStyleContextBorrowedOrNull;
|
||||
use style::gecko_bindings::bindings::nsTArrayBorrowed_uintptr_t;
|
||||
use style::gecko_bindings::bindings::nsTimingFunctionBorrowed;
|
||||
|
@ -91,9 +90,8 @@ use style::invalidation::element::restyle_hints::{self, RestyleHint};
|
|||
use style::media_queries::{MediaList, parse_media_query_list};
|
||||
use style::parallel;
|
||||
use style::parser::ParserContext;
|
||||
use style::properties::{ComputedValues, ComputedValuesInner, Importance};
|
||||
use style::properties::{ComputedValues, Importance};
|
||||
use style::properties::{IS_FIELDSET_CONTENT, LonghandIdSet};
|
||||
use style::properties::{ParentStyleContextInfo, PseudoInfo};
|
||||
use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
|
||||
use style::properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, SourcePropertyDeclaration, StyleBuilder};
|
||||
use style::properties::animated_properties::{Animatable, AnimatableLonghand, AnimationValue};
|
||||
|
@ -1504,7 +1502,6 @@ pub extern "C" fn Servo_DocumentRule_GetConditionText(rule: RawServoDocumentRule
|
|||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null: ServoStyleContextBorrowedOrNull,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoStyleContextStrong {
|
||||
|
@ -1521,20 +1518,19 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
|||
cascade_flags.insert(IS_FIELDSET_CONTENT);
|
||||
}
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
data.stylist.precomputed_values_for_pseudo(&guards, &pseudo, parent_style_or_null.map(|x| &**x),
|
||||
cascade_flags, &metrics,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_or_null)
|
||||
.into_strong()
|
||||
data.stylist.precomputed_values_for_pseudo(
|
||||
&guards,
|
||||
&pseudo,
|
||||
parent_style_or_null.map(|x| &*x),
|
||||
cascade_flags, &metrics
|
||||
).into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
is_probe: bool,
|
||||
inherited_style: ServoComputedValuesBorrowedOrNull,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
inherited_style: ServoStyleContextBorrowedOrNull,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> ServoStyleContextStrong
|
||||
{
|
||||
|
@ -1551,9 +1547,7 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
return if is_probe {
|
||||
Strong::null()
|
||||
} else {
|
||||
doc_data.default_computed_values()
|
||||
.clone().to_outer(doc_data.stylist.device(), parent_style_context,
|
||||
Some((pseudo_tag, pseudo_type))).into_strong()
|
||||
doc_data.default_computed_values().clone().into_strong()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1571,8 +1565,6 @@ pub extern "C" fn Servo_ResolvePseudoStyle(element: RawGeckoElementBorrowed,
|
|||
inherited_style,
|
||||
&*doc_data,
|
||||
is_probe,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_context
|
||||
);
|
||||
|
||||
match style {
|
||||
|
@ -1624,11 +1616,9 @@ fn get_pseudo_style(
|
|||
pseudo: &PseudoElement,
|
||||
rule_inclusion: RuleInclusion,
|
||||
styles: &ElementStyles,
|
||||
inherited_styles: Option<&ComputedValuesInner>,
|
||||
inherited_styles: Option<&ComputedValues>,
|
||||
doc_data: &PerDocumentStyleDataImpl,
|
||||
is_probe: bool,
|
||||
pseudo_info: PseudoInfo,
|
||||
parent_style_context: ParentStyleContextInfo,
|
||||
) -> Option<Arc<ComputedValues>> {
|
||||
let style = match pseudo.cascade_type() {
|
||||
PseudoElementCascadeType::Eager => {
|
||||
|
@ -1648,17 +1638,17 @@ fn get_pseudo_style(
|
|||
doc_data.stylist
|
||||
.compute_pseudo_element_style_with_inputs(
|
||||
&inputs,
|
||||
pseudo,
|
||||
&guards,
|
||||
inherited_styles,
|
||||
&metrics,
|
||||
pseudo_info.clone(),
|
||||
parent_style_context)
|
||||
&metrics
|
||||
)
|
||||
})
|
||||
},
|
||||
_ => {
|
||||
debug_assert!(inherited_styles.is_none() ||
|
||||
ptr::eq(&*inherited_styles.unwrap(),
|
||||
&***styles.primary()));
|
||||
ptr::eq(inherited_styles.unwrap(),
|
||||
&**styles.primary()));
|
||||
styles.pseudos.get(&pseudo).cloned()
|
||||
},
|
||||
}
|
||||
|
@ -1666,8 +1656,8 @@ fn get_pseudo_style(
|
|||
PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
debug_assert!(inherited_styles.is_none() ||
|
||||
ptr::eq(&*inherited_styles.unwrap(),
|
||||
&***styles.primary()));
|
||||
ptr::eq(inherited_styles.unwrap(),
|
||||
&**styles.primary()));
|
||||
let base = if pseudo.inherits_from_default_values() {
|
||||
doc_data.default_computed_values()
|
||||
} else {
|
||||
|
@ -1684,8 +1674,7 @@ fn get_pseudo_style(
|
|||
base,
|
||||
is_probe,
|
||||
&metrics,
|
||||
pseudo_info.clone(),
|
||||
parent_style_context)
|
||||
)
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -1695,17 +1684,17 @@ fn get_pseudo_style(
|
|||
|
||||
Some(style.unwrap_or_else(|| {
|
||||
StyleBuilder::for_inheritance(
|
||||
doc_data.stylist.device(),
|
||||
styles.primary(),
|
||||
doc_data.default_computed_values(),
|
||||
).build().to_outer(doc_data.stylist.device(), parent_style_context,
|
||||
Some(pseudo_info))
|
||||
Some(pseudo),
|
||||
).build()
|
||||
}))
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
target: structs::InheritTarget
|
||||
|
@ -1713,10 +1702,17 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
|||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
|
||||
let for_text = target == structs::InheritTarget::Text;
|
||||
let atom = Atom::from(pseudo_tag);
|
||||
let pseudo = PseudoElement::from_anon_box_atom(&atom)
|
||||
.expect("Not an anon-box? Gah!");
|
||||
let style = if let Some(reference) = parent_style_context {
|
||||
let mut style =
|
||||
StyleBuilder::for_inheritance(reference,
|
||||
&data.default_computed_values());
|
||||
let mut style = StyleBuilder::for_inheritance(
|
||||
data.stylist.device(),
|
||||
reference,
|
||||
data.default_computed_values(),
|
||||
Some(&pseudo)
|
||||
);
|
||||
|
||||
if for_text {
|
||||
StyleAdjuster::new(&mut style)
|
||||
.adjust_for_text();
|
||||
|
@ -1725,16 +1721,14 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
|||
style.build()
|
||||
} else {
|
||||
debug_assert!(!for_text);
|
||||
data.default_computed_values().clone()
|
||||
StyleBuilder::for_derived_style(
|
||||
data.stylist.device(),
|
||||
data.default_computed_values(),
|
||||
Some(&pseudo),
|
||||
).build()
|
||||
};
|
||||
|
||||
let pseudo_info = if pseudo_tag.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some((pseudo_tag, pseudo_type))
|
||||
};
|
||||
|
||||
style.to_outer(data.stylist.device(), parent_style_context, pseudo_info).into_strong()
|
||||
style.into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -2814,8 +2808,6 @@ pub extern "C" fn Servo_ResolveStyle(element: RawGeckoElementBorrowed,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
||||
pseudo_type: CSSPseudoElementType,
|
||||
pseudo_tag: *mut nsIAtom,
|
||||
parent_style_context: ServoStyleContextBorrowedOrNull,
|
||||
rule_inclusion: StyleRuleInclusion,
|
||||
snapshots: *const ServoElementSnapshotTable,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
|
@ -2840,8 +2832,6 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed,
|
|||
/* inherited_styles = */ None,
|
||||
&*data,
|
||||
/* is_probe = */ false,
|
||||
(pseudo_tag, pseudo_type),
|
||||
parent_style_context
|
||||
).expect("We're not probing, so we should always get a style \
|
||||
back")
|
||||
}
|
||||
|
@ -2895,8 +2885,9 @@ fn simulate_compute_values_failure(_: &PropertyValuePair) -> bool {
|
|||
|
||||
fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
||||
font_metrics_provider: &'a FontMetricsProvider,
|
||||
style: &'a ComputedValuesInner,
|
||||
parent_style: &'a Option<&ComputedValuesInner>)
|
||||
style: &'a ComputedValues,
|
||||
parent_style: Option<&'a ComputedValues>,
|
||||
pseudo: Option<&'a PseudoElement>)
|
||||
-> Context<'a> {
|
||||
let default_values = per_doc_data.default_computed_values();
|
||||
let inherited_style = parent_style.unwrap_or(default_values);
|
||||
|
@ -2905,8 +2896,7 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
|||
is_root_element: false,
|
||||
device: per_doc_data.stylist.device(),
|
||||
inherited_style: inherited_style,
|
||||
layout_parent_style: inherited_style,
|
||||
style: StyleBuilder::for_derived_style(&style),
|
||||
style: StyleBuilder::for_derived_style(per_doc_data.stylist.device(), style, pseudo),
|
||||
font_metrics_provider: font_metrics_provider,
|
||||
cached_system_font: None,
|
||||
in_media_query: false,
|
||||
|
@ -2917,7 +2907,7 @@ fn create_context<'a>(per_doc_data: &'a PerDocumentStyleDataImpl,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeListBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
style: ServoStyleContextBorrowed,
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
computed_keyframes: RawGeckoComputedKeyframeValuesListBorrowedMut)
|
||||
{
|
||||
|
@ -2926,13 +2916,15 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
|||
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
let pseudo = style.pseudo();
|
||||
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
|
@ -3001,18 +2993,20 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBlockBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
style: ServoStyleContextBorrowed,
|
||||
raw_data: RawServoStyleSetBorrowed,
|
||||
animation_values: RawGeckoServoAnimationValueListBorrowedMut) {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
let pseudo = style.pseudo();
|
||||
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||
|
||||
let default_values = data.default_computed_values();
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
|
@ -3029,18 +3023,20 @@ pub extern "C" fn Servo_GetAnimationValues(declarations: RawServoDeclarationBloc
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AnimationValue_Compute(element: RawGeckoElementBorrowed,
|
||||
declarations: RawServoDeclarationBlockBorrowed,
|
||||
style: ServoComputedValuesBorrowed,
|
||||
style: ServoStyleContextBorrowed,
|
||||
raw_data: RawServoStyleSetBorrowed)
|
||||
-> RawServoAnimationValueStrong {
|
||||
let data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let metrics = get_metrics_provider_for_product();
|
||||
let style = ComputedValues::as_arc(&style);
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let parent_element = element.inheritance_parent();
|
||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &***x);
|
||||
let parent_style = parent_data.as_ref().map(|d| d.styles.primary()).map(|x| &**x);
|
||||
|
||||
let mut context = create_context(&data, &metrics, style, &parent_style);
|
||||
let pseudo = style.pseudo();
|
||||
let mut context = create_context(&data, &metrics, style, parent_style, pseudo.as_ref());
|
||||
|
||||
let default_values = data.default_computed_values();
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
|
@ -3291,16 +3287,17 @@ pub extern "C" fn Servo_StyleSet_ResolveForDeclarations(
|
|||
let guards = StylesheetGuards::same(&guard);
|
||||
|
||||
let parent_style = match parent_style_context {
|
||||
Some(parent) => &**parent,
|
||||
Some(parent) => &*parent,
|
||||
None => doc_data.default_computed_values(),
|
||||
};
|
||||
|
||||
let declarations = Locked::<PropertyDeclarationBlock>::as_arc(&declarations);
|
||||
|
||||
doc_data.stylist.compute_for_declarations(&guards,
|
||||
parent_style,
|
||||
declarations.clone_arc(),
|
||||
parent_style_context).into_strong()
|
||||
doc_data.stylist.compute_for_declarations(
|
||||
&guards,
|
||||
parent_style,
|
||||
declarations.clone_arc(),
|
||||
).into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue