mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
Add a function that returns a base computed values (i.e. computed values without any animations rules).
This base value will be used for additive, accumulative animations and also SMIL.
This commit is contained in:
parent
2c0b821564
commit
fb6aceba31
2 changed files with 58 additions and 0 deletions
|
@ -1210,6 +1210,34 @@ pub trait MatchMethods : TElement {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns computed values without animation and transition rules.
|
||||
fn get_base_style(&self,
|
||||
shared_context: &SharedStyleContext,
|
||||
primary_style: &ComputedStyle,
|
||||
pseudo_style: &Option<(&PseudoElement, &ComputedStyle)>)
|
||||
-> Arc<ComputedValues> {
|
||||
let style = &pseudo_style.as_ref().map_or(primary_style, |p| &*p.1);
|
||||
let rule_node = &style.rules;
|
||||
let without_animation_rules =
|
||||
shared_context.stylist.rule_tree.remove_animation_and_transition_rules(rule_node);
|
||||
if without_animation_rules == *rule_node {
|
||||
// Note that unwrapping here is fine, because the style is
|
||||
// only incomplete during the styling process.
|
||||
return style.values.as_ref().unwrap().clone();
|
||||
}
|
||||
|
||||
let mut cascade_flags = CascadeFlags::empty();
|
||||
if self.skip_root_and_item_based_display_fixup() {
|
||||
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
|
||||
}
|
||||
self.cascade_with_rules(shared_context,
|
||||
&without_animation_rules,
|
||||
primary_style,
|
||||
cascade_flags,
|
||||
pseudo_style.is_some())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
impl<E: TElement> MatchMethods for E {}
|
||||
|
|
|
@ -310,6 +310,36 @@ pub extern "C" fn Servo_AnimationValue_DeepEqual(this: RawServoAnimationValueBor
|
|||
this_value == other_value
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleSet_GetBaseComputedValuesForElement(raw_data: RawServoStyleSetBorrowed,
|
||||
element: RawGeckoElementBorrowed,
|
||||
pseudo_tag: *mut nsIAtom)
|
||||
-> ServoComputedValuesStrong
|
||||
{
|
||||
use style::matching::MatchMethods;
|
||||
|
||||
let doc_data = PerDocumentStyleData::from_ffi(raw_data).borrow();
|
||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||
let guard = global_style_data.shared_lock.read();
|
||||
let shared_context = &create_shared_context(&guard, &doc_data, false);
|
||||
|
||||
let element = GeckoElement(element);
|
||||
let element_data = element.borrow_data().unwrap();
|
||||
let styles = element_data.styles();
|
||||
|
||||
let pseudo = if pseudo_tag.is_null() {
|
||||
None
|
||||
} else {
|
||||
let atom = Atom::from(pseudo_tag);
|
||||
Some(PseudoElement::from_atom_unchecked(atom, /* anon_box = */ false))
|
||||
};
|
||||
let pseudos = &styles.pseudos;
|
||||
let pseudo_style = pseudo.as_ref().map(|p| (p, pseudos.get(p).unwrap()));
|
||||
|
||||
element.get_base_style(shared_context, &styles.primary, &pseudo_style)
|
||||
.into_strong()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_StyleWorkerThreadCount() -> u32 {
|
||||
GLOBAL_STYLE_DATA.num_threads as u32
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue