diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-05-12 07:08:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-12 07:08:50 -0400 |
commit | c5617efff0f77ce79a7827668cf929def2d9337a (patch) | |
tree | b2427a9f19befc3017860053d3a416fda3d87275 /components/script/dom/document.rs | |
parent | aa9f16ce45f6eb22ffd5bc6a10802ded4cc2319b (diff) | |
parent | 3b0619aedd967238091367f6e03dabf262e116ad (diff) | |
download | servo-c5617efff0f77ce79a7827668cf929def2d9337a.tar.gz servo-c5617efff0f77ce79a7827668cf929def2d9337a.zip |
Auto merge of #26464 - mrobinson:move-animations-to-script, r=jdm
Move most animation processing to script
This is preparation for sharing this code with layout_2020 and
implementing selective off-the-main-thread animations.
We still look for nodes not in the flow tree in the layout thread.
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes do not require tests because they should not change behavior.
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 5e40f433da5..86c5b1caaa1 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use crate::animation_timeline::AnimationTimeline; +use crate::animations::{Animations, AnimationsUpdate}; use crate::document_loader::{DocumentLoader, LoadType}; use crate::dom::attr::Attr; use crate::dom::beforeunloadevent::BeforeUnloadEvent; @@ -384,6 +385,8 @@ pub struct Document { /// A timeline for animations which is used for synchronizing animations. /// https://drafts.csswg.org/web-animations/#timeline animation_timeline: DomRefCell<AnimationTimeline>, + /// Animations for this Document + animations: DomRefCell<Animations>, } #[derive(JSTraceable, MallocSizeOf)] @@ -2913,6 +2916,7 @@ impl Document { } else { DomRefCell::new(AnimationTimeline::new()) }, + animations: DomRefCell::new(Animations::new()), } } @@ -3615,17 +3619,27 @@ impl Document { .collect() } - pub fn advance_animation_timeline_for_testing(&self, delta: f64) { + pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) { self.animation_timeline.borrow_mut().advance_specific(delta); } - pub fn update_animation_timeline(&self) { + pub(crate) fn update_animation_timeline(&self) { self.animation_timeline.borrow_mut().update(); } - pub fn current_animation_timeline_value(&self) -> f64 { + pub(crate) fn current_animation_timeline_value(&self) -> f64 { self.animation_timeline.borrow().current_value() } + + pub(crate) fn animations(&self) -> Ref<Animations> { + self.animations.borrow() + } + + pub(crate) fn update_animations(&self) -> AnimationsUpdate { + self.animations + .borrow_mut() + .do_post_reflow_update(&self.window, self.current_animation_timeline_value()) + } } impl Element { |