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

@ -177,7 +177,7 @@ use crate::dom::window::{ReflowReason, Window};
use crate::dom::windowproxy::WindowProxy;
use crate::fetch::FetchCanceller;
use crate::realms::{AlreadyInRealm, InRealm};
use crate::script_runtime::{CommonScriptMsg, ScriptThreadEventCategory};
use crate::script_runtime::{CanGc, CommonScriptMsg, ScriptThreadEventCategory};
use crate::script_thread::{MainThreadScriptMsg, ScriptThread};
use crate::stylesheet_set::StylesheetSetRef;
use crate::task::TaskBox;
@ -3409,6 +3409,7 @@ impl Document {
pub fn Constructor(
window: &Window,
proto: Option<HandleObject>,
can_gc: CanGc,
) -> Fallible<DomRoot<Document>> {
let doc = window.Document();
let docloader = DocumentLoader::new(&doc.loader());
@ -3428,6 +3429,7 @@ impl Document {
None,
None,
Default::default(),
can_gc,
))
}
@ -3464,6 +3466,7 @@ impl Document {
referrer_policy,
status_code,
canceller,
CanGc::note(),
)
}
@ -3484,6 +3487,7 @@ impl Document {
referrer_policy: Option<ReferrerPolicy>,
status_code: Option<u16>,
canceller: FetchCanceller,
can_gc: CanGc,
) -> DomRoot<Document> {
let document = reflect_dom_object_with_proto(
Box::new(Document::new_inherited(
@ -3504,6 +3508,7 @@ impl Document {
)),
window,
proto,
can_gc,
);
{
let node = document.upcast::<Node>();
@ -4593,7 +4598,7 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-createrange
fn CreateRange(&self) -> DomRoot<Range> {
Range::new_with_doc(self, None)
Range::new_with_doc(self, None, CanGc::note())
}
// https://dom.spec.whatwg.org/#dom-document-createnodeiteratorroot-whattoshow-filter