diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-01-17 15:57:30 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-01-17 15:57:30 -0500 |
commit | fb95f9df9cab44afd66eae809af164637bd8f00a (patch) | |
tree | 45ab882b624d2ae2d3fdb017405b3f74989de683 /components/script/dom/globalscope.rs | |
parent | 866fd55ded6ded98b49862a29951d746a7846f64 (diff) | |
parent | 367014a4ea5b3fff5e4f33df199db0fdb7a95925 (diff) | |
download | servo-fb95f9df9cab44afd66eae809af164637bd8f00a.tar.gz servo-fb95f9df9cab44afd66eae809af164637bd8f00a.zip |
Auto merge of #22353 - jdm:runtime-parent, r=nox
Update rust-mozjs
These changes adjust our uses of the rust-mozjs APIs to accommodate the changes in https://github.com/servo/rust-mozjs/pull/450.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #22342.
- [x] There are tests for these changes
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22353)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index 4aa3a29cea6..91112299034 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -47,7 +47,7 @@ use js::jsapi::{HandleObject, Heap}; use js::jsapi::{JSAutoCompartment, JSContext}; use js::panic::maybe_resume_unwind; use js::rust::wrappers::Evaluate2; -use js::rust::{get_object_class, CompileOptionsWrapper, Runtime}; +use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime}; use js::rust::{HandleValue, MutableHandleValue}; use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL}; use msg::constellation_msg::PipelineId; @@ -711,6 +711,16 @@ impl GlobalScope { unreachable!(); } + pub fn runtime_handle(&self) -> ParentRuntime { + if self.is::<Window>() { + ScriptThread::runtime_handle() + } else if let Some(worker) = self.downcast::<WorkerGlobalScope>() { + worker.runtime_handle() + } else { + unreachable!() + } + } + /// Returns the ["current"] global object. /// /// ["current"]: https://html.spec.whatwg.org/multipage/#current |