script: Expose new methods for obtaining a global that require a realm. (#36116)

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2025-03-26 19:27:25 -04:00 committed by GitHub
parent 73e7d38a8d
commit 1df1ba58d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 42 additions and 19 deletions

View file

@ -2021,10 +2021,7 @@ impl GlobalScope {
/// Returns the global scope of the realm that the given DOM object's reflector
/// was created in.
#[allow(unsafe_code)]
pub(crate) fn from_reflector<T: DomObject>(
reflector: &T,
_realm: &AlreadyInRealm,
) -> DomRoot<Self> {
pub(crate) fn from_reflector<T: DomObject>(reflector: &T, _realm: InRealm) -> DomRoot<Self> {
unsafe { GlobalScope::from_object(*reflector.reflector().get_jsobject()) }
}
@ -3337,10 +3334,7 @@ pub(crate) trait GlobalScopeHelpers<D: crate::DomTypes> {
unsafe fn from_context(cx: *mut JSContext, realm: InRealm) -> DomRoot<D::GlobalScope>;
fn get_cx() -> SafeJSContext;
unsafe fn from_object(obj: *mut JSObject) -> DomRoot<D::GlobalScope>;
fn from_reflector(
reflector: &impl DomObject,
realm: &AlreadyInRealm,
) -> DomRoot<D::GlobalScope>;
fn from_reflector(reflector: &impl DomObject, realm: InRealm) -> DomRoot<D::GlobalScope>;
unsafe fn from_object_maybe_wrapped(
obj: *mut JSObject,
@ -3370,7 +3364,7 @@ impl GlobalScopeHelpers<crate::DomTypeHolder> for GlobalScope {
GlobalScope::from_object(obj)
}
fn from_reflector(reflector: &impl DomObject, realm: &AlreadyInRealm) -> DomRoot<Self> {
fn from_reflector(reflector: &impl DomObject, realm: InRealm) -> DomRoot<Self> {
GlobalScope::from_reflector(reflector, realm)
}