Propagate CanGc arguments through callers in constructors (#35541)

Signed-off-by: Auguste Baum <auguste.apple@gmail.com>
This commit is contained in:
Auguste Baum 2025-02-20 17:17:45 +01:00 committed by GitHub
parent 5465bfc2af
commit 863d2ce871
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
260 changed files with 986 additions and 603 deletions

View file

@ -255,7 +255,7 @@ impl TransmitBodyConnectHandler {
}); });
let handler = let handler =
PromiseNativeHandler::new(&global, Some(promise_handler), Some(rejection_handler)); PromiseNativeHandler::new(&global, Some(promise_handler), Some(rejection_handler), CanGc::note());
let realm = enter_realm(&*global); let realm = enter_realm(&*global);
let comp = InRealm::Entered(&realm); let comp = InRealm::Entered(&realm);
@ -704,8 +704,12 @@ impl Callback for ConsumeBodyPromiseHandler {
result_promise: self.result_promise.clone(), result_promise: self.result_promise.clone(),
}); });
let handler = let handler = PromiseNativeHandler::new(
PromiseNativeHandler::new(&global, Some(promise_handler), Some(rejection_handler)); &global,
Some(promise_handler),
Some(rejection_handler),
can_gc,
);
let realm = enter_realm(&*global); let realm = enter_realm(&*global);
let comp = InRealm::Entered(&realm); let comp = InRealm::Entered(&realm);
@ -792,6 +796,7 @@ fn consume_body_with_promise<T: BodyMixin + DomObject>(
&object.global(), &object.global(),
promise_handler.take().map(|h| Box::new(h) as Box<_>), promise_handler.take().map(|h| Box::new(h) as Box<_>),
Some(rejection_handler), Some(rejection_handler),
can_gc,
); );
// We are already in a realm and a script. // We are already in a realm and a script.
read_promise.append_native_handler(&handler, comp, can_gc); read_promise.append_native_handler(&handler, comp, can_gc);

View file

@ -852,6 +852,7 @@ impl CanvasState {
CanvasGradient::new( CanvasGradient::new(
global, global,
CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0, *y0, *x1, *y1, Vec::new())), CanvasGradientStyle::Linear(LinearGradientStyle::new(*x0, *y0, *x1, *y1, Vec::new())),
CanGc::note(),
) )
} }
@ -882,6 +883,7 @@ impl CanvasState {
*r1, *r1,
Vec::new(), Vec::new(),
)), )),
CanGc::note(),
)) ))
} }
@ -939,6 +941,7 @@ impl CanvasState {
image_size, image_size,
rep, rep,
self.is_origin_clean(image), self.is_origin_clean(image),
CanGc::note(),
))) )))
} else { } else {
Err(Error::Syntax) Err(Error::Syntax)
@ -1079,6 +1082,7 @@ impl CanvasState {
metrics.hanging_baseline.into(), metrics.hanging_baseline.into(),
metrics.alphabetic_baseline.into(), metrics.alphabetic_baseline.into(),
metrics.ideographic_baseline.into(), metrics.ideographic_baseline.into(),
can_gc,
) )
} }

View file

@ -43,6 +43,7 @@ impl AbstractRange {
start_offset: u32, start_offset: u32,
end_container: &Node, end_container: &Node,
end_offset: u32, end_offset: u32,
can_gc: CanGc,
) -> DomRoot<AbstractRange> { ) -> DomRoot<AbstractRange> {
let abstractrange = reflect_dom_object( let abstractrange = reflect_dom_object(
Box::new(AbstractRange::new_inherited( Box::new(AbstractRange::new_inherited(
@ -52,7 +53,7 @@ impl AbstractRange {
end_offset, end_offset,
)), )),
document.window(), document.window(),
CanGc::note(), can_gc,
); );
abstractrange abstractrange
} }

View file

@ -68,6 +68,7 @@ impl AudioBufferSourceNode {
*options.playbackRate, *options.playbackRate,
f32::MIN, f32::MIN,
f32::MAX, f32::MAX,
CanGc::note(),
); );
let detune = AudioParam::new( let detune = AudioParam::new(
window, window,
@ -79,6 +80,7 @@ impl AudioBufferSourceNode {
*options.detune, *options.detune,
f32::MIN, f32::MIN,
f32::MAX, f32::MAX,
CanGc::note(),
); );
let node = AudioBufferSourceNode { let node = AudioBufferSourceNode {
source_node, source_node,

View file

@ -43,9 +43,10 @@ impl AudioDestinationNode {
global: &GlobalScope, global: &GlobalScope,
context: &BaseAudioContext, context: &BaseAudioContext,
options: &AudioNodeOptions, options: &AudioNodeOptions,
can_gc: CanGc,
) -> DomRoot<AudioDestinationNode> { ) -> DomRoot<AudioDestinationNode> {
let node = AudioDestinationNode::new_inherited(context, options); let node = AudioDestinationNode::new_inherited(context, options);
reflect_dom_object(Box::new(node), global, CanGc::note()) reflect_dom_object(Box::new(node), global, can_gc)
} }
} }

View file

@ -49,6 +49,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let position_y = AudioParam::new( let position_y = AudioParam::new(
window, window,
@ -60,6 +61,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let position_z = AudioParam::new( let position_z = AudioParam::new(
window, window,
@ -71,6 +73,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let forward_x = AudioParam::new( let forward_x = AudioParam::new(
window, window,
@ -82,6 +85,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let forward_y = AudioParam::new( let forward_y = AudioParam::new(
window, window,
@ -93,6 +97,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let forward_z = AudioParam::new( let forward_z = AudioParam::new(
window, window,
@ -104,6 +109,7 @@ impl AudioListener {
-1., // default value -1., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let up_x = AudioParam::new( let up_x = AudioParam::new(
window, window,
@ -115,6 +121,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let up_y = AudioParam::new( let up_y = AudioParam::new(
window, window,
@ -126,6 +133,7 @@ impl AudioListener {
1., // default value 1., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let up_z = AudioParam::new( let up_z = AudioParam::new(
window, window,
@ -137,6 +145,7 @@ impl AudioListener {
0., // default value 0., // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
AudioListener { AudioListener {

View file

@ -78,6 +78,7 @@ impl AudioParam {
default_value: f32, default_value: f32,
min_value: f32, min_value: f32,
max_value: f32, max_value: f32,
can_gc: CanGc,
) -> DomRoot<AudioParam> { ) -> DomRoot<AudioParam> {
let audio_param = AudioParam::new_inherited( let audio_param = AudioParam::new_inherited(
context, context,
@ -89,7 +90,7 @@ impl AudioParam {
min_value, min_value,
max_value, max_value,
); );
reflect_dom_object(Box::new(audio_param), window, CanGc::note()) reflect_dom_object(Box::new(audio_param), window, can_gc)
} }
fn message_node(&self, message: AudioNodeMessage) { fn message_node(&self, message: AudioNodeMessage) {

View file

@ -52,13 +52,14 @@ impl AudioTrack {
label: DOMString, label: DOMString,
language: DOMString, language: DOMString,
track_list: Option<&AudioTrackList>, track_list: Option<&AudioTrackList>,
can_gc: CanGc,
) -> DomRoot<AudioTrack> { ) -> DomRoot<AudioTrack> {
reflect_dom_object( reflect_dom_object(
Box::new(AudioTrack::new_inherited( Box::new(AudioTrack::new_inherited(
id, kind, label, language, track_list, id, kind, label, language, track_list,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -40,11 +40,12 @@ impl AudioTrackList {
window: &Window, window: &Window,
tracks: &[&AudioTrack], tracks: &[&AudioTrack],
media_element: Option<&HTMLMediaElement>, media_element: Option<&HTMLMediaElement>,
can_gc: CanGc,
) -> DomRoot<AudioTrackList> { ) -> DomRoot<AudioTrackList> {
reflect_dom_object( reflect_dom_object(
Box::new(AudioTrackList::new_inherited(tracks, media_element)), Box::new(AudioTrackList::new_inherited(tracks, media_element)),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -324,7 +324,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
options.channelCount = Some(self.channel_count); options.channelCount = Some(self.channel_count);
options.channelCountMode = Some(ChannelCountMode::Explicit); options.channelCountMode = Some(ChannelCountMode::Explicit);
options.channelInterpretation = Some(ChannelInterpretation::Speakers); options.channelInterpretation = Some(ChannelInterpretation::Speakers);
AudioDestinationNode::new(&global, self, &options) AudioDestinationNode::new(&global, self, &options, CanGc::note())
}) })
} }
@ -560,7 +560,7 @@ impl BaseAudioContextMethods<crate::DomTypeHolder> for BaseAudioContext {
let resolver = resolvers.remove(&uuid).unwrap(); let resolver = resolvers.remove(&uuid).unwrap();
if let Some(callback) = resolver.error_callback { if let Some(callback) = resolver.error_callback {
let _ = callback.Call__( let _ = callback.Call__(
&DOMException::new(&this.global(), DOMErrorName::DataCloneError), &DOMException::new(&this.global(), DOMErrorName::DataCloneError, CanGc::note()),
ExceptionHandling::Report); ExceptionHandling::Report);
} }
let error = format!("Audio decode error {:?}", error); let error = format!("Audio decode error {:?}", error);

View file

@ -33,12 +33,8 @@ impl BeforeUnloadEvent {
} }
} }
pub(crate) fn new_uninitialized(window: &Window) -> DomRoot<BeforeUnloadEvent> { pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<BeforeUnloadEvent> {
reflect_dom_object( reflect_dom_object(Box::new(BeforeUnloadEvent::new_inherited()), window, can_gc)
Box::new(BeforeUnloadEvent::new_inherited()),
window,
CanGc::note(),
)
} }
pub(crate) fn new( pub(crate) fn new(
@ -47,7 +43,7 @@ impl BeforeUnloadEvent {
bubbles: EventBubbles, bubbles: EventBubbles,
cancelable: EventCancelable, cancelable: EventCancelable,
) -> DomRoot<BeforeUnloadEvent> { ) -> DomRoot<BeforeUnloadEvent> {
let ev = BeforeUnloadEvent::new_uninitialized(window); let ev = BeforeUnloadEvent::new_uninitialized(window, CanGc::note());
{ {
let event = ev.upcast::<Event>(); let event = ev.upcast::<Event>();
event.init_event(type_, bool::from(bubbles), bool::from(cancelable)); event.init_event(type_, bool::from(bubbles), bool::from(cancelable));

View file

@ -159,7 +159,7 @@ pub(crate) fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, resul
unsafe { unsafe {
assert!(!JS_IsExceptionPending(*cx)); assert!(!JS_IsExceptionPending(*cx));
let exception = DOMException::new(global, code); let exception = DOMException::new(global, code, CanGc::note());
rooted!(in(*cx) let mut thrown = UndefinedValue()); rooted!(in(*cx) let mut thrown = UndefinedValue());
exception.to_jsval(*cx, thrown.handle_mut()); exception.to_jsval(*cx, thrown.handle_mut());
JS_SetPendingException(*cx, thrown.handle(), ExceptionStackBehavior::Capture); JS_SetPendingException(*cx, thrown.handle(), ExceptionStackBehavior::Capture);

View file

@ -70,6 +70,7 @@ impl BiquadFilterNode {
options.gain, // default value options.gain, // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let q = AudioParam::new( let q = AudioParam::new(
window, window,
@ -81,6 +82,7 @@ impl BiquadFilterNode {
options.q, // default value options.q, // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let frequency = AudioParam::new( let frequency = AudioParam::new(
window, window,
@ -92,6 +94,7 @@ impl BiquadFilterNode {
options.frequency, // default value options.frequency, // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
let detune = AudioParam::new( let detune = AudioParam::new(
window, window,
@ -103,6 +106,7 @@ impl BiquadFilterNode {
options.detune, // default value options.detune, // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
Ok(BiquadFilterNode { Ok(BiquadFilterNode {
node, node,

View file

@ -151,8 +151,8 @@ impl Bluetooth {
} }
} }
pub(crate) fn new(global: &GlobalScope) -> DomRoot<Bluetooth> { pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Bluetooth> {
reflect_dom_object(Box::new(Bluetooth::new_inherited()), global, CanGc::note()) reflect_dom_object(Box::new(Bluetooth::new_inherited()), global, can_gc)
} }
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> {
@ -582,7 +582,7 @@ impl BluetoothMethods<crate::DomTypeHolder> for Bluetooth {
} }
impl AsyncBluetoothListener for Bluetooth { impl AsyncBluetoothListener for Bluetooth {
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) { fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, can_gc: CanGc) {
match response { match response {
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices // https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
// Step 11, 13 - 14. // Step 11, 13 - 14.
@ -596,6 +596,7 @@ impl AsyncBluetoothListener for Bluetooth {
DOMString::from(device.id.clone()), DOMString::from(device.id.clone()),
device.name.map(DOMString::from), device.name.map(DOMString::from),
self, self,
can_gc,
); );
device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device)); device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device));

View file

@ -65,6 +65,7 @@ impl BluetoothCharacteristicProperties {
authenticatedSignedWrites: bool, authenticatedSignedWrites: bool,
reliableWrite: bool, reliableWrite: bool,
writableAuxiliaries: bool, writableAuxiliaries: bool,
can_gc: CanGc,
) -> DomRoot<BluetoothCharacteristicProperties> { ) -> DomRoot<BluetoothCharacteristicProperties> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothCharacteristicProperties::new_inherited( Box::new(BluetoothCharacteristicProperties::new_inherited(
@ -79,7 +80,7 @@ impl BluetoothCharacteristicProperties {
writableAuxiliaries, writableAuxiliaries,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -81,17 +81,18 @@ impl BluetoothDevice {
id: DOMString, id: DOMString,
name: Option<DOMString>, name: Option<DOMString>,
context: &Bluetooth, context: &Bluetooth,
can_gc: CanGc,
) -> DomRoot<BluetoothDevice> { ) -> DomRoot<BluetoothDevice> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothDevice::new_inherited(id, name, context)), Box::new(BluetoothDevice::new_inherited(id, name, context)),
global, global,
CanGc::note(), can_gc,
) )
} }
pub(crate) fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> { pub(crate) fn get_gatt(&self) -> DomRoot<BluetoothRemoteGATTServer> {
self.gatt self.gatt
.or_init(|| BluetoothRemoteGATTServer::new(&self.global(), self)) .or_init(|| BluetoothRemoteGATTServer::new(&self.global(), self, CanGc::note()))
} }
fn get_context(&self) -> DomRoot<Bluetooth> { fn get_context(&self) -> DomRoot<Bluetooth> {
@ -114,6 +115,7 @@ impl BluetoothDevice {
DOMString::from(service.uuid.clone()), DOMString::from(service.uuid.clone()),
service.is_primary, service.is_primary,
service.instance_id.clone(), service.instance_id.clone(),
CanGc::note(),
); );
service_map.insert(service.instance_id.clone(), Dom::from_ref(&bt_service)); service_map.insert(service.instance_id.clone(), Dom::from_ref(&bt_service));
bt_service bt_service
@ -140,6 +142,7 @@ impl BluetoothDevice {
characteristic.authenticated_signed_writes, characteristic.authenticated_signed_writes,
characteristic.reliable_write, characteristic.reliable_write,
characteristic.writable_auxiliaries, characteristic.writable_auxiliaries,
CanGc::note(),
); );
let bt_characteristic = BluetoothRemoteGATTCharacteristic::new( let bt_characteristic = BluetoothRemoteGATTCharacteristic::new(
&service.global(), &service.global(),
@ -147,6 +150,7 @@ impl BluetoothDevice {
DOMString::from(characteristic.uuid.clone()), DOMString::from(characteristic.uuid.clone()),
&properties, &properties,
characteristic.instance_id.clone(), characteristic.instance_id.clone(),
CanGc::note(),
); );
characteristic_map.insert( characteristic_map.insert(
characteristic.instance_id.clone(), characteristic.instance_id.clone(),
@ -181,6 +185,7 @@ impl BluetoothDevice {
characteristic, characteristic,
DOMString::from(descriptor.uuid.clone()), DOMString::from(descriptor.uuid.clone()),
descriptor.instance_id.clone(), descriptor.instance_id.clone(),
CanGc::note(),
); );
descriptor_map.insert( descriptor_map.insert(
descriptor.instance_id.clone(), descriptor.instance_id.clone(),

View file

@ -48,11 +48,12 @@ impl BluetoothPermissionResult {
pub(crate) fn new( pub(crate) fn new(
global: &GlobalScope, global: &GlobalScope,
status: &PermissionStatus, status: &PermissionStatus,
can_gc: CanGc,
) -> DomRoot<BluetoothPermissionResult> { ) -> DomRoot<BluetoothPermissionResult> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothPermissionResult::new_inherited(status)), Box::new(BluetoothPermissionResult::new_inherited(status)),
global, global,
CanGc::note(), can_gc,
) )
} }
@ -96,7 +97,7 @@ impl BluetoothPermissionResultMethods<crate::DomTypeHolder> for BluetoothPermiss
} }
impl AsyncBluetoothListener for BluetoothPermissionResult { impl AsyncBluetoothListener for BluetoothPermissionResult {
fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, _can_gc: CanGc) { fn handle_response(&self, response: BluetoothResponse, promise: &Rc<Promise>, can_gc: CanGc) {
match response { match response {
// https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices // https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices
// Step 3, 11, 13 - 14. // Step 3, 11, 13 - 14.
@ -118,6 +119,7 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
DOMString::from(device.id.clone()), DOMString::from(device.id.clone()),
device.name.map(DOMString::from), device.name.map(DOMString::from),
&bluetooth, &bluetooth,
can_gc,
); );
device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device)); device_instance_map.insert(device.id.clone(), Dom::from_ref(&bt_device));
self.global() self.global()

View file

@ -70,6 +70,7 @@ impl BluetoothRemoteGATTCharacteristic {
uuid: DOMString, uuid: DOMString,
properties: &BluetoothCharacteristicProperties, properties: &BluetoothCharacteristicProperties,
instance_id: String, instance_id: String,
can_gc: CanGc,
) -> DomRoot<BluetoothRemoteGATTCharacteristic> { ) -> DomRoot<BluetoothRemoteGATTCharacteristic> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothRemoteGATTCharacteristic::new_inherited( Box::new(BluetoothRemoteGATTCharacteristic::new_inherited(
@ -79,7 +80,7 @@ impl BluetoothRemoteGATTCharacteristic {
instance_id, instance_id,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -58,6 +58,7 @@ impl BluetoothRemoteGATTDescriptor {
characteristic: &BluetoothRemoteGATTCharacteristic, characteristic: &BluetoothRemoteGATTCharacteristic,
uuid: DOMString, uuid: DOMString,
instance_id: String, instance_id: String,
can_gc: CanGc,
) -> DomRoot<BluetoothRemoteGATTDescriptor> { ) -> DomRoot<BluetoothRemoteGATTDescriptor> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothRemoteGATTDescriptor::new_inherited( Box::new(BluetoothRemoteGATTDescriptor::new_inherited(
@ -66,7 +67,7 @@ impl BluetoothRemoteGATTDescriptor {
instance_id, instance_id,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -42,11 +42,12 @@ impl BluetoothRemoteGATTServer {
pub(crate) fn new( pub(crate) fn new(
global: &GlobalScope, global: &GlobalScope,
device: &BluetoothDevice, device: &BluetoothDevice,
can_gc: CanGc,
) -> DomRoot<BluetoothRemoteGATTServer> { ) -> DomRoot<BluetoothRemoteGATTServer> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothRemoteGATTServer::new_inherited(device)), Box::new(BluetoothRemoteGATTServer::new_inherited(device)),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -54,13 +54,14 @@ impl BluetoothRemoteGATTService {
uuid: DOMString, uuid: DOMString,
isPrimary: bool, isPrimary: bool,
instanceID: String, instanceID: String,
can_gc: CanGc,
) -> DomRoot<BluetoothRemoteGATTService> { ) -> DomRoot<BluetoothRemoteGATTService> {
reflect_dom_object( reflect_dom_object(
Box::new(BluetoothRemoteGATTService::new_inherited( Box::new(BluetoothRemoteGATTService::new_inherited(
device, uuid, isPrimary, instanceID, device, uuid, isPrimary, instanceID,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -29,8 +29,8 @@ impl TestRunner {
} }
} }
pub(crate) fn new(global: &GlobalScope) -> DomRoot<TestRunner> { pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<TestRunner> {
reflect_dom_object(Box::new(TestRunner::new_inherited()), global, CanGc::note()) reflect_dom_object(Box::new(TestRunner::new_inherited()), global, can_gc)
} }
fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> { fn get_bluetooth_thread(&self) -> IpcSender<BluetoothRequest> {

View file

@ -42,11 +42,15 @@ impl CanvasGradient {
} }
} }
pub(crate) fn new(global: &GlobalScope, style: CanvasGradientStyle) -> DomRoot<CanvasGradient> { pub(crate) fn new(
global: &GlobalScope,
style: CanvasGradientStyle,
can_gc: CanGc,
) -> DomRoot<CanvasGradient> {
reflect_dom_object( reflect_dom_object(
Box::new(CanvasGradient::new_inherited(style)), Box::new(CanvasGradient::new_inherited(style)),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -53,6 +53,7 @@ impl CanvasPattern {
surface_size: Size2D<u32>, surface_size: Size2D<u32>,
repeat: RepetitionStyle, repeat: RepetitionStyle,
origin_clean: bool, origin_clean: bool,
can_gc: CanGc,
) -> DomRoot<CanvasPattern> { ) -> DomRoot<CanvasPattern> {
reflect_dom_object( reflect_dom_object(
Box::new(CanvasPattern::new_inherited( Box::new(CanvasPattern::new_inherited(
@ -62,7 +63,7 @@ impl CanvasPattern {
origin_clean, origin_clean,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }
pub(crate) fn origin_is_clean(&self) -> bool { pub(crate) fn origin_is_clean(&self) -> bool {

View file

@ -61,13 +61,14 @@ impl CanvasRenderingContext2D {
global: &GlobalScope, global: &GlobalScope,
canvas: &HTMLCanvasElement, canvas: &HTMLCanvasElement,
size: Size2D<u32>, size: Size2D<u32>,
can_gc: CanGc,
) -> DomRoot<CanvasRenderingContext2D> { ) -> DomRoot<CanvasRenderingContext2D> {
let boxed = Box::new(CanvasRenderingContext2D::new_inherited( let boxed = Box::new(CanvasRenderingContext2D::new_inherited(
global, global,
Some(canvas), Some(canvas),
size, size,
)); ));
reflect_dom_object(boxed, global, CanGc::note()) reflect_dom_object(boxed, global, can_gc)
} }
// https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions // https://html.spec.whatwg.org/multipage/#concept-canvas-set-bitmap-dimensions

View file

@ -39,11 +39,11 @@ impl Client {
} }
} }
pub(crate) fn new(window: &Window) -> DomRoot<Client> { pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<Client> {
reflect_dom_object( reflect_dom_object(
Box::new(Client::new_inherited(window.get_url())), Box::new(Client::new_inherited(window.get_url())),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -31,12 +31,8 @@ impl CompositionEvent {
} }
} }
pub(crate) fn new_uninitialized(window: &Window) -> DomRoot<CompositionEvent> { pub(crate) fn new_uninitialized(window: &Window, can_gc: CanGc) -> DomRoot<CompositionEvent> {
reflect_dom_object( reflect_dom_object(Box::new(CompositionEvent::new_inherited()), window, can_gc)
Box::new(CompositionEvent::new_inherited()),
window,
CanGc::note(),
)
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]

View file

@ -55,6 +55,7 @@ impl ConstantSourceNode {
*options.offset, *options.offset,
f32::MIN, f32::MIN,
f32::MAX, f32::MAX,
CanGc::note(),
); );
Ok(ConstantSourceNode { Ok(ConstantSourceNode {

View file

@ -37,15 +37,16 @@ impl Crypto {
} }
} }
pub(crate) fn new(global: &GlobalScope) -> DomRoot<Crypto> { pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<Crypto> {
reflect_dom_object(Box::new(Crypto::new_inherited()), global, CanGc::note()) reflect_dom_object(Box::new(Crypto::new_inherited()), global, can_gc)
} }
} }
impl CryptoMethods<crate::DomTypeHolder> for Crypto { impl CryptoMethods<crate::DomTypeHolder> for Crypto {
/// <https://w3c.github.io/webcrypto/#dfn-Crypto-attribute-subtle> /// <https://w3c.github.io/webcrypto/#dfn-Crypto-attribute-subtle>
fn Subtle(&self) -> DomRoot<SubtleCrypto> { fn Subtle(&self) -> DomRoot<SubtleCrypto> {
self.subtle.or_init(|| SubtleCrypto::new(&self.global())) self.subtle
.or_init(|| SubtleCrypto::new(&self.global(), CanGc::note()))
} }
#[allow(unsafe_code)] #[allow(unsafe_code)]

View file

@ -78,6 +78,7 @@ impl CryptoKey {
} }
} }
#[allow(clippy::too_many_arguments)]
pub(crate) fn new( pub(crate) fn new(
global: &GlobalScope, global: &GlobalScope,
key_type: KeyType, key_type: KeyType,
@ -86,6 +87,7 @@ impl CryptoKey {
algorithm_object: HandleObject, algorithm_object: HandleObject,
usages: Vec<KeyUsage>, usages: Vec<KeyUsage>,
handle: Handle, handle: Handle,
can_gc: CanGc,
) -> DomRoot<CryptoKey> { ) -> DomRoot<CryptoKey> {
let object = reflect_dom_object( let object = reflect_dom_object(
Box::new(CryptoKey::new_inherited( Box::new(CryptoKey::new_inherited(
@ -96,7 +98,7 @@ impl CryptoKey {
handle, handle,
)), )),
global, global,
CanGc::note(), can_gc,
); );
object.algorithm_object.set(algorithm_object.get()); object.algorithm_object.set(algorithm_object.get());

View file

@ -39,6 +39,7 @@ impl CSSFontFaceRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
fontfacerule: Arc<Locked<FontFaceRule>>, fontfacerule: Arc<Locked<FontFaceRule>>,
can_gc: CanGc,
) -> DomRoot<CSSFontFaceRule> { ) -> DomRoot<CSSFontFaceRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSFontFaceRule::new_inherited( Box::new(CSSFontFaceRule::new_inherited(
@ -46,7 +47,7 @@ impl CSSFontFaceRule {
fontfacerule, fontfacerule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -16,6 +16,7 @@ use crate::dom::bindings::str::DOMString;
use crate::dom::cssrule::CSSRule; use crate::dom::cssrule::CSSRule;
use crate::dom::cssrulelist::{CSSRuleList, RulesSource}; use crate::dom::cssrulelist::{CSSRuleList, RulesSource};
use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub(crate) struct CSSGroupingRule { pub(crate) struct CSSGroupingRule {
@ -45,6 +46,7 @@ impl CSSGroupingRule {
self.global().as_window(), self.global().as_window(),
parent_stylesheet, parent_stylesheet,
RulesSource::Rules(self.rules.clone()), RulesSource::Rules(self.rules.clone()),
CanGc::note(),
) )
}) })
} }

View file

@ -42,11 +42,12 @@ impl CSSImportRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
import_rule: Arc<Locked<ImportRule>>, import_rule: Arc<Locked<ImportRule>>,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
reflect_dom_object( reflect_dom_object(
Box::new(Self::new_inherited(parent_stylesheet, import_rule)), Box::new(Self::new_inherited(parent_stylesheet, import_rule)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -45,6 +45,7 @@ impl CSSKeyframeRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
keyframerule: Arc<Locked<Keyframe>>, keyframerule: Arc<Locked<Keyframe>>,
can_gc: CanGc,
) -> DomRoot<CSSKeyframeRule> { ) -> DomRoot<CSSKeyframeRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSKeyframeRule::new_inherited( Box::new(CSSKeyframeRule::new_inherited(
@ -52,7 +53,7 @@ impl CSSKeyframeRule {
keyframerule, keyframerule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
} }
@ -70,6 +71,7 @@ impl CSSKeyframeRuleMethods<crate::DomTypeHolder> for CSSKeyframeRule {
), ),
None, None,
CSSModificationAccess::ReadWrite, CSSModificationAccess::ReadWrite,
CanGc::note(),
) )
}) })
} }

View file

@ -49,6 +49,7 @@ impl CSSKeyframesRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
keyframesrule: Arc<Locked<KeyframesRule>>, keyframesrule: Arc<Locked<KeyframesRule>>,
can_gc: CanGc,
) -> DomRoot<CSSKeyframesRule> { ) -> DomRoot<CSSKeyframesRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSKeyframesRule::new_inherited( Box::new(CSSKeyframesRule::new_inherited(
@ -56,7 +57,7 @@ impl CSSKeyframesRule {
keyframesrule, keyframesrule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
@ -67,6 +68,7 @@ impl CSSKeyframesRule {
self.global().as_window(), self.global().as_window(),
parent_stylesheet, parent_stylesheet,
RulesSource::Keyframes(self.keyframesrule.clone()), RulesSource::Keyframes(self.keyframesrule.clone()),
CanGc::note(),
) )
}) })
} }

View file

@ -45,6 +45,7 @@ impl CSSLayerBlockRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
layerblockrule: Arc<LayerBlockRule>, layerblockrule: Arc<LayerBlockRule>,
can_gc: CanGc,
) -> DomRoot<CSSLayerBlockRule> { ) -> DomRoot<CSSLayerBlockRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSLayerBlockRule::new_inherited( Box::new(CSSLayerBlockRule::new_inherited(
@ -52,7 +53,7 @@ impl CSSLayerBlockRule {
layerblockrule, layerblockrule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -43,6 +43,7 @@ impl CSSLayerStatementRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
layerstatementrule: Arc<LayerStatementRule>, layerstatementrule: Arc<LayerStatementRule>,
can_gc: CanGc,
) -> DomRoot<CSSLayerStatementRule> { ) -> DomRoot<CSSLayerStatementRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSLayerStatementRule::new_inherited( Box::new(CSSLayerStatementRule::new_inherited(
@ -50,7 +51,7 @@ impl CSSLayerStatementRule {
layerstatementrule, layerstatementrule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -43,11 +43,12 @@ impl CSSMediaRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
mediarule: Arc<MediaRule>, mediarule: Arc<MediaRule>,
can_gc: CanGc,
) -> DomRoot<CSSMediaRule> { ) -> DomRoot<CSSMediaRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSMediaRule::new_inherited(parent_stylesheet, mediarule)), Box::new(CSSMediaRule::new_inherited(parent_stylesheet, mediarule)),
window, window,
CanGc::note(), can_gc,
) )
} }
@ -57,6 +58,7 @@ impl CSSMediaRule {
self.global().as_window(), self.global().as_window(),
self.cssconditionrule.parent_stylesheet(), self.cssconditionrule.parent_stylesheet(),
self.mediarule.media_queries.clone(), self.mediarule.media_queries.clone(),
CanGc::note(),
) )
}) })
} }

View file

@ -40,6 +40,7 @@ impl CSSNamespaceRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
namespacerule: Arc<NamespaceRule>, namespacerule: Arc<NamespaceRule>,
can_gc: CanGc,
) -> DomRoot<CSSNamespaceRule> { ) -> DomRoot<CSSNamespaceRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSNamespaceRule::new_inherited( Box::new(CSSNamespaceRule::new_inherited(
@ -47,7 +48,7 @@ impl CSSNamespaceRule {
namespacerule, namespacerule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -25,6 +25,7 @@ use crate::dom::cssstylerule::CSSStyleRule;
use crate::dom::cssstylesheet::CSSStyleSheet; use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::dom::csssupportsrule::CSSSupportsRule; use crate::dom::csssupportsrule::CSSSupportsRule;
use crate::dom::window::Window; use crate::dom::window::Window;
use crate::script_runtime::CanGc;
#[dom_struct] #[dom_struct]
pub(crate) struct CSSRule { pub(crate) struct CSSRule {
@ -82,38 +83,65 @@ impl CSSRule {
) -> DomRoot<CSSRule> { ) -> DomRoot<CSSRule> {
// be sure to update the match in as_specific when this is updated // be sure to update the match in as_specific when this is updated
match rule { match rule {
StyleCssRule::Import(s) => { StyleCssRule::Import(s) => DomRoot::upcast(CSSImportRule::new(
DomRoot::upcast(CSSImportRule::new(window, parent_stylesheet, s)) window,
}, parent_stylesheet,
StyleCssRule::Style(s) => { s,
DomRoot::upcast(CSSStyleRule::new(window, parent_stylesheet, s)) CanGc::note(),
}, )),
StyleCssRule::FontFace(s) => { StyleCssRule::Style(s) => DomRoot::upcast(CSSStyleRule::new(
DomRoot::upcast(CSSFontFaceRule::new(window, parent_stylesheet, s)) window,
}, parent_stylesheet,
s,
CanGc::note(),
)),
StyleCssRule::FontFace(s) => DomRoot::upcast(CSSFontFaceRule::new(
window,
parent_stylesheet,
s,
CanGc::note(),
)),
StyleCssRule::FontFeatureValues(_) => unimplemented!(), StyleCssRule::FontFeatureValues(_) => unimplemented!(),
StyleCssRule::CounterStyle(_) => unimplemented!(), StyleCssRule::CounterStyle(_) => unimplemented!(),
StyleCssRule::Keyframes(s) => { StyleCssRule::Keyframes(s) => DomRoot::upcast(CSSKeyframesRule::new(
DomRoot::upcast(CSSKeyframesRule::new(window, parent_stylesheet, s)) window,
}, parent_stylesheet,
StyleCssRule::Media(s) => { s,
DomRoot::upcast(CSSMediaRule::new(window, parent_stylesheet, s)) CanGc::note(),
}, )),
StyleCssRule::Namespace(s) => { StyleCssRule::Media(s) => DomRoot::upcast(CSSMediaRule::new(
DomRoot::upcast(CSSNamespaceRule::new(window, parent_stylesheet, s)) window,
}, parent_stylesheet,
StyleCssRule::Supports(s) => { s,
DomRoot::upcast(CSSSupportsRule::new(window, parent_stylesheet, s)) CanGc::note(),
}, )),
StyleCssRule::Namespace(s) => DomRoot::upcast(CSSNamespaceRule::new(
window,
parent_stylesheet,
s,
CanGc::note(),
)),
StyleCssRule::Supports(s) => DomRoot::upcast(CSSSupportsRule::new(
window,
parent_stylesheet,
s,
CanGc::note(),
)),
StyleCssRule::Page(_) => unreachable!(), StyleCssRule::Page(_) => unreachable!(),
StyleCssRule::Container(_) => unimplemented!(), // TODO StyleCssRule::Container(_) => unimplemented!(), // TODO
StyleCssRule::Document(_) => unimplemented!(), // TODO StyleCssRule::Document(_) => unimplemented!(), // TODO
StyleCssRule::LayerBlock(s) => { StyleCssRule::LayerBlock(s) => DomRoot::upcast(CSSLayerBlockRule::new(
DomRoot::upcast(CSSLayerBlockRule::new(window, parent_stylesheet, s)) window,
}, parent_stylesheet,
StyleCssRule::LayerStatement(s) => { s,
DomRoot::upcast(CSSLayerStatementRule::new(window, parent_stylesheet, s)) CanGc::note(),
}, )),
StyleCssRule::LayerStatement(s) => DomRoot::upcast(CSSLayerStatementRule::new(
window,
parent_stylesheet,
s,
CanGc::note(),
)),
StyleCssRule::FontPaletteValues(_) => unimplemented!(), // TODO StyleCssRule::FontPaletteValues(_) => unimplemented!(), // TODO
StyleCssRule::Property(_) => unimplemented!(), // TODO StyleCssRule::Property(_) => unimplemented!(), // TODO
StyleCssRule::Margin(_) => unimplemented!(), // TODO StyleCssRule::Margin(_) => unimplemented!(), // TODO

View file

@ -87,11 +87,12 @@ impl CSSRuleList {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
rules: RulesSource, rules: RulesSource,
can_gc: CanGc,
) -> DomRoot<CSSRuleList> { ) -> DomRoot<CSSRuleList> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSRuleList::new_inherited(parent_stylesheet, rules)), Box::new(CSSRuleList::new_inherited(parent_stylesheet, rules)),
window, window,
CanGc::note(), can_gc,
) )
} }
@ -193,6 +194,7 @@ impl CSSRuleList {
self.global().as_window(), self.global().as_window(),
parent_stylesheet, parent_stylesheet,
rules.read_with(&guard).keyframes[idx as usize].clone(), rules.read_with(&guard).keyframes[idx as usize].clone(),
CanGc::note(),
)), )),
} }
}) })

View file

@ -235,6 +235,7 @@ impl CSSStyleDeclaration {
owner: CSSStyleOwner, owner: CSSStyleOwner,
pseudo: Option<PseudoElement>, pseudo: Option<PseudoElement>,
modification_access: CSSModificationAccess, modification_access: CSSModificationAccess,
can_gc: CanGc,
) -> DomRoot<CSSStyleDeclaration> { ) -> DomRoot<CSSStyleDeclaration> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSStyleDeclaration::new_inherited( Box::new(CSSStyleDeclaration::new_inherited(
@ -243,7 +244,7 @@ impl CSSStyleDeclaration {
modification_access, modification_access,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -50,11 +50,12 @@ impl CSSStyleRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
stylerule: Arc<Locked<StyleRule>>, stylerule: Arc<Locked<StyleRule>>,
can_gc: CanGc,
) -> DomRoot<CSSStyleRule> { ) -> DomRoot<CSSStyleRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSStyleRule::new_inherited(parent_stylesheet, stylerule)), Box::new(CSSStyleRule::new_inherited(parent_stylesheet, stylerule)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }
@ -86,6 +87,7 @@ impl CSSStyleRuleMethods<crate::DomTypeHolder> for CSSStyleRule {
), ),
None, None,
CSSModificationAccess::ReadWrite, CSSModificationAccess::ReadWrite,
CanGc::note(),
) )
}) })
} }

View file

@ -58,20 +58,26 @@ impl CSSStyleSheet {
href: Option<DOMString>, href: Option<DOMString>,
title: Option<DOMString>, title: Option<DOMString>,
stylesheet: Arc<StyleStyleSheet>, stylesheet: Arc<StyleStyleSheet>,
can_gc: CanGc,
) -> DomRoot<CSSStyleSheet> { ) -> DomRoot<CSSStyleSheet> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSStyleSheet::new_inherited( Box::new(CSSStyleSheet::new_inherited(
owner, type_, href, title, stylesheet, owner, type_, href, title, stylesheet,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }
fn rulelist(&self) -> DomRoot<CSSRuleList> { fn rulelist(&self) -> DomRoot<CSSRuleList> {
self.rulelist.or_init(|| { self.rulelist.or_init(|| {
let rules = self.style_stylesheet.contents.rules.clone(); let rules = self.style_stylesheet.contents.rules.clone();
CSSRuleList::new(self.global().as_window(), self, RulesSource::Rules(rules)) CSSRuleList::new(
self.global().as_window(),
self,
RulesSource::Rules(rules),
CanGc::note(),
)
}) })
} }
@ -113,6 +119,7 @@ impl CSSStyleSheet {
self.global().as_window(), self.global().as_window(),
self, self,
self.style_stylesheet().media.clone(), self.style_stylesheet().media.clone(),
CanGc::note(),
) )
} }
} }

View file

@ -27,11 +27,15 @@ impl CSSStyleValue {
} }
} }
pub(crate) fn new(global: &GlobalScope, value: String) -> DomRoot<CSSStyleValue> { pub(crate) fn new(
global: &GlobalScope,
value: String,
can_gc: CanGc,
) -> DomRoot<CSSStyleValue> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSStyleValue::new_inherited(value)), Box::new(CSSStyleValue::new_inherited(value)),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -42,6 +42,7 @@ impl CSSSupportsRule {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
supportsrule: Arc<SupportsRule>, supportsrule: Arc<SupportsRule>,
can_gc: CanGc,
) -> DomRoot<CSSSupportsRule> { ) -> DomRoot<CSSSupportsRule> {
reflect_dom_object( reflect_dom_object(
Box::new(CSSSupportsRule::new_inherited( Box::new(CSSSupportsRule::new_inherited(
@ -49,7 +50,7 @@ impl CSSSupportsRule {
supportsrule, supportsrule,
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -89,11 +89,11 @@ impl CustomElementRegistry {
} }
} }
pub(crate) fn new(window: &Window) -> DomRoot<CustomElementRegistry> { pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<CustomElementRegistry> {
reflect_dom_object( reflect_dom_object(
Box::new(CustomElementRegistry::new_inherited(window)), Box::new(CustomElementRegistry::new_inherited(window)),
window, window,
CanGc::note(), can_gc,
) )
} }
@ -581,6 +581,7 @@ impl CustomElementRegistryMethods<crate::DomTypeHolder> for CustomElementRegistr
promise.reject_native(&DOMException::new( promise.reject_native(&DOMException::new(
self.window.as_global_scope(), self.window.as_global_scope(),
DOMErrorName::SyntaxError, DOMErrorName::SyntaxError,
CanGc::note(),
)); ));
return promise; return promise;
} }

View file

@ -261,6 +261,6 @@ impl DataTransferMethods<crate::DomTypeHolder> for DataTransfer {
} }
// Step 5 // Step 5
FileList::new(self.global().as_window(), files) FileList::new(self.global().as_window(), files, can_gc)
} }
} }

View file

@ -37,11 +37,14 @@ impl DissimilarOriginLocation {
} }
} }
pub(crate) fn new(window: &DissimilarOriginWindow) -> DomRoot<DissimilarOriginLocation> { pub(crate) fn new(
window: &DissimilarOriginWindow,
can_gc: CanGc,
) -> DomRoot<DissimilarOriginLocation> {
reflect_dom_object( reflect_dom_object(
Box::new(DissimilarOriginLocation::new_inherited(window)), Box::new(DissimilarOriginLocation::new_inherited(window)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -21,7 +21,7 @@ use crate::dom::bindings::trace::RootedTraceableBox;
use crate::dom::dissimilaroriginlocation::DissimilarOriginLocation; use crate::dom::dissimilaroriginlocation::DissimilarOriginLocation;
use crate::dom::globalscope::GlobalScope; use crate::dom::globalscope::GlobalScope;
use crate::dom::windowproxy::WindowProxy; use crate::dom::windowproxy::WindowProxy;
use crate::script_runtime::JSContext; use crate::script_runtime::{CanGc, JSContext};
/// Represents a dissimilar-origin `Window` that exists in another script thread. /// Represents a dissimilar-origin `Window` that exists in another script thread.
/// ///
@ -193,7 +193,7 @@ impl DissimilarOriginWindowMethods<crate::DomTypeHolder> for DissimilarOriginWin
// https://html.spec.whatwg.org/multipage/#dom-location // https://html.spec.whatwg.org/multipage/#dom-location
fn Location(&self) -> DomRoot<DissimilarOriginLocation> { fn Location(&self) -> DomRoot<DissimilarOriginLocation> {
self.location self.location
.or_init(|| DissimilarOriginLocation::new(self)) .or_init(|| DissimilarOriginLocation::new(self, CanGc::note()))
} }
} }

View file

@ -2039,7 +2039,7 @@ impl Document {
let touch = Touch::new( let touch = Touch::new(
window, identifier, &target, client_x, window, identifier, &target, client_x,
client_y, // TODO: Get real screen coordinates? client_y, // TODO: Get real screen coordinates?
client_x, client_y, page_x, page_y, client_x, client_y, page_x, page_y, can_gc,
); );
match event.event_type { match event.event_type {
@ -2079,7 +2079,7 @@ impl Document {
let touches = { let touches = {
let touches = self.active_touch_points.borrow(); let touches = self.active_touch_points.borrow();
target_touches.extend(touches.iter().filter(|t| t.Target() == target).cloned()); target_touches.extend(touches.iter().filter(|t| t.Target() == target).cloned());
TouchList::new(window, touches.r()) TouchList::new(window, touches.r(), can_gc)
}; };
let event = DomTouchEvent::new( let event = DomTouchEvent::new(
@ -2090,8 +2090,8 @@ impl Document {
Some(window), Some(window),
0i32, 0i32,
&touches, &touches,
&TouchList::new(window, from_ref(&&*touch)), &TouchList::new(window, from_ref(&&*touch), can_gc),
&TouchList::new(window, target_touches.r()), &TouchList::new(window, target_touches.r(), can_gc),
// FIXME: modifier keys // FIXME: modifier keys
false, false,
false, false,
@ -4558,8 +4558,12 @@ impl Document {
self.visibility_state.set(visibility_state); self.visibility_state.set(visibility_state);
// Step 3 Queue a new VisibilityStateEntry whose visibility state is visibilityState and whose timestamp is // Step 3 Queue a new VisibilityStateEntry whose visibility state is visibilityState and whose timestamp is
// the current high resolution time given document's relevant global object. // the current high resolution time given document's relevant global object.
let entry = let entry = VisibilityStateEntry::new(
VisibilityStateEntry::new(&self.global(), visibility_state, CrossProcessInstant::now()); &self.global(),
visibility_state,
CrossProcessInstant::now(),
can_gc,
);
self.window self.window
.Performance() .Performance()
.queue_entry(entry.upcast::<PerformanceEntry>(), can_gc); .queue_entry(entry.upcast::<PerformanceEntry>(), can_gc);
@ -4649,13 +4653,15 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
StyleSheetList::new( StyleSheetList::new(
&self.window, &self.window,
StyleSheetListOwner::Document(Dom::from_ref(self)), StyleSheetListOwner::Document(Dom::from_ref(self)),
CanGc::note(),
) )
}) })
} }
// https://dom.spec.whatwg.org/#dom-document-implementation // https://dom.spec.whatwg.org/#dom-document-implementation
fn Implementation(&self) -> DomRoot<DOMImplementation> { fn Implementation(&self) -> DomRoot<DOMImplementation> {
self.implementation.or_init(|| DOMImplementation::new(self)) self.implementation
.or_init(|| DOMImplementation::new(self, CanGc::note()))
} }
// https://dom.spec.whatwg.org/#dom-document-url // https://dom.spec.whatwg.org/#dom-document-url
@ -5055,9 +5061,10 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
match &*interface { match &*interface {
"beforeunloadevent" => Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized( "beforeunloadevent" => Ok(DomRoot::upcast(BeforeUnloadEvent::new_uninitialized(
&self.window, &self.window,
can_gc,
))), ))),
"compositionevent" | "textevent" => Ok(DomRoot::upcast( "compositionevent" | "textevent" => Ok(DomRoot::upcast(
CompositionEvent::new_uninitialized(&self.window), CompositionEvent::new_uninitialized(&self.window, can_gc),
)), )),
"customevent" => Ok(DomRoot::upcast(CustomEvent::new_uninitialized( "customevent" => Ok(DomRoot::upcast(CustomEvent::new_uninitialized(
self.window.upcast(), self.window.upcast(),
@ -5095,9 +5102,10 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
))), ))),
"touchevent" => Ok(DomRoot::upcast(DomTouchEvent::new_uninitialized( "touchevent" => Ok(DomRoot::upcast(DomTouchEvent::new_uninitialized(
&self.window, &self.window,
&TouchList::new(&self.window, &[]), &TouchList::new(&self.window, &[], can_gc),
&TouchList::new(&self.window, &[]), &TouchList::new(&self.window, &[], can_gc),
&TouchList::new(&self.window, &[]), &TouchList::new(&self.window, &[], can_gc),
can_gc,
))), ))),
"uievent" | "uievents" => Ok(DomRoot::upcast(UIEvent::new_uninitialized( "uievent" | "uievents" => Ok(DomRoot::upcast(UIEvent::new_uninitialized(
&self.window, &self.window,
@ -5942,7 +5950,10 @@ impl DocumentMethods<crate::DomTypeHolder> for Document {
// https://w3c.github.io/selection-api/#dom-document-getselection // https://w3c.github.io/selection-api/#dom-document-getselection
fn GetSelection(&self) -> Option<DomRoot<Selection>> { fn GetSelection(&self) -> Option<DomRoot<Selection>> {
if self.has_browsing_context { if self.has_browsing_context {
Some(self.selection.or_init(|| Selection::new(self))) Some(
self.selection
.or_init(|| Selection::new(self, CanGc::note())),
)
} else { } else {
None None
} }

View file

@ -145,13 +145,17 @@ impl DOMException {
} }
} }
pub(crate) fn new(global: &GlobalScope, code: DOMErrorName) -> DomRoot<DOMException> { pub(crate) fn new(
global: &GlobalScope,
code: DOMErrorName,
can_gc: CanGc,
) -> DomRoot<DOMException> {
let (message, name) = DOMException::get_error_data_by_code(code); let (message, name) = DOMException::get_error_data_by_code(code);
reflect_dom_object( reflect_dom_object(
Box::new(DOMException::new_inherited(message, name)), Box::new(DOMException::new_inherited(message, name)),
global, global,
CanGc::note(), can_gc,
) )
} }

View file

@ -47,12 +47,12 @@ impl DOMImplementation {
} }
} }
pub(crate) fn new(document: &Document) -> DomRoot<DOMImplementation> { pub(crate) fn new(document: &Document, can_gc: CanGc) -> DomRoot<DOMImplementation> {
let window = document.window(); let window = document.window();
reflect_dom_object( reflect_dom_object(
Box::new(DOMImplementation::new_inherited(document)), Box::new(DOMImplementation::new_inherited(document)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }
@ -110,6 +110,7 @@ impl DOMImplementationMethods<crate::DomTypeHolder> for DOMImplementation {
DocumentSource::NotFromParser, DocumentSource::NotFromParser,
loader, loader,
Some(self.document.insecure_requests_policy()), Some(self.document.insecure_requests_policy()),
can_gc,
); );
// Step 2. Let element be null. // Step 2. Let element be null.

View file

@ -27,11 +27,15 @@ impl DOMStringList {
} }
#[allow(unused)] #[allow(unused)]
pub(crate) fn new(window: &Window, strings: Vec<DOMString>) -> DomRoot<DOMStringList> { pub(crate) fn new(
window: &Window,
strings: Vec<DOMString>,
can_gc: CanGc,
) -> DomRoot<DOMStringList> {
reflect_dom_object( reflect_dom_object(
Box::new(DOMStringList::new_inherited(strings)), Box::new(DOMStringList::new_inherited(strings)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -27,11 +27,11 @@ impl DOMStringMap {
} }
} }
pub(crate) fn new(element: &HTMLElement) -> DomRoot<DOMStringMap> { pub(crate) fn new(element: &HTMLElement, can_gc: CanGc) -> DomRoot<DOMStringMap> {
reflect_dom_object( reflect_dom_object(
Box::new(DOMStringMap::new_inherited(element)), Box::new(DOMStringMap::new_inherited(element)),
&*element.owner_window(), &*element.owner_window(),
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -45,6 +45,7 @@ impl DOMTokenList {
element: &Element, element: &Element,
local_name: &LocalName, local_name: &LocalName,
supported_tokens: Option<Vec<Atom>>, supported_tokens: Option<Vec<Atom>>,
can_gc: CanGc,
) -> DomRoot<DOMTokenList> { ) -> DomRoot<DOMTokenList> {
reflect_dom_object( reflect_dom_object(
Box::new(DOMTokenList::new_inherited( Box::new(DOMTokenList::new_inherited(
@ -53,7 +54,7 @@ impl DOMTokenList {
supported_tokens, supported_tokens,
)), )),
&*element.owner_window(), &*element.owner_window(),
CanGc::note(), can_gc,
) )
} }

View file

@ -45,11 +45,12 @@ impl DynamicModuleOwner {
global: &GlobalScope, global: &GlobalScope,
promise: Rc<Promise>, promise: Rc<Promise>,
id: DynamicModuleId, id: DynamicModuleId,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
reflect_dom_object( reflect_dom_object(
Box::new(DynamicModuleOwner::new_inherited(promise, id)), Box::new(DynamicModuleOwner::new_inherited(promise, id)),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -546,6 +546,7 @@ impl Element {
mode, mode,
slot_assignment_mode, slot_assignment_mode,
clonable, clonable,
CanGc::note(),
); );
self.ensure_rare_data().shadow_root = Some(Dom::from_ref(&*shadow_root)); self.ensure_rare_data().shadow_root = Some(Dom::from_ref(&*shadow_root));
shadow_root shadow_root
@ -2182,7 +2183,7 @@ impl Element {
let elem = self let elem = self
.downcast::<HTMLElement>() .downcast::<HTMLElement>()
.expect("ensure_element_internals should only be called for an HTMLElement"); .expect("ensure_element_internals should only be called for an HTMLElement");
Dom::from_ref(&*ElementInternals::new(elem)) Dom::from_ref(&*ElementInternals::new(elem, CanGc::note()))
})) }))
} }
} }
@ -2245,7 +2246,7 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
// https://dom.spec.whatwg.org/#dom-element-classlist // https://dom.spec.whatwg.org/#dom-element-classlist
fn ClassList(&self) -> DomRoot<DOMTokenList> { fn ClassList(&self) -> DomRoot<DOMTokenList> {
self.class_list self.class_list
.or_init(|| DOMTokenList::new(self, &local_name!("class"), None)) .or_init(|| DOMTokenList::new(self, &local_name!("class"), None, CanGc::note()))
} }
// https://dom.spec.whatwg.org/#dom-element-slot // https://dom.spec.whatwg.org/#dom-element-slot
@ -2257,7 +2258,7 @@ impl ElementMethods<crate::DomTypeHolder> for Element {
// https://dom.spec.whatwg.org/#dom-element-attributes // https://dom.spec.whatwg.org/#dom-element-attributes
fn Attributes(&self) -> DomRoot<NamedNodeMap> { fn Attributes(&self) -> DomRoot<NamedNodeMap> {
self.attr_list self.attr_list
.or_init(|| NamedNodeMap::new(&self.owner_window(), self)) .or_init(|| NamedNodeMap::new(&self.owner_window(), self, CanGc::note()))
} }
// https://dom.spec.whatwg.org/#dom-element-hasattributes // https://dom.spec.whatwg.org/#dom-element-hasattributes

View file

@ -87,12 +87,12 @@ impl ElementInternals {
} }
} }
pub(crate) fn new(element: &HTMLElement) -> DomRoot<ElementInternals> { pub(crate) fn new(element: &HTMLElement, can_gc: CanGc) -> DomRoot<ElementInternals> {
let global = element.owner_window(); let global = element.owner_window();
reflect_dom_object( reflect_dom_object(
Box::new(ElementInternals::new_inherited(element)), Box::new(ElementInternals::new_inherited(element)),
&*global, &*global,
CanGc::note(), can_gc,
) )
} }
@ -350,6 +350,7 @@ impl Validatable for ElementInternals {
ValidityState::new( ValidityState::new(
&self.target_element.owner_window(), &self.target_element.owner_window(),
self.target_element.upcast(), self.target_element.upcast(),
CanGc::note(),
) )
}) })
} }

View file

@ -30,13 +30,17 @@ impl FileList {
} }
#[cfg_attr(crown, allow(crown::unrooted_must_root))] #[cfg_attr(crown, allow(crown::unrooted_must_root))]
pub(crate) fn new(window: &Window, files: Vec<DomRoot<File>>) -> DomRoot<FileList> { pub(crate) fn new(
window: &Window,
files: Vec<DomRoot<File>>,
can_gc: CanGc,
) -> DomRoot<FileList> {
reflect_dom_object( reflect_dom_object(
Box::new(FileList::new_inherited( Box::new(FileList::new_inherited(
files.iter().map(|r| Dom::from_ref(&**r)).collect(), files.iter().map(|r| Dom::from_ref(&**r)).collect(),
)), )),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -214,7 +214,7 @@ impl FileReader {
fr.change_ready_state(FileReaderReadyState::Done); fr.change_ready_state(FileReaderReadyState::Done);
*fr.result.borrow_mut() = None; *fr.result.borrow_mut() = None;
let exception = DOMException::new(&fr.global(), error); let exception = DOMException::new(&fr.global(), error, can_gc);
fr.error.set(Some(&exception)); fr.error.set(Some(&exception));
fr.dispatch_progress_event(atom!("error"), 0, None, can_gc); fr.dispatch_progress_event(atom!("error"), 0, None, can_gc);
@ -413,7 +413,7 @@ impl FileReaderMethods<crate::DomTypeHolder> for FileReader {
// Steps 1 & 3 // Steps 1 & 3
*self.result.borrow_mut() = None; *self.result.borrow_mut() = None;
let exception = DOMException::new(&self.global(), DOMErrorName::AbortError); let exception = DOMException::new(&self.global(), DOMErrorName::AbortError, can_gc);
self.error.set(Some(&exception)); self.error.set(Some(&exception));
self.terminate_ongoing_reading(); self.terminate_ongoing_reading();

View file

@ -58,6 +58,7 @@ impl GainNode {
*options.gain, // default value *options.gain, // default value
f32::MIN, // min value f32::MIN, // min value
f32::MAX, // max value f32::MAX, // max value
CanGc::note(),
); );
Ok(GainNode { Ok(GainNode {
node, node,

View file

@ -35,11 +35,12 @@ impl GamepadButton {
global: &GlobalScope, global: &GlobalScope,
pressed: bool, pressed: bool,
touched: bool, touched: bool,
can_gc: CanGc,
) -> DomRoot<GamepadButton> { ) -> DomRoot<GamepadButton> {
reflect_dom_object( reflect_dom_object(
Box::new(GamepadButton::new_inherited(pressed, touched)), Box::new(GamepadButton::new_inherited(pressed, touched)),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -27,11 +27,15 @@ impl GamepadButtonList {
} }
} }
pub(crate) fn new(global: &GlobalScope, list: &[&GamepadButton]) -> DomRoot<GamepadButtonList> { pub(crate) fn new(
global: &GlobalScope,
list: &[&GamepadButton],
can_gc: CanGc,
) -> DomRoot<GamepadButtonList> {
reflect_dom_object( reflect_dom_object(
Box::new(GamepadButtonList::new_inherited(list)), Box::new(GamepadButtonList::new_inherited(list)),
global, global,
CanGc::note(), can_gc,
) )
} }
} }
@ -60,25 +64,25 @@ impl GamepadButtonList {
/// <https://www.w3.org/TR/gamepad/#dfn-initializing-buttons> /// <https://www.w3.org/TR/gamepad/#dfn-initializing-buttons>
pub(crate) fn init_buttons(global: &GlobalScope) -> DomRoot<GamepadButtonList> { pub(crate) fn init_buttons(global: &GlobalScope) -> DomRoot<GamepadButtonList> {
let standard_buttons = &[ let standard_buttons = &[
GamepadButton::new(global, false, false), // Bottom button in right cluster GamepadButton::new(global, false, false, CanGc::note()), // Bottom button in right cluster
GamepadButton::new(global, false, false), // Right button in right cluster GamepadButton::new(global, false, false, CanGc::note()), // Right button in right cluster
GamepadButton::new(global, false, false), // Left button in right cluster GamepadButton::new(global, false, false, CanGc::note()), // Left button in right cluster
GamepadButton::new(global, false, false), // Top button in right cluster GamepadButton::new(global, false, false, CanGc::note()), // Top button in right cluster
GamepadButton::new(global, false, false), // Top left front button GamepadButton::new(global, false, false, CanGc::note()), // Top left front button
GamepadButton::new(global, false, false), // Top right front button GamepadButton::new(global, false, false, CanGc::note()), // Top right front button
GamepadButton::new(global, false, false), // Bottom left front button GamepadButton::new(global, false, false, CanGc::note()), // Bottom left front button
GamepadButton::new(global, false, false), // Bottom right front button GamepadButton::new(global, false, false, CanGc::note()), // Bottom right front button
GamepadButton::new(global, false, false), // Left button in center cluster GamepadButton::new(global, false, false, CanGc::note()), // Left button in center cluster
GamepadButton::new(global, false, false), // Right button in center cluster GamepadButton::new(global, false, false, CanGc::note()), // Right button in center cluster
GamepadButton::new(global, false, false), // Left stick pressed button GamepadButton::new(global, false, false, CanGc::note()), // Left stick pressed button
GamepadButton::new(global, false, false), // Right stick pressed button GamepadButton::new(global, false, false, CanGc::note()), // Right stick pressed button
GamepadButton::new(global, false, false), // Top button in left cluster GamepadButton::new(global, false, false, CanGc::note()), // Top button in left cluster
GamepadButton::new(global, false, false), // Bottom button in left cluster GamepadButton::new(global, false, false, CanGc::note()), // Bottom button in left cluster
GamepadButton::new(global, false, false), // Left button in left cluster GamepadButton::new(global, false, false, CanGc::note()), // Left button in left cluster
GamepadButton::new(global, false, false), // Right button in left cluster GamepadButton::new(global, false, false, CanGc::note()), // Right button in left cluster
GamepadButton::new(global, false, false), // Center button in center cluster GamepadButton::new(global, false, false, CanGc::note()), // Center button in center cluster
]; ];
rooted_vec!(let buttons <- standard_buttons.iter().map(DomRoot::as_traced)); rooted_vec!(let buttons <- standard_buttons.iter().map(DomRoot::as_traced));
Self::new(global, buttons.r()) Self::new(global, buttons.r(), CanGc::note())
} }
} }

View file

@ -44,12 +44,8 @@ impl GamepadPose {
} }
} }
pub(crate) fn new(global: &GlobalScope) -> DomRoot<GamepadPose> { pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<GamepadPose> {
reflect_dom_object( reflect_dom_object(Box::new(GamepadPose::new_inherited()), global, can_gc)
Box::new(GamepadPose::new_inherited()),
global,
CanGc::note(),
)
} }
} }

View file

@ -814,7 +814,8 @@ impl GlobalScope {
} }
// Step 2.1 -> 2.5 // Step 2.1 -> 2.5
let new_registration = ServiceWorkerRegistration::new(self, scope.clone(), registration_id); let new_registration =
ServiceWorkerRegistration::new(self, scope.clone(), registration_id, CanGc::note());
// Step 2.6 // Step 2.6
if let Some(worker_id) = installing_worker { if let Some(worker_id) = installing_worker {
@ -849,7 +850,13 @@ impl GlobalScope {
} else { } else {
// Step 2.1 // Step 2.1
// TODO: step 2.2, worker state. // TODO: step 2.2, worker state.
let new_worker = ServiceWorker::new(self, script_url.clone(), scope.clone(), worker_id); let new_worker = ServiceWorker::new(
self,
script_url.clone(),
scope.clone(),
worker_id,
CanGc::note(),
);
// Step 2.3 // Step 2.3
workers.insert(worker_id, Dom::from_ref(&*new_worker)); workers.insert(worker_id, Dom::from_ref(&*new_worker));
@ -2136,7 +2143,7 @@ impl GlobalScope {
} }
pub(crate) fn crypto(&self) -> DomRoot<Crypto> { pub(crate) fn crypto(&self) -> DomRoot<Crypto> {
self.crypto.or_init(|| Crypto::new(self)) self.crypto.or_init(|| Crypto::new(self, CanGc::note()))
} }
pub(crate) fn live_devtools_updates(&self) -> bool { pub(crate) fn live_devtools_updates(&self) -> bool {
@ -2719,7 +2726,8 @@ impl GlobalScope {
.map(|data| data.to_vec()) .map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]); .unwrap_or_else(|| vec![0; size.area() as usize * 4]);
let image_bitmap = ImageBitmap::new(self, size.width, size.height).unwrap(); let image_bitmap =
ImageBitmap::new(self, size.width, size.height, can_gc).unwrap();
image_bitmap.set_bitmap_data(data); image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean()); image_bitmap.set_origin_clean(canvas.origin_is_clean());
@ -2739,7 +2747,8 @@ impl GlobalScope {
.map(|data| data.to_vec()) .map(|data| data.to_vec())
.unwrap_or_else(|| vec![0; size.area() as usize * 4]); .unwrap_or_else(|| vec![0; size.area() as usize * 4]);
let image_bitmap = ImageBitmap::new(self, size.width, size.height).unwrap(); let image_bitmap =
ImageBitmap::new(self, size.width, size.height, can_gc).unwrap();
image_bitmap.set_bitmap_data(data); image_bitmap.set_bitmap_data(data);
image_bitmap.set_origin_clean(canvas.origin_is_clean()); image_bitmap.set_origin_clean(canvas.origin_is_clean());
p.resolve_native(&(image_bitmap)); p.resolve_native(&(image_bitmap));

View file

@ -62,12 +62,8 @@ impl History {
} }
} }
pub(crate) fn new(window: &Window) -> DomRoot<History> { pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<History> {
reflect_dom_object( reflect_dom_object(Box::new(History::new_inherited(window)), window, can_gc)
Box::new(History::new_inherited(window)),
window,
CanGc::note(),
)
} }
} }

View file

@ -153,6 +153,7 @@ impl HTMLAnchorElementMethods<crate::DomTypeHolder> for HTMLAnchorElement {
Atom::from("noreferrer"), Atom::from("noreferrer"),
Atom::from("opener"), Atom::from("opener"),
]), ]),
CanGc::note(),
) )
}) })
} }

View file

@ -370,6 +370,7 @@ impl HTMLAreaElementMethods<crate::DomTypeHolder> for HTMLAreaElement {
Atom::from("noreferrer"), Atom::from("noreferrer"),
Atom::from("opener"), Atom::from("opener"),
]), ]),
CanGc::note(),
) )
}) })
} }

View file

@ -333,7 +333,7 @@ impl Validatable for HTMLButtonElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -276,7 +276,8 @@ impl HTMLCanvasElement {
let window = self.owner_window(); let window = self.owner_window();
let size = self.get_size(); let size = self.get_size();
let context = CanvasRenderingContext2D::new(window.as_global_scope(), self, size); let context =
CanvasRenderingContext2D::new(window.as_global_scope(), self, size, CanGc::note());
*self.context.borrow_mut() = Some(CanvasContext::Context2d(Dom::from_ref(&*context))); *self.context.borrow_mut() = Some(CanvasContext::Context2d(Dom::from_ref(&*context)));
Some(context) Some(context)
} }
@ -356,7 +357,7 @@ impl HTMLCanvasElement {
.recv() .recv()
.expect("Failed to get WebGPU channel") .expect("Failed to get WebGPU channel")
.map(|channel| { .map(|channel| {
let context = GPUCanvasContext::new(&global_scope, self, channel); let context = GPUCanvasContext::new(&global_scope, self, channel, CanGc::note());
*self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context))); *self.context.borrow_mut() = Some(CanvasContext::WebGPU(Dom::from_ref(&*context)));
context context
}) })
@ -717,7 +718,12 @@ impl HTMLCanvasElementMethods<crate::DomTypeHolder> for HTMLCanvasElement {
) -> DomRoot<MediaStream> { ) -> DomRoot<MediaStream> {
let global = self.global(); let global = self.global();
let stream = MediaStream::new(&global, can_gc); let stream = MediaStream::new(&global, can_gc);
let track = MediaStreamTrack::new(&global, MediaStreamId::new(), MediaStreamType::Video); let track = MediaStreamTrack::new(
&global,
MediaStreamId::new(),
MediaStreamType::Video,
can_gc,
);
stream.AddTrack(&track); stream.AddTrack(&track);
stream stream
} }

View file

@ -96,7 +96,7 @@ impl HTMLCollection {
} }
} }
Self::new(window, root, Box::new(NoFilter)) Self::new(window, root, Box::new(NoFilter), CanGc::note())
} }
#[cfg_attr(crown, allow(crown::unrooted_must_root))] #[cfg_attr(crown, allow(crown::unrooted_must_root))]
@ -104,12 +104,9 @@ impl HTMLCollection {
window: &Window, window: &Window,
root: &Node, root: &Node,
filter: Box<dyn CollectionFilter + 'static>, filter: Box<dyn CollectionFilter + 'static>,
can_gc: CanGc,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
reflect_dom_object( reflect_dom_object(Box::new(Self::new_inherited(root, filter)), window, can_gc)
Box::new(Self::new_inherited(root, filter)),
window,
CanGc::note(),
)
} }
/// Create a new [`HTMLCollection`] that just filters element using a static function. /// Create a new [`HTMLCollection`] that just filters element using a static function.
@ -135,6 +132,7 @@ impl HTMLCollection {
window, window,
root, root,
Box::new(StaticFunctionFilter(filter_function)), Box::new(StaticFunctionFilter(filter_function)),
CanGc::note(),
) )
} }
@ -143,7 +141,7 @@ impl HTMLCollection {
root: &Node, root: &Node,
filter: Box<dyn CollectionFilter + 'static>, filter: Box<dyn CollectionFilter + 'static>,
) -> DomRoot<Self> { ) -> DomRoot<Self> {
Self::new(window, root, filter) Self::new(window, root, filter, CanGc::note())
} }
fn validate_cache(&self) { fn validate_cache(&self) {

View file

@ -144,6 +144,7 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement {
CSSStyleOwner::Element(Dom::from_ref(self.upcast())), CSSStyleOwner::Element(Dom::from_ref(self.upcast())),
None, None,
CSSModificationAccess::ReadWrite, CSSModificationAccess::ReadWrite,
CanGc::note(),
) )
}) })
} }
@ -183,7 +184,8 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement {
// https://html.spec.whatwg.org/multipage/#dom-dataset // https://html.spec.whatwg.org/multipage/#dom-dataset
fn Dataset(&self) -> DomRoot<DOMStringMap> { fn Dataset(&self) -> DomRoot<DOMStringMap> {
self.dataset.or_init(|| DOMStringMap::new(self)) self.dataset
.or_init(|| DOMStringMap::new(self, CanGc::note()))
} }
// https://html.spec.whatwg.org/multipage/#handler-onerror // https://html.spec.whatwg.org/multipage/#handler-onerror

View file

@ -271,7 +271,7 @@ impl Validatable for HTMLFieldSetElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -45,11 +45,12 @@ impl HTMLFormControlsCollection {
window: &Window, window: &Window,
form: &HTMLFormElement, form: &HTMLFormElement,
filter: Box<dyn CollectionFilter + 'static>, filter: Box<dyn CollectionFilter + 'static>,
can_gc: CanGc,
) -> DomRoot<HTMLFormControlsCollection> { ) -> DomRoot<HTMLFormControlsCollection> {
reflect_dom_object( reflect_dom_object(
Box::new(HTMLFormControlsCollection::new_inherited(form, filter)), Box::new(HTMLFormControlsCollection::new_inherited(form, filter)),
window, window,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -420,7 +420,7 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement {
form: DomRoot::from_ref(self), form: DomRoot::from_ref(self),
}); });
let window = self.owner_window(); let window = self.owner_window();
HTMLFormControlsCollection::new(&window, self, filter) HTMLFormControlsCollection::new(&window, self, filter, CanGc::note())
})) }))
} }
@ -502,6 +502,7 @@ impl HTMLFormElementMethods<crate::DomTypeHolder> for HTMLFormElement {
Atom::from("noreferrer"), Atom::from("noreferrer"),
Atom::from("opener"), Atom::from("opener"),
]), ]),
CanGc::note(),
) )
}) })
} }

View file

@ -597,6 +597,7 @@ impl HTMLIFrameElementMethods<crate::DomTypeHolder> for HTMLIFrameElement {
Atom::from("allow-scripts"), Atom::from("allow-scripts"),
Atom::from("allow-top-navigation"), Atom::from("allow-top-navigation"),
]), ]),
CanGc::note(),
) )
}) })
} }

View file

@ -1179,6 +1179,7 @@ impl HTMLImageElement {
promise.reject_native(&DOMException::new( promise.reject_native(&DOMException::new(
&document.global(), &document.global(),
DOMErrorName::EncodingError, DOMErrorName::EncodingError,
CanGc::note(),
)); ));
} else if matches!( } else if matches!(
self.current_request.borrow().state, self.current_request.borrow().state,
@ -1206,6 +1207,7 @@ impl HTMLImageElement {
promise.reject_native(&DOMException::new( promise.reject_native(&DOMException::new(
&document.global(), &document.global(),
DOMErrorName::EncodingError, DOMErrorName::EncodingError,
CanGc::note(),
)); ));
} }
self.image_decode_promises.borrow_mut().clear(); self.image_decode_promises.borrow_mut().clear();

View file

@ -1326,7 +1326,7 @@ impl HTMLInputElementMethods<crate::DomTypeHolder> for HTMLInputElement {
ValueMode::Filename => { ValueMode::Filename => {
if value.is_empty() { if value.is_empty() {
let window = self.owner_window(); let window = self.owner_window();
let fl = FileList::new(&window, vec![]); let fl = FileList::new(&window, vec![], can_gc);
self.filelist.set(Some(&fl)); self.filelist.set(Some(&fl));
} else { } else {
return Err(Error::InvalidState); return Err(Error::InvalidState);
@ -1961,7 +1961,7 @@ impl HTMLInputElement {
if let Some(err) = error { if let Some(err) = error {
debug!("Input file select error: {:?}", err); debug!("Input file select error: {:?}", err);
} else { } else {
let filelist = FileList::new(&window, files); let filelist = FileList::new(&window, files, can_gc);
self.filelist.set(Some(&filelist)); self.filelist.set(Some(&filelist));
target.fire_bubbling_event(atom!("input"), can_gc); target.fire_bubbling_event(atom!("input"), can_gc);
@ -2380,7 +2380,7 @@ impl VirtualMethods for HTMLInputElement {
if new_type == InputType::File { if new_type == InputType::File {
let window = self.owner_window(); let window = self.owner_window();
let filelist = FileList::new(&window, vec![]); let filelist = FileList::new(&window, vec![], CanGc::note());
self.filelist.set(Some(&filelist)); self.filelist.set(Some(&filelist));
} }
@ -2722,7 +2722,7 @@ impl Validatable for HTMLInputElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -183,6 +183,7 @@ impl HTMLLinkElement {
None, // todo handle location None, // todo handle location
None, // todo handle title None, // todo handle title
sheet, sheet,
CanGc::note(),
) )
}) })
}) })
@ -582,6 +583,7 @@ impl HTMLLinkElementMethods<crate::DomTypeHolder> for HTMLLinkElement {
Atom::from("prerender"), Atom::from("prerender"),
Atom::from("stylesheet"), Atom::from("stylesheet"),
]), ]),
CanGc::note(),
) )
}) })
} }

View file

@ -1014,8 +1014,7 @@ impl HTMLMediaElement {
// Step 1. // Step 1.
this.error.set(Some(&*MediaError::new( this.error.set(Some(&*MediaError::new(
&this.owner_window(), &this.owner_window(),
MEDIA_ERR_SRC_NOT_SUPPORTED, MEDIA_ERR_SRC_NOT_SUPPORTED, CanGc::note())));
)));
// Step 2. // Step 2.
this.AudioTracks().clear(); this.AudioTracks().clear();
@ -1562,6 +1561,7 @@ impl HTMLMediaElement {
self.error.set(Some(&*MediaError::new( self.error.set(Some(&*MediaError::new(
&self.owner_window(), &self.owner_window(),
MEDIA_ERR_DECODE, MEDIA_ERR_DECODE,
can_gc,
))); )));
// 3. Set the element's networkState attribute to the NETWORK_IDLE value. // 3. Set the element's networkState attribute to the NETWORK_IDLE value.
@ -1601,6 +1601,7 @@ impl HTMLMediaElement {
DOMString::new(), DOMString::new(),
DOMString::new(), DOMString::new(),
Some(&*self.AudioTracks()), Some(&*self.AudioTracks()),
can_gc,
); );
// Steps 2. & 3. // Steps 2. & 3.
@ -1660,6 +1661,7 @@ impl HTMLMediaElement {
DOMString::new(), DOMString::new(),
DOMString::new(), DOMString::new(),
Some(&*self.VideoTracks()), Some(&*self.VideoTracks()),
can_gc,
); );
// Steps 2. & 3. // Steps 2. & 3.
@ -2380,7 +2382,11 @@ impl HTMLMediaElementMethods<crate::DomTypeHolder> for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-media-played // https://html.spec.whatwg.org/multipage/#dom-media-played
fn Played(&self) -> DomRoot<TimeRanges> { fn Played(&self) -> DomRoot<TimeRanges> {
TimeRanges::new(self.global().as_window(), self.played.borrow().clone()) TimeRanges::new(
self.global().as_window(),
self.played.borrow().clone(),
CanGc::note(),
)
} }
// https://html.spec.whatwg.org/multipage/#dom-media-buffered // https://html.spec.whatwg.org/multipage/#dom-media-buffered
@ -2393,28 +2399,28 @@ impl HTMLMediaElementMethods<crate::DomTypeHolder> for HTMLMediaElement {
} }
} }
} }
TimeRanges::new(self.global().as_window(), buffered) TimeRanges::new(self.global().as_window(), buffered, CanGc::note())
} }
// https://html.spec.whatwg.org/multipage/#dom-media-audiotracks // https://html.spec.whatwg.org/multipage/#dom-media-audiotracks
fn AudioTracks(&self) -> DomRoot<AudioTrackList> { fn AudioTracks(&self) -> DomRoot<AudioTrackList> {
let window = self.owner_window(); let window = self.owner_window();
self.audio_tracks_list self.audio_tracks_list
.or_init(|| AudioTrackList::new(&window, &[], Some(self))) .or_init(|| AudioTrackList::new(&window, &[], Some(self), CanGc::note()))
} }
// https://html.spec.whatwg.org/multipage/#dom-media-videotracks // https://html.spec.whatwg.org/multipage/#dom-media-videotracks
fn VideoTracks(&self) -> DomRoot<VideoTrackList> { fn VideoTracks(&self) -> DomRoot<VideoTrackList> {
let window = self.owner_window(); let window = self.owner_window();
self.video_tracks_list self.video_tracks_list
.or_init(|| VideoTrackList::new(&window, &[], Some(self))) .or_init(|| VideoTrackList::new(&window, &[], Some(self), CanGc::note()))
} }
// https://html.spec.whatwg.org/multipage/#dom-media-texttracks // https://html.spec.whatwg.org/multipage/#dom-media-texttracks
fn TextTracks(&self) -> DomRoot<TextTrackList> { fn TextTracks(&self) -> DomRoot<TextTrackList> {
let window = self.owner_window(); let window = self.owner_window();
self.text_tracks_list self.text_tracks_list
.or_init(|| TextTrackList::new(&window, &[])) .or_init(|| TextTrackList::new(&window, &[], CanGc::note()))
} }
// https://html.spec.whatwg.org/multipage/#dom-media-addtexttrack // https://html.spec.whatwg.org/multipage/#dom-media-addtexttrack
@ -2435,6 +2441,7 @@ impl HTMLMediaElementMethods<crate::DomTypeHolder> for HTMLMediaElement {
language, language,
TextTrackMode::Hidden, TextTrackMode::Hidden,
None, None,
CanGc::note(),
); );
// Step 3 & 4 // Step 3 & 4
self.TextTracks().add(&track); self.TextTracks().add(&track);
@ -2855,6 +2862,7 @@ impl FetchResponseListener for HTMLMediaElementFetchListener {
elem.error.set(Some(&*MediaError::new( elem.error.set(Some(&*MediaError::new(
&elem.owner_window(), &elem.owner_window(),
MEDIA_ERR_NETWORK, MEDIA_ERR_NETWORK,
CanGc::note(),
))); )));
// Step 3 // Step 3

View file

@ -139,7 +139,7 @@ impl Validatable for HTMLObjectElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -47,11 +47,12 @@ impl HTMLOptionsCollection {
window: &Window, window: &Window,
select: &HTMLSelectElement, select: &HTMLSelectElement,
filter: Box<dyn CollectionFilter + 'static>, filter: Box<dyn CollectionFilter + 'static>,
can_gc: CanGc,
) -> DomRoot<HTMLOptionsCollection> { ) -> DomRoot<HTMLOptionsCollection> {
reflect_dom_object( reflect_dom_object(
Box::new(HTMLOptionsCollection::new_inherited(select, filter)), Box::new(HTMLOptionsCollection::new_inherited(select, filter)),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -188,7 +188,7 @@ impl Validatable for HTMLOutputElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -280,7 +280,7 @@ impl HTMLSelectElementMethods<crate::DomTypeHolder> for HTMLSelectElement {
fn Options(&self) -> DomRoot<HTMLOptionsCollection> { fn Options(&self) -> DomRoot<HTMLOptionsCollection> {
self.options.or_init(|| { self.options.or_init(|| {
let window = self.owner_window(); let window = self.owner_window();
HTMLOptionsCollection::new(&window, self, Box::new(OptionsFilter)) HTMLOptionsCollection::new(&window, self, Box::new(OptionsFilter), CanGc::note())
}) })
} }
@ -510,7 +510,7 @@ impl Validatable for HTMLSelectElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -177,6 +177,7 @@ impl HTMLStyleElement {
None, // todo handle location None, // todo handle location
None, // todo handle title None, // todo handle title
sheet, sheet,
CanGc::note(),
) )
}) })
}) })

View file

@ -187,7 +187,12 @@ impl HTMLTableElementMethods<crate::DomTypeHolder> for HTMLTableElement {
// https://html.spec.whatwg.org/multipage/#dom-table-rows // https://html.spec.whatwg.org/multipage/#dom-table-rows
fn Rows(&self) -> DomRoot<HTMLCollection> { fn Rows(&self) -> DomRoot<HTMLCollection> {
let filter = self.get_rows(); let filter = self.get_rows();
HTMLCollection::new(&self.owner_window(), self.upcast(), Box::new(filter)) HTMLCollection::new(
&self.owner_window(),
self.upcast(),
Box::new(filter),
CanGc::note(),
)
} }
// https://html.spec.whatwg.org/multipage/#dom-table-caption // https://html.spec.whatwg.org/multipage/#dom-table-caption

View file

@ -723,7 +723,7 @@ impl Validatable for HTMLTextAreaElement {
fn validity_state(&self) -> DomRoot<ValidityState> { fn validity_state(&self) -> DomRoot<ValidityState> {
self.validity_state self.validity_state
.or_init(|| ValidityState::new(&self.owner_window(), self.upcast())) .or_init(|| ValidityState::new(&self.owner_window(), self.upcast(), CanGc::note()))
} }
fn is_instance_validatable(&self) -> bool { fn is_instance_validatable(&self) -> bool {

View file

@ -65,6 +65,7 @@ impl HTMLTrackElement {
Default::default(), Default::default(),
Default::default(), Default::default(),
None, None,
can_gc,
); );
Node::reflect_node_with_proto( Node::reflect_node_with_proto(
Box::new(HTMLTrackElement::new_inherited( Box::new(HTMLTrackElement::new_inherited(

View file

@ -44,11 +44,12 @@ impl ImageBitmap {
global: &GlobalScope, global: &GlobalScope,
width: u32, width: u32,
height: u32, height: u32,
can_gc: CanGc,
) -> Fallible<DomRoot<ImageBitmap>> { ) -> Fallible<DomRoot<ImageBitmap>> {
//assigning to a variable the return object of new_inherited //assigning to a variable the return object of new_inherited
let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height)); let imagebitmap = Box::new(ImageBitmap::new_inherited(width, height));
Ok(reflect_dom_object(imagebitmap, global, CanGc::note())) Ok(reflect_dom_object(imagebitmap, global, can_gc))
} }
pub(crate) fn set_bitmap_data(&self, data: Vec<u8>) { pub(crate) fn set_bitmap_data(&self, data: Vec<u8>) {

View file

@ -57,12 +57,8 @@ impl Location {
} }
} }
pub(crate) fn new(window: &Window) -> DomRoot<Location> { pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<Location> {
reflect_dom_object( reflect_dom_object(Box::new(Location::new_inherited(window)), window, can_gc)
Box::new(Location::new_inherited(window)),
window,
CanGc::note(),
)
} }
/// Navigate the relevant `Document`'s browsing context. /// Navigate the relevant `Document`'s browsing context.

View file

@ -46,13 +46,14 @@ impl MediaDeviceInfo {
kind: MediaDeviceKind, kind: MediaDeviceKind,
label: &str, label: &str,
group_id: &str, group_id: &str,
can_gc: CanGc,
) -> DomRoot<MediaDeviceInfo> { ) -> DomRoot<MediaDeviceInfo> {
reflect_dom_object( reflect_dom_object(
Box::new(MediaDeviceInfo::new_inherited( Box::new(MediaDeviceInfo::new_inherited(
device_id, kind, label, group_id, device_id, kind, label, group_id,
)), )),
global, global,
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -40,12 +40,8 @@ impl MediaDevices {
} }
} }
pub(crate) fn new(global: &GlobalScope) -> DomRoot<MediaDevices> { pub(crate) fn new(global: &GlobalScope, can_gc: CanGc) -> DomRoot<MediaDevices> {
reflect_dom_object( reflect_dom_object(Box::new(MediaDevices::new_inherited()), global, can_gc)
Box::new(MediaDevices::new_inherited()),
global,
CanGc::note(),
)
} }
} }
@ -63,13 +59,15 @@ impl MediaDevicesMethods<crate::DomTypeHolder> for MediaDevices {
let stream = MediaStream::new(&self.global(), can_gc); let stream = MediaStream::new(&self.global(), can_gc);
if let Some(constraints) = convert_constraints(&constraints.audio) { if let Some(constraints) = convert_constraints(&constraints.audio) {
if let Some(audio) = media.create_audioinput_stream(constraints) { if let Some(audio) = media.create_audioinput_stream(constraints) {
let track = MediaStreamTrack::new(&self.global(), audio, MediaStreamType::Audio); let track =
MediaStreamTrack::new(&self.global(), audio, MediaStreamType::Audio, can_gc);
stream.add_track(&track); stream.add_track(&track);
} }
} }
if let Some(constraints) = convert_constraints(&constraints.video) { if let Some(constraints) = convert_constraints(&constraints.video) {
if let Some(video) = media.create_videoinput_stream(constraints) { if let Some(video) = media.create_videoinput_stream(constraints) {
let track = MediaStreamTrack::new(&self.global(), video, MediaStreamType::Video); let track =
MediaStreamTrack::new(&self.global(), video, MediaStreamType::Video, can_gc);
stream.add_track(&track); stream.add_track(&track);
} }
} }
@ -102,6 +100,7 @@ impl MediaDevicesMethods<crate::DomTypeHolder> for MediaDevices {
device.kind.convert(), device.kind.convert(),
&device.label, &device.label,
"", "",
can_gc,
) )
}) })
.collect(), .collect(),

View file

@ -25,12 +25,8 @@ impl MediaError {
} }
} }
pub(crate) fn new(window: &Window, code: u16) -> DomRoot<MediaError> { pub(crate) fn new(window: &Window, code: u16, can_gc: CanGc) -> DomRoot<MediaError> {
reflect_dom_object( reflect_dom_object(Box::new(MediaError::new_inherited(code)), window, can_gc)
Box::new(MediaError::new_inherited(code)),
window,
CanGc::note(),
)
} }
} }

View file

@ -47,11 +47,12 @@ impl MediaList {
window: &Window, window: &Window,
parent_stylesheet: &CSSStyleSheet, parent_stylesheet: &CSSStyleSheet,
media_queries: Arc<Locked<StyleMediaList>>, media_queries: Arc<Locked<StyleMediaList>>,
can_gc: CanGc,
) -> DomRoot<MediaList> { ) -> DomRoot<MediaList> {
reflect_dom_object( reflect_dom_object(
Box::new(MediaList::new_inherited(parent_stylesheet, media_queries)), Box::new(MediaList::new_inherited(parent_stylesheet, media_queries)),
window, window,
CanGc::note(), can_gc,
) )
} }

View file

@ -46,11 +46,15 @@ impl MediaQueryList {
} }
} }
pub(crate) fn new(document: &Document, media_query_list: MediaList) -> DomRoot<MediaQueryList> { pub(crate) fn new(
document: &Document,
media_query_list: MediaList,
can_gc: CanGc,
) -> DomRoot<MediaQueryList> {
reflect_dom_object( reflect_dom_object(
Box::new(MediaQueryList::new_inherited(document, media_query_list)), Box::new(MediaQueryList::new_inherited(document, media_query_list)),
document.window(), document.window(),
CanGc::note(), can_gc,
) )
} }
} }

View file

@ -63,12 +63,8 @@ impl MediaSession {
} }
} }
pub(crate) fn new(window: &Window) -> DomRoot<MediaSession> { pub(crate) fn new(window: &Window, can_gc: CanGc) -> DomRoot<MediaSession> {
reflect_dom_object( reflect_dom_object(Box::new(MediaSession::new_inherited()), window, can_gc)
Box::new(MediaSession::new_inherited()),
window,
CanGc::note(),
)
} }
pub(crate) fn register_media_instance(&self, media_instance: &HTMLMediaElement) { pub(crate) fn register_media_instance(&self, media_instance: &HTMLMediaElement) {

View file

@ -57,7 +57,7 @@ impl MediaStream {
can_gc: CanGc, can_gc: CanGc,
) -> DomRoot<MediaStream> { ) -> DomRoot<MediaStream> {
let this = Self::new(global, can_gc); let this = Self::new(global, can_gc);
let track = MediaStreamTrack::new(global, id, ty); let track = MediaStreamTrack::new(global, id, ty, can_gc);
this.AddTrack(&track); this.AddTrack(&track);
this this
} }

View file

@ -38,11 +38,12 @@ impl MediaStreamTrack {
global: &GlobalScope, global: &GlobalScope,
id: MediaStreamId, id: MediaStreamId,
ty: MediaStreamType, ty: MediaStreamType,
can_gc: CanGc,
) -> DomRoot<MediaStreamTrack> { ) -> DomRoot<MediaStreamTrack> {
reflect_dom_object( reflect_dom_object(
Box::new(MediaStreamTrack::new_inherited(id, ty)), Box::new(MediaStreamTrack::new_inherited(id, ty)),
global, global,
CanGc::note(), can_gc,
) )
} }
@ -71,6 +72,6 @@ impl MediaStreamTrackMethods<crate::DomTypeHolder> for MediaStreamTrack {
/// <https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone> /// <https://w3c.github.io/mediacapture-main/#dom-mediastreamtrack-clone>
fn Clone(&self) -> DomRoot<MediaStreamTrack> { fn Clone(&self) -> DomRoot<MediaStreamTrack> {
MediaStreamTrack::new(&self.global(), self.id, self.ty) MediaStreamTrack::new(&self.global(), self.id, self.ty, CanGc::note())
} }
} }

View file

@ -27,10 +27,10 @@ impl MessageChannel {
can_gc: CanGc, can_gc: CanGc,
) -> DomRoot<MessageChannel> { ) -> DomRoot<MessageChannel> {
// Step 1 // Step 1
let port1 = MessagePort::new(incumbent); let port1 = MessagePort::new(incumbent, can_gc);
// Step 2 // Step 2
let port2 = MessagePort::new(incumbent); let port2 = MessagePort::new(incumbent, can_gc);
incumbent.track_message_port(&port1, None); incumbent.track_message_port(&port1, None);
incumbent.track_message_port(&port2, None); incumbent.track_message_port(&port2, None);

Some files were not shown because too many files have changed in this diff Show more