mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Use MutNullableJS::or_init in Window.
This commit is contained in:
parent
c66cefa313
commit
d9993ebcc3
1 changed files with 7 additions and 32 deletions
|
@ -10,7 +10,7 @@ use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
use dom::bindings::codegen::InheritTypes::EventTargetCast;
|
||||||
use dom::bindings::error::{Fallible, InvalidCharacter};
|
use dom::bindings::error::{Fallible, InvalidCharacter};
|
||||||
use dom::bindings::global;
|
use dom::bindings::global;
|
||||||
use dom::bindings::js::{MutNullableJS, JSRef, Temporary, OptionalSettable};
|
use dom::bindings::js::{MutNullableJS, JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::browsercontext::BrowserContext;
|
use dom::browsercontext::BrowserContext;
|
||||||
use dom::console::Console;
|
use dom::console::Console;
|
||||||
|
@ -207,36 +207,19 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Location(self) -> Temporary<Location> {
|
fn Location(self) -> Temporary<Location> {
|
||||||
if self.location.get().is_none() {
|
self.location.or_init(|| Location::new(self, self.page.clone()))
|
||||||
let page = self.page.clone();
|
|
||||||
let location = Location::new(self, page);
|
|
||||||
self.location.assign(Some(location));
|
|
||||||
}
|
|
||||||
self.location.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SessionStorage(self) -> Temporary<Storage> {
|
fn SessionStorage(self) -> Temporary<Storage> {
|
||||||
if self.session_storage.get().is_none() {
|
self.session_storage.or_init(|| Storage::new(&global::Window(self)))
|
||||||
let session_storage = Storage::new(&global::Window(self));
|
|
||||||
self.session_storage.assign(Some(session_storage));
|
|
||||||
}
|
|
||||||
self.session_storage.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Console(self) -> Temporary<Console> {
|
fn Console(self) -> Temporary<Console> {
|
||||||
if self.console.get().is_none() {
|
self.console.or_init(|| Console::new(global::Window(self)))
|
||||||
let console = Console::new(global::Window(self));
|
|
||||||
self.console.assign(Some(console));
|
|
||||||
}
|
|
||||||
self.console.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Navigator(self) -> Temporary<Navigator> {
|
fn Navigator(self) -> Temporary<Navigator> {
|
||||||
if self.navigator.get().is_none() {
|
self.navigator.or_init(|| Navigator::new(self))
|
||||||
let navigator = Navigator::new(self);
|
|
||||||
self.navigator.assign(Some(navigator));
|
|
||||||
}
|
|
||||||
self.navigator.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetTimeout(self, _cx: *mut JSContext, callback: Function, timeout: i32, args: Vec<JSVal>) -> i32 {
|
fn SetTimeout(self, _cx: *mut JSContext, callback: Function, timeout: i32, args: Vec<JSVal>) -> i32 {
|
||||||
|
@ -284,11 +267,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Performance(self) -> Temporary<Performance> {
|
fn Performance(self) -> Temporary<Performance> {
|
||||||
if self.performance.get().is_none() {
|
self.performance.or_init(|| Performance::new(self))
|
||||||
let performance = Performance::new(self);
|
|
||||||
self.performance.assign(Some(performance));
|
|
||||||
}
|
|
||||||
self.performance.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event_handler!(click, GetOnclick, SetOnclick)
|
event_handler!(click, GetOnclick, SetOnclick)
|
||||||
|
@ -297,11 +276,7 @@ impl<'a> WindowMethods for JSRef<'a, Window> {
|
||||||
error_event_handler!(error, GetOnerror, SetOnerror)
|
error_event_handler!(error, GetOnerror, SetOnerror)
|
||||||
|
|
||||||
fn Screen(self) -> Temporary<Screen> {
|
fn Screen(self) -> Temporary<Screen> {
|
||||||
if self.screen.get().is_none() {
|
self.screen.or_init(|| Screen::new(self))
|
||||||
let screen = Screen::new(self);
|
|
||||||
self.screen.assign(Some(screen));
|
|
||||||
}
|
|
||||||
self.screen.get().unwrap()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Debug(self, message: DOMString) {
|
fn Debug(self, message: DOMString) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue