diff options
Diffstat (limited to 'components/script/dom/customelementregistry.rs')
-rw-r--r-- | components/script/dom/customelementregistry.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs index 99b38717ac2..a208f99def6 100644 --- a/components/script/dom/customelementregistry.rs +++ b/components/script/dom/customelementregistry.rs @@ -121,7 +121,8 @@ impl CustomElementRegistry { /// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define> /// Steps 10.3, 10.4 - fn get_callbacks(&self, prototype: HandleObject) -> Fallible<LifecycleCallbacks> { + #[allow(unsafe_code)] + unsafe fn get_callbacks(&self, prototype: HandleObject) -> Fallible<LifecycleCallbacks> { let cx = self.window.get_cx(); // Step 4 @@ -164,20 +165,21 @@ impl CustomElementRegistry { /// <https://html.spec.whatwg.org/multipage/#dom-customelementregistry-define> /// Step 10.4 #[allow(unsafe_code)] -fn get_callback(cx: *mut JSContext, prototype: HandleObject, name: &[u8]) -> Fallible<Option<Rc<Function>>> { +unsafe fn get_callback( + cx: *mut JSContext, + prototype: HandleObject, + name: &[u8], +) -> Fallible<Option<Rc<Function>>> { rooted!(in(cx) let mut callback = UndefinedValue()); // Step 10.4.1 - if unsafe { !JS_GetProperty(cx, - prototype, - name.as_ptr() as *const _, - callback.handle_mut()) } { + if !JS_GetProperty(cx, prototype, name.as_ptr() as *const _, callback.handle_mut()) { return Err(Error::JSFailed); } // Step 10.4.2 if !callback.is_undefined() { - if !callback.is_object() || unsafe { !IsCallable(callback.to_object()) } { + if !callback.is_object() || !IsCallable(callback.to_object()) { return Err(Error::Type("Lifecycle callback is not callable".to_owned())); } Ok(Some(Function::new(cx, callback.to_object()))) @@ -265,7 +267,7 @@ impl CustomElementRegistryMethods for CustomElementRegistry { rooted!(in(cx) let proto_object = prototype.to_object()); let callbacks = { let _ac = JSAutoCompartment::new(cx, proto_object.get()); - match self.get_callbacks(proto_object.handle()) { + match unsafe { self.get_callbacks(proto_object.handle()) } { Ok(callbacks) => callbacks, Err(error) => { self.element_definition_is_running.set(false); |