diff options
author | marmeladema <xademax@gmail.com> | 2019-07-22 22:14:11 +0100 |
---|---|---|
committer | marmeladema <xademax@gmail.com> | 2019-07-24 09:53:10 +0100 |
commit | 88cacfb0098e20be70c27bfde6b74cd3290f1fe4 (patch) | |
tree | 95d7cd9ffad7eaff05114946a1e12f8e49d55fab /components/script/dom/bindings | |
parent | 2c5d0a6ebc39ad263e2bbe623e357a11b4cec5aa (diff) | |
download | servo-88cacfb0098e20be70c27bfde6b74cd3290f1fe4.tar.gz servo-88cacfb0098e20be70c27bfde6b74cd3290f1fe4.zip |
Modify *::get_cx methods to return a safe JSContext instead of a raw one
Diffstat (limited to 'components/script/dom/bindings')
-rw-r--r-- | components/script/dom/bindings/callback.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bindings/htmlconstructor.rs | 14 | ||||
-rw-r--r-- | components/script/dom/bindings/reflector.rs | 12 | ||||
-rw-r--r-- | components/script/dom/bindings/structuredclone.rs | 2 |
4 files changed, 13 insertions, 19 deletions
diff --git a/components/script/dom/bindings/callback.rs b/components/script/dom/bindings/callback.rs index 77f6880e35a..03b8f326f55 100644 --- a/components/script/dom/bindings/callback.rs +++ b/components/script/dom/bindings/callback.rs @@ -255,8 +255,8 @@ impl CallSetup { let ais = callback.incumbent().map(AutoIncumbentScript::new); CallSetup { exception_global: global, - cx: cx, - old_realm: unsafe { EnterRealm(cx, callback.callback()) }, + cx: *cx, + old_realm: unsafe { EnterRealm(*cx, callback.callback()) }, handling: handling, entry_script: Some(aes), incumbent_script: ais, diff --git a/components/script/dom/bindings/htmlconstructor.rs b/components/script/dom/bindings/htmlconstructor.rs index f976a09ee91..6faa4f6211c 100644 --- a/components/script/dom/bindings/htmlconstructor.rs +++ b/components/script/dom/bindings/htmlconstructor.rs @@ -100,7 +100,7 @@ where // Step 2 is checked in the generated caller code // Step 3 - rooted!(in(window.get_cx()) let new_target = call_args.new_target().to_object()); + rooted!(in(*window.get_cx()) let new_target = call_args.new_target().to_object()); let definition = match registry.lookup_definition_by_constructor(new_target.handle()) { Some(definition) => definition, None => { @@ -110,15 +110,15 @@ where }, }; - rooted!(in(window.get_cx()) let callee = UnwrapObjectStatic(call_args.callee())); + rooted!(in(*window.get_cx()) let callee = UnwrapObjectStatic(call_args.callee())); if callee.is_null() { return Err(Error::Security); } { - let _ac = JSAutoRealm::new(window.get_cx(), callee.get()); - rooted!(in(window.get_cx()) let mut constructor = ptr::null_mut::<JSObject>()); - rooted!(in(window.get_cx()) let global_object = CurrentGlobalOrNull(window.get_cx())); + let _ac = JSAutoRealm::new(*window.get_cx(), callee.get()); + rooted!(in(*window.get_cx()) let mut constructor = ptr::null_mut::<JSObject>()); + rooted!(in(*window.get_cx()) let global_object = CurrentGlobalOrNull(*window.get_cx())); if definition.is_autonomous() { // Step 4 @@ -126,7 +126,7 @@ where // Retrieve the constructor object for HTMLElement HTMLElementBinding::GetConstructorObject( - SafeJSContext::from_ptr(window.get_cx()), + window.get_cx(), global_object.handle(), constructor.handle_mut(), ); @@ -134,7 +134,7 @@ where // Step 5 get_constructor_object_from_local_name( definition.local_name.clone(), - window.get_cx(), + *window.get_cx(), global_object.handle(), constructor.handle_mut(), ); diff --git a/components/script/dom/bindings/reflector.rs b/components/script/dom/bindings/reflector.rs index a66ff114226..dc13fca77b0 100644 --- a/components/script/dom/bindings/reflector.rs +++ b/components/script/dom/bindings/reflector.rs @@ -7,7 +7,7 @@ use crate::dom::bindings::conversions::DerivedFrom; use crate::dom::bindings::root::DomRoot; use crate::dom::globalscope::GlobalScope; -use crate::script_runtime::JSContext as SafeJSContext; +use crate::script_runtime::JSContext; use js::jsapi::{Heap, JSObject}; use js::rust::HandleObject; use std::default::Default; @@ -17,20 +17,14 @@ use std::default::Default; pub fn reflect_dom_object<T, U>( obj: Box<T>, global: &U, - wrap_fn: unsafe fn(SafeJSContext, &GlobalScope, Box<T>) -> DomRoot<T>, + wrap_fn: unsafe fn(JSContext, &GlobalScope, Box<T>) -> DomRoot<T>, ) -> DomRoot<T> where T: DomObject, U: DerivedFrom<GlobalScope>, { let global_scope = global.upcast(); - unsafe { - wrap_fn( - SafeJSContext::from_ptr(global_scope.get_cx()), - global_scope, - obj, - ) - } + unsafe { wrap_fn(global_scope.get_cx(), global_scope, obj) } } /// A struct to store a reference to the reflector of a DOM object. diff --git a/components/script/dom/bindings/structuredclone.rs b/components/script/dom/bindings/structuredclone.rs index 167b375dbc7..f35a4af7210 100644 --- a/components/script/dom/bindings/structuredclone.rs +++ b/components/script/dom/bindings/structuredclone.rs @@ -321,7 +321,7 @@ impl StructuredCloneData { WriteBytesToJSStructuredCloneData(data as *const u8, nbytes, scdata); assert!(JS_ReadStructuredClone( - cx, + *cx, scdata, JS_STRUCTURED_CLONE_VERSION, StructuredCloneScope::DifferentProcess, |