mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
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:
parent
9a1051c917
commit
60ef6bc461
140 changed files with 1336 additions and 304 deletions
|
@ -22,7 +22,7 @@ use crate::dom::bindings::str::DOMString;
|
|||
use crate::dom::bindings::trace::RootedTraceableBox;
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::globalscope::GlobalScope;
|
||||
use crate::script_runtime::JSContext;
|
||||
use crate::script_runtime::{CanGc, JSContext};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct ErrorEvent {
|
||||
|
@ -47,8 +47,12 @@ impl ErrorEvent {
|
|||
}
|
||||
}
|
||||
|
||||
fn new_uninitialized(global: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<ErrorEvent> {
|
||||
reflect_dom_object_with_proto(Box::new(ErrorEvent::new_inherited()), global, proto)
|
||||
fn new_uninitialized(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<ErrorEvent> {
|
||||
reflect_dom_object_with_proto(Box::new(ErrorEvent::new_inherited()), global, proto, can_gc)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
|
@ -64,7 +68,17 @@ impl ErrorEvent {
|
|||
error: HandleValue,
|
||||
) -> DomRoot<ErrorEvent> {
|
||||
Self::new_with_proto(
|
||||
global, None, type_, bubbles, cancelable, message, filename, lineno, colno, error,
|
||||
global,
|
||||
None,
|
||||
type_,
|
||||
bubbles,
|
||||
cancelable,
|
||||
message,
|
||||
filename,
|
||||
lineno,
|
||||
colno,
|
||||
error,
|
||||
CanGc::note(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -80,8 +94,9 @@ impl ErrorEvent {
|
|||
lineno: u32,
|
||||
colno: u32,
|
||||
error: HandleValue,
|
||||
can_gc: CanGc,
|
||||
) -> DomRoot<ErrorEvent> {
|
||||
let ev = ErrorEvent::new_uninitialized(global, proto);
|
||||
let ev = ErrorEvent::new_uninitialized(global, proto, can_gc);
|
||||
{
|
||||
let event = ev.upcast::<Event>();
|
||||
event.init_event(type_, bool::from(bubbles), bool::from(cancelable));
|
||||
|
@ -98,6 +113,7 @@ impl ErrorEvent {
|
|||
pub fn Constructor(
|
||||
global: &GlobalScope,
|
||||
proto: Option<HandleObject>,
|
||||
can_gc: CanGc,
|
||||
type_: DOMString,
|
||||
init: RootedTraceableBox<ErrorEventBinding::ErrorEventInit>,
|
||||
) -> Fallible<DomRoot<ErrorEvent>> {
|
||||
|
@ -130,6 +146,7 @@ impl ErrorEvent {
|
|||
line_num,
|
||||
col_num,
|
||||
init.error.handle(),
|
||||
can_gc,
|
||||
);
|
||||
Ok(event)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue