diff options
author | marmeladema <xademax@gmail.com> | 2019-07-27 18:52:12 +0100 |
---|---|---|
committer | marmeladema <xademax@gmail.com> | 2019-08-09 00:43:24 +0100 |
commit | 78034a90d07470d50202b01457c4e18cf7c305fb (patch) | |
tree | e0c963feb5a0b85fc1b2ca4331c4c430edf242a9 /components/script/dom/bindings/guard.rs | |
parent | 8b070fef526bf8c1470c9c82ae2431067b2da4ff (diff) | |
download | servo-78034a90d07470d50202b01457c4e18cf7c305fb.tar.gz servo-78034a90d07470d50202b01457c4e18cf7c305fb.zip |
Use safe JSContext when possible in interface.rs
Diffstat (limited to 'components/script/dom/bindings/guard.rs')
-rw-r--r-- | components/script/dom/bindings/guard.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/components/script/dom/bindings/guard.rs b/components/script/dom/bindings/guard.rs index 40052c7098e..bba30e1581c 100644 --- a/components/script/dom/bindings/guard.rs +++ b/components/script/dom/bindings/guard.rs @@ -6,7 +6,7 @@ use crate::dom::bindings::codegen::InterfaceObjectMap; use crate::dom::bindings::interface::is_exposed_in; -use js::jsapi::JSContext; +use crate::script_runtime::JSContext; use js::rust::HandleObject; use servo_config::prefs; @@ -28,12 +28,7 @@ impl<T: Clone + Copy> Guard<T> { /// Expose the value if the condition is satisfied. /// /// The passed handle is the object on which the value may be exposed. - pub unsafe fn expose( - &self, - cx: *mut JSContext, - obj: HandleObject, - global: HandleObject, - ) -> Option<T> { + pub fn expose(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> Option<T> { if self.condition.is_satisfied(cx, obj, global) { Some(self.value) } else { @@ -45,7 +40,7 @@ impl<T: Clone + Copy> Guard<T> { /// A condition to expose things. pub enum Condition { /// The condition is satisfied if the function returns true. - Func(unsafe fn(*mut JSContext, HandleObject) -> bool), + Func(fn(JSContext, HandleObject) -> bool), /// The condition is satisfied if the preference is set. Pref(&'static str), // The condition is satisfied if the interface is exposed in the global. @@ -55,12 +50,7 @@ pub enum Condition { } impl Condition { - unsafe fn is_satisfied( - &self, - cx: *mut JSContext, - obj: HandleObject, - global: HandleObject, - ) -> bool { + fn is_satisfied(&self, cx: JSContext, obj: HandleObject, global: HandleObject) -> bool { match *self { Condition::Pref(name) => prefs::pref_map().get(name).as_bool().unwrap_or(false), Condition::Func(f) => f(cx, obj), |