diff options
Diffstat (limited to 'components/script/dom/window.rs')
-rw-r--r-- | components/script/dom/window.rs | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index e133eb6cb46..9121fa75fc0 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -33,10 +33,11 @@ use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use js::conversions::ToJSValConvertible; use js::jsapi::{GCReason, Heap, JSAutoRealm, JSObject, StackFormat, JSPROP_ENUMERATE, JS_GC}; -use js::jsval::{JSVal, NullValue, UndefinedValue}; +use js::jsval::{NullValue, UndefinedValue}; use js::rust::wrappers::JS_DefineProperty; use js::rust::{ CustomAutoRooter, CustomAutoRooterGuard, HandleObject, HandleValue, MutableHandleObject, + MutableHandleValue, }; use malloc_size_of::MallocSizeOf; use media::WindowGLContext; @@ -697,22 +698,32 @@ impl WindowMethods for Window { } // https://html.spec.whatwg.org/multipage/#dom-opener - fn GetOpener(&self, cx: JSContext, in_realm_proof: InRealm) -> Fallible<JSVal> { + fn GetOpener( + &self, + cx: JSContext, + in_realm_proof: InRealm, + mut retval: MutableHandleValue, + ) -> Fallible<()> { // Step 1, Let current be this Window object's browsing context. let current = match self.window_proxy.get() { Some(proxy) => proxy, // Step 2, If current is null, then return null. - None => return Ok(NullValue()), + None => { + retval.set(NullValue()); + return Ok(()); + }, }; // Still step 2, since the window's BC is the associated doc's BC, // see https://html.spec.whatwg.org/multipage/#window-bc // and a doc's BC is null if it has been discarded. // see https://html.spec.whatwg.org/multipage/#concept-document-bc if current.is_browsing_context_discarded() { - return Ok(NullValue()); + retval.set(NullValue()); + return Ok(()); } // Step 3 to 5. - Ok(current.opener(*cx, in_realm_proof)) + current.opener(*cx, in_realm_proof, retval); + Ok(()) } #[allow(unsafe_code)] @@ -1388,17 +1399,12 @@ impl WindowMethods for Window { // https://dom.spec.whatwg.org/#dom-window-event #[allow(unsafe_code)] - fn Event(&self, cx: JSContext) -> JSVal { - rooted!(in(*cx) let mut rval = UndefinedValue()); + fn Event(&self, cx: JSContext, rval: MutableHandleValue) { if let Some(ref event) = *self.current_event.borrow() { unsafe { - event - .reflector() - .get_jsobject() - .to_jsval(*cx, rval.handle_mut()); + event.reflector().get_jsobject().to_jsval(*cx, rval); } } - rval.get() } fn IsSecureContext(&self) -> bool { @@ -1571,9 +1577,10 @@ impl WindowMethods for Window { cx: JSContext, value: HandleValue, options: RootedTraceableBox<StructuredSerializeOptions>, - ) -> Fallible<js::jsval::JSVal> { + retval: MutableHandleValue, + ) -> Fallible<()> { self.upcast::<GlobalScope>() - .structured_clone(cx, value, options) + .structured_clone(cx, value, options, retval) } } |