Script: removed a few opts::get()

This commit is contained in:
oneturkmen 2019-06-07 23:38:01 -06:00
parent 57205318c5
commit 42569280e2
17 changed files with 238 additions and 45 deletions

View file

@ -58,6 +58,7 @@ use profile_traits::{mem as profile_mem, time as profile_time};
use script_traits::{MsDuration, ScriptToConstellationChan, TimerEvent};
use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource};
use servo_url::{MutableOrigin, ServoUrl};
use std::borrow::Cow;
use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
@ -157,6 +158,12 @@ pub struct GlobalScope {
/// <https://html.spec.whatwg.org/multipage/#outstanding-rejected-promises-weak-set>
#[ignore_malloc_size_of = "mozjs"]
consumed_rejections: DomRefCell<Vec<Box<Heap<*mut JSObject>>>>,
/// True if headless mode.
is_headless: bool,
/// An optional string allowing the user agent to be set for testing.
user_agent: Cow<'static, str>,
}
impl GlobalScope {
@ -171,6 +178,8 @@ impl GlobalScope {
timer_event_chan: IpcSender<TimerEvent>,
origin: MutableOrigin,
microtask_queue: Rc<MicrotaskQueue>,
is_headless: bool,
user_agent: Cow<'static, str>,
) -> Self {
Self {
eventtarget: EventTarget::new_inherited(),
@ -193,6 +202,8 @@ impl GlobalScope {
event_source_tracker: DOMTracker::new(),
uncaught_rejections: Default::default(),
consumed_rejections: Default::default(),
is_headless,
user_agent,
}
}
@ -799,6 +810,14 @@ impl GlobalScope {
}
unreachable!();
}
pub fn is_headless(&self) -> bool {
self.is_headless
}
pub fn get_user_agent(&self) -> Cow<'static, str> {
self.user_agent.clone()
}
}
fn timestamp_in_ms(time: Timespec) -> u64 {