Start marking functions that can transitively trigger a GC (#33144)

* Mark JS reflector wrappers as CanGc.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from reflect_dom_object_with_proto.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Mark DOM constructors as GC operations.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-08-22 07:42:36 -04:00 committed by GitHub
parent 9a1051c917
commit 60ef6bc461
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
140 changed files with 1336 additions and 304 deletions

View file

@ -50,6 +50,7 @@ use crate::dom::rtcsessiondescription::RTCSessionDescription;
use crate::dom::rtctrackevent::RTCTrackEvent;
use crate::dom::window::Window;
use crate::realms::{enter_realm, InRealm};
use crate::script_runtime::CanGc;
use crate::task::TaskCanceller;
use crate::task_source::networking::NetworkingTaskSource;
use crate::task_source::TaskSource;
@ -197,11 +198,13 @@ impl RTCPeerConnection {
global: &GlobalScope,
proto: Option<HandleObject>,
config: &RTCConfiguration,
can_gc: CanGc,
) -> DomRoot<RTCPeerConnection> {
let this = reflect_dom_object_with_proto(
Box::new(RTCPeerConnection::new_inherited()),
global,
proto,
can_gc,
);
let signaller = this.make_signaller();
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
@ -232,9 +235,15 @@ impl RTCPeerConnection {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
can_gc: CanGc,
config: &RTCConfiguration,
) -> Fallible<DomRoot<RTCPeerConnection>> {
Ok(RTCPeerConnection::new(&window.global(), proto, config))
Ok(RTCPeerConnection::new(
&window.global(),
proto,
config,
can_gc,
))
}
pub fn get_webrtc_controller(&self) -> &DomRefCell<Option<WebRtcController>> {
@ -650,6 +659,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
let desc = RTCSessionDescription::Constructor(
this.global().as_window(),
None,
CanGc::note(),
&desc,
).unwrap();
this.local_description.set(Some(&desc));
@ -690,6 +700,7 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
let desc = RTCSessionDescription::Constructor(
this.global().as_window(),
None,
CanGc::note(),
&desc,
).unwrap();
this.remote_description.set(Some(&desc));