script creates methods taking '*mut JSContext' unsafe

rebase + marked the necessary new code as unsafe
This commit is contained in:
Abelardo E. Mendoza 2016-06-03 12:11:35 -06:00 committed by Florent FAYOLLE
parent 9fd6f0acd5
commit b372e7c98f
28 changed files with 274 additions and 226 deletions

View file

@ -483,8 +483,10 @@ impl WindowMethods for Window {
self.navigator.or_init(|| Navigator::new(self))
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout
fn SetTimeout(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
unsafe fn SetTimeout(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32,
args: Vec<HandleValue>) -> i32 {
self.upcast::<GlobalScope>().set_timeout_or_interval(
TimerCallback::FunctionTimerCallback(callback),
args,
@ -492,8 +494,10 @@ impl WindowMethods for Window {
IsInterval::NonInterval)
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout
fn SetTimeout_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
unsafe fn SetTimeout_(&self, _cx: *mut JSContext, callback: DOMString,
timeout: i32, args: Vec<HandleValue>) -> i32 {
self.upcast::<GlobalScope>().set_timeout_or_interval(
TimerCallback::StringTimerCallback(callback),
args,
@ -506,8 +510,10 @@ impl WindowMethods for Window {
self.upcast::<GlobalScope>().clear_timeout_or_interval(handle);
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetInterval(&self, _cx: *mut JSContext, callback: Rc<Function>, timeout: i32, args: Vec<HandleValue>) -> i32 {
unsafe fn SetInterval(&self, _cx: *mut JSContext, callback: Rc<Function>,
timeout: i32, args: Vec<HandleValue>) -> i32 {
self.upcast::<GlobalScope>().set_timeout_or_interval(
TimerCallback::FunctionTimerCallback(callback),
args,
@ -515,8 +521,10 @@ impl WindowMethods for Window {
IsInterval::Interval)
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
fn SetInterval_(&self, _cx: *mut JSContext, callback: DOMString, timeout: i32, args: Vec<HandleValue>) -> i32 {
unsafe fn SetInterval_(&self, _cx: *mut JSContext, callback: DOMString,
timeout: i32, args: Vec<HandleValue>) -> i32 {
self.upcast::<GlobalScope>().set_timeout_or_interval(
TimerCallback::StringTimerCallback(callback),
args,
@ -610,8 +618,9 @@ impl WindowMethods for Window {
doc.cancel_animation_frame(ident);
}
#[allow(unsafe_code)]
// https://html.spec.whatwg.org/multipage/#dom-window-postmessage
fn PostMessage(&self,
unsafe fn PostMessage(&self,
cx: *mut JSContext,
message: HandleValue,
origin: DOMString)
@ -670,8 +679,8 @@ impl WindowMethods for Window {
}
#[allow(unsafe_code)]
fn WebdriverCallback(&self, cx: *mut JSContext, val: HandleValue) {
let rv = unsafe { jsval_to_webdriver(cx, val) };
unsafe fn WebdriverCallback(&self, cx: *mut JSContext, val: HandleValue) {
let rv = 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();
@ -1511,6 +1520,7 @@ impl Window {
}
impl Window {
#[allow(unsafe_code)]
pub fn new(runtime: Rc<Runtime>,
script_chan: MainThreadScriptChan,
dom_task_source: DOMManipulationTaskSource,
@ -1598,7 +1608,9 @@ impl Window {
test_runner: Default::default(),
};
WindowBinding::Wrap(runtime.cx(), win)
unsafe {
WindowBinding::Wrap(runtime.cx(), win)
}
}
}