diff options
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r-- | components/script/dom/window.rs | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 6df91312931..c97a3fd08fb 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -615,26 +615,28 @@ impl WindowMethods for Window { #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-opener - unsafe fn Opener(&self, cx: *mut JSContext) -> JSVal { - self.window_proxy().opener(cx) + fn Opener(&self, cx: SafeJSContext) -> JSVal { + unsafe { self.window_proxy().opener(*cx) } } #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-opener - unsafe fn SetOpener(&self, cx: *mut JSContext, value: HandleValue) { + fn SetOpener(&self, cx: SafeJSContext, value: HandleValue) { // Step 1. if value.is_null() { return self.window_proxy().disown(); } // Step 2. let obj = self.reflector().get_jsobject(); - assert!(JS_DefineProperty( - cx, - obj, - "opener\0".as_ptr() as *const libc::c_char, - value, - JSPROP_ENUMERATE as u32 - )); + unsafe { + assert!(JS_DefineProperty( + *cx, + obj, + "opener\0".as_ptr() as *const libc::c_char, + value, + JSPROP_ENUMERATE as u32 + )); + } } // https://html.spec.whatwg.org/multipage/#dom-window-closed @@ -739,11 +741,10 @@ impl WindowMethods for Window { self.navigator.or_init(|| Navigator::new(self)) } - #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout - unsafe fn SetTimeout( + fn SetTimeout( &self, - _cx: *mut JSContext, + _cx: SafeJSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>, @@ -756,11 +757,10 @@ impl WindowMethods for Window { ) } - #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout - unsafe fn SetTimeout_( + fn SetTimeout_( &self, - _cx: *mut JSContext, + _cx: SafeJSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>, @@ -779,11 +779,10 @@ impl WindowMethods for Window { .clear_timeout_or_interval(handle); } - #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval - unsafe fn SetInterval( + fn SetInterval( &self, - _cx: *mut JSContext, + _cx: SafeJSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>, @@ -796,11 +795,10 @@ impl WindowMethods for Window { ) } - #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval - unsafe fn SetInterval_( + fn SetInterval_( &self, - _cx: *mut JSContext, + _cx: SafeJSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>, @@ -903,11 +901,10 @@ impl WindowMethods for Window { doc.cancel_animation_frame(ident); } - #[allow(unsafe_code)] // https://html.spec.whatwg.org/multipage/#dom-window-postmessage - unsafe fn PostMessage( + fn PostMessage( &self, - cx: *mut JSContext, + cx: SafeJSContext, message: HandleValue, origin: DOMString, ) -> ErrorResult { @@ -926,7 +923,7 @@ impl WindowMethods for Window { // Step 1-2, 6-8. // TODO(#12717): Should implement the `transfer` argument. - let data = StructuredCloneData::write(cx, message)?; + let data = StructuredCloneData::write(*cx, message)?; // Step 9. self.post_message(origin, &*source.window_proxy(), data); @@ -961,8 +958,8 @@ impl WindowMethods for Window { } #[allow(unsafe_code)] - unsafe fn WebdriverCallback(&self, cx: *mut JSContext, val: HandleValue) { - let rv = jsval_to_webdriver(cx, val); + fn WebdriverCallback(&self, cx: SafeJSContext, val: HandleValue) { + let rv = unsafe { jsval_to_webdriver(*cx, val) }; let opt_chan = self.webdriver_script_chan.borrow_mut().take(); if let Some(chan) = opt_chan { chan.send(rv).unwrap(); |