mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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
|
||||
* 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::crypto::Crypto;
|
||||
use dom::eventtarget::EventTarget;
|
||||
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct GlobalScope {
|
||||
eventtarget: EventTarget,
|
||||
crypto: MutNullableHeap<JS<Crypto>>,
|
||||
}
|
||||
|
||||
impl GlobalScope {
|
||||
pub fn new_inherited() -> GlobalScope {
|
||||
GlobalScope {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
crypto: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,4 +33,8 @@ impl GlobalScope {
|
|||
context
|
||||
}
|
||||
}
|
||||
|
||||
pub fn crypto(&self) -> Root<Crypto> {
|
||||
self.crypto.or_init(|| Crypto::new(self))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue