mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
script: Stop using time
in DOM timers (#33262)
This switches to using `std::time` types for DOM timer operations, which allows removing our custom time units in favor of `Duration`. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
8a0c7487e7
commit
a4ceb82ef5
13 changed files with 78 additions and 106 deletions
|
@ -18,6 +18,7 @@ use std::borrow::Cow;
|
|||
use std::collections::{HashMap, VecDeque};
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use background_hang_monitor_api::BackgroundHangMonitorRegister;
|
||||
use base::id::{
|
||||
|
@ -32,7 +33,7 @@ use crossbeam_channel::{RecvTimeoutError, Sender};
|
|||
use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId};
|
||||
use embedder_traits::CompositorEventVariant;
|
||||
use euclid::default::Point2D;
|
||||
use euclid::{Length, Rect, Scale, Size2D, UnknownUnit, Vector2D};
|
||||
use euclid::{Rect, Scale, Size2D, UnknownUnit, Vector2D};
|
||||
use http::{HeaderMap, Method};
|
||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||
use ipc_channel::Error as IpcError;
|
||||
|
@ -577,7 +578,7 @@ pub struct TimerEventRequest(
|
|||
pub IpcSender<TimerEvent>,
|
||||
pub TimerSource,
|
||||
pub TimerEventId,
|
||||
pub MsDuration,
|
||||
pub Duration,
|
||||
);
|
||||
|
||||
/// The message used to send a request to the timer scheduler.
|
||||
|
@ -603,23 +604,6 @@ pub enum TimerSource {
|
|||
#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub struct TimerEventId(pub u32);
|
||||
|
||||
/// Unit of measurement.
|
||||
#[derive(Clone, Copy, MallocSizeOf)]
|
||||
pub enum Milliseconds {}
|
||||
/// Unit of measurement.
|
||||
#[derive(Clone, Copy, MallocSizeOf)]
|
||||
pub enum Nanoseconds {}
|
||||
|
||||
/// Amount of milliseconds.
|
||||
pub type MsDuration = Length<u64, Milliseconds>;
|
||||
/// Amount of nanoseconds.
|
||||
pub type NsDuration = Length<u64, Nanoseconds>;
|
||||
|
||||
/// Returns the duration since an unspecified epoch measured in ms.
|
||||
pub fn precise_time_ms() -> MsDuration {
|
||||
Length::new(time::precise_time_ns() / (1000 * 1000))
|
||||
}
|
||||
|
||||
/// Data needed to construct a script thread.
|
||||
///
|
||||
/// NB: *DO NOT* add any Senders or Receivers here! pcwalton will have to rewrite your code if you
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue