mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Put computed values into AnimationValueMap instead of hashtable in gecko.
Before this patch, we store each computed values in a hashtable, nsRefPtrHashtable<nsUint32HashKey, RawServoAnimationValue>, for all KeyframeEffectReadOnly on an element, and convert the ServoAnimationValues of the hashtable into an nsTArray<ServoAnimationValue*> and then convert the ServoAnimationValues of the nsTArray into PropertyDeclarationBlock in rust. This way was really inefficient. In this patch, we store the computed values into AnimationValueMap and convert all AnimationValue in the map into PropertyDeclarationBlock after EffectCompositor::GetAnimationRule.
This commit is contained in:
parent
c0baac4194
commit
b210813124
5 changed files with 41 additions and 12 deletions
|
@ -46,6 +46,7 @@ use parking_lot::RwLock;
|
|||
use parser::ParserContextExtraData;
|
||||
use properties::{ComputedValues, parse_style_attribute};
|
||||
use properties::PropertyDeclarationBlock;
|
||||
use properties::animated_properties::AnimationValueMap;
|
||||
use rule_tree::CascadeLevel as ServoCascadeLevel;
|
||||
use selector_parser::{ElementExt, Snapshot};
|
||||
use selectors::Element;
|
||||
|
@ -403,6 +404,20 @@ fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
|
|||
gecko_flags
|
||||
}
|
||||
|
||||
fn get_animation_rule(element: &GeckoElement,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
cascade_level: CascadeLevel)
|
||||
-> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
|
||||
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
|
||||
let animation_values = Arc::new(RwLock::new(AnimationValueMap::new()));
|
||||
if unsafe { Gecko_GetAnimationRule(element.0, atom_ptr, cascade_level,
|
||||
HasArcFFI::arc_as_borrowed(&animation_values)) } {
|
||||
Some(Arc::new(RwLock::new(PropertyDeclarationBlock::from_animation_value_map(&animation_values.read()))))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
impl<'le> TElement for GeckoElement<'le> {
|
||||
type ConcreteNode = GeckoNode<'le>;
|
||||
|
||||
|
@ -422,14 +437,12 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
|
||||
fn get_animation_rule(&self, pseudo: Option<&PseudoElement>)
|
||||
-> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
|
||||
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
|
||||
unsafe { Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Animations).into_arc_opt() }
|
||||
get_animation_rule(self, pseudo, CascadeLevel::Animations)
|
||||
}
|
||||
|
||||
fn get_transition_rule(&self, pseudo: Option<&PseudoElement>)
|
||||
-> Option<Arc<RwLock<PropertyDeclarationBlock>>> {
|
||||
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
|
||||
unsafe { Gecko_GetAnimationRule(self.0, atom_ptr, CascadeLevel::Transitions).into_arc_opt() }
|
||||
get_animation_rule(self, pseudo, CascadeLevel::Transitions)
|
||||
}
|
||||
|
||||
fn get_state(&self) -> ElementState {
|
||||
|
|
|
@ -582,8 +582,10 @@ extern "C" {
|
|||
pub fn Gecko_GetAnimationRule(aElement: RawGeckoElementBorrowed,
|
||||
aPseudoTag: *mut nsIAtom,
|
||||
aCascadeLevel:
|
||||
EffectCompositor_CascadeLevel)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
EffectCompositor_CascadeLevel,
|
||||
aAnimationValues:
|
||||
RawServoAnimationValueMapBorrowed)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_StyleAnimationsEquals(arg1:
|
||||
|
@ -1496,6 +1498,13 @@ extern "C" {
|
|||
result:
|
||||
RawGeckoComputedKeyframeValuesListBorrowedMut);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValueMap_Push(arg1:
|
||||
RawServoAnimationValueMapBorrowed,
|
||||
property: nsCSSPropertyID,
|
||||
value:
|
||||
RawServoAnimationValueBorrowed);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_AnimationValues_Interpolate(from:
|
||||
RawServoAnimationValueBorrowed,
|
||||
|
|
|
@ -8214,9 +8214,6 @@ pub mod root {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ServoAnimationRule([u8; 0]);
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AnimationPerformanceWarning([u8; 0]);
|
||||
pub type CSSPseudoClassTypeBase = u8;
|
||||
#[repr(u8)]
|
||||
|
|
|
@ -8026,9 +8026,6 @@ pub mod root {
|
|||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct ServoAnimationRule([u8; 0]);
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct AnimationPerformanceWarning([u8; 0]);
|
||||
pub type CSSPseudoClassTypeBase = u8;
|
||||
#[repr(u8)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue