diff options
author | Kamil Niski <kamil.niski@gmail.com> | 2019-05-04 11:27:21 +0200 |
---|---|---|
committer | Kamil Niski <kamil.niski@gmail.com> | 2019-06-29 19:23:17 +0200 |
commit | adb402487e7f8bf2cd0a1db360b16592f5c654ed (patch) | |
tree | cd04a40769e20f2a2c63c5eff914dedc4c745e62 /components/script/script_thread.rs | |
parent | 84786add227f2c0a675f4bcca708ac8a70011f6c (diff) | |
download | servo-adb402487e7f8bf2cd0a1db360b16592f5c654ed.tar.gz servo-adb402487e7f8bf2cd0a1db360b16592f5c654ed.zip |
Create a helper API for entering a DOM object's compartment
Revert some unnecessary changes
Fix fmt errors
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index e2ea62c1fc3..aab5970faac 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -17,6 +17,7 @@ //! a page runs its course and the script thread returns to processing events in the main event //! loop. +use crate::compartments::enter_realm; use crate::devtools; use crate::document_loader::DocumentLoader; use crate::dom::bindings::cell::DomRefCell; @@ -98,7 +99,7 @@ use hyper_serde::Serde; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use js::glue::GetWindowProxyClass; -use js::jsapi::{JSAutoRealm, JSContext, JS_SetWrapObjectCallbacks}; +use js::jsapi::{JSContext, JS_SetWrapObjectCallbacks}; use js::jsapi::{JSTracer, SetWindowProxyClass}; use js::jsval::UndefinedValue; use js::rust::ParentRuntime; @@ -2054,10 +2055,7 @@ impl ScriptThread { fn handle_exit_fullscreen(&self, id: PipelineId) { let document = self.documents.borrow().find_document(id); if let Some(document) = document { - let _ac = JSAutoRealm::new( - document.global().get_cx(), - document.reflector().get_jsobject().get(), - ); + let _ac = enter_realm(&*document); document.exit_fullscreen(); return; } @@ -3397,10 +3395,7 @@ impl ScriptThread { let script_source = percent_decode(encoded.as_bytes()).decode_utf8_lossy(); // Script source is ready to be evaluated (11.) - let _ac = JSAutoRealm::new( - global_scope.get_cx(), - global_scope.reflector().get_jsobject().get(), - ); + let _ac = enter_realm(global_scope); rooted!(in(global_scope.get_cx()) let mut jsval = UndefinedValue()); global_scope.evaluate_js_on_global_with_result(&script_source, jsval.handle_mut()); |