mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Set restyle subtree restyle hint if the element animates display style from 'none' to other.
When display style is changed from 'none' to other in animation-only restyle we need to resolve descendant elements' style that were in the display:none subtree. Three possible ways to resolve the descendant elements' style; 1) Traversing unstyled elements in animation-only restyle We can't simply traverse unstyled elements in the animation-only restyle since when we decided to traverse the unstyled elements we don't know yet the elements will be initially styled or are in display:none subtree. It will result that the new elements are styled in animation-only restyle, it's undesirable. 2) Creating a SequentialTask and resolve the descendants' style with ServoStyleSet::StyleNewSubtree() We can't resolve the descendants' styles with ServoStyleSet::StyleNewSubtree() in SequentialTask since at the moment we are still in servo traversal (i.e. sInServoTraversal is true). That means AutoSetInServoTraversal fails in PrepareAndTraverseSubtree(). 3) Creating a SequentialTask and set restyle subtree hint and defer descendants' restyle in a subsequent normal traversal Note that, when we process throttled animations flush, we don't process normal traversal so the descendants will not be traversed until normal restyle happens but it will not be a big problem since it's really rare that user clicks display animation element just at the right moment when display property changes from none to other. Also, if it will be really a problem, we should process *only* transform animations on the compositor, it's ideally right thing to do. Display property never runs on the compositor. This patch takes the third approach.
This commit is contained in:
parent
ffc01687e4
commit
0841db70ee
4 changed files with 119 additions and 10 deletions
|
@ -409,7 +409,7 @@ impl TraversalStatistics {
|
|||
#[cfg(feature = "gecko")]
|
||||
bitflags! {
|
||||
/// Represents which tasks are performed in a SequentialTask of
|
||||
/// UpdateAnimations.
|
||||
/// UpdateAnimations which is a result of normal restyle.
|
||||
pub flags UpdateAnimationsTasks: u8 {
|
||||
/// Update CSS Animations.
|
||||
const CSS_ANIMATIONS = structs::UpdateAnimationsTasks_CSSAnimations,
|
||||
|
@ -422,6 +422,18 @@ bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
bitflags! {
|
||||
/// Represents which tasks are performed in a SequentialTask as a result of
|
||||
/// animation-only restyle.
|
||||
pub flags PostAnimationTasks: u8 {
|
||||
/// Display property was changed from none in animation-only restyle so
|
||||
/// that we need to resolve styles for descendants in a subsequent
|
||||
/// normal restyle.
|
||||
const DISPLAY_CHANGED_FROM_NONE_FOR_SMIL = 0x01,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// A task to be run in sequential mode on the parent (non-worker) thread. This
|
||||
/// is used by the style system to queue up work which is not safe to do during
|
||||
|
@ -443,6 +455,17 @@ pub enum SequentialTask<E: TElement> {
|
|||
/// The tasks which are performed in this SequentialTask.
|
||||
tasks: UpdateAnimationsTasks
|
||||
},
|
||||
|
||||
/// Performs one of a number of possible tasks as a result of animation-only restyle.
|
||||
/// Currently we do only process for resolving descendant elements that were display:none
|
||||
/// subtree for SMIL animation.
|
||||
#[cfg(feature = "gecko")]
|
||||
PostAnimation {
|
||||
/// The target element.
|
||||
el: SendElement<E>,
|
||||
/// The tasks which are performed in this SequentialTask.
|
||||
tasks: PostAnimationTasks
|
||||
},
|
||||
}
|
||||
|
||||
impl<E: TElement> SequentialTask<E> {
|
||||
|
@ -456,6 +479,10 @@ impl<E: TElement> SequentialTask<E> {
|
|||
UpdateAnimations { el, before_change_style, tasks } => {
|
||||
unsafe { el.update_animations(before_change_style, tasks) };
|
||||
}
|
||||
#[cfg(feature = "gecko")]
|
||||
PostAnimation { el, tasks } => {
|
||||
unsafe { el.process_post_animation(tasks) };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -472,6 +499,17 @@ impl<E: TElement> SequentialTask<E> {
|
|||
tasks: tasks,
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a task to do post-process for a given element as a result of
|
||||
/// animation-only restyle.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn process_post_animation(el: E, tasks: PostAnimationTasks) -> Self {
|
||||
use self::SequentialTask::*;
|
||||
PostAnimation {
|
||||
el: unsafe { SendElement::new(el) },
|
||||
tasks: tasks,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Map from Elements to ElementSelectorFlags. Used to defer applying selector
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue