Bug 952907 - Patch 1: Use WebIDL codegen to implement Bluetooth events, r=smaug

This commit is contained in:
Gina Yeh 2014-01-22 14:26:29 +08:00
parent 5cd41c7b0e
commit a3eb2efd58
15 changed files with 24 additions and 132 deletions

View File

@ -164,10 +164,6 @@
#include "FMRadio.h"
#endif
#ifdef MOZ_B2G_BT
#include "BluetoothDevice.h"
#endif
#include "nsIDOMCameraManager.h"
#include "nsIDOMGlobalObjectConstructor.h"
#include "nsIDOMLockedFile.h"
@ -488,11 +484,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
#endif
#ifdef MOZ_B2G_BT
NS_DEFINE_CLASSINFO_DATA(BluetoothDevice, nsEventTargetSH,
EVENTTARGET_SCRIPTABLE_FLAGS)
#endif
NS_DEFINE_CLASSINFO_DATA(CameraCapabilities, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -1203,12 +1194,6 @@ nsDOMClassInfo::Init()
#endif
#ifdef MOZ_B2G_BT
DOM_CLASSINFO_MAP_BEGIN(BluetoothDevice, nsIDOMBluetoothDevice)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBluetoothDevice)
DOM_CLASSINFO_MAP_END
#endif
DOM_CLASSINFO_MAP_BEGIN(CameraCapabilities, nsICameraCapabilities)
DOM_CLASSINFO_MAP_ENTRY(nsICameraCapabilities)
DOM_CLASSINFO_MAP_END

View File

@ -108,10 +108,6 @@ DOMCI_CLASS(CSSPageRule)
DOMCI_CLASS(MozIccManager)
#endif
#ifdef MOZ_B2G_BT
DOMCI_CLASS(BluetoothDevice)
#endif
DOMCI_CLASS(CameraCapabilities)
DOMCI_CLASS(LockedFile)

View File

@ -5,17 +5,16 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/basictypes.h"
#include "GeneratedEvents.h"
#include "nsCxPusher.h"
#include "nsDOMClassInfo.h"
#include "nsIDOMBluetoothDeviceEvent.h"
#include "nsIDOMBluetoothStatusChangedEvent.h"
#include "nsTArrayHelpers.h"
#include "DOMRequest.h"
#include "nsThreadUtils.h"
#include "mozilla/dom/bluetooth/BluetoothTypes.h"
#include "mozilla/dom/BluetoothAdapterBinding.h"
#include "mozilla/dom/BluetoothDeviceEvent.h"
#include "mozilla/dom/BluetoothStatusChangedEvent.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/LazyIdleThread.h"
@ -305,12 +304,13 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
BluetoothValue v = aData.value();
if (aData.name().EqualsLiteral("DeviceFound")) {
nsRefPtr<BluetoothDevice> device = BluetoothDevice::Create(GetOwner(), mPath, aData.value());
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothDeviceEvent(getter_AddRefs(event), this, nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothDeviceEvent> e = do_QueryInterface(event);
e->InitBluetoothDeviceEvent(NS_LITERAL_STRING("devicefound"),
false, false, device);
BluetoothDeviceEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mDevice = device;
nsRefPtr<BluetoothDeviceEvent> event =
BluetoothDeviceEvent::Constructor(this, NS_LITERAL_STRING("devicefound"), init);
DispatchTrustedEvent(event);
} else if (aData.name().EqualsLiteral("PropertyChanged")) {
MOZ_ASSERT(v.type() == BluetoothValue::TArrayOfBluetoothNamedValue);
@ -335,13 +335,13 @@ BluetoothAdapter::Notify(const BluetoothSignal& aData)
nsString address = arr[0].value().get_nsString();
bool status = arr[1].value().get_bool();
nsCOMPtr<nsIDOMEvent> event;
NS_NewDOMBluetoothStatusChangedEvent(
getter_AddRefs(event), this, nullptr, nullptr);
nsCOMPtr<nsIDOMBluetoothStatusChangedEvent> e = do_QueryInterface(event);
e->InitBluetoothStatusChangedEvent(aData.name(), false, false,
address, status);
BluetoothStatusChangedEventInit init;
init.mBubbles = false;
init.mCancelable = false;
init.mAddress = address;
init.mStatus = status;
nsRefPtr<BluetoothStatusChangedEvent> event =
BluetoothStatusChangedEvent::Constructor(this, aData.name(), init);
DispatchTrustedEvent(event);
} else if (aData.name().EqualsLiteral(REQUEST_MEDIA_PLAYSTATUS_ID)) {
nsCOMPtr<nsIDOMEvent> event;

View File

@ -12,7 +12,6 @@
#include "BluetoothPropertyContainer.h"
#include "nsCOMPtr.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMBluetoothDevice.h"
namespace mozilla {
namespace dom {

View File

@ -39,8 +39,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(BluetoothDevice,
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(BluetoothDevice)
NS_INTERFACE_MAP_ENTRY(nsIDOMBluetoothDevice)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(BluetoothDevice)
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(BluetoothDevice, nsDOMEventTargetHelper)

View File

@ -11,11 +11,8 @@
#include "BluetoothCommon.h"
#include "BluetoothPropertyContainer.h"
#include "nsDOMEventTargetHelper.h"
#include "nsIDOMBluetoothDevice.h"
#include "nsString.h"
class nsIDOMDOMRequest;
BEGIN_BLUETOOTH_NAMESPACE
class BluetoothNamedValue;
@ -24,15 +21,11 @@ class BluetoothSignal;
class BluetoothSocket;
class BluetoothDevice : public nsDOMEventTargetHelper
, public nsIDOMBluetoothDevice
, public BluetoothSignalObserver
, public BluetoothPropertyContainer
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIDOMBLUETOOTHDEVICE
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(nsDOMEventTargetHelper)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(BluetoothDevice,
nsDOMEventTargetHelper)

View File

@ -1,14 +0,0 @@
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_B2G_BT']:
XPIDL_SOURCES += [
'nsIDOMBluetoothDevice.idl',
'nsIDOMBluetoothDeviceEvent.idl',
'nsIDOMBluetoothStatusChangedEvent.idl',
]
XPIDL_MODULE = 'dom_bluetooth'

View File

@ -1,14 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEventTarget.idl"
// XPIDL interfaces might need this definition; so we keep it in place
// until we completely switched to WebIDL. See bug 900904.
[scriptable, builtinclass, uuid(291fdda9-4f96-4f2f-857f-900f89fb0412)]
interface nsIDOMBluetoothDevice : nsIDOMEventTarget
{
};

View File

@ -1,25 +0,0 @@
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEvent.idl"
interface nsIDOMBluetoothDevice;
[scriptable, builtinclass, uuid(e53dd06e-acd7-444a-914a-5fb60df0ad5b)]
interface nsIDOMBluetoothDeviceEvent : nsIDOMEvent
{
readonly attribute nsIDOMBluetoothDevice device;
[noscript] void initBluetoothDeviceEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in nsIDOMBluetoothDevice aDevice);
};
dictionary BluetoothDeviceEventInit : EventInit
{
nsIDOMBluetoothDevice device;
};

View File

@ -1,24 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsIDOMEvent.idl"
[scriptable, builtinclass, uuid(07f6d8d0-d364-4033-92e2-d69de323d7b7)]
interface nsIDOMBluetoothStatusChangedEvent : nsIDOMEvent
{
readonly attribute DOMString address;
readonly attribute boolean status;
[noscript] void initBluetoothStatusChangedEvent(in DOMString aType,
in boolean aCanBubble,
in boolean aCancelable,
in DOMString aAddress,
in boolean aStatus);
};
dictionary BluetoothStatusChangedEventInit : EventInit
{
DOMString address;
bool status;
};

View File

@ -5,8 +5,6 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if CONFIG['MOZ_B2G_BT']:
PARALLEL_DIRS += ['interfaces']
SOURCES += [
'BluetoothAdapter.cpp',
'BluetoothDevice.cpp',

View File

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional BluetoothDeviceEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
[Constructor(DOMString type, optional BluetoothDeviceEventInit eventInitDict)]
interface BluetoothDeviceEvent : Event
{
readonly attribute BluetoothDevice? device;

View File

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
[Constructor(DOMString type, optional BluetoothStatusChangedEventInit eventInitDict), HeaderFile="GeneratedEventClasses.h"]
[Constructor(DOMString type, optional BluetoothStatusChangedEventInit eventInitDict)]
interface BluetoothStatusChangedEvent : Event
{
readonly attribute DOMString address;

View File

@ -511,9 +511,7 @@ if CONFIG['MOZ_B2G_BT']:
WEBIDL_FILES += [
'BluetoothAdapter.webidl',
'BluetoothDevice.webidl',
'BluetoothDeviceEvent.webidl',
'BluetoothManager.webidl',
'BluetoothStatusChangedEvent.webidl',
]
if CONFIG['MOZ_B2G_RIL']:
@ -583,3 +581,10 @@ if CONFIG['MOZ_GAMEPAD']:
'GamepadButtonEvent.webidl',
'GamepadEvent.webidl',
]
if CONFIG['MOZ_B2G_BT']:
GENERATED_EVENTS_WEBIDL_FILES += [
'BluetoothDeviceEvent.webidl',
'BluetoothStatusChangedEvent.webidl',
]

View File

@ -27,10 +27,6 @@ simple_events = [
'MozWifiStatusChangeEvent',
'MozWifiConnectionInfoEvent',
#endif
#ifdef MOZ_B2G_BT
'BluetoothDeviceEvent',
'BluetoothStatusChangedEvent',
#endif
#ifdef MOZ_B2G_RIL
'MozCellBroadcastEvent',
'MozVoicemailEvent',
@ -65,7 +61,6 @@ exclude_automatic_type_include = [
""" Map xpidl interface names to implementation classes. The third column is the canonical interface. """
xpidl_to_native = [
['nsIDOMBluetoothDevice', 'bluetooth::BluetoothDevice', 'nsIDOMBluetoothDevice'],
['nsIDOMDocument', 'nsIDocument', 'nsIDocument'],
['nsIDOMElement', 'mozilla::dom::Element', 'mozilla::dom::Element'],
['nsIDOMCSSStyleSheet', 'nsCSSStyleSheet', 'nsIStyleSheet'],