mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Introduce GlobalScope::crypto
This commit is contained in:
parent
fcb59d3057
commit
38273fe7a8
3 changed files with 10 additions and 6 deletions
|
@ -2,19 +2,23 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
use dom::bindings::js::{JS, MutNullableHeap, Root};
|
||||||
use dom::bindings::reflector::Reflectable;
|
use dom::bindings::reflector::Reflectable;
|
||||||
|
use dom::crypto::Crypto;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
|
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
|
||||||
|
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct GlobalScope {
|
pub struct GlobalScope {
|
||||||
eventtarget: EventTarget,
|
eventtarget: EventTarget,
|
||||||
|
crypto: MutNullableHeap<JS<Crypto>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalScope {
|
impl GlobalScope {
|
||||||
pub fn new_inherited() -> GlobalScope {
|
pub fn new_inherited() -> GlobalScope {
|
||||||
GlobalScope {
|
GlobalScope {
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
|
crypto: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,4 +33,8 @@ impl GlobalScope {
|
||||||
context
|
context
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn crypto(&self) -> Root<Crypto> {
|
||||||
|
self.crypto.or_init(|| Crypto::new(self))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,6 @@ pub struct Window {
|
||||||
history_traversal_task_source: HistoryTraversalTaskSource,
|
history_traversal_task_source: HistoryTraversalTaskSource,
|
||||||
#[ignore_heap_size_of = "task sources are hard"]
|
#[ignore_heap_size_of = "task sources are hard"]
|
||||||
file_reading_task_source: FileReadingTaskSource,
|
file_reading_task_source: FileReadingTaskSource,
|
||||||
crypto: MutNullableHeap<JS<Crypto>>,
|
|
||||||
navigator: MutNullableHeap<JS<Navigator>>,
|
navigator: MutNullableHeap<JS<Navigator>>,
|
||||||
#[ignore_heap_size_of = "channels are hard"]
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
image_cache_thread: ImageCacheThread,
|
image_cache_thread: ImageCacheThread,
|
||||||
|
@ -505,7 +504,7 @@ impl WindowMethods for Window {
|
||||||
|
|
||||||
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto
|
// https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#dfn-GlobalCrypto
|
||||||
fn Crypto(&self) -> Root<Crypto> {
|
fn Crypto(&self) -> Root<Crypto> {
|
||||||
self.crypto.or_init(|| Crypto::new(self.upcast()))
|
self.upcast::<GlobalScope>().crypto()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-frameelement
|
// https://html.spec.whatwg.org/multipage/#dom-frameelement
|
||||||
|
@ -1638,7 +1637,6 @@ impl Window {
|
||||||
history_traversal_task_source: history_task_source,
|
history_traversal_task_source: history_task_source,
|
||||||
file_reading_task_source: file_task_source,
|
file_reading_task_source: file_task_source,
|
||||||
image_cache_chan: image_cache_chan,
|
image_cache_chan: image_cache_chan,
|
||||||
crypto: Default::default(),
|
|
||||||
navigator: Default::default(),
|
navigator: Default::default(),
|
||||||
image_cache_thread: image_cache_thread,
|
image_cache_thread: image_cache_thread,
|
||||||
mem_profiler_chan: mem_profiler_chan,
|
mem_profiler_chan: mem_profiler_chan,
|
||||||
|
|
|
@ -89,7 +89,6 @@ pub struct WorkerGlobalScope {
|
||||||
resource_threads: ResourceThreads,
|
resource_threads: ResourceThreads,
|
||||||
location: MutNullableHeap<JS<WorkerLocation>>,
|
location: MutNullableHeap<JS<WorkerLocation>>,
|
||||||
navigator: MutNullableHeap<JS<WorkerNavigator>>,
|
navigator: MutNullableHeap<JS<WorkerNavigator>>,
|
||||||
crypto: MutNullableHeap<JS<Crypto>>,
|
|
||||||
timers: OneshotTimers,
|
timers: OneshotTimers,
|
||||||
|
|
||||||
#[ignore_heap_size_of = "Defined in std"]
|
#[ignore_heap_size_of = "Defined in std"]
|
||||||
|
@ -147,7 +146,6 @@ impl WorkerGlobalScope {
|
||||||
resource_threads: init.resource_threads,
|
resource_threads: init.resource_threads,
|
||||||
location: Default::default(),
|
location: Default::default(),
|
||||||
navigator: Default::default(),
|
navigator: Default::default(),
|
||||||
crypto: Default::default(),
|
|
||||||
timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan.clone()),
|
timers: OneshotTimers::new(timer_event_chan, init.scheduler_chan.clone()),
|
||||||
mem_profiler_chan: init.mem_profiler_chan,
|
mem_profiler_chan: init.mem_profiler_chan,
|
||||||
time_profiler_chan: init.time_profiler_chan,
|
time_profiler_chan: init.time_profiler_chan,
|
||||||
|
@ -343,7 +341,7 @@ impl WorkerGlobalScopeMethods for WorkerGlobalScope {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
|
// https://html.spec.whatwg.org/multipage/#dfn-Crypto
|
||||||
fn Crypto(&self) -> Root<Crypto> {
|
fn Crypto(&self) -> Root<Crypto> {
|
||||||
self.crypto.or_init(|| Crypto::new(self.upcast()))
|
self.upcast::<GlobalScope>().crypto()
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
// https://html.spec.whatwg.org/multipage/#dom-windowbase64-btoa
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue