Skip to content

Commit

Permalink
Use rooted_vec instead of Vec<JS<T>>
Browse files Browse the repository at this point in the history
  • Loading branch information
Zakor Gyula authored and dati91 committed Feb 13, 2017
1 parent 4a62562 commit f7e86d2
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions components/script/dom/bluetooth.rs
Expand Up @@ -573,7 +573,6 @@ impl PermissionAlgorithm for Bluetooth {
}
}

#[allow(unrooted_must_root)]
// https://webbluetoothcg.github.io/web-bluetooth/#query-the-bluetooth-permission
fn permission_query(cx: *mut JSContext, promise: &Rc<Promise>,
descriptor: &BluetoothPermissionDescriptor,
Expand All @@ -590,7 +589,7 @@ impl PermissionAlgorithm for Bluetooth {
}

// Step 4.
let mut matching_devices: Vec<JS<BluetoothDevice>> = Vec::new();
rooted_vec!(let mut matching_devices);

// TODO: Step 5: Create a map between the current setting object and BluetoothPermissionData
// extra permission data, which replaces the exisitng EXTRA_PERMISSION_DATA global variable.
Expand Down Expand Up @@ -644,13 +643,13 @@ impl PermissionAlgorithm for Bluetooth {
// Step 6.3.
// TODO: Implement this correctly, not just using device ids here.
// https://webbluetoothcg.github.io/web-bluetooth/#get-the-bluetoothdevice-representing
if let Some(ref device) = device_map.get(&device_id) {
matching_devices.push(JS::from_ref(&*device));
if let Some(device) = device_map.get(&device_id) {
matching_devices.push(JS::from_ref(&**device));
}
}

// Step 7.
status.set_devices(matching_devices);
status.set_devices(matching_devices.drain(..).collect());

// https://w3c.github.io/permissions/#dom-permissions-query
// Step 7.
Expand Down

0 comments on commit f7e86d2

Please sign in to comment.