diff options
author | Anthony Urena <anthony.urena@protonmail.com> | 2018-03-24 19:40:38 -0400 |
---|---|---|
committer | Anthony Urena <anthony.urena@protonmail.com> | 2018-03-24 20:46:14 -0400 |
commit | ef0e93c9b163ae1f61e583014372e5f4a623074c (patch) | |
tree | 378225047a83c09fcdf23b1e886e14bf562c6484 /components | |
parent | 5bf2e71407d7d0cdde5d5da381dce545135ae93a (diff) | |
download | servo-ef0e93c9b163ae1f61e583014372e5f4a623074c.tar.gz servo-ef0e93c9b163ae1f61e583014372e5f4a623074c.zip |
Updates Bluetooth type to use BufferSource
Diffstat (limited to 'components')
-rw-r--r-- | components/script/dom/bluetooth.rs | 14 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattcharacteristic.rs | 4 | ||||
-rw-r--r-- | components/script/dom/bluetoothremotegattdescriptor.rs | 4 | ||||
-rw-r--r-- | components/script/dom/webidls/Bluetooth.webidl | 6 |
4 files changed, 17 insertions, 11 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs index e0dd0f00e10..b980562c46d 100644 --- a/components/script/dom/bluetooth.rs +++ b/components/script/dom/bluetooth.rs @@ -14,7 +14,7 @@ use dom::bindings::codegen::Bindings::BluetoothPermissionResultBinding::Bluetoot use dom::bindings::codegen::Bindings::BluetoothRemoteGATTServerBinding::BluetoothRemoteGATTServerBinding:: BluetoothRemoteGATTServerMethods; use dom::bindings::codegen::Bindings::PermissionStatusBinding::{PermissionName, PermissionState}; -use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong; +use dom::bindings::codegen::UnionTypes::{ArrayBufferViewOrArrayBuffer, StringOrUnsignedLong}; use dom::bindings::error::Error::{self, Network, Security, Type}; use dom::bindings::error::Fallible; use dom::bindings::refcounted::{Trusted, TrustedPromise}; @@ -442,12 +442,20 @@ fn canonicalize_filter(filter: &BluetoothLEScanFilterInit) -> Fallible<Bluetooth // https://webbluetoothcg.github.io/web-bluetooth/#bluetoothdatafilterinit-canonicalizing fn canonicalize_bluetooth_data_filter_init(bdfi: &BluetoothDataFilterInit) -> Fallible<(Vec<u8>, Vec<u8>)> { // Step 1. - let data_prefix = bdfi.dataPrefix.clone().unwrap_or(vec![]); + let data_prefix = match bdfi.dataPrefix { + Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(), + Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(), + None => vec![] + }; // Step 2. // If no mask present, mask will be a sequence of 0xFF bytes the same length as dataPrefix. // Masking dataPrefix with this, leaves dataPrefix untouched. - let mask = bdfi.mask.clone().unwrap_or(vec![0xFF; data_prefix.len()]); + let mask = match bdfi.mask { + Some(ArrayBufferViewOrArrayBuffer::ArrayBufferView(ref avb)) => avb.to_vec(), + Some(ArrayBufferViewOrArrayBuffer::ArrayBuffer(ref ab)) => ab.to_vec(), + None => vec![0xFF; data_prefix.len()] + }; // Step 3. if mask.len() != data_prefix.len() { diff --git a/components/script/dom/bluetoothremotegattcharacteristic.rs b/components/script/dom/bluetoothremotegattcharacteristic.rs index a8dc2d39a5a..8034623ff5c 100644 --- a/components/script/dom/bluetoothremotegattcharacteristic.rs +++ b/components/script/dom/bluetoothremotegattcharacteristic.rs @@ -167,8 +167,8 @@ impl BluetoothRemoteGATTCharacteristicMethods for BluetoothRemoteGATTCharacteris // Step 2 - 3. let vec = match value { - ArrayBufferViewOrArrayBuffer::ArrayBufferView(mut avb) => avb.to_vec(), - ArrayBufferViewOrArrayBuffer::ArrayBuffer(mut ab) => ab.to_vec(), + ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(), + ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(), }; if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH { diff --git a/components/script/dom/bluetoothremotegattdescriptor.rs b/components/script/dom/bluetoothremotegattdescriptor.rs index e120648d661..493550ee91b 100644 --- a/components/script/dom/bluetoothremotegattdescriptor.rs +++ b/components/script/dom/bluetoothremotegattdescriptor.rs @@ -126,8 +126,8 @@ impl BluetoothRemoteGATTDescriptorMethods for BluetoothRemoteGATTDescriptor { // Step 2 - 3. let vec = match value { - ArrayBufferViewOrArrayBuffer::ArrayBufferView(mut avb) => avb.to_vec(), - ArrayBufferViewOrArrayBuffer::ArrayBuffer(mut ab) => ab.to_vec(), + ArrayBufferViewOrArrayBuffer::ArrayBufferView(avb) => avb.to_vec(), + ArrayBufferViewOrArrayBuffer::ArrayBuffer(ab) => ab.to_vec(), }; if vec.len() > MAXIMUM_ATTRIBUTE_LENGTH { p.reject_error(InvalidModification); diff --git a/components/script/dom/webidls/Bluetooth.webidl b/components/script/dom/webidls/Bluetooth.webidl index 7fc4c7392ad..f891b5f38a5 100644 --- a/components/script/dom/webidls/Bluetooth.webidl +++ b/components/script/dom/webidls/Bluetooth.webidl @@ -5,10 +5,8 @@ // https://webbluetoothcg.github.io/web-bluetooth/#bluetooth dictionary BluetoothDataFilterInit { - // BufferSource dataPrefix; - sequence<octet> dataPrefix; - // BufferSource mask; - sequence<octet> mask; + BufferSource dataPrefix; + BufferSource mask; }; dictionary BluetoothLEScanFilterInit { |