revert: Introduce Untransplantable trait to indicate transplantability at the type level

(8f7b0cff87f0eab921e13e6990d76e12935e8675)
This commit is contained in:
Delan Azabani 2023-02-27 22:20:16 +08:00
parent 4c7f198ee2
commit 1f74d4c75b
8 changed files with 47 additions and 382 deletions

View file

@ -30,7 +30,7 @@ use crate::dom::bindings::conversions::{
};
use crate::dom::bindings::inheritance::Castable;
use crate::dom::bindings::refcounted::Trusted;
use crate::dom::bindings::reflector::{AssertUntransplantable, DomObject};
use crate::dom::bindings::reflector::DomObject;
use crate::dom::bindings::root::ThreadLocalStackRoots;
use crate::dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootCollection};
use crate::dom::bindings::str::DOMString;
@ -522,11 +522,7 @@ pub struct ScriptThread {
documents: DomRefCell<Documents>,
/// The window proxies known by this thread
/// TODO: this map grows, but never shrinks. Issue #15258.
///
/// Safety: `AssertUntransplantable` is safe to be used here because
/// `ScriptThread` is rooted and not traced by other GC things.
window_proxies:
DomRefCell<HashMap<BrowsingContextId, Dom<AssertUntransplantable<WindowProxy>>>>,
window_proxies: DomRefCell<HashMap<BrowsingContextId, Dom<WindowProxy>>>,
/// A list of data pertaining to loads that have not yet received a network response
incomplete_loads: DomRefCell<Vec<InProgressLoad>>,
/// A vector containing parser contexts which have not yet been fully processed
@ -1122,7 +1118,7 @@ impl ScriptThread {
.window_proxies
.borrow()
.get(&id)
.map(|context| DomRoot::from_ref(&***context))
.map(|context| DomRoot::from_ref(&**context))
})
})
}
@ -1133,7 +1129,7 @@ impl ScriptThread {
let script_thread = unsafe { &*script_thread };
for (_, proxy) in script_thread.window_proxies.borrow().iter() {
if proxy.get_name() == *name {
return Some(DomRoot::from_ref(&***proxy));
return Some(DomRoot::from_ref(&**proxy));
}
}
None
@ -3149,13 +3145,9 @@ impl ScriptThread {
opener,
creator,
);
// Safety: See `ScriptThread::window_proxies`.
self.window_proxies.borrow_mut().insert(
browsing_context_id,
Dom::from_ref(unsafe { AssertUntransplantable::from_ref(&*window_proxy) }),
);
self.window_proxies
.borrow_mut()
.insert(browsing_context_id, Dom::from_ref(&*window_proxy));
Some(window_proxy)
}
@ -3210,13 +3202,9 @@ impl ScriptThread {
opener,
creator,
);
// Safety: See `ScriptThread::window_proxies`.
self.window_proxies.borrow_mut().insert(
browsing_context_id,
Dom::from_ref(unsafe { AssertUntransplantable::from_ref(&*window_proxy) }),
);
self.window_proxies
.borrow_mut()
.insert(browsing_context_id, Dom::from_ref(&*window_proxy));
window_proxy
}