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

@ -34,6 +34,7 @@ use crate::dom::node::{Node, ShadowIncluding};
use crate::dom::performance::reduce_timing_resolution;
use crate::dom::virtualmethods::vtable_for;
use crate::dom::window::Window;
use crate::script_runtime::CanGc;
use crate::task::TaskOnce;
#[dom_struct]
@ -76,14 +77,15 @@ impl Event {
}
pub fn new_uninitialized(global: &GlobalScope) -> DomRoot<Event> {
Self::new_uninitialized_with_proto(global, None)
Self::new_uninitialized_with_proto(global, None, CanGc::note())
}
pub fn new_uninitialized_with_proto(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
) -> DomRoot<Event> {
reflect_dom_object_with_proto(Box::new(Event::new_inherited()), global, proto)
reflect_dom_object_with_proto(Box::new(Event::new_inherited()), global, proto, can_gc)
}
pub fn new(
@ -92,7 +94,7 @@ impl Event {
bubbles: EventBubbles,
cancelable: EventCancelable,
) -> DomRoot<Event> {
Self::new_with_proto(global, None, type_, bubbles, cancelable)
Self::new_with_proto(global, None, type_, bubbles, cancelable, CanGc::note())
}
fn new_with_proto(
@ -101,8 +103,9 @@ impl Event {
type_: Atom,
bubbles: EventBubbles,
cancelable: EventCancelable,
can_gc: CanGc,
) -> DomRoot<Event> {
let event = Event::new_uninitialized_with_proto(global, proto);
let event = Event::new_uninitialized_with_proto(global, proto, can_gc);
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
event
}
@ -111,6 +114,7 @@ impl Event {
pub fn Constructor(
global: &GlobalScope,
proto: Option<HandleObject>,
can_gc: CanGc,
type_: DOMString,
init: &EventBinding::EventInit,
) -> Fallible<DomRoot<Event>> {
@ -122,6 +126,7 @@ impl Event {
Atom::from(type_),
bubbles,
cancelable,
can_gc,
))
}