aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetooth.rs
diff options
context:
space:
mode:
authorAttila Dusnoki <dati91@gmail.com>2016-11-18 19:08:25 +0100
committerAttila Dusnoki <dati91@users.noreply.github.com>2016-11-28 10:49:49 +0100
commitd9c7ffb5b3c86e16d412d8489c038573cf59f965 (patch)
treede5c94cbe85e5f50c65a53c4f00fff62ad54441e /components/script/dom/bluetooth.rs
parentb18ec28fa7dab1728bb9e01d675534a28c43bb6a (diff)
downloadservo-d9c7ffb5b3c86e16d412d8489c038573cf59f965.tar.gz
servo-d9c7ffb5b3c86e16d412d8489c038573cf59f965.zip
Add event target for bluetooth
Diffstat (limited to 'components/script/dom/bluetooth.rs')
-rw-r--r--components/script/dom/bluetooth.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/components/script/dom/bluetooth.rs b/components/script/dom/bluetooth.rs
index afee568d735..0cb9005e282 100644
--- a/components/script/dom/bluetooth.rs
+++ b/components/script/dom/bluetooth.rs
@@ -11,12 +11,13 @@ use core::clone::Clone;
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::BluetoothBinding::{self, BluetoothDataFilterInit, BluetoothLEScanFilterInit};
use dom::bindings::codegen::Bindings::BluetoothBinding::{BluetoothMethods, RequestDeviceOptions};
+use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::UnionTypes::StringOrUnsignedLong;
use dom::bindings::error::Error::{self, NotFound, Security, Type};
use dom::bindings::error::Fallible;
use dom::bindings::js::{JS, MutHeap, Root};
use dom::bindings::refcounted::{Trusted, TrustedPromise};
-use dom::bindings::reflector::{Reflectable, Reflector, reflect_dom_object};
+use dom::bindings::reflector::{Reflectable, reflect_dom_object};
use dom::bindings::str::DOMString;
use dom::bluetoothadvertisingdata::BluetoothAdvertisingData;
use dom::bluetoothdevice::BluetoothDevice;
@@ -24,6 +25,7 @@ use dom::bluetoothremotegattcharacteristic::BluetoothRemoteGATTCharacteristic;
use dom::bluetoothremotegattdescriptor::BluetoothRemoteGATTDescriptor;
use dom::bluetoothremotegattservice::BluetoothRemoteGATTService;
use dom::bluetoothuuid::{BluetoothServiceUUID, BluetoothUUID};
+use dom::eventtarget::EventTarget;
use dom::globalscope::GlobalScope;
use dom::promise::Promise;
use ipc_channel::ipc::{self, IpcSender};
@@ -84,7 +86,7 @@ impl<Listener: AsyncBluetoothListener + Reflectable> BluetoothResponseListener f
// https://webbluetoothcg.github.io/web-bluetooth/#bluetooth
#[dom_struct]
pub struct Bluetooth {
- reflector_: Reflector,
+ eventtarget: EventTarget,
device_instance_map: DOMRefCell<HashMap<String, MutHeap<JS<BluetoothDevice>>>>,
service_instance_map: DOMRefCell<HashMap<String, MutHeap<JS<BluetoothRemoteGATTService>>>>,
characteristic_instance_map: DOMRefCell<HashMap<String, MutHeap<JS<BluetoothRemoteGATTCharacteristic>>>>,
@@ -94,7 +96,7 @@ pub struct Bluetooth {
impl Bluetooth {
pub fn new_inherited() -> Bluetooth {
Bluetooth {
- reflector_: Reflector::new(),
+ eventtarget: EventTarget::new_inherited(),
device_instance_map: DOMRefCell::new(HashMap::new()),
service_instance_map: DOMRefCell::new(HashMap::new()),
characteristic_instance_map: DOMRefCell::new(HashMap::new()),
@@ -382,6 +384,9 @@ impl BluetoothMethods for Bluetooth {
// TODO(#4282): Step 3-5: Reject and resolve promise.
return p;
}
+
+ // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-onavailabilitychanged
+ event_handler!(availabilitychanged, GetOnavailabilitychanged, SetOnavailabilitychanged);
}
impl AsyncBluetoothListener for Bluetooth {