mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Add animation and transition support for pseudo-elements
This change extends the DocumentAnimationSet to hold animations for pseudo-elements. Since pseudo-elements in Servo are not in the DOM like in Gecko, they need to be handled a bit carefully in stylo. When a pseudo-element has an animation, recascade the style. Finally, this change passes the pseudo-element string properly to animation events. Fixes: #10316
This commit is contained in:
parent
ba5568a0a6
commit
f3e373bc62
19 changed files with 359 additions and 138 deletions
|
@ -484,7 +484,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
let node = self.as_node();
|
||||
let document = node.owner_doc();
|
||||
context.animations.get_animation_declarations(
|
||||
&AnimationSetKey(node.opaque()),
|
||||
&AnimationSetKey::new_for_non_pseudo(node.opaque()),
|
||||
context.current_time_for_animations,
|
||||
document.style_shared_lock(),
|
||||
)
|
||||
|
@ -497,7 +497,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
let node = self.as_node();
|
||||
let document = node.owner_doc();
|
||||
context.animations.get_transition_declarations(
|
||||
&AnimationSetKey(node.opaque()),
|
||||
&AnimationSetKey::new_for_non_pseudo(node.opaque()),
|
||||
context.current_time_for_animations,
|
||||
document.style_shared_lock(),
|
||||
)
|
||||
|
@ -621,16 +621,26 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
fn has_animations(&self, context: &SharedStyleContext) -> bool {
|
||||
return self.has_css_animations(context) || self.has_css_transitions(context);
|
||||
// This is not used for pseudo elements currently so we can pass None.
|
||||
return self.has_css_animations(context, /* pseudo_element = */ None) ||
|
||||
self.has_css_transitions(context, /* pseudo_element = */ None);
|
||||
}
|
||||
|
||||
fn has_css_animations(&self, context: &SharedStyleContext) -> bool {
|
||||
let key = AnimationSetKey(self.as_node().opaque());
|
||||
fn has_css_animations(
|
||||
&self,
|
||||
context: &SharedStyleContext,
|
||||
pseudo_element: Option<PseudoElement>,
|
||||
) -> bool {
|
||||
let key = AnimationSetKey::new(self.as_node().opaque(), pseudo_element);
|
||||
context.animations.has_active_animations(&key)
|
||||
}
|
||||
|
||||
fn has_css_transitions(&self, context: &SharedStyleContext) -> bool {
|
||||
let key = AnimationSetKey(self.as_node().opaque());
|
||||
fn has_css_transitions(
|
||||
&self,
|
||||
context: &SharedStyleContext,
|
||||
pseudo_element: Option<PseudoElement>,
|
||||
) -> bool {
|
||||
let key = AnimationSetKey::new(self.as_node().opaque(), pseudo_element);
|
||||
context.animations.has_active_transitions(&key)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue