Bug 1031051: Part 15 - Migrate Speech events to the WebIDL code generator. r=smaug
authorKyle Huey <khuey@kylehuey.com>
Mon, 30 Jun 2014 16:02:03 -0700
changeset 191623 09613e3e814a319a1f03563e8f2c9bebebd24f49
parent 191622 bfc886fd4f836c2f16955ba44a1fc8af04c9a6ba
child 191624 64e6f04bb4109f76ec00a6d26d90dc7090649c41
push id27055
push usercbook@mozilla.com
push dateTue, 01 Jul 2014 12:01:46 +0000
treeherdermozilla-central@4a9353b5762d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1031051
milestone33.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
Bug 1031051: Part 15 - Migrate Speech events to the WebIDL code generator. r=smaug
content/media/webspeech/recognition/SpeechRecognition.cpp
content/media/webspeech/recognition/moz.build
content/media/webspeech/recognition/nsIDOMSpeechRecognitionEvent.idl
content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
content/media/webspeech/synth/moz.build
content/media/webspeech/synth/nsIDOMSpeechSynthesisEvent.idl
dom/webidl/SpeechRecognitionEvent.webidl
dom/webidl/SpeechSynthesisEvent.webidl
dom/webidl/moz.build
js/xpconnect/src/event_impl_gen.conf.in
xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
--- a/content/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognition.cpp
@@ -13,17 +13,17 @@
 #include "mozilla/dom/MediaStreamTrackBinding.h"
 #include "mozilla/MediaManager.h"
 #include "mozilla/Services.h"
 
 #include "AudioSegment.h"
 #include "endpointer.h"
 
 #include "GeneratedEvents.h"
-#include "nsIDOMSpeechRecognitionEvent.h"
+#include "mozilla/dom/SpeechRecognitionEvent.h"
 #include "nsIObserverService.h"
 #include "nsServiceManagerUtils.h"
 
 #include <algorithm>
 
 namespace mozilla {
 namespace dom {
 
@@ -462,30 +462,30 @@ SpeechRecognition::WaitForSpeechEnd(Spee
   }
 }
 
 void
 SpeechRecognition::NotifyFinalResult(SpeechEvent* aEvent)
 {
   ResetAndEnd();
 
-  nsCOMPtr<nsIDOMEvent> domEvent;
-  NS_NewDOMSpeechRecognitionEvent(getter_AddRefs(domEvent), nullptr, nullptr, nullptr);
+  SpeechRecognitionEventInit init;
+  init.mBubbles = true;
+  init.mCancelable = false;
+  // init.mResultIndex = 0;
+  init.mResults = aEvent->mRecognitionResultList;
+  init.mInterpretation = NS_LITERAL_STRING("NOT_IMPLEMENTED");
+  // init.mEmma = nullptr;
 
-  nsCOMPtr<nsIDOMSpeechRecognitionEvent> srEvent = do_QueryInterface(domEvent);
-  nsRefPtr<SpeechRecognitionResultList> rlist = aEvent->mRecognitionResultList;
-  nsCOMPtr<nsISupports> ilist = do_QueryInterface(rlist);
-  srEvent->InitSpeechRecognitionEvent(NS_LITERAL_STRING("result"),
-                                      true, false, 0, ilist,
-                                      NS_LITERAL_STRING("NOT_IMPLEMENTED"),
-                                      nullptr);
-  domEvent->SetTrusted(true);
+  nsRefPtr<SpeechRecognitionEvent> event =
+    SpeechRecognitionEvent::Constructor(this, NS_LITERAL_STRING("result"), init);
+  event->SetTrusted(true);
 
   bool defaultActionEnabled;
-  this->DispatchEvent(domEvent, &defaultActionEnabled);
+  this->DispatchEvent(event, &defaultActionEnabled);
 }
 
 void
 SpeechRecognition::DoNothing(SpeechEvent* aEvent)
 {
 }
 
 void
--- a/content/media/webspeech/recognition/moz.build
+++ b/content/media/webspeech/recognition/moz.build
@@ -1,17 +1,16 @@
 # 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/.
 
 XPIDL_MODULE = 'dom_webspeechrecognition'
 
 XPIDL_SOURCES = [
-  'nsIDOMSpeechRecognitionEvent.idl',
   'nsISpeechRecognitionService.idl'
 ]
 
 TEST_DIRS += ['test']
 
 EXPORTS.mozilla.dom += [
     'SpeechGrammar.h',
     'SpeechGrammarList.h',
deleted file mode 100644
--- a/content/media/webspeech/recognition/nsIDOMSpeechRecognitionEvent.idl
+++ /dev/null
@@ -1,31 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
- *
- * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
- * liability, trademark and document use rules apply.
- */
-
-#include "nsIDOMEvent.idl"
-
-interface SpeechRecognitionResultList;
-
-[builtinclass, uuid(98dded70-33af-42d5-819d-e15b6f4a3aba)]
-interface nsIDOMSpeechRecognitionEvent : nsIDOMEvent {
-    [noscript] void initSpeechRecognitionEvent(in DOMString eventTypeArg,
-                                               in boolean canBubbleArg,
-                                               in boolean cancelableArg,
-                                               in unsigned long resultIndex,
-                                               in nsISupports results,
-                                               in DOMString interpretation,
-                                               in nsIDOMDocument emma);
-
-    readonly attribute unsigned long resultIndex;
-    readonly attribute nsISupports results;
-    readonly attribute DOMString interpretation;
-    readonly attribute nsIDOMDocument emma;
-};
--- a/content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
+++ b/content/media/webspeech/synth/SpeechSynthesisUtterance.cpp
@@ -3,19 +3,17 @@
 /* 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 "nsCOMPtr.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsGkAtoms.h"
 
-#include "GeneratedEvents.h"
-#include "nsIDOMSpeechSynthesisEvent.h"
-
+#include "mozilla/dom/SpeechSynthesisEvent.h"
 #include "mozilla/dom/SpeechSynthesisUtteranceBinding.h"
 #include "SpeechSynthesisUtterance.h"
 #include "SpeechSynthesisVoice.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(SpeechSynthesisUtterance,
@@ -152,20 +150,22 @@ SpeechSynthesisUtterance::SetPitch(float
 }
 
 void
 SpeechSynthesisUtterance::DispatchSpeechSynthesisEvent(const nsAString& aEventType,
                                                        uint32_t aCharIndex,
                                                        float aElapsedTime,
                                                        const nsAString& aName)
 {
-  nsCOMPtr<nsIDOMEvent> domEvent;
-  NS_NewDOMSpeechSynthesisEvent(getter_AddRefs(domEvent), nullptr, nullptr, nullptr);
+  SpeechSynthesisEventInit init;
+  init.mBubbles = false;
+  init.mCancelable = false;
+  init.mCharIndex = aCharIndex;
+  init.mElapsedTime = aElapsedTime;
+  init.mName = aName;
 
-  nsCOMPtr<nsIDOMSpeechSynthesisEvent> ssEvent = do_QueryInterface(domEvent);
-  ssEvent->InitSpeechSynthesisEvent(aEventType, false, false,
-                                    aCharIndex, aElapsedTime, aName);
-
-  DispatchTrustedEvent(domEvent);
+  nsRefPtr<SpeechSynthesisEvent> event =
+    SpeechSynthesisEvent::Constructor(this, aEventType, init);
+  DispatchTrustedEvent(event);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/media/webspeech/synth/moz.build
+++ b/content/media/webspeech/synth/moz.build
@@ -5,17 +5,16 @@
 
 if CONFIG['MOZ_WEBSPEECH']:
 
     TEST_DIRS += ['test', 'ipc/test']
 
     XPIDL_MODULE = 'dom_webspeechsynth'
 
     XPIDL_SOURCES += [
-        'nsIDOMSpeechSynthesisEvent.idl',
         'nsISpeechService.idl',
         'nsISynthVoiceRegistry.idl'
     ]
 
     EXPORTS.mozilla.dom += [
         'ipc/SpeechSynthesisChild.h',
         'ipc/SpeechSynthesisParent.h',
         'nsSpeechTask.h',
deleted file mode 100644
--- a/content/media/webspeech/synth/nsIDOMSpeechSynthesisEvent.idl
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- 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/.
- *
- * The origin of this IDL file is
- * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
- *
- * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
- * liability, trademark and document use rules apply.
- */
-
-#include "nsIDOMEvent.idl"
-
-[uuid(b5240841-dc69-43dd-bcf1-9306b8ddaa09)]
-interface nsIDOMSpeechSynthesisEvent : nsIDOMEvent {
-  [noscript] void initSpeechSynthesisEvent(in DOMString aEventTypeArg,
-                                           in boolean aCanBubbleArg,
-                                           in boolean aCancelableArg,
-                                           in unsigned long aCharIndex,
-                                           in float aElapsedTime,
-                                           in DOMString aName);
-
-  readonly attribute unsigned long charIndex;
-  readonly attribute float elapsedTime;
-  readonly attribute DOMString name;
-};
--- a/dom/webidl/SpeechRecognitionEvent.webidl
+++ b/dom/webidl/SpeechRecognitionEvent.webidl
@@ -1,18 +1,17 @@
 /* -*- 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/.
  */
 interface nsISupports;
 
 [Pref="media.webspeech.recognition.enable",
- Constructor(DOMString type, optional SpeechRecognitionEventInit eventInitDict),
- HeaderFile="GeneratedEventClasses.h"]
+ Constructor(DOMString type, optional SpeechRecognitionEventInit eventInitDict)]
 interface SpeechRecognitionEvent : Event
 {
   readonly attribute unsigned long resultIndex;
   readonly attribute nsISupports? results;
   readonly attribute DOMString? interpretation;
   readonly attribute Document? emma;
 };
 
--- a/dom/webidl/SpeechSynthesisEvent.webidl
+++ b/dom/webidl/SpeechSynthesisEvent.webidl
@@ -6,17 +6,16 @@
  * The origin of this IDL file is
  * http://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 [Constructor(DOMString type, optional SpeechSynthesisEventInit eventInitDict),
- HeaderFile="GeneratedEventClasses.h",
  Pref="media.webspeech.synth.enabled"]
 interface SpeechSynthesisEvent : Event
 {
   readonly attribute unsigned long charIndex;
   readonly attribute float elapsedTime;
   readonly attribute DOMString? name;
 };
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -511,16 +511,18 @@ if CONFIG['MOZ_WEBRTC']:
     ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     WEBIDL_FILES += [
         'SpeechGrammar.webidl',
         'SpeechGrammarList.webidl',
         'SpeechRecognition.webidl',
         'SpeechRecognitionAlternative.webidl',
+        'SpeechRecognitionError.webidl',
+        'SpeechRecognitionEvent.webidl',
         'SpeechRecognitionResult.webidl',
         'SpeechRecognitionResultList.webidl',
         'SpeechSynthesis.webidl',
         'SpeechSynthesisEvent.webidl',
         'SpeechSynthesisUtterance.webidl',
         'SpeechSynthesisVoice.webidl',
     ]
 
@@ -602,22 +604,16 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk
         'MozWifiManager.webidl',
         'MozWifiP2pManager.webidl',
     ]
 else:
     WEBIDL_FILES += [
         'InstallTrigger.webidl',
     ]
 
-if CONFIG['MOZ_WEBSPEECH']:
-    WEBIDL_FILES += [
-        'SpeechRecognitionError.webidl',
-        'SpeechRecognitionEvent.webidl',
-    ]
-
 if CONFIG['MOZ_B2G_FM']:
     WEBIDL_FILES += [
         'FMRadio.webidl',
     ]
 
 if not CONFIG['MOZ_DISABLE_CRYPTOLEGACY']:
     WEBIDL_FILES += [
         'CRMFObject.webidl',
@@ -662,16 +658,22 @@ GENERATED_EVENTS_WEBIDL_FILES = [
     'RTCPeerConnectionIdentityErrorEvent.webidl',
     'RTCPeerConnectionIdentityEvent.webidl',
     'SmartCardEvent.webidl',
     'TrackEvent.webidl',
     'UserProximityEvent.webidl',
     'USSDReceivedEvent.webidl',
 ]
 
+if CONFIG['MOZ_WEBSPEECH']:
+    GENERATED_EVENTS_WEBIDL_FILES += [
+        'SpeechRecognitionEvent.webidl',
+        'SpeechSynthesisEvent.webidl',
+    ]
+
 if CONFIG['MOZ_GAMEPAD']:
     GENERATED_EVENTS_WEBIDL_FILES += [
         'GamepadAxisMoveEvent.webidl',
         'GamepadButtonEvent.webidl',
         'GamepadEvent.webidl',
     ]
 
 if CONFIG['MOZ_B2G_BT']:
--- a/js/xpconnect/src/event_impl_gen.conf.in
+++ b/js/xpconnect/src/event_impl_gen.conf.in
@@ -7,22 +7,16 @@
  and should be in nsIDOM<name>.idl file and which should have
  <name>Init dictionary for the event constructor. """
 
 simple_events = [
     'CustomEvent',
     'StyleRuleChangeEvent',
     'StyleSheetChangeEvent',
     'StyleSheetApplicableStateChangeEvent',
-#ifdef MOZ_WEBSPEECH
-    'SpeechSynthesisEvent',
-#endif
-#ifdef MOZ_WEBSPEECH
-    'SpeechRecognitionEvent',
-#endif
   ]
 
 """ include file names """
 special_includes = [
     'nsContentUtils.h',
     'nsIDOMApplicationRegistry.h',
     'nsIDOMFile.h'
   ]
--- a/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/ShimInterfaceInfo.cpp
@@ -119,20 +119,16 @@
 #include "nsIDOMParser.h"
 #include "nsIDOMProcessingInstruction.h"
 #include "nsIDOMRange.h"
 #include "nsIDOMRect.h"
 #include "nsIDOMScreen.h"
 #include "nsIDOMScrollAreaEvent.h"
 #include "nsIDOMSerializer.h"
 #include "nsIDOMSimpleGestureEvent.h"
-#ifdef MOZ_WEBSPEECH
-#include "nsIDOMSpeechRecognitionEvent.h"
-#include "nsIDOMSpeechSynthesisEvent.h"
-#endif // MOZ_WEBSPEECH
 #include "nsIDOMStyleSheet.h"
 #include "nsIDOMStyleSheetList.h"
 #include "nsIDOMStyleRuleChangeEvent.h"
 #include "nsIDOMStyleSheetApplicableStateChangeEvent.h"
 #include "nsIDOMStyleSheetChangeEvent.h"
 #include "nsIDOMSVGElement.h"
 #include "nsIDOMSVGLength.h"
 #include "nsIDOMText.h"
@@ -266,20 +262,16 @@
 #include "mozilla/dom/PositionErrorBinding.h"
 #include "mozilla/dom/ProcessingInstructionBinding.h"
 #include "mozilla/dom/RangeBinding.h"
 #include "mozilla/dom/RectBinding.h"
 #include "mozilla/dom/ScreenBinding.h"
 #include "mozilla/dom/SelectionBinding.h"
 #include "mozilla/dom/ScrollAreaEventBinding.h"
 #include "mozilla/dom/SimpleGestureEventBinding.h"
-#ifdef MOZ_WEBSPEECH
-#include "mozilla/dom/SpeechRecognitionEventBinding.h"
-#include "mozilla/dom/SpeechSynthesisEventBinding.h"
-#endif // MOZ_WEBSPEECH
 #include "mozilla/dom/StorageEventBinding.h"
 #include "mozilla/dom/StyleSheetBinding.h"
 #include "mozilla/dom/StyleSheetListBinding.h"
 #include "mozilla/dom/StyleRuleChangeEventBinding.h"
 #include "mozilla/dom/StyleSheetApplicableStateChangeEventBinding.h"
 #include "mozilla/dom/StyleSheetChangeEventBinding.h"
 #include "mozilla/dom/SVGElementBinding.h"
 #include "mozilla/dom/SVGLengthBinding.h"
@@ -464,20 +456,16 @@ const ComponentsInterfaceShimEntry kComp
   DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMParser, DOMParser),
   DEFINE_SHIM(ProcessingInstruction),
   DEFINE_SHIM(Range),
   DEFINE_SHIM(Rect),
   DEFINE_SHIM(Screen),
   DEFINE_SHIM(ScrollAreaEvent),
   DEFINE_SHIM_WITH_CUSTOM_INTERFACE(nsIDOMSerializer, XMLSerializer),
   DEFINE_SHIM(SimpleGestureEvent),
-#ifdef MOZ_WEBSPEECH
-  DEFINE_SHIM(SpeechRecognitionEvent),
-  DEFINE_SHIM(SpeechSynthesisEvent),
-#endif // MOZ_WEBSPEECH
   DEFINE_SHIM(StyleSheet),
   DEFINE_SHIM(StyleSheetList),
   DEFINE_SHIM(StyleRuleChangeEvent),
   DEFINE_SHIM(StyleSheetApplicableStateChangeEvent),
   DEFINE_SHIM(StyleSheetChangeEvent),
   DEFINE_SHIM(SVGElement),
   DEFINE_SHIM(SVGLength),
   DEFINE_SHIM(Text),