Make GlobalScope.get_cx a static method.

This commit is contained in:
Josh Matthews 2023-02-16 23:09:50 -05:00
parent 4998c65c42
commit f79e1e327d
39 changed files with 132 additions and 127 deletions

View file

@ -9,6 +9,7 @@ use crate::dom::bindings::iterable::{Iterable, IterableIterator};
use crate::dom::bindings::root::{Dom, DomRoot, Root};
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::globalscope::GlobalScope;
use crate::realms::AlreadyInRealm;
use crate::script_runtime::JSContext;
use js::jsapi::{Heap, JSObject};
use js::rust::HandleObject;
@ -22,7 +23,7 @@ where
U: DerivedFrom<GlobalScope>,
{
let global_scope = global.upcast();
unsafe { T::WRAP(global_scope.get_cx(), global_scope, obj) }
unsafe { T::WRAP(GlobalScope::get_cx(), global_scope, obj) }
}
/// A struct to store a reference to the reflector of a DOM object.
@ -82,7 +83,8 @@ pub trait DomObject: JSTraceable + 'static {
where
Self: Sized,
{
GlobalScope::from_reflector(self)
let realm = AlreadyInRealm::assert_for_cx(GlobalScope::get_cx());
GlobalScope::from_reflector(self, &realm)
}
}