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

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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