Auto merge of #13185 - nox:namespaces, r=jdm,Ms2ger

Make console a namespace (fixes #13010)

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13185)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-09-10 07:33:25 -05:00 committed by GitHub
commit 84f3cf22bf
16 changed files with 223 additions and 120 deletions

View file

@ -12,7 +12,7 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::reflector::Reflectable;
use dom::bindings::str::DOMString;
use dom::console::Console;
use dom::console::TimerSet;
use dom::crypto::Crypto;
use dom::dedicatedworkerglobalscope::DedicatedWorkerGlobalScope;
use dom::eventtarget::EventTarget;
@ -80,7 +80,6 @@ pub struct WorkerGlobalScope {
resource_threads: ResourceThreads,
location: MutNullableHeap<JS<WorkerLocation>>,
navigator: MutNullableHeap<JS<WorkerNavigator>>,
console: MutNullableHeap<JS<Console>>,
crypto: MutNullableHeap<JS<Crypto>>,
timers: OneshotTimers,
@ -110,6 +109,9 @@ pub struct WorkerGlobalScope {
#[ignore_heap_size_of = "Defined in std"]
scheduler_chan: IpcSender<TimerEventRequest>,
/// Timers used by the Console API.
console_timers: TimerSet,
}
impl WorkerGlobalScope {
@ -130,7 +132,6 @@ impl WorkerGlobalScope {
resource_threads: init.resource_threads,
location: Default::default(),
navigator: Default::default(),
console: Default::default(),
crypto: Default::default(),
timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan.clone()),
mem_profiler_chan: init.mem_profiler_chan,
@ -141,9 +142,14 @@ impl WorkerGlobalScope {
devtools_wants_updates: Cell::new(false),
constellation_chan: init.constellation_chan,
scheduler_chan: init.scheduler_chan,
console_timers: TimerSet::new(),
}
}
pub fn console_timers(&self) -> &TimerSet {
&self.console_timers
}
pub fn mem_profiler_chan(&self) -> &mem::ProfilerChan {
&self.mem_profiler_chan
}
@ -299,11 +305,6 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
self.navigator.or_init(|| WorkerNavigator::new(self))
}
// https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/console
fn Console(&self) -> Root<Console> {
self.console.or_init(|| Console::new(GlobalRef::Worker(self)))
}
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
fn Crypto(&self) -> Root<Crypto> {
self.crypto.or_init(|| Crypto::new(GlobalRef::Worker(self)))