mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Start having animations conform to the HTML spec
This is a small step toward fixing #19242. The main idea is that the clock for animations should advance as the event loop ticks. We accomplish this by moving the clock from layout and naming it the "animation timeline" which is the spec language. This should fix flakiness with animations and transitions tests where a reflow could move animations forward while script was running. This change also starts to break out transition and animation events into their own data structure, because it's quite likely that the next step in fixing #19242 is to no longer send these events through a channel.
This commit is contained in:
parent
b585ce5b1f
commit
3a74013abc
45 changed files with 159 additions and 2094 deletions
|
@ -2,6 +2,7 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use crate::animation_timeline::AnimationTimeline;
|
||||
use crate::document_loader::{DocumentLoader, LoadType};
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::beforeunloadevent::BeforeUnloadEvent;
|
||||
|
@ -380,6 +381,9 @@ pub struct Document {
|
|||
csp_list: DomRefCell<Option<CspList>>,
|
||||
/// https://w3c.github.io/slection-api/#dfn-selection
|
||||
selection: MutNullableDom<Selection>,
|
||||
/// A timeline for animations which is used for synchronizing animations.
|
||||
/// https://drafts.csswg.org/web-animations/#timeline
|
||||
animation_timeline: DomRefCell<AnimationTimeline>,
|
||||
}
|
||||
|
||||
#[derive(JSTraceable, MallocSizeOf)]
|
||||
|
@ -2904,6 +2908,11 @@ impl Document {
|
|||
dirty_webgl_contexts: DomRefCell::new(HashMap::new()),
|
||||
csp_list: DomRefCell::new(None),
|
||||
selection: MutNullableDom::new(None),
|
||||
animation_timeline: if pref!(layout.animations.test.enabled) {
|
||||
DomRefCell::new(AnimationTimeline::new_for_testing())
|
||||
} else {
|
||||
DomRefCell::new(AnimationTimeline::new())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3605,6 +3614,18 @@ impl Document {
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn advance_animation_timeline_for_testing(&self, delta: f64) {
|
||||
self.animation_timeline.borrow_mut().advance_specific(delta);
|
||||
}
|
||||
|
||||
pub fn update_animation_timeline(&self) {
|
||||
self.animation_timeline.borrow_mut().update();
|
||||
}
|
||||
|
||||
pub fn current_animation_timeline_value(&self) -> f64 {
|
||||
self.animation_timeline.borrow().current_value()
|
||||
}
|
||||
}
|
||||
|
||||
impl Element {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue