aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/globalscope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r--components/script/dom/globalscope.rs14
1 files changed, 5 insertions, 9 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 6a1467d7076..c78d24c7e8f 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -11,6 +11,7 @@ use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread::JoinHandle;
+use std::time::Instant;
use std::{mem, ptr};
use content_security_policy::CspList;
@@ -54,7 +55,6 @@ use script_traits::{
ScriptToConstellationChan, TimerEvent, TimerEventId, TimerSchedulerMsg, TimerSource,
};
use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl};
-use time::{get_time, Timespec};
use uuid::Uuid;
use webgpu::identity::WebGPUOpResult;
use webgpu::{ErrorScopeId, WebGPUDevice};
@@ -203,8 +203,8 @@ pub struct GlobalScope {
/// live updates from the worker.
devtools_wants_updates: Cell<bool>,
- /// Timers used by the Console API.
- console_timers: DomRefCell<HashMap<DOMString, u64>>,
+ /// Timers (milliseconds) used by the Console API.
+ console_timers: DomRefCell<HashMap<DOMString, Instant>>,
/// module map is used when importing JavaScript modules
/// https://html.spec.whatwg.org/multipage/#concept-settings-object-module-map
@@ -2262,7 +2262,7 @@ impl GlobalScope {
}
match timers.entry(label) {
Entry::Vacant(entry) => {
- entry.insert(timestamp_in_ms(get_time()));
+ entry.insert(Instant::now());
Ok(())
},
Entry::Occupied(_) => Err(()),
@@ -2274,7 +2274,7 @@ impl GlobalScope {
.borrow_mut()
.remove(label)
.ok_or(())
- .map(|start| timestamp_in_ms(get_time()) - start)
+ .map(|start| (Instant::now() - start).as_millis() as u64)
}
/// Get an `&IpcSender<ScriptToDevtoolsControlMsg>` to send messages
@@ -3111,10 +3111,6 @@ impl GlobalScope {
}
}
-fn timestamp_in_ms(time: Timespec) -> u64 {
- (time.sec * 1000 + (time.nsec / 1000000) as i64) as u64
-}
-
/// Returns the Rust global scope from a JS global object.
#[allow(unsafe_code)]
unsafe fn global_scope_from_global(