diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-03 02:26:05 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-06 21:35:46 +0200 |
commit | 86d2008137f48432ba14aed5009775cfd4dadcc5 (patch) | |
tree | 079f17c19a61d5c1efea2e7f81be94a63970d4c0 /components/script/dom/bindings/global.rs | |
parent | d4fccbace431b003abbc49f2fbc5e8b2de6b3f2a (diff) | |
download | servo-86d2008137f48432ba14aed5009775cfd4dadcc5.tar.gz servo-86d2008137f48432ba14aed5009775cfd4dadcc5.zip |
Introduce GlobalScope::report_an_error
Diffstat (limited to 'components/script/dom/bindings/global.rs')
-rw-r--r-- | components/script/dom/bindings/global.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index 7366d507649..9ff4ae047da 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -8,7 +8,7 @@ //! code that works in workers as well as window scopes. use dom::bindings::conversions::root_from_object; -use dom::bindings::error::{ErrorInfo, report_pending_exception}; +use dom::bindings::error::report_pending_exception; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::reflector::{Reflectable, Reflector}; @@ -18,8 +18,8 @@ use dom::workerglobalscope::WorkerGlobalScope; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use js::glue::{IsWrapper, UnwrapObject}; use js::jsapi::{CurrentGlobalOrNull, Evaluate2, GetGlobalForObjectCrossCompartment}; -use js::jsapi::{HandleValue, JS_GetClass, JSAutoCompartment, JSContext}; -use js::jsapi::{JSObject, MutableHandleValue}; +use js::jsapi::{JSAutoCompartment, JSContext, JSObject}; +use js::jsapi::{JS_GetClass, MutableHandleValue}; use js::rust::CompileOptionsWrapper; use libc; use net_traits::{CoreResourceThread, IpcSend, ResourceThreads}; @@ -220,14 +220,6 @@ impl<'a> GlobalRef<'a> { GlobalRef::Worker(ref worker) => worker.flush_promise_jobs(), } } - - /// https://html.spec.whatwg.org/multipage/#report-the-error - pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) { - match *self { - GlobalRef::Window(ref window) => window.report_an_error(error_info, value), - GlobalRef::Worker(ref worker) => worker.report_an_error(error_info, value), - } - } } impl<'a> Reflectable for GlobalRef<'a> { @@ -296,6 +288,13 @@ pub unsafe fn global_root_from_object(obj: *mut JSObject) -> GlobalRoot { global_root_from_global(global) } +/// Returns the global scope for the given JSContext +#[allow(unrooted_must_root)] +pub unsafe fn global_scope_from_context(cx: *mut JSContext) -> Root<GlobalScope> { + let global = CurrentGlobalOrNull(cx); + global_scope_from_global(global) +} + /// Returns the global object for the given JSContext #[allow(unrooted_must_root)] pub unsafe fn global_root_from_context(cx: *mut JSContext) -> GlobalRoot { |