diff options
author | Auguste Baum <52001167+augustebaum@users.noreply.github.com> | 2024-01-16 13:23:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-16 12:23:18 +0000 |
commit | 9654363c187ee549b82bca8c4e3098e4c20c7287 (patch) | |
tree | 83744130e3842433d89e1011fadc0f6db172aa2b /components/script/animation_timeline.rs | |
parent | c06ae7faf201e539a4cfbaefb6d5b8444796f472 (diff) | |
download | servo-9654363c187ee549b82bca8c4e3098e4c20c7287.tar.gz servo-9654363c187ee549b82bca8c4e3098e4c20c7287.zip |
script: Start replacing `time` with `std::time` and `chrono` (#30639)
* Replace `time` with `chrono` in `script/animation_timeline`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/script_thread.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` and `chrono` in `script/script_thread.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/script_runtime.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/script_runtime.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/workerglobalscope.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `chrono` in `script/dom/workerglobalscope.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/htmlmedialelement.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/htmlmedialelement.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/globalscope.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `chrono` in `script/dom/globalscope.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/htmlformelement.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Replace `time` with `std::time` in `script/dom/htmlformelement.rs`
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
* Increase precision of animation timeline
* Some fixes
Use Instant a bit more and stop using chrono. Do not transition
`navigation_start_precise` to Instant yet as we need to coordinate this
across all crates.
---------
Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
Diffstat (limited to 'components/script/animation_timeline.rs')
-rw-r--r-- | components/script/animation_timeline.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/components/script/animation_timeline.rs b/components/script/animation_timeline.rs index ea2a88af380..6cae2640cfa 100644 --- a/components/script/animation_timeline.rs +++ b/components/script/animation_timeline.rs @@ -7,8 +7,9 @@ //! A timeline module, used to specify an `AnimationTimeline` which determines //! the time used for synchronizing animations in the script thread. +use std::time::{SystemTime, UNIX_EPOCH}; + use jstraceable_derive::JSTraceable; -use time; /// A `AnimationTimeline` which is used to synchronize animations during the script /// event loop. @@ -22,7 +23,10 @@ impl AnimationTimeline { #[inline] pub fn new() -> Self { Self { - current_value: time::precise_time_s(), + current_value: SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs_f64(), } } @@ -39,7 +43,10 @@ impl AnimationTimeline { /// Updates the value of the `AnimationTimeline` to the current clock time. pub fn update(&mut self) { - self.current_value = time::precise_time_s(); + self.current_value = SystemTime::now() + .duration_since(UNIX_EPOCH) + .unwrap_or_default() + .as_secs_f64(); } /// Increments the current value of the timeline by a specific number of seconds. |