Bug 765163 - Implement code generator for simple DOM events, r=jst,khuey
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Fri, 20 Jul 2012 19:42:08 +0300
changeset 103025 4590a7ed92ab6b2b391b36ab0edf31a0f12b9b49
parent 103024 eea94a9b40a1c5d88913adf597f5b84dd89fd4fc
child 103026 6628418273dcca1fd6bf3574793a3d25eabef76b
push id1989
push userakeybl@mozilla.com
push dateTue, 28 Aug 2012 00:20:43 +0000
treeherdermozilla-aurora@a8e95ae10ea7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst, khuey
bugs765163
milestone17.0a1
Bug 765163 - Implement code generator for simple DOM events, r=jst,khuey
content/base/public/nsContentUtils.h
content/base/src/nsEventSource.cpp
content/base/src/nsInProcessTabChildGlobal.cpp
content/base/src/nsNodeIterator.cpp
content/base/src/nsTreeWalker.cpp
content/events/src/Makefile.in
content/events/src/nsDOMApplicationEvent.cpp
content/events/src/nsDOMContactChangeEvent.cpp
content/events/src/nsDOMCustomEvent.cpp
content/events/src/nsDOMCustomEvent.h
content/events/src/nsDOMDeviceProximityEvent.cpp
content/events/src/nsDOMDeviceProximityEvent.h
content/events/src/nsDOMDragEvent.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMMessageEvent.cpp
content/events/src/nsDOMMouseEvent.cpp
content/events/src/nsDOMNotifyPaintEvent.cpp
content/events/src/nsDOMUIEvent.cpp
content/events/src/nsDOMUserProximityEvent.cpp
content/events/src/nsDOMUserProximityEvent.h
content/events/src/nsDOMWifiEvent.cpp
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventListenerService.cpp
content/svg/content/src/nsSVGRect.cpp
content/xul/document/src/nsXULCommandDispatcher.cpp
content/xul/document/src/nsXULControllers.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsDOMClassInfoClasses.h
dom/file/FileRequest.cpp
dom/indexedDB/IDBKeyRange.cpp
dom/interfaces/events/nsIDOMEvent.idl
dom/src/geolocation/nsGeoPosition.cpp
dom/src/geolocation/nsGeoPosition.h
dom/system/nsDeviceSensors.cpp
js/xpconnect/src/Makefile.in
js/xpconnect/src/dictionary_helper_gen.conf
js/xpconnect/src/dictionary_helper_gen.py
js/xpconnect/src/event_impl_gen.conf
js/xpconnect/src/event_impl_gen.py
layout/generic/nsSelection.cpp
layout/style/StyleRule.cpp
layout/style/nsCSSRules.cpp
layout/style/nsCSSStyleSheet.cpp
layout/style/nsDOMCSSDeclaration.cpp
layout/style/nsDOMCSSRGBColor.cpp
layout/style/nsDOMCSSRect.cpp
layout/style/nsDOMCSSValueList.cpp
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -27,17 +27,17 @@ static fp_except_t allmask = FP_X_INV|FP
 static fp_except_t allmask = FP_X_INV|FP_X_OFL|FP_X_UFL|FP_X_DZ|FP_X_IMP|FP_X_DNML;
 #endif
 static fp_except_t oldmask = fpsetmask(~allmask);
 #endif
 
 #include "nsAString.h"
 #include "nsIStatefulFrame.h"
 #include "nsNodeInfoManager.h"
-#include "nsDOMClassInfoID.h"
+#include "nsIXPCScriptable.h"
 #include "nsDataHashtable.h"
 #include "nsIDOMEvent.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
 #include "nsINode.h"
 #include "nsIDOMNode.h"
 #include "nsHtml5StringParser.h"
 #include "nsIDocument.h"
--- a/content/base/src/nsEventSource.cpp
+++ b/content/base/src/nsEventSource.cpp
@@ -27,16 +27,17 @@
 #include "nsIContentSecurityPolicy.h"
 #include "nsContentUtils.h"
 #include "mozilla/Preferences.h"
 #include "xpcpublic.h"
 #include "nsCrossSiteListenerProxy.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "mozilla/Attributes.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 #define REPLACEMENT_CHAR     (PRUnichar)0xFFFD
 #define BOM_CHAR             (PRUnichar)0xFEFF
 #define SPACE_CHAR           (PRUnichar)0x0020
 #define CR_CHAR              (PRUnichar)0x000D
 #define LF_CHAR              (PRUnichar)0x000A
--- a/content/base/src/nsInProcessTabChildGlobal.cpp
+++ b/content/base/src/nsInProcessTabChildGlobal.cpp
@@ -14,16 +14,17 @@
 #include "nsIJSRuntimeService.h"
 #include "nsComponentManagerUtils.h"
 #include "nsNetUtil.h"
 #include "nsScriptLoader.h"
 #include "nsIJSContextStack.h"
 #include "nsFrameLoader.h"
 #include "xpcpublic.h"
 #include "nsIMozBrowserFrame.h"
+#include "nsDOMClassInfoID.h"
 
 bool SendSyncMessageToParent(void* aCallbackData,
                              const nsAString& aMessage,
                              const nsAString& aJSON,
                              InfallibleTArray<nsString>* aJSONRetVal)
 {
   nsInProcessTabChildGlobal* tabChild =
     static_cast<nsInProcessTabChildGlobal*>(aCallbackData);
--- a/content/base/src/nsNodeIterator.cpp
+++ b/content/base/src/nsNodeIterator.cpp
@@ -11,17 +11,17 @@
 #include "nsNodeIterator.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
-
+#include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 #include "nsCOMPtr.h"
 
 /*
  * NodePointer implementation
  */
 nsNodeIterator::NodePointer::NodePointer(nsINode *aNode,
                                          bool aBeforeNode) :
--- a/content/base/src/nsTreeWalker.cpp
+++ b/content/base/src/nsTreeWalker.cpp
@@ -9,17 +9,17 @@
  */
 
 #include "nsTreeWalker.h"
 
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsDOMError.h"
 #include "nsINode.h"
-
+#include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 
 /*
  * Factories, constructors and destructors
  */
 
 nsTreeWalker::nsTreeWalker(nsINode *aRoot,
                            PRUint32 aWhatToShow,
--- a/content/events/src/Makefile.in
+++ b/content/events/src/Makefile.in
@@ -31,18 +31,16 @@ CPPSRCS		= \
 		nsDOMUIEvent.cpp \
 		nsDOMKeyboardEvent.cpp \
 		nsDOMTextEvent.cpp \
 		nsDOMMouseEvent.cpp \
 		nsDOMMouseScrollEvent.cpp \
 		nsDOMDragEvent.cpp \
 		nsDOMMutationEvent.cpp \
 		nsDOMPopupBlockedEvent.cpp \
-		nsDOMDeviceProximityEvent.cpp \
-		nsDOMUserProximityEvent.cpp \
 		nsDOMDeviceLightEvent.cpp \
 		nsDOMDeviceOrientationEvent.cpp \
 		nsDOMDeviceMotionEvent.cpp \
 		nsDOMBeforeUnloadEvent.cpp \
 		nsDOMPageTransitionEvent.cpp \
 		nsDOMXULCommandEvent.cpp \
 		nsDOMCommandEvent.cpp \
 		nsDOMMessageEvent.cpp \
@@ -66,17 +64,16 @@ CPPSRCS		= \
 		nsDOMTransitionEvent.cpp \
 		nsDOMAnimationEvent.cpp \
 		nsDOMPopStateEvent.cpp \
 		nsDOMHashChangeEvent.cpp \
 		nsDOMCloseEvent.cpp \
 		nsDOMSettingsEvent.cpp \
 		nsDOMContactChangeEvent.cpp \
 		nsDOMTouchEvent.cpp \
-		nsDOMCustomEvent.cpp \
 		nsDOMCompositionEvent.cpp \
 		nsDOMApplicationEvent.cpp \
 		$(NULL)
 
 ifdef MOZ_B2G_RIL
 CPPSRCS += \
     nsDOMWifiEvent.cpp \
     $(NULL)
--- a/content/events/src/nsDOMApplicationEvent.cpp
+++ b/content/events/src/nsDOMApplicationEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
  
 #include "nsDOMApplicationEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
  
 DOMCI_DATA(MozApplicationEvent, nsDOMMozApplicationEvent)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozApplicationEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozApplicationEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mApplication)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
--- a/content/events/src/nsDOMContactChangeEvent.cpp
+++ b/content/events/src/nsDOMContactChangeEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 #include "nsDOMContactChangeEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
 
 DOMCI_DATA(MozContactChangeEvent, nsDOMMozContactChangeEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMMozContactChangeEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMozContactChangeEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MozContactChangeEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
deleted file mode 100644
--- a/content/events/src/nsDOMCustomEvent.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; 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/. */
-
-#include "nsDOMClassInfoID.h"
-#include "nsDOMCustomEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMCustomEvent)
-
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mDetail)
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
-
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mDetail)
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-
-DOMCI_DATA(CustomEvent, nsDOMCustomEvent)
-
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMCustomEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCustomEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(CustomEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMPL_ADDREF_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMCustomEvent::GetDetail(nsIVariant** aDetail)
-{
-  NS_IF_ADDREF(*aDetail = mDetail);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMCustomEvent::InitCustomEvent(const nsAString& aType,
-                                  bool aCanBubble,
-                                  bool aCancelable,
-                                  nsIVariant* aDetail)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  mDetail = aDetail;
-  return NS_OK;
-}
-
-nsresult
-nsDOMCustomEvent::InitFromCtor(const nsAString& aType,
-                               JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::CustomEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitCustomEvent(aType, d.bubbles, d.cancelable, d.detail);
-}
-
-nsresult
-NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult,
-                     nsPresContext* aPresContext,
-                     nsEvent* aEvent) 
-{
-  nsDOMCustomEvent* e = new nsDOMCustomEvent(aPresContext, aEvent);
-  return CallQueryInterface(e, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMCustomEvent.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* -*- Mode: C++; 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/. */
-
-#ifndef nsDOMCustomEvent_h__
-#define nsDOMCustomEvent_h__
-
-#include "nsIDOMCustomEvent.h"
-#include "nsDOMEvent.h"
-#include "nsCycleCollectionParticipant.h"
-
-class nsDOMCustomEvent : public nsDOMEvent,
-                         public nsIDOMCustomEvent
-{
-public:
-  nsDOMCustomEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-    : nsDOMEvent(aPresContext, aEvent)
-  {
-  }
-                     
-  NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMCustomEvent, nsDOMEvent)
-
-  NS_DECL_NSIDOMCUSTOMEVENT
-
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx, jsval* aVal);
-private:
-  nsCOMPtr<nsIVariant> mDetail;
-};
-
-#endif // nsDOMCustomEvent_h__
deleted file mode 100644
--- a/content/events/src/nsDOMDeviceProximityEvent.cpp
+++ /dev/null
@@ -1,81 +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 "nsDOMClassInfoID.h"
-#include "nsDOMDeviceProximityEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_ADDREF_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDeviceProximityEvent, nsDOMEvent)
-
-DOMCI_DATA(DeviceProximityEvent, nsDOMDeviceProximityEvent)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMDeviceProximityEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceProximityEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceProximityEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::InitDeviceProximityEvent(const nsAString & aEventTypeArg,
-                                                    bool aCanBubbleArg,
-                                                    bool aCancelableArg,
-                                                    double aValue,
-                                                    double aMin,
-                                                    double aMax)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-    
-  mValue = aValue;
-  mMin = aMin;
-  mMax = aMax;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetValue(double *aValue)
-{
-  NS_ENSURE_ARG_POINTER(aValue);
-
-  *aValue = mValue;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetMin(double *aMin)
-{
-  NS_ENSURE_ARG_POINTER(aMin);
-
-  *aMin = mMin;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMDeviceProximityEvent::GetMax(double *aMax)
-{
-  NS_ENSURE_ARG_POINTER(aMax);
-
-  *aMax = mMax;
-  return NS_OK;
-}
-
-nsresult
-nsDOMDeviceProximityEvent::InitFromCtor(const nsAString& aType,
-                                        JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::DeviceProximityEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitDeviceProximityEvent(aType, d.bubbles, d.cancelable, d.value, d.min, d.max);
-}
-
-nsresult
-NS_NewDOMDeviceProximityEvent(nsIDOMEvent** aInstancePtrResult,
-                              nsPresContext* aPresContext,
-                              nsEvent *aEvent)
-{
-  NS_ENSURE_ARG_POINTER(aInstancePtrResult);
-  nsDOMDeviceProximityEvent* it = new nsDOMDeviceProximityEvent(aPresContext, aEvent);
-  return CallQueryInterface(it, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMDeviceProximityEvent.h
+++ /dev/null
@@ -1,38 +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/. */
-
-#ifndef nsDOMDeviceProximityEvent_h__
-#define nsDOMDeviceProximityEvent_h__
-
-#include "nsIDOMDeviceProximityEvent.h"
-#include "nsDOMEvent.h"
-
-class nsDOMDeviceProximityEvent
- : public nsDOMEvent
- , public nsIDOMDeviceProximityEvent
-{
-public:
-
- nsDOMDeviceProximityEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-  : nsDOMEvent(aPresContext, aEvent),
-    mValue(-1),
-    mMin(0),
-    mMax(0) {}
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // Forward to nsDOMEvent
-  NS_FORWARD_TO_NSDOMEVENT
-
-  // nsIDOMDeviceProximityEvent Interface
-  NS_DECL_NSIDOMDEVICEPROXIMITYEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx,
-                                jsval* aVal);
-protected:
-  double mValue, mMin, mMax;
-};
-
-#endif
--- a/content/events/src/nsDOMDragEvent.cpp
+++ b/content/events/src/nsDOMDragEvent.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMDragEvent.h"
 #include "nsIServiceManager.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsDOMDataTransfer.h"
 #include "nsIDragService.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMDragEvent::nsDOMDragEvent(nsPresContext* aPresContext,
                                nsInputEvent* aEvent)
   : nsDOMMouseEvent(aPresContext, aEvent ? aEvent :
                     new nsDragEvent(false, 0, nsnull))
 {
   if (aEvent) {
     mEventIsInternal = false;
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -26,16 +26,17 @@
 #include "nsIScriptSecurityManager.h"
 #include "nsIScriptError.h"
 #include "nsDOMPopStateEvent.h"
 #include "mozilla/Preferences.h"
 #include "nsJSUtils.h"
 #include "DictionaryHelpers.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 static const char* const sEventNames[] = {
   "mousedown", "mouseup", "click", "dblclick", "mouseenter", "mouseleave", "mouseover",
   "mouseout", "MozMouseHittest", "mousemove", "contextmenu", "keydown", "keyup", "keypress",
   "focus", "blur", "load", "popstate", "beforescriptexecute",
   "afterscriptexecute", "beforeunload", "unload",
--- a/content/events/src/nsDOMMessageEvent.cpp
+++ b/content/events/src/nsDOMMessageEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 #include "nsDOMMessageEvent.h"
 #include "nsContentUtils.h"
 #include "jsapi.h"
+#include "nsDOMClassInfoID.h"
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
   if (tmp->mDataRooted) {
     tmp->UnrootData();
   }
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSource)
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -3,16 +3,17 @@
  * 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 "nsDOMMouseEvent.h"
 #include "nsGUIEvent.h"
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 nsDOMMouseEvent::nsDOMMouseEvent(nsPresContext* aPresContext,
                                  nsInputEvent* aEvent)
   : nsDOMUIEvent(aPresContext, aEvent ? aEvent :
                  new nsMouseEvent(false, 0, nsnull,
                                   nsMouseEvent::eReal))
--- a/content/events/src/nsDOMNotifyPaintEvent.cpp
+++ b/content/events/src/nsDOMNotifyPaintEvent.cpp
@@ -5,16 +5,17 @@
 
 #include "base/basictypes.h"
 #include "IPC/IPCMessageUtils.h"
 #include "nsDOMNotifyPaintEvent.h"
 #include "nsContentUtils.h"
 #include "nsClientRect.h"
 #include "nsPaintRequest.h"
 #include "nsIFrame.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMNotifyPaintEvent::nsDOMNotifyPaintEvent(nsPresContext* aPresContext,
                                              nsEvent* aEvent,
                                              PRUint32 aEventType,
                                              nsInvalidateRequestList* aInvalidateRequests)
 : nsDOMEvent(aPresContext, aEvent)
 {
   if (mEvent) {
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -14,16 +14,17 @@
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIScrollableFrame.h"
 #include "DictionaryHelpers.h"
 #include "mozilla/Util.h"
 #include "mozilla/Assertions.h"
+#include "nsDOMClassInfoID.h"
 
 using namespace mozilla;
 
 nsDOMUIEvent::nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ?
                static_cast<nsEvent *>(aEvent) :
                static_cast<nsEvent *>(new nsUIEvent(false, 0, 0)))
   , mClientPoint(0, 0), mLayerPoint(0, 0), mPagePoint(0, 0), mMovementPoint(0, 0)
deleted file mode 100644
--- a/content/events/src/nsDOMUserProximityEvent.cpp
+++ /dev/null
@@ -1,57 +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 "nsDOMClassInfoID.h"
-#include "nsDOMUserProximityEvent.h"
-#include "DictionaryHelpers.h"
-
-NS_IMPL_ADDREF_INHERITED(nsDOMUserProximityEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMUserProximityEvent, nsDOMEvent)
-
-DOMCI_DATA(UserProximityEvent, nsDOMUserProximityEvent)
-
-NS_INTERFACE_MAP_BEGIN(nsDOMUserProximityEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMUserProximityEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(UserProximityEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
-
-NS_IMETHODIMP
-nsDOMUserProximityEvent::InitUserProximityEvent(const nsAString & aEventTypeArg,
-                                                bool aCanBubbleArg,
-                                                bool aCancelableArg,
-                                                bool aNear)
-{
-  nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-  mNear = aNear;
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMUserProximityEvent::GetNear(bool *aNear)
-{
-  NS_ENSURE_ARG_POINTER(aNear);
-  *aNear = mNear;
-  return NS_OK;
-}
-
-nsresult
-nsDOMUserProximityEvent::InitFromCtor(const nsAString& aType,
-                                      JSContext* aCx, jsval* aVal)
-{
-  mozilla::dom::UserProximityEventInit d;
-  nsresult rv = d.Init(aCx, aVal);
-  NS_ENSURE_SUCCESS(rv, rv);
-  return InitUserProximityEvent(aType, d.bubbles, d.cancelable, d.near);
-}
-
-nsresult
-NS_NewDOMUserProximityEvent(nsIDOMEvent** aInstancePtrResult,
-                            nsPresContext* aPresContext,
-                            nsEvent *aEvent) 
-{
-  NS_ENSURE_ARG_POINTER(aInstancePtrResult);
-  nsDOMUserProximityEvent* it = new nsDOMUserProximityEvent(aPresContext, aEvent);
-  return CallQueryInterface(it, aInstancePtrResult);
-}
deleted file mode 100644
--- a/content/events/src/nsDOMUserProximityEvent.h
+++ /dev/null
@@ -1,36 +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/. */
-
-#ifndef nsDOMUserProximityEvent_h__
-#define nsDOMUserProximityEvent_h__
-
-#include "nsIDOMUserProximityEvent.h"
-#include "nsDOMEvent.h"
-
-class nsDOMUserProximityEvent
- : public nsDOMEvent
- , public nsIDOMUserProximityEvent
-{
-public:
-
-  nsDOMUserProximityEvent(nsPresContext* aPresContext, nsEvent* aEvent)
-  : nsDOMEvent(aPresContext, aEvent),
-    mNear(false) {}
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  // Forward to nsDOMEvent
-  NS_FORWARD_TO_NSDOMEVENT
-
-  // nsIDOMUserProximityEvent Interface
-  NS_DECL_NSIDOMUSERPROXIMITYEVENT
-
-  virtual nsresult InitFromCtor(const nsAString& aType,
-                                JSContext* aCx,
-                                jsval* aVal);
-protected:
-  bool mNear;
-};
-
-#endif
--- a/content/events/src/nsDOMWifiEvent.cpp
+++ b/content/events/src/nsDOMWifiEvent.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 #include "nsDOMWifiEvent.h"
 #include "nsContentUtils.h"
 #include "DictionaryHelpers.h"
+#include "nsDOMClassInfoID.h"
 
 // nsDOMMozWifiStatusChangeEvent
 
 DOMCI_DATA(MozWifiStatusChangeEvent, nsDOMMozWifiStatusChangeEvent)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMozWifiStatusChangeEvent)
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMozWifiStatusChangeEvent, nsDOMEvent)
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -17,16 +17,17 @@
 #include "nsINode.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMPopStateEvent.h"
 #include "nsDOMHashChangeEvent.h"
 #include "nsFrameLoader.h"
 #include "nsDOMTouchEvent.h"
 #include "nsDOMStorage.h"
 #include "sampler.h"
+#include "GeneratedEvents.h"
 
 #define NS_TARGET_CHAIN_FORCE_CONTENT_DISPATCH  (1 << 0)
 #define NS_TARGET_CHAIN_WANTS_WILL_HANDLE_EVENT (1 << 1)
 #define NS_TARGET_CHAIN_MAY_HAVE_MANAGER        (1 << 2)
 
 static nsEventTargetChainItem* gCachedETCI = nsnull;
 
 // nsEventTargetChainItem represents a single item in the event target chain.
--- a/content/events/src/nsEventListenerService.cpp
+++ b/content/events/src/nsEventListenerService.cpp
@@ -15,16 +15,17 @@
 #include "nsJSUtils.h"
 #include "nsIJSContextStack.h"
 #include "nsGUIEvent.h"
 #include "nsEventDispatcher.h"
 #include "nsIJSEventListener.h"
 #ifdef MOZ_JSDEBUGGER
 #include "jsdIDebuggerService.h"
 #endif
+#include "nsDOMClassInfoID.h"
 
 NS_IMPL_CYCLE_COLLECTION_1(nsEventListenerInfo, mListener)
 
 DOMCI_DATA(EventListenerInfo, nsEventListenerInfo)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsEventListenerInfo)
   NS_INTERFACE_MAP_ENTRY(nsIEventListenerInfo)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
--- a/content/svg/content/src/nsSVGRect.cpp
+++ b/content/svg/content/src/nsSVGRect.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; 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/. */
 
 #include "nsSVGRect.h"
 #include "nsTextFormatter.h"
 #include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 //----------------------------------------------------------------------
 // implementation:
 
 nsSVGRect::nsSVGRect(float x, float y, float w, float h)
     : mX(x), mY(y), mWidth(w), mHeight(h)
 {
 }
--- a/content/xul/document/src/nsXULCommandDispatcher.cpp
+++ b/content/xul/document/src/nsXULCommandDispatcher.cpp
@@ -28,16 +28,17 @@
 #include "prlog.h"
 #include "nsIDOMEventTarget.h"
 #include "nsGUIEvent.h"
 #include "nsContentUtils.h"
 #include "nsReadableUtils.h"
 #include "nsCRT.h"
 #include "nsDOMError.h"
 #include "nsEventDispatcher.h"
+#include "nsDOMClassInfoID.h"
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gLog;
 #endif
 
 ////////////////////////////////////////////////////////////////////////
 
 nsXULCommandDispatcher::nsXULCommandDispatcher(nsIDocument* aDocument)
--- a/content/xul/document/src/nsXULControllers.cpp
+++ b/content/xul/document/src/nsXULControllers.cpp
@@ -11,16 +11,17 @@
 */
 
 #include "nsString.h"
 
 #include "nsIControllers.h"
 #include "nsIDOMElement.h"
 #include "nsXULControllers.h"
 #include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 //----------------------------------------------------------------------
 
 nsXULControllers::nsXULControllers()
 : mCurControllerID(0)
 {
 }
 
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -294,18 +294,19 @@
 #include "nsIDOMCSSFontFaceRule.h"
 #include "nsIDOMCSSMozDocumentRule.h"
 #include "nsIDOMMozCSSKeyframeRule.h"
 #include "nsIDOMMozCSSKeyframesRule.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleRule.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsDOMCSSValueList.h"
-#include "nsIDOMDeviceProximityEvent.h"
-#include "nsIDOMUserProximityEvent.h"
+#define MOZ_GENERATED_EVENTS_INCLUDES
+#include "GeneratedEvents.h"
+#undef MOZ_GENERATED_EVENTS_INCLUDES
 #include "nsIDOMDeviceLightEvent.h"
 #include "nsIDOMDeviceOrientationEvent.h"
 #include "nsIDOMDeviceMotionEvent.h"
 #include "nsIDOMRange.h"
 #include "nsIDOMNodeIterator.h"
 #include "nsIDOMTreeWalker.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMXULElement.h"
@@ -481,17 +482,16 @@
 #include "mozilla/dom/indexedDB/IDBKeyRange.h"
 #include "mozilla/dom/indexedDB/IDBIndex.h"
 
 using mozilla::dom::indexedDB::IDBWrapperCache;
 
 #include "nsIDOMMediaQueryList.h"
 
 #include "nsDOMTouchEvent.h"
-#include "nsIDOMCustomEvent.h"
 #include "nsDOMMutationObserver.h"
 
 #include "nsWrapperCacheInlines.h"
 #include "dombindings.h"
 
 #include "nsIDOMBatteryManager.h"
 #include "BatteryManager.h"
 #include "nsIDOMPowerManager.h"
@@ -527,17 +527,17 @@ using mozilla::dom::indexedDB::IDBWrappe
 #include "DOMError.h"
 #include "DOMRequest.h"
 #include "nsIOpenWindowEventDetail.h"
 #include "nsIDOMGlobalObjectConstructor.h"
 
 #include "DOMFileHandle.h"
 #include "FileRequest.h"
 #include "LockedFile.h"
-
+#include "GeneratedEvents.h"
 #include "mozilla/Likely.h"
 
 #undef None // something included above defines this preprocessor symbol, maybe Xlib headers
 #include "WebGLContext.h"
 #include "nsICanvasRenderingContextInternal.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -815,22 +815,24 @@ static nsDOMClassInfoData sClassInfoData
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(CompositionEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   // Device Light
   NS_DEFINE_CLASSINFO_DATA(DeviceLightEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  // Device Proximity
-  NS_DEFINE_CLASSINFO_DATA(DeviceProximityEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  // User Proximity
-  NS_DEFINE_CLASSINFO_DATA(UserProximityEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+
+#define MOZ_GENERATED_EVENT_LIST
+#define MOZ_GENERATED_EVENT(_event_interface)                \
+  NS_DEFINE_CLASSINFO_DATA(_event_interface, nsDOMGenericSH, \
+                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
+#include "GeneratedEvents.h"
+#undef MOZ_GENERATED_EVENT_LIST
+
   // Device Orientation
   NS_DEFINE_CLASSINFO_DATA(DeviceOrientationEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(DeviceMotionEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(DeviceAcceleration, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(DeviceRotationRate, nsDOMGenericSH,
@@ -1639,18 +1641,16 @@ static nsDOMClassInfoData sClassInfoData
 
   NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframeRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozCSSKeyframesRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CLASSINFO_DATA(MediaQueryList, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(CustomEvent, nsDOMGenericSH,
-                           DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MutationObserver, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MutationRecord, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozSettingsEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(MozContactChangeEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
@@ -1731,34 +1731,37 @@ static const nsContractIDMapData kConstr
   {                                                         \
     nsIDOMEvent* e = nsnull;                                \
     nsresult rv = NS_NewDOM##_class(&e, nsnull, nsnull);    \
     *aInstancePtrResult = e;                                \
     return rv;                                              \
   }
 
 NS_DEFINE_EVENT_CTOR(Event)
-NS_DEFINE_EVENT_CTOR(CustomEvent)
 NS_DEFINE_EVENT_CTOR(PopStateEvent)
 NS_DEFINE_EVENT_CTOR(HashChangeEvent)
 NS_DEFINE_EVENT_CTOR(PageTransitionEvent)
 NS_DEFINE_EVENT_CTOR(CloseEvent)
 NS_DEFINE_EVENT_CTOR(MozSettingsEvent)
 NS_DEFINE_EVENT_CTOR(MozContactChangeEvent)
 NS_DEFINE_EVENT_CTOR(MozApplicationEvent)
 NS_DEFINE_EVENT_CTOR(UIEvent)
 NS_DEFINE_EVENT_CTOR(MouseEvent)
 NS_DEFINE_EVENT_CTOR(DeviceLightEvent)
-NS_DEFINE_EVENT_CTOR(DeviceProximityEvent)
-NS_DEFINE_EVENT_CTOR(UserProximityEvent)
 #ifdef MOZ_B2G_RIL
 NS_DEFINE_EVENT_CTOR(MozWifiStatusChangeEvent)
 NS_DEFINE_EVENT_CTOR(MozWifiConnectionInfoEvent)
 #endif
 
+#define MOZ_GENERATED_EVENT_LIST
+#define MOZ_GENERATED_EVENT(_event_interface) \
+  NS_DEFINE_EVENT_CTOR(_event_interface)
+#include "GeneratedEvents.h"
+#undef MOZ_GENERATED_EVENT_LIST
+
 nsresult
 NS_DOMStorageEventCtor(nsISupports** aInstancePtrResult)
 {
   nsDOMStorageEvent* e = new nsDOMStorageEvent();
   return CallQueryInterface(e, aInstancePtrResult);
 }
 
 nsresult
@@ -1781,34 +1784,35 @@ struct nsConstructorFuncMapData
   { eDOMClassInfo_##_class##_id, NS_DOM##_class##Ctor },
 
 static const nsConstructorFuncMapData kConstructorFuncMap[] =
 {
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(Blob, nsDOMMultipartFile::NewBlob)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(File, nsDOMFileFile::NewFile)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozBlobBuilder, NS_NewBlobBuilder)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(Event)
-  NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CustomEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PopStateEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(HashChangeEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(PageTransitionEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(CloseEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozSettingsEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozContactChangeEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozApplicationEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UIEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MouseEvent)
-  NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(DeviceProximityEvent)
-  NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(UserProximityEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(DeviceLightEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(StorageEvent)
 #ifdef MOZ_B2G_RIL
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozWifiStatusChangeEvent)
   NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(MozWifiConnectionInfoEvent)
 #endif
+#define MOZ_GENERATED_EVENT_LIST
+#define MOZ_GENERATED_EVENT(_event_interface) \
+  NS_DEFINE_EVENT_CONSTRUCTOR_FUNC_DATA(_event_interface)
+#include "GeneratedEvents.h"
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(MozSmsFilter, sms::SmsFilter::NewSmsFilter)
   NS_DEFINE_CONSTRUCTOR_FUNC_DATA(XMLHttpRequest, NS_XMLHttpRequestCtor)
 };
 
 nsIXPConnect *nsDOMClassInfo::sXPConnect = nsnull;
 nsIScriptSecurityManager *nsDOMClassInfo::sSecMan = nsnull;
 bool nsDOMClassInfo::sIsInitialized = false;
 bool nsDOMClassInfo::sDisableDocumentAllSupport = false;
@@ -2615,25 +2619,24 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DeviceLightEvent, nsIDOMDeviceLightEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceLightEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(DeviceProximityEvent, nsIDOMDeviceProximityEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceProximityEvent)
-    DOM_CLASSINFO_EVENT_MAP_ENTRIES
-  DOM_CLASSINFO_MAP_END
-
-  DOM_CLASSINFO_MAP_BEGIN(UserProximityEvent, nsIDOMUserProximityEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMUserProximityEvent)
-    DOM_CLASSINFO_EVENT_MAP_ENTRIES
-  DOM_CLASSINFO_MAP_END
+#define MOZ_GENERATED_EVENT_LIST
+#define MOZ_GENERATED_EVENT(_event_interface)                         \
+  DOM_CLASSINFO_MAP_BEGIN(_event_interface, nsIDOM##_event_interface) \
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOM##_event_interface)                 \
+    DOM_CLASSINFO_EVENT_MAP_ENTRIES                                   \
+  DOM_CLASSINFO_MAP_END
+#include "GeneratedEvents.h"
+#undef MOZ_GENERATED_EVENT_LIST
 
   DOM_CLASSINFO_MAP_BEGIN(DeviceOrientationEvent, nsIDOMDeviceOrientationEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DeviceMotionEvent, nsIDOMDeviceMotionEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceMotionEvent)
@@ -4427,21 +4430,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_BEGIN(MozCSSKeyframesRule, nsIDOMMozCSSKeyframesRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMozCSSKeyframesRule)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MediaQueryList, nsIDOMMediaQueryList)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMediaQueryList)
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(CustomEvent, nsIDOMCustomEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMCustomEvent)
-    DOM_CLASSINFO_EVENT_MAP_ENTRIES
-  DOM_CLASSINFO_MAP_END
-
   DOM_CLASSINFO_MAP_BEGIN(MutationObserver, nsIDOMMutationObserver)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationObserver)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(MutationRecord, nsIDOMMutationRecord)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMMutationRecord)
   DOM_CLASSINFO_MAP_END
 
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -39,18 +39,20 @@ DOMCI_CLASS(MutationEvent)
 DOMCI_CLASS(UIEvent)
 DOMCI_CLASS(MouseEvent)
 DOMCI_CLASS(MouseScrollEvent)
 DOMCI_CLASS(DragEvent)
 DOMCI_CLASS(KeyboardEvent)
 DOMCI_CLASS(CompositionEvent)
 DOMCI_CLASS(PopupBlockedEvent)
 DOMCI_CLASS(DeviceLightEvent)
-DOMCI_CLASS(DeviceProximityEvent)
-DOMCI_CLASS(UserProximityEvent)
+#define MOZ_GENERATED_EVENT_LIST
+#define MOZ_GENERATED_EVENT(_event_interface) DOMCI_CLASS(_event_interface)
+#include "GeneratedEvents.h"
+#undef MOZ_GENERATED_EVENT_LIST
 DOMCI_CLASS(DeviceOrientationEvent)
 DOMCI_CLASS(DeviceMotionEvent)
 DOMCI_CLASS(DeviceAcceleration)
 DOMCI_CLASS(DeviceRotationRate)
 
 // HTML classes
 DOMCI_CLASS(HTMLDocument)
 DOMCI_CLASS(HTMLOptionsCollection)
@@ -502,17 +504,16 @@ DOMCI_CLASS(IDBOpenDBRequest)
 DOMCI_CLASS(Touch)
 DOMCI_CLASS(TouchList)
 DOMCI_CLASS(TouchEvent)
 
 DOMCI_CLASS(MozCSSKeyframeRule)
 DOMCI_CLASS(MozCSSKeyframesRule)
 
 DOMCI_CLASS(MediaQueryList)
-DOMCI_CLASS(CustomEvent)
 
 DOMCI_CLASS(MutationObserver)
 DOMCI_CLASS(MutationRecord)
 
 DOMCI_CLASS(MozSettingsEvent)
 DOMCI_CLASS(MozContactChangeEvent)
 
 DOMCI_CLASS(MozApplicationEvent)
--- a/dom/file/FileRequest.cpp
+++ b/dom/file/FileRequest.cpp
@@ -6,17 +6,17 @@
 
 #include "FileRequest.h"
 
 #include "nsIJSContextStack.h"
 
 #include "nsContentUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsDOMProgressEvent.h"
-
+#include "nsDOMClassInfoID.h"
 #include "FileHelper.h"
 #include "LockedFile.h"
 
 USING_FILE_NAMESPACE
 
 FileRequest::FileRequest(nsIDOMWindow* aWindow)
 : DOMRequest(aWindow), mIsFileRequest(true)
 {
--- a/dom/indexedDB/IDBKeyRange.cpp
+++ b/dom/indexedDB/IDBKeyRange.cpp
@@ -8,17 +8,17 @@
 
 #include "IDBKeyRange.h"
 
 #include "nsIXPConnect.h"
 
 #include "nsJSUtils.h"
 #include "nsThreadUtils.h"
 #include "nsContentUtils.h"
-
+#include "nsDOMClassInfoID.h"
 #include "Key.h"
 
 #include "mozilla/dom/indexedDB/PIndexedDBIndex.h"
 #include "mozilla/dom/indexedDB/PIndexedDBObjectStore.h"
 
 USING_INDEXEDDB_NAMESPACE
 using namespace mozilla::dom::indexedDB::ipc;
 
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -199,20 +199,16 @@ nsresult
 NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsKeyEvent *aEvent);
 nsresult
 NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsCompositionEvent *aEvent);
 nsresult
 NS_NewDOMMutationEvent(nsIDOMEvent** aResult NS_OUTPARAM, nsPresContext* aPresContext, class nsMutationEvent* aEvent);
 nsresult
 NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
-NS_NewDOMDeviceProximityEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent *aEvent);
-nsresult
-NS_NewDOMUserProximityEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent *aEvent);
-nsresult
 NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMDeviceLightEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);
 nsresult
@@ -256,18 +252,16 @@ nsresult
 NS_NewDOMAnimationEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsAnimationEvent* aEvent);
 nsresult
 NS_NewDOMCloseEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsEvent* aEvent);
 nsresult
 NS_NewDOMMozTouchEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsMozTouchEvent* aEvent);
 nsresult
 NS_NewDOMTouchEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsTouchEvent *aEvent);
 nsresult
-NS_NewDOMCustomEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
-nsresult
 NS_NewDOMSmsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMMozSettingsEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMMozContactChangeEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMMozWifiStatusChangeEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
--- a/dom/src/geolocation/nsGeoPosition.cpp
+++ b/dom/src/geolocation/nsGeoPosition.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; 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/. */
 
 #include "nsGeoPosition.h"
 #include "nsDOMClassInfoID.h"
+#include "nsIClassInfo.h"
 
 ////////////////////////////////////////////////////
 // nsGeoPositionCoords
 ////////////////////////////////////////////////////
 nsGeoPositionCoords::nsGeoPositionCoords(double aLat, double aLong,
                                          double aAlt, double aHError,
                                          double aVError, double aHeading,
                                          double aSpeed)
--- a/dom/src/geolocation/nsGeoPosition.h
+++ b/dom/src/geolocation/nsGeoPosition.h
@@ -2,18 +2,16 @@
 /* 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/. */
 
 #ifndef nsGeoPosition_h
 #define nsGeoPosition_h
 
 #include "nsAutoPtr.h"
-#include "nsIClassInfo.h"
-#include "nsDOMClassInfoID.h"
 #include "nsIDOMGeoPositionCoords.h"
 #include "nsIDOMGeoPosition.h"
 #include "nsString.h"
 #include "mozilla/Attributes.h"
 
 ////////////////////////////////////////////////////
 // nsGeoPositionCoords
 ////////////////////////////////////////////////////
--- a/dom/system/nsDeviceSensors.cpp
+++ b/dom/system/nsDeviceSensors.cpp
@@ -10,17 +10,17 @@
 #include "nsAutoPtr.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIServiceManager.h"
 #include "nsIServiceManager.h"
-
+#include "GeneratedEvents.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Attributes.h"
 
 using namespace mozilla;
 using namespace hal;
 
 #undef near
 
--- a/js/xpconnect/src/Makefile.in
+++ b/js/xpconnect/src/Makefile.in
@@ -52,16 +52,17 @@ CPPSRCS		= \
 		XPCWrappedNativeProto.cpp \
 		XPCWrappedNativeScope.cpp \
 		XPCJSWeakReference.cpp \
 		XPCWrapper.cpp \
 		XPCQuickStubs.cpp \
 		dom_quickstubs.cpp \
 		dombindings.cpp \
 		DictionaryHelpers.cpp \
+		GeneratedEvents.cpp \
 		$(NULL)
 
 include $(topsrcdir)/config/config.mk
 
 LOCAL_INCLUDES = \
 		-I$(srcdir)/../wrappers \
 		-I$(srcdir)/../loader \
 		-I$(topsrcdir)/caps/include \
@@ -107,16 +108,18 @@ endif
 endif
 endif
 endif
 
 nsXPConnect.$(OBJ_SUFFIX): dom_quickstubs.h
 
 XPCJSRuntime.$(OBJ_SUFFIX): dom_quickstubs.h
 
+nsScriptError.$(OBJ_SUFFIX): GeneratedEvents.h
+
 dom_quickstubs.h: dom_quickstubs.cpp
 
 dom_quickstubs.cpp: $(srcdir)/dom_quickstubs.qsconf \
                     $(srcdir)/qsgen.py \
                     $(LIBXUL_DIST)/sdk/bin/header.py \
                     $(LIBXUL_DIST)/sdk/bin/xpidl.py \
                     $(DEPTH)/js/src/js-confdefs.h
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
@@ -163,59 +166,105 @@ dombindings_gen.cpp: $(srcdir)/dombindin
 	  --stub-output dombindings_gen.cpp \
 	  --makedepend-output $(MDDEPDIR)/dombindingsgen.pp \
 	  $(srcdir)/dombindings.conf
 
 DictionaryHelpers.$(OBJ_SUFFIX): DictionaryHelpers.h \
                                  DictionaryHelpers.cpp
 
 DictionaryHelpers.h: $(srcdir)/dictionary_helper_gen.conf \
+                     $(srcdir)/event_impl_gen.conf \
                      $(srcdir)/dictionary_helper_gen.py \
                      $(srcdir)/codegen.py \
                      $(LIBXUL_DIST)/sdk/bin/header.py \
                      $(LIBXUL_DIST)/sdk/bin/xpidl.py \
                      $(DEPTH)/js/src/js-confdefs.h
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  -I$(LIBXUL_DIST)/sdk/bin \
 	  $(srcdir)/dictionary_helper_gen.py \
 	  -I $(DEPTH)/dist/idl \
 	  --header-output DictionaryHelpers.h \
-	  $(srcdir)/dictionary_helper_gen.conf
+	  $(srcdir)/dictionary_helper_gen.conf \
+	  $(srcdir)/event_impl_gen.conf
 
 DictionaryHelpers.cpp: $(srcdir)/dictionary_helper_gen.conf \
+                       $(srcdir)/event_impl_gen.conf \
                        $(srcdir)/dictionary_helper_gen.py \
                        $(srcdir)/codegen.py \
                        $(LIBXUL_DIST)/sdk/bin/header.py \
                        $(LIBXUL_DIST)/sdk/bin/xpidl.py \
                        $(DEPTH)/js/src/js-confdefs.h
 	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
 	  $(PLY_INCLUDE) \
 	  -I$(LIBXUL_DIST)/sdk/bin \
 	  $(srcdir)/dictionary_helper_gen.py \
 	  -I $(DEPTH)/dist/idl \
 	  --header-output DictionaryHelpers.h \
 	  --stub-output DictionaryHelpers.cpp \
 	  --makedepend-output $(MDDEPDIR)/dictionary_helper_gen.pp \
-	  $(srcdir)/dictionary_helper_gen.conf
+	  $(srcdir)/dictionary_helper_gen.conf \
+	  $(srcdir)/event_impl_gen.conf
+
+GeneratedEvents.$(OBJ_SUFFIX): GeneratedEvents.h \
+                               GeneratedEvents.cpp
+
+GeneratedEvents.h: $(srcdir)/dictionary_helper_gen.conf \
+                   $(srcdir)/event_impl_gen.conf \
+                   $(srcdir)/dictionary_helper_gen.py \
+                   $(srcdir)/event_impl_gen.py \
+                   $(srcdir)/codegen.py \
+                   $(LIBXUL_DIST)/sdk/bin/header.py \
+                   $(LIBXUL_DIST)/sdk/bin/xpidl.py \
+                   $(DEPTH)/js/src/js-confdefs.h
+	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
+	  $(PLY_INCLUDE) \
+	  -I$(LIBXUL_DIST)/sdk/bin \
+	  $(srcdir)/event_impl_gen.py \
+	  -I $(DEPTH)/dist/idl \
+	  --header-output GeneratedEvents.h \
+	  $(srcdir)/event_impl_gen.conf
+
+GeneratedEvents.cpp: DictionaryHelpers.h \
+                     $(srcdir)/dictionary_helper_gen.conf \
+                     $(srcdir)/event_impl_gen.conf \
+                     $(srcdir)/dictionary_helper_gen.py \
+                     $(srcdir)/event_impl_gen.py \
+                     $(srcdir)/codegen.py \
+                     $(LIBXUL_DIST)/sdk/bin/header.py \
+                     $(LIBXUL_DIST)/sdk/bin/xpidl.py \
+                     $(DEPTH)/js/src/js-confdefs.h
+	$(PYTHON) $(topsrcdir)/config/pythonpath.py \
+	  $(PLY_INCLUDE) \
+	  -I$(LIBXUL_DIST)/sdk/bin \
+	  $(srcdir)/event_impl_gen.py \
+	  -I $(DEPTH)/dist/idl \
+	  --header-output GeneratedEvents.h \
+	  --stub-output GeneratedEvents.cpp \
+	  --makedepend-output $(MDDEPDIR)/event_impl_gen.pp \
+	  $(srcdir)/event_impl_gen.conf
 
 _EXTRA_EXPORT_FILES = \
   DictionaryHelpers.h \
+  GeneratedEvents.h \
   $(NULL)
 
 libs:: $(_EXTRA_EXPORT_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/dist/include
 
 GARBAGE += \
 		dom_quickstubs.h \
 		dom_quickstubs.cpp \
 		dombindings_gen.h \
 		dombindings_gen.cpp \
 		DictionaryHelpers.h \
 		DictionaryHelpers.cpp \
+		GeneratedEvents.h \
+		GeneratedEvents.cpp \
 		xpidl_debug \
 		$(MDDEPDIR)/dom_qsgen.pp \
 		$(MDDEPDIR)/dombindingsgen.pp \
 		$(MDDEPDIR)/dictionary_helper_gen.pp \
+		$(MDDEPDIR)/event_impl_gen.pp \
 		$(wildcard $(topsrcdir)/other-licenses/ply/ply/*.pyc) \
 		$(NULL)
 
 DEFINES += -D_IMPL_NS_LAYOUT
--- a/js/xpconnect/src/dictionary_helper_gen.conf
+++ b/js/xpconnect/src/dictionary_helper_gen.conf
@@ -1,34 +1,31 @@
 # 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/.
 
 # Dictionary interface name, interface file name
 dictionaries = [
      [ 'EventInit', 'nsIDOMEvent.idl' ],
-     [ 'CustomEventInit', 'nsIDOMCustomEvent.idl' ],
      [ 'PopStateEventInit', 'nsIDOMPopStateEvent.idl' ],
      [ 'HashChangeEventInit', 'nsIDOMHashChangeEvent.idl' ],
      [ 'PageTransitionEventInit', 'nsIDOMPageTransitionEvent.idl' ],
      [ 'CloseEventInit', 'nsIDOMCloseEvent.idl' ],
      [ 'UIEventInit', 'nsIDOMUIEvent.idl' ],
      [ 'MouseEventInit', 'nsIDOMMouseEvent.idl' ],
      [ 'IDBObjectStoreParameters', 'nsIIDBDatabase.idl' ],
      [ 'IDBIndexParameters', 'nsIIDBObjectStore.idl' ],
      [ 'StorageEventInit', 'nsIDOMStorageEvent.idl' ],
      [ 'BlobPropertyBag', 'nsIDOMFile.idl' ],
      [ 'MutationObserverInit', 'nsIDOMMutationObserver.idl' ],
      [ 'SettingsEventInit', 'nsIDOMSettingsManager.idl' ],
      [ 'ContactChangeEventInit', 'nsIDOMContactManager.idl' ],
      [ 'WifiConnectionInfoEventInit', 'nsIWifiEventInits.idl' ],
      [ 'WifiStatusChangeEventInit', 'nsIWifiEventInits.idl' ],
      [ 'GeoPositionOptions', 'nsIDOMGeoGeolocation.idl' ],
-     [ 'DeviceProximityEventInit', 'nsIDOMDeviceProximityEvent.idl' ],
-     [ 'UserProximityEventInit', 'nsIDOMUserProximityEvent.idl' ],
      [ 'DeviceLightEventInit', 'nsIDOMDeviceLightEvent.idl' ],
      [ 'MozApplicationEventInit', 'nsIDOMApplicationRegistry.idl' ],
      [ 'DOMFileMetadataParameters', 'nsIDOMLockedFile.idl' ],
      [ 'XMLHttpRequestParameters', 'nsIXMLHttpRequest.idl' ],
      [ 'DeviceStorageEnumerationParameters', 'nsIDOMDeviceStorage.idl' ]
    ]
 
 # include file names
--- a/js/xpconnect/src/dictionary_helper_gen.py
+++ b/js/xpconnect/src/dictionary_helper_gen.py
@@ -435,30 +435,40 @@ if __name__ == '__main__':
                  help="Quick stub C++ source output file", metavar="FILE")
     o.add_option('--header-output', type='string', default=None,
                  help="Quick stub header output file", metavar="FILE")
     o.add_option('--makedepend-output', type='string', default=None,
                  help="gnumake dependencies output file", metavar="FILE")
     o.add_option('--cachedir', dest='cachedir', default=None,
                  help="Directory in which to cache lex/parse tables.")
     (options, filenames) = o.parse_args()
-    if len(filenames) != 1:
-        o.error("Exactly one config filename is needed.")
+    if len(filenames) < 1:
+        o.error("At least one config filename is needed.")
     filename = filenames[0]
 
     if options.cachedir is not None:
         if not os.path.isdir(options.cachedir):
             os.mkdir(options.cachedir)
         sys.path.append(options.cachedir)
 
     # Instantiate the parser.
     p = xpidl.IDLParser(outputdir=options.cachedir)
 
     conf = readConfigFile(filename)
 
+    if (len(filenames) > 1):
+        eventconfig = {}
+        execfile(filenames[1], eventconfig)
+        simple_events = eventconfig.get('simple_events', [])
+        for e in simple_events:
+            eventdict = ("%sInit" % e)
+            eventidl = ("nsIDOM%s.idl" % e)
+            conf.dictionaries.append([eventdict, eventidl]);
+
+
     if options.header_output is not None:
         outfd = open(options.header_output, 'w')
         print_header_file(outfd, conf)
         outfd.close()
     if options.stub_output is not None:
         make_targets.append(options.stub_output)
         outfd = open(options.stub_output, 'w')
         print_cpp_file(outfd, conf)
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/src/event_impl_gen.conf
@@ -0,0 +1,24 @@
+# -*- Mode: 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/.
+
+# Name of the event which real interface should have nsIDOM-prefix,
+# and should be in nsIDOM<name>.idl file and which should have
+# <name>Init dictionary for the event constructor.
+simple_events = [
+    'DeviceProximityEvent',
+    'UserProximityEvent',
+    'CustomEvent'
+  ]
+
+# include file names
+special_includes = [
+    'DictionaryHelpers.h',
+    'nsContentUtils.h'
+  ]
+
+# name of the type to not include using #include "typename.h"
+exclude_automatic_type_include = [
+    'nsISupports'
+  ]
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/src/event_impl_gen.py
@@ -0,0 +1,371 @@
+#!/usr/bin/env python
+# header.py - Generate C++ header files from IDL.
+#
+# 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/.
+
+from codegen import *
+import sys, os.path, re, xpidl, itertools
+
+# --makedepend-output support.
+make_dependencies = []
+make_targets = []
+
+def strip_end(text, suffix):
+    if not text.endswith(suffix):
+        return text
+    return text[:-len(suffix)]
+
+# Copied from dombindingsgen.py
+def writeMakeDependOutput(filename):
+    print "Creating makedepend file", filename
+    f = open(filename, 'w')
+    try:
+        if len(make_targets) > 0:
+            f.write("%s:" % makeQuote(make_targets[0]))
+            for filename in make_dependencies:
+                f.write(' \\\n\t\t%s' % makeQuote(filename))
+            f.write('\n\n')
+            for filename in make_targets[1:]:
+                f.write('%s: %s\n' % (makeQuote(filename), makeQuote(make_targets[0])))
+    finally:
+        f.close()
+
+def findIDL(includePath, interfaceFileName):
+    for d in includePath:
+        # Not os.path.join: we need a forward slash even on Windows because
+        # this filename ends up in makedepend output.
+        path = d + '/' + interfaceFileName
+        if os.path.exists(path):
+            return path
+    raise BaseException("No IDL file found for interface %s "
+                        "in include path %r"
+                        % (interfaceFileName, includePath))
+
+def loadIDL(parser, includePath, filename):
+    idlFile = findIDL(includePath, filename)
+    if not idlFile in make_dependencies:
+        make_dependencies.append(idlFile)
+    idl = p.parse(open(idlFile).read(), idlFile)
+    idl.resolve(includePath, p)
+    return idl
+
+def loadEventIDL(parser, includePath, eventname):
+    eventidl = ("nsIDOM%s.idl" % eventname)
+    idlFile = findIDL(includePath, eventidl)
+    if not idlFile in make_dependencies:
+        make_dependencies.append(idlFile)
+    idl = p.parse(open(idlFile).read(), idlFile)
+    idl.resolve(includePath, p)
+    return idl
+
+class Configuration:
+    def __init__(self, filename):
+        config = {}
+        execfile(filename, config)
+        self.simple_events = config.get('simple_events', [])
+        self.special_includes = config.get('special_includes', [])
+        self.exclude_automatic_type_include = config.get('exclude_automatic_type_include', [])
+
+def readConfigFile(filename):
+    return Configuration(filename)
+
+def firstCap(str):
+    return str[0].upper() + str[1:]
+
+def attributeVariableTypeAndName(a):
+    if a.realtype.nativeType('in').endswith('*'):
+        l = ["nsCOMPtr<%s> %s" % (a.realtype.nativeType('in').strip('* '),
+                   a.name)]
+    elif a.realtype.nativeType('in').count("nsAString"):
+        l = ["nsAutoString %s" % a.name]
+    elif a.realtype.nativeType('in').count("JS::Value"):
+        l = ["JS::Value %s" % a.name]
+    else:
+        l = ["%s%s" % (a.realtype.nativeType('in'),
+                       a.name)]
+
+    return ", ".join(l)
+
+def print_header_file(fd, conf):
+    fd.write("#if defined MOZ_GENERATED_EVENT_LIST\n")
+    for e in conf.simple_events:
+        fd.write("MOZ_GENERATED_EVENT(%s)\n" % e);
+    fd.write("#undef MOZ_GENERATED_EVENT\n");
+    fd.write("\n#elif defined MOZ_GENERATED_EVENTS_INCLUDES\n")
+    for e in conf.simple_events:
+        fd.write("#include \"nsIDOM%s.h\"\n" % e)
+    fd.write("#else\n")
+    fd.write("#ifndef _gen_mozilla_generated_events_h_\n"
+             "#define _gen_mozilla_generated_events_h_\n\n")
+    fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n")
+    fd.write("#include \"nscore.h\"\n")
+    fd.write("class nsEvent;\n")
+    fd.write("class nsIDOMEvent;\n")
+    fd.write("class nsPresContext;\n\n")
+    for e in conf.simple_events:
+        fd.write("nsresult\n")
+        fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, nsPresContext* aPresContext, nsEvent* aEvent);\n" % e)
+ 
+    fd.write("\n#endif\n")
+    fd.write("#endif\n")
+
+def collect_names_and_non_primitive_attribute_types(idl, attrnames, forwards):
+    for p in idl.productions:
+        if p.kind == 'interface' or p.kind == 'dictionary':
+            interfaces = []
+            base = p.base
+            baseiface = p
+            while base is not None:
+                baseiface = baseiface.idl.getName(baseiface.base, baseiface.location)    
+                interfaces.append(baseiface)
+                base = baseiface.base
+
+            interfaces.reverse()
+            interfaces.append(p)
+
+            for iface in interfaces:
+                collect_names_and_non_primitive_attribute_types_from_interface(iface, attrnames, forwards)
+
+def collect_names_and_non_primitive_attribute_types_from_interface(iface, attrnames, forwards):
+    for member in iface.members:
+        if isinstance(member, xpidl.Attribute):
+            if not member.name in attrnames:
+                attrnames.append(member.name)
+            if member.realtype.nativeType('in').endswith('*'):
+                t = member.realtype.nativeType('in').strip('* ')
+                if not t in forwards:
+                    forwards.append(t)
+
+def print_cpp(idl, fd, conf, eventname):
+    for p in idl.productions:
+        if p.kind == 'interface':
+            write_cpp(eventname, p, fd)
+
+def print_cpp_file(fd, conf):
+    fd.write("/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */\n\n")
+    fd.write('#include "GeneratedEvents.h"\n')
+    fd.write('#include "nsDOMClassInfoID.h"\n')
+    fd.write('#include "nsPresContext.h"\n')
+    fd.write('#include "nsGUIEvent.h"\n')
+    fd.write('#include "nsDOMEvent.h"\n');
+
+    includes = []
+    for s in conf.special_includes:
+        if not s in includes:
+            includes.append(strip_end(s, ".h"))
+    
+    for e in conf.simple_events:
+        if not e in includes:
+            includes.append(("nsIDOM%s" % e))
+
+    attrnames = []
+    for e in conf.simple_events:
+        idl = loadEventIDL(p, options.incdirs, e)
+        collect_names_and_non_primitive_attribute_types(idl, attrnames, includes)
+    
+    for c in includes:
+      if not c in conf.exclude_automatic_type_include:
+            fd.write("#include \"%s.h\"\n" % c)
+
+    for e in conf.simple_events:
+        idlname = ("nsIDOM%s.idl" % e)
+        idl = p.parse(open(findIDL(options.incdirs, idlname)).read(), idlname)
+        idl.resolve(options.incdirs, p)
+        print_cpp(idl, fd, conf, e)
+
+def init_value(attribute):
+    realtype = attribute.realtype.nativeType('in')
+    realtype = realtype.strip(' ')
+    if realtype.endswith('*'):
+        return "nsnull"
+    if realtype == "bool":
+        return "false"
+    if realtype.count("nsAString"):
+        return ""
+    if realtype.count("nsACString"):
+        return ""
+    if realtype.count("JS::Value"):
+      raise BaseException("JS::Value not supported in simple events!")
+    return "0"
+
+def attributeVariableTypeAndName(a):
+    if a.realtype.nativeType('in').endswith('*'):
+        l = ["nsCOMPtr<%s> m%s;" % (a.realtype.nativeType('in').strip('* '),
+                   firstCap(a.name))]
+    elif a.realtype.nativeType('in').count("nsAString"):
+        l = ["nsString m%s;" % firstCap(a.name)]
+    elif a.realtype.nativeType('in').count("nsACString"):
+        l = ["nsCString m%s;" % firstCap(a.name)]
+    else:
+        l = ["%sm%s;" % (a.realtype.nativeType('in'),
+                       firstCap(a.name))]
+    return ", ".join(l)
+
+def writeAttributeGetter(fd, classname, a):
+    fd.write("NS_IMETHODIMP\n")
+    fd.write("%s::Get%s(" % (classname, firstCap(a.name)))
+    if a.realtype.nativeType('in').endswith('*'):
+        fd.write("%s** a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name)))
+    elif a.realtype.nativeType('in').count("nsAString"):
+        fd.write("nsAString& a%s" % firstCap(a.name))
+    elif a.realtype.nativeType('in').count("nsACString"):
+        fd.write("nsACString& a%s" % firstCap(a.name))
+    else:
+        fd.write("%s*a%s" % (a.realtype.nativeType('in'), firstCap(a.name)))
+    fd.write(")\n");
+    fd.write("{\n");
+    if a.realtype.nativeType('in').endswith('*'):
+        fd.write("  NS_IF_ADDREF(*a%s = m%s);\n" % (firstCap(a.name), firstCap(a.name)))
+    elif a.realtype.nativeType('in').count("nsAString"):
+        fd.write("  a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
+    elif a.realtype.nativeType('in').count("nsACString"):
+        fd.write("  a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
+    else:
+        fd.write("  *a%s = m%s;\n" % (firstCap(a.name), firstCap(a.name)))
+    fd.write("  return NS_OK;\n");
+    fd.write("}\n\n");
+
+def writeAttributeParams(fd, a):
+    if a.realtype.nativeType('in').endswith('*'):
+        fd.write(", %s* a%s" % (a.realtype.nativeType('in').strip('* '), firstCap(a.name)))
+    elif a.realtype.nativeType('in').count("nsAString"):
+        fd.write(", const nsAString& a%s" % firstCap(a.name))
+    elif a.realtype.nativeType('in').count("nsACString"):
+        fd.write(", const nsACString& a%s" % firstCap(a.name))
+    else:
+        fd.write(", %s a%s" % (a.realtype.nativeType('in'), firstCap(a.name)))
+
+def write_cpp(eventname, iface, fd):
+    classname = ("nsDOM%s" % eventname)
+    attributes = []
+    ccattributes = []
+    for member in iface.members:
+        if isinstance(member, xpidl.Attribute):
+            attributes.append(member)
+            if (member.realtype.nativeType('in').endswith('*')):
+                ccattributes.append(member);
+
+    fd.write("\nclass %s : public nsDOMEvent, public %s\n" % (classname, iface.name))
+    fd.write("{\n")
+    fd.write("public:\n")
+    fd.write("  %s(nsPresContext* aPresContext, nsEvent* aEvent)\n" % classname)
+    fd.write("  : nsDOMEvent(aPresContext, aEvent)")
+    for a in attributes:
+        fd.write(",\n    m%s(%s)" % (firstCap(a.name), init_value(a)))
+    fd.write("\n  {}\n")
+    fd.write("  virtual ~%s() {}\n\n" % classname)
+    fd.write("  NS_DECL_ISUPPORTS_INHERITED\n")
+    if len(ccattributes) > 0:
+        fd.write("  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(%s, nsDOMEvent)\n" % classname)
+    fd.write("  NS_FORWARD_TO_NSDOMEVENT\n")
+    fd.write("  NS_DECL_%s\n" % iface.name.upper())
+    fd.write("  virtual nsresult InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal);\n")
+    fd.write("protected:\n")
+    for a in attributes:
+        fd.write("  %s\n" % attributeVariableTypeAndName(a))
+    fd.write("};\n\n")
+
+    if len(ccattributes) > 0:
+        fd.write("NS_IMPL_CYCLE_COLLECTION_CLASS(%s)\n\n" % classname)
+        fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(%s, nsDOMEvent)\n" % classname)
+        for c in ccattributes:
+            fd.write("  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(m%s)\n" % firstCap(a.name))
+        fd.write("NS_IMPL_CYCLE_COLLECTION_UNLINK_END\n\n");
+        fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(%s, nsDOMEvent)\n" % classname)
+        for c in ccattributes:
+            fd.write("  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(m%s)\n" % firstCap(a.name))
+        fd.write("NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END\n\n");
+
+    fd.write("NS_IMPL_ADDREF_INHERITED(%s, nsDOMEvent)\n" % classname)
+    fd.write("NS_IMPL_RELEASE_INHERITED(%s, nsDOMEvent)\n\n" % classname)
+
+    fd.write("DOMCI_DATA(%s, %s)\n\n" % (eventname, classname))
+
+    if len(ccattributes) > 0:
+        fd.write("NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(%s)\n" % classname)
+    else:
+        fd.write("NS_INTERFACE_MAP_BEGIN(%s)\n" % classname)
+
+    fd.write("  NS_INTERFACE_MAP_ENTRY(nsIDOM%s)\n" % eventname)
+    fd.write("  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(%s)\n" % eventname)
+    fd.write("NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)\n\n")
+
+
+    fd.write("nsresult\n")
+    fd.write("%s::InitFromCtor(const nsAString& aType, JSContext* aCx, jsval* aVal)\n" % classname)
+    fd.write("{\n");
+    fd.write("  mozilla::dom::%sInit d;\n" % eventname)
+    fd.write("  nsresult rv = d.Init(aCx, aVal);\n")
+    fd.write("  NS_ENSURE_SUCCESS(rv, rv);\n")
+    fd.write("  return Init%s(aType, d.bubbles, d.cancelable" % eventname)
+    for a in attributes:
+        fd.write(", d.%s" % a.name)
+    fd.write(");\n")
+    fd.write("}\n\n")
+
+    fd.write("NS_IMETHODIMP\n")
+    fd.write("%s::Init%s(" % (classname, eventname))
+    fd.write("const nsAString& aType, bool aCanBubble, bool aCancelable")
+    for a in attributes:
+        writeAttributeParams(fd, a)
+    fd.write(")\n{\n")
+    fd.write("  nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);\n")
+    fd.write("  NS_ENSURE_SUCCESS(rv, rv);\n")
+    for a in attributes:
+        fd.write("  m%s = a%s;\n" % (firstCap(a.name), firstCap(a.name)))
+    fd.write("  return NS_OK;\n")
+    fd.write("}\n\n")
+
+    for a in attributes:
+        writeAttributeGetter(fd, classname, a)
+
+    fd.write("nsresult\n")
+    fd.write("NS_NewDOM%s(nsIDOMEvent** aInstance, nsPresContext* aPresContext, nsEvent* aEvent)\n" % eventname)
+    fd.write("{\n")
+    fd.write("  %s* it = new %s(aPresContext, aEvent);\n" % (classname, classname))
+    fd.write("  return CallQueryInterface(it, aInstance);\n")
+    fd.write("}\n\n")
+
+if __name__ == '__main__':
+    from optparse import OptionParser
+    o = OptionParser(usage="usage: %prog [options] configfile")
+    o.add_option('-I', action='append', dest='incdirs', default=['.'],
+                 help="Directory to search for imported files")
+    o.add_option('-o', "--stub-output",
+                 type='string', dest='stub_output', default=None,
+                 help="Quick stub C++ source output file", metavar="FILE")
+    o.add_option('--header-output', type='string', default=None,
+                 help="Quick stub header output file", metavar="FILE")
+    o.add_option('--makedepend-output', type='string', default=None,
+                 help="gnumake dependencies output file", metavar="FILE")
+    o.add_option('--cachedir', dest='cachedir', default=None,
+                 help="Directory in which to cache lex/parse tables.")
+    (options, filenames) = o.parse_args()
+    if len(filenames) != 1:
+        o.error("Exactly one config filename is needed.")
+    filename = filenames[0]
+
+    if options.cachedir is not None:
+        if not os.path.isdir(options.cachedir):
+            os.mkdir(options.cachedir)
+        sys.path.append(options.cachedir)
+
+    # Instantiate the parser.
+    p = xpidl.IDLParser(outputdir=options.cachedir)
+
+    conf = readConfigFile(filename)
+
+    if options.header_output is not None:
+        outfd = open(options.header_output, 'w')
+        print_header_file(outfd, conf)
+        outfd.close()
+    if options.stub_output is not None:
+        make_targets.append(options.stub_output)
+        outfd = open(options.stub_output, 'w')
+        print_cpp_file(outfd, conf)
+        outfd.close()
+        if options.makedepend_output is not None:
+            writeMakeDependOutput(options.makedepend_output)
+
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -50,16 +50,17 @@
 static NS_DEFINE_CID(kFrameTraversalCID, NS_FRAMETRAVERSAL_CID);
 #include "nsTextFrame.h"
 
 #include "nsIDOMText.h"
 
 #include "nsContentUtils.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Preferences.h"
+#include "nsDOMClassInfoID.h"
 
 //included for desired x position;
 #include "nsPresContext.h"
 #include "nsIPresShell.h"
 #include "nsCaret.h"
 
 
 #include "nsITimer.h"
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -30,17 +30,17 @@
 #include "nsRuleNode.h"
 #include "nsUnicharUtils.h"
 #include "nsCSSPseudoElements.h"
 #include "nsIPrincipal.h"
 #include "nsComponentManagerUtils.h"
 #include "nsCSSPseudoClasses.h"
 #include "nsCSSAnonBoxes.h"
 #include "nsTArray.h"
-
+#include "nsDOMClassInfoID.h"
 #include "nsContentUtils.h"
 #include "nsContentErrors.h"
 #include "mozAutoDocUpdate.h"
 
 #include "prlog.h"
 
 namespace css = mozilla::css;
 
--- a/layout/style/nsCSSRules.cpp
+++ b/layout/style/nsCSSRules.cpp
@@ -29,16 +29,17 @@
 
 #include "nsContentUtils.h"
 #include "nsStyleConsts.h"
 #include "nsDOMError.h"
 #include "nsStyleUtil.h"
 #include "mozilla/css/Declaration.h"
 #include "nsCSSParser.h"
 #include "nsPrintfCString.h"
+#include "nsDOMClassInfoID.h"
 
 namespace css = mozilla::css;
 
 #define IMPL_STYLE_RULE_INHERIT_GET_DOM_RULE_WEAK(class_, super_) \
 /* virtual */ nsIDOMCSSRule* class_::GetDOMRule() \
   { return this; }
 #define IMPL_STYLE_RULE_INHERIT_MAP_RULE_INFO_INTO(class_, super_) \
 /* virtual */ void class_::MapRuleInfoInto(nsRuleData* aRuleData) \
--- a/layout/style/nsCSSStyleSheet.cpp
+++ b/layout/style/nsCSSStyleSheet.cpp
@@ -32,16 +32,17 @@
 #include "nsXMLNameSpaceMap.h"
 #include "nsCOMPtr.h"
 #include "nsContentUtils.h"
 #include "nsIScriptSecurityManager.h"
 #include "mozAutoDocUpdate.h"
 #include "mozilla/css/Declaration.h"
 #include "nsRuleNode.h"
 #include "nsMediaFeatures.h"
+#include "nsDOMClassInfoID.h"
 
 namespace css = mozilla::css;
 
 // -------------------------------
 // Style Rule List for the DOM
 //
 class CSSRuleListImpl : public nsICSSRuleList
 {
--- a/layout/style/nsDOMCSSDeclaration.cpp
+++ b/layout/style/nsDOMCSSDeclaration.cpp
@@ -13,17 +13,17 @@
 #include "nsIStyleRule.h"
 #include "mozilla/css/Rule.h"
 #include "mozilla/css/Declaration.h"
 #include "nsCSSProps.h"
 #include "nsCOMPtr.h"
 #include "nsIURL.h"
 #include "nsReadableUtils.h"
 #include "nsIPrincipal.h"
-
+#include "nsDOMClassInfoID.h"
 #include "mozAutoDocUpdate.h"
 
 namespace css = mozilla::css;
 
 nsDOMCSSDeclaration::~nsDOMCSSDeclaration()
 {
 }
 
--- a/layout/style/nsDOMCSSRGBColor.cpp
+++ b/layout/style/nsDOMCSSRGBColor.cpp
@@ -5,16 +5,17 @@
 
 /* DOM object representing color values in DOM computed style */
 
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsDOMCSSRGBColor.h"
 #include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMCSSRGBColor::nsDOMCSSRGBColor(nsIDOMCSSPrimitiveValue* aRed,
                                    nsIDOMCSSPrimitiveValue* aGreen,
                                    nsIDOMCSSPrimitiveValue* aBlue,
                                    nsIDOMCSSPrimitiveValue* aAlpha,
                                    bool aHasAlpha)
   : mRed(aRed), mGreen(aGreen), mBlue(aBlue), mAlpha(aAlpha)
   , mHasAlpha(aHasAlpha)
--- a/layout/style/nsDOMCSSRect.cpp
+++ b/layout/style/nsDOMCSSRect.cpp
@@ -5,16 +5,17 @@
 
 /* DOM object representing rectangle values in DOM computed style */
 
 #include "nsISupports.h"
 #include "nsCOMPtr.h"
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsDOMCSSRect.h"
 #include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMCSSRect::nsDOMCSSRect(nsIDOMCSSPrimitiveValue* aTop,
                            nsIDOMCSSPrimitiveValue* aRight,
                            nsIDOMCSSPrimitiveValue* aBottom,
                            nsIDOMCSSPrimitiveValue* aLeft)
   : mTop(aTop), mRight(aRight), mBottom(aBottom), mLeft(aLeft)
 {
 }
--- a/layout/style/nsDOMCSSValueList.cpp
+++ b/layout/style/nsDOMCSSValueList.cpp
@@ -4,16 +4,17 @@
 
 /* DOM object representing lists of values in DOM computed style */
 
 #include "nsDOMCSSValueList.h"
 #include "nsCOMPtr.h"
 #include "nsDOMError.h"
 #include "prtypes.h"
 #include "nsContentUtils.h"
+#include "nsDOMClassInfoID.h"
 
 nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
   : mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
 {
 }
 
 nsDOMCSSValueList::~nsDOMCSSValueList()
 {