author | David Zbarsky <dzbarsky@gmail.com> |
Wed, 11 Sep 2013 18:35:51 -0400 | |
changeset 146717 | 2494c41c421fbb7275b90fbb6316584773762298 |
parent 146716 | 84e4c20ddd860b1ca89068f4d7e795fa017c7935 |
child 146718 | 28aa5abe0efb6802bc335635231bf550c589f1e4 |
push id | 25270 |
push user | emorley@mozilla.com |
push date | Thu, 12 Sep 2013 11:04:52 +0000 |
treeherder | mozilla-central@b83f6d80af5f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | smaug |
bugs | 856373 |
milestone | 26.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
dom/bindings/Codegen.py | file | annotate | diff | comparison | revisions | |
dom/gamepad/GamepadService.cpp | file | annotate | diff | comparison | revisions | |
dom/interfaces/events/moz.build | file | annotate | diff | comparison | revisions | |
dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl | file | annotate | diff | comparison | revisions | |
dom/interfaces/events/nsIDOMGamepadButtonEvent.idl | file | annotate | diff | comparison | revisions | |
dom/interfaces/events/nsIDOMGamepadEvent.idl | file | annotate | diff | comparison | revisions | |
dom/webidl/GamepadAxisMoveEvent.webidl | file | annotate | diff | comparison | revisions | |
dom/webidl/GamepadButtonEvent.webidl | file | annotate | diff | comparison | revisions | |
dom/webidl/GamepadEvent.webidl | file | annotate | diff | comparison | revisions | |
dom/webidl/moz.build | file | annotate | diff | comparison | revisions | |
js/xpconnect/src/event_impl_gen.conf.in | file | annotate | diff | comparison | revisions |
--- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -10738,22 +10738,25 @@ class CGEventMethod(CGNativeMember): self.args.insert(0, Argument("const GlobalObject&", "aGlobal")) self.args.append(Argument('ErrorResult&', 'aRv')) return constructorForNativeCaller + CGNativeMember.declare(self, cgClass) def define(self, cgClass): self.args = list(self.originalArgs) members = "" holdJS = "" - for m in self.descriptorProvider.interface.members: - if m.isAttr(): - name = CGDictionary.makeMemberName(m.identifier.name) - members += "e->%s = %s.%s;\n" % (name, self.args[1].name, name) - if m.type.isAny() or m.type.isObject() or m.type.isSpiderMonkeyInterface(): - holdJS = "mozilla::HoldJSObjects(e.get());\n" + iface = self.descriptorProvider.interface + while iface.identifier.name != "Event": + for m in self.descriptorProvider.getDescriptor(iface.identifier.name).interface.members: + if m.isAttr(): + name = CGDictionary.makeMemberName(m.identifier.name) + members += "e->%s = %s.%s;\n" % (name, self.args[1].name, name) + if m.type.isAny() or m.type.isObject() or m.type.isSpiderMonkeyInterface(): + holdJS = "mozilla::HoldJSObjects(e.get());\n" + iface = iface.parent self.body = ( "nsRefPtr<${nativeType}> e = new ${nativeType}(aOwner);\n" "bool trusted = e->Init(aOwner);\n" "e->InitEvent(${eventType}, ${eventInit}.mBubbles, ${eventInit}.mCancelable);\n" "${members}" "e->SetTrusted(trusted);\n" "${holdJS}" @@ -10819,31 +10822,34 @@ class CGEventClass(CGBindingImplClass): nativeType = "JS::Heap<JS::Value>" elif m.type.isObject() or m.type.isSpiderMonkeyInterface(): nativeType = "JS::Heap<JSObject*>" members.append(ClassMember(CGDictionary.makeMemberName(m.identifier.name), nativeType, visibility="private", body="body")) + parent = self.descriptor.interface.parent + self.parentType = self.descriptor.getDescriptor(parent.identifier.name).nativeType.split('::')[-1] baseDeclarations=( "public:\n" " NS_DECL_ISUPPORTS_INHERITED\n" - " NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(${nativeType}, nsDOMEvent)\n" + " NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(${nativeType}, ${parentType})\n" " virtual ~${nativeType}();\n" "protected:\n" " ${nativeType}(mozilla::dom::EventTarget* aOwner);\n\n") baseDeclarations = string.Template(baseDeclarations).substitute( { - "nativeType": self.descriptor.nativeType.split('::')[-1] + "nativeType": self.descriptor.nativeType.split('::')[-1], + "parentType": self.parentType }) CGClass.__init__(self, descriptor.nativeType.split('::')[-1], - bases=[ClassBase("nsDOMEvent")], + bases=[ClassBase(self.parentType)], methods=self.methodDecls, members=members, extradeclarations=baseDeclarations) def getWrapObjectBody(self): return "return %sBinding::Wrap(aCx, aScope, this);" % self.descriptor.name def implTraverse(self): @@ -10886,47 +10892,52 @@ class CGEventClass(CGBindingImplClass): member = CGDictionary.makeMemberName(m.identifier.name); if m.type.isAny(): dropJS += " " + member + " = JS::UndefinedValue();\n" elif m.type.isObject() or m.type.isSpiderMonkeyInterface(): dropJS += " " + member + " = nullptr;\n" if dropJS != "": dropJS += " mozilla::DropJSObjects(this);\n" # Just override CGClass and do our own thing + nativeType = self.descriptor.nativeType.split('::')[-1] + ctorParams = ("aOwner, nullptr, nullptr" if self.parentType == "nsDOMEvent" + else "aOwner") classImpl = """ NS_IMPL_CYCLE_COLLECTION_CLASS(${nativeType}) -NS_IMPL_ADDREF_INHERITED(${nativeType}, nsDOMEvent) -NS_IMPL_RELEASE_INHERITED(${nativeType}, nsDOMEvent) - -NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_ADDREF_INHERITED(${nativeType}, ${parentType}) +NS_IMPL_RELEASE_INHERITED(${nativeType}, ${parentType}) + +NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(${nativeType}, ${parentType}) ${traverse}NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(${nativeType}, ${parentType}) ${trace}NS_IMPL_CYCLE_COLLECTION_TRACE_END -NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(${nativeType}, nsDOMEvent) +NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(${nativeType}, ${parentType}) ${unlink}NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(${nativeType}) -NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent) +NS_INTERFACE_MAP_END_INHERITING(${parentType}) ${nativeType}::${nativeType}(mozilla::dom::EventTarget* aOwner) - : nsDOMEvent(aOwner, nullptr, nullptr) + : ${parentType}(${ctorParams}) { } ${nativeType}::~${nativeType}() { ${dropJS}} """ return string.Template(classImpl).substitute( { "ifaceName": self.descriptor.name, - "nativeType": self.descriptor.nativeType.split('::')[-1], + "nativeType": nativeType, + "ctorParams": ctorParams, + "parentType": self.parentType, "traverse": self.implTraverse(), "unlink": self.implUnlink(), "trace": self.implTrace(), "dropJS": dropJS} ) + CGBindingImplClass.define(self) class CGEventRoot(CGThing): @@ -10937,19 +10948,21 @@ class CGEventRoot(CGThing): self.root = CGWrapper(CGEventClass(descriptor), pre="\n", post="\n") self.root = CGNamespace.build(["mozilla", "dom"], self.root) self.root = CGList([CGClassForwardDeclare("JSContext", isStruct=True), self.root], "\n") + parent = descriptor.interface.parent.identifier.name + # Throw in our #includes self.root = CGHeaders([descriptor], [], [], [], - [ "nsDOMEvent.h", + [ config.getDescriptor(parent, False).headerFile, "mozilla/Attributes.h", "mozilla/ErrorResult.h" , "mozilla/dom/%sBinding.h" % interfaceName, 'mozilla/dom/BindingUtils.h', ], [ "%s.h" % interfaceName, "js/GCAPI.h", 'mozilla/dom/Nullable.h',
--- a/dom/gamepad/GamepadService.cpp +++ b/dom/gamepad/GamepadService.cpp @@ -7,28 +7,29 @@ #include "mozilla/Preferences.h" #include "mozilla/StaticPtr.h" #include "GamepadService.h" #include "Gamepad.h" #include "nsAutoPtr.h" #include "nsIDOMEvent.h" #include "nsIDOMDocument.h" -#include "nsIDOMGamepadButtonEvent.h" -#include "nsIDOMGamepadAxisMoveEvent.h" -#include "nsIDOMGamepadEvent.h" #include "GeneratedEvents.h" #include "nsIDOMWindow.h" #include "nsIObserver.h" #include "nsIObserverService.h" #include "nsIServiceManager.h" #include "nsITimer.h" #include "nsThreadUtils.h" #include "mozilla/Services.h" +#include "mozilla/dom/GamepadAxisMoveEvent.h" +#include "mozilla/dom/GamepadButtonEvent.h" +#include "mozilla/dom/GamepadEvent.h" + #include <cstddef> namespace mozilla { namespace dom { namespace { const char* kGamepadEnabledPref = "dom.gamepad.enabled"; const char* kGamepadEventsEnabledPref = @@ -236,28 +237,29 @@ GamepadService::NewButtonEvent(uint32_t } void GamepadService::FireButtonEvent(EventTarget* aTarget, Gamepad* aGamepad, uint32_t aButton, double aValue) { - nsCOMPtr<nsIDOMEvent> event; - bool defaultActionEnabled = true; - NS_NewDOMGamepadButtonEvent(getter_AddRefs(event), aTarget, nullptr, nullptr); - nsCOMPtr<nsIDOMGamepadButtonEvent> je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - - nsString name = aValue == 1.0L ? NS_LITERAL_STRING("gamepadbuttondown") : NS_LITERAL_STRING("gamepadbuttonup"); - je->InitGamepadButtonEvent(name, false, false, aGamepad, aButton); - je->SetTrusted(true); + GamepadButtonEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + init.mButton = aButton; + nsRefPtr<GamepadButtonEvent> event = + GamepadButtonEvent::Constructor(aTarget, name, init); + event->SetTrusted(true); + + bool defaultActionEnabled = true; aTarget->DispatchEvent(event, &defaultActionEnabled); } void GamepadService::NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue) { if (mShuttingDown || aIndex >= mGamepads.Length()) { return; @@ -300,27 +302,30 @@ GamepadService::NewAxisMoveEvent(uint32_ } void GamepadService::FireAxisMoveEvent(EventTarget* aTarget, Gamepad* aGamepad, uint32_t aAxis, double aValue) { - nsCOMPtr<nsIDOMEvent> event; + GamepadAxisMoveEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + init.mAxis = aAxis; + init.mValue = aValue; + nsRefPtr<GamepadAxisMoveEvent> event = + GamepadAxisMoveEvent::Constructor(aTarget, + NS_LITERAL_STRING("gamepadaxismove"), + init); + + event->SetTrusted(true); + bool defaultActionEnabled = true; - NS_NewDOMGamepadAxisMoveEvent(getter_AddRefs(event), aTarget, nullptr, - nullptr); - nsCOMPtr<nsIDOMGamepadAxisMoveEvent> je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - - je->InitGamepadAxisMoveEvent(NS_LITERAL_STRING("gamepadaxismove"), - false, false, aGamepad, aAxis, aValue); - je->SetTrusted(true); - aTarget->DispatchEvent(event, &defaultActionEnabled); } void GamepadService::NewConnectionEvent(uint32_t aIndex, bool aConnected) { if (mShuttingDown || aIndex >= mGamepads.Length()) { return; @@ -376,27 +381,28 @@ GamepadService::NewConnectionEvent(uint3 } } void GamepadService::FireConnectionEvent(EventTarget* aTarget, Gamepad* aGamepad, bool aConnected) { - nsCOMPtr<nsIDOMEvent> event; - bool defaultActionEnabled = true; - NS_NewDOMGamepadEvent(getter_AddRefs(event), aTarget, nullptr, nullptr); - nsCOMPtr<nsIDOMGamepadEvent> je = do_QueryInterface(event); - MOZ_ASSERT(je, "QI should not fail"); - nsString name = aConnected ? NS_LITERAL_STRING("gamepadconnected") : NS_LITERAL_STRING("gamepaddisconnected"); - je->InitGamepadEvent(name, false, false, aGamepad); - je->SetTrusted(true); + GamepadEventInitInitializer init; + init.mBubbles = false; + init.mCancelable = false; + init.mGamepad = aGamepad; + nsRefPtr<GamepadEvent> event = + GamepadEvent::Constructor(aTarget, name, init); + event->SetTrusted(true); + + bool defaultActionEnabled = true; aTarget->DispatchEvent(event, &defaultActionEnabled); } void GamepadService::SyncGamepadState(uint32_t aIndex, Gamepad* aGamepad) { if (mShuttingDown || !mEnabled || aIndex > mGamepads.Length()) { return;
--- a/dom/interfaces/events/moz.build +++ b/dom/interfaces/events/moz.build @@ -19,19 +19,16 @@ XPIDL_SOURCES += [ 'nsIDOMDeviceMotionEvent.idl', 'nsIDOMDeviceOrientationEvent.idl', 'nsIDOMDragEvent.idl', 'nsIDOMElementReplaceEvent.idl', 'nsIDOMEvent.idl', 'nsIDOMEventListener.idl', 'nsIDOMEventTarget.idl', 'nsIDOMFocusEvent.idl', - 'nsIDOMGamepadAxisMoveEvent.idl', - 'nsIDOMGamepadButtonEvent.idl', - 'nsIDOMGamepadEvent.idl', 'nsIDOMHashChangeEvent.idl', 'nsIDOMKeyEvent.idl', 'nsIDOMMessageEvent.idl', 'nsIDOMMouseEvent.idl', 'nsIDOMMouseScrollEvent.idl', 'nsIDOMMutationEvent.idl', 'nsIDOMNSEvent.idl', 'nsIDOMNotifyAudioAvailableEvent.idl',
deleted file mode 100644 --- a/dom/interfaces/events/nsIDOMGamepadAxisMoveEvent.idl +++ /dev/null @@ -1,33 +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 "nsIDOMGamepadEvent.idl" - -[builtinclass, scriptable, uuid(bd09eef8-8e07-4baf-8d39-4f92003dbca8)] -interface nsIDOMGamepadAxisMoveEvent : nsIDOMGamepadEvent -{ - /** - * Index in gamepad.axes of the axis that was moved. - */ - readonly attribute unsigned long axis; - - /** - * Position of the axis in the range -1.0...1.0. - */ - readonly attribute double value; - - [noscript] - void initGamepadAxisMoveEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad, - in unsigned long axis, - in double value); -}; - -dictionary GamepadAxisMoveEventInit : GamepadEventInit -{ - unsigned long axis; - double value; -};
deleted file mode 100644 --- a/dom/interfaces/events/nsIDOMGamepadButtonEvent.idl +++ /dev/null @@ -1,26 +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 "nsIDOMGamepadEvent.idl" - -[builtinclass, scriptable, uuid(d75d4d2b-e7b4-4b93-ac35-2e70b57d9b28)] -interface nsIDOMGamepadButtonEvent : nsIDOMGamepadEvent -{ - /** - * Index in gamepad.buttons of the button that was pressed or released. - */ - readonly attribute unsigned long button; - - [noscript] - void initGamepadButtonEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad, - in unsigned long button); -}; - -dictionary GamepadButtonEventInit : GamepadEventInit -{ - unsigned long button; -};
deleted file mode 100644 --- a/dom/interfaces/events/nsIDOMGamepadEvent.idl +++ /dev/null @@ -1,27 +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" - -interface nsIDOMGamepad; - -[builtinclass, scriptable, uuid(93b048d6-2aef-46a9-b0f4-06d7f00d8ef2)] -interface nsIDOMGamepadEvent : nsIDOMEvent -{ - /** - * The device that generated this event. - */ - readonly attribute nsIDOMGamepad gamepad; - - [noscript] - void initGamepadEvent(in DOMString typeArg, - in boolean canBubbleArg, - in boolean cancelableArg, - in nsIDOMGamepad gamepad); -}; - -dictionary GamepadEventInit : EventInit -{ - nsIDOMGamepad gamepad; -};
--- a/dom/webidl/GamepadAxisMoveEvent.webidl +++ b/dom/webidl/GamepadAxisMoveEvent.webidl @@ -1,17 +1,16 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ [Pref="dom.gamepad.non_standard_events.enabled", - Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadAxisMoveEventInit eventInitDict)] interface GamepadAxisMoveEvent : GamepadEvent { readonly attribute unsigned long axis; readonly attribute double value; }; dictionary GamepadAxisMoveEventInit : GamepadEventInit {
--- a/dom/webidl/GamepadButtonEvent.webidl +++ b/dom/webidl/GamepadButtonEvent.webidl @@ -1,17 +1,16 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ [Pref="dom.gamepad.non_standard_events.enabled", - Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadButtonEventInit eventInitDict)] interface GamepadButtonEvent : GamepadEvent { readonly attribute unsigned long button; }; dictionary GamepadButtonEventInit : GamepadEventInit { unsigned long button = 0;
--- a/dom/webidl/GamepadEvent.webidl +++ b/dom/webidl/GamepadEvent.webidl @@ -1,17 +1,16 @@ /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* 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/. */ [Pref="dom.gamepad.enabled", - Constructor(DOMString type, optional GamepadEventInit eventInitDict), - HeaderFile="GeneratedEventClasses.h"] + Constructor(DOMString type, optional GamepadEventInit eventInitDict)] interface GamepadEvent : Event { readonly attribute Gamepad? gamepad; }; dictionary GamepadEventInit : EventInit { Gamepad? gamepad = null;
--- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -501,23 +501,16 @@ if CONFIG['MOZ_B2G_RIL']: 'MozEmergencyCbModeEvent.webidl', 'MozOtaStatusEvent.webidl', 'MozVoicemailEvent.webidl', 'MozWifiConnectionInfoEvent.webidl', 'MozWifiStatusChangeEvent.webidl', 'USSDReceivedEvent.webidl', ] -if CONFIG['MOZ_GAMEPAD']: - WEBIDL_FILES += [ - 'GamepadAxisMoveEvent.webidl', - 'GamepadButtonEvent.webidl', - 'GamepadEvent.webidl', - ] - if CONFIG['MOZ_WEBSPEECH']: WEBIDL_FILES += [ 'SpeechRecognitionError.webidl', 'SpeechRecognitionEvent.webidl', ] if CONFIG['MOZ_B2G_FM']: WEBIDL_FILES += [ @@ -538,8 +531,17 @@ if CONFIG['MOZ_B2G']: WEBIDL_FILES += [ 'InputMethod.webidl', ] GENERATED_EVENTS_WEBIDL_FILES = [ 'BlobEvent.webidl', 'DeviceProximityEvent.webidl', ] + +if CONFIG['MOZ_GAMEPAD']: + GENERATED_EVENTS_WEBIDL_FILES += [ + 'GamepadAxisMoveEvent.webidl', + 'GamepadButtonEvent.webidl', + 'GamepadEvent.webidl', + ] + +
--- a/js/xpconnect/src/event_impl_gen.conf.in +++ b/js/xpconnect/src/event_impl_gen.conf.in @@ -46,21 +46,16 @@ simple_events = [ 'MozSmsEvent', 'MozMmsEvent', #ifdef MOZ_WEBSPEECH 'SpeechSynthesisEvent', #endif 'DeviceStorageChangeEvent', 'PopupBlockedEvent', 'RecordErrorEvent', -#ifdef MOZ_GAMEPAD - 'GamepadEvent', - 'GamepadButtonEvent', - 'GamepadAxisMoveEvent', -#endif #ifdef MOZ_WEBSPEECH 'SpeechRecognitionEvent', #endif ] """ include file names """ special_includes = [ 'nsContentUtils.h', @@ -76,11 +71,10 @@ 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'], - ['nsIDOMGamepad', 'Gamepad', 'nsIDOMGamepad'] ]