Bug 922160 - Bring EventHandler.webidl more in line with the spec, rename BeforeUnloadEventHandler to OnBeforeUnloadEventHandler. r=bz.
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 08 Oct 2013 17:51:15 +0200
changeset 165815 2c1f60140a95a92baff1471350c952824460b2b8
parent 165814 01b3315d12f5b94133f304b88c5bcb669e9c2944
child 165816 ab00f3093e18aa10b1f33bbf91ff21596633d0d1
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs922160
milestone27.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 922160 - Bring EventHandler.webidl more in line with the spec, rename BeforeUnloadEventHandler to OnBeforeUnloadEventHandler. r=bz.
content/events/src/nsEventListenerManager.cpp
content/events/src/nsEventListenerManager.h
content/html/content/src/HTMLBodyElement.cpp
content/html/content/src/HTMLBodyElement.h
content/html/content/src/HTMLFrameSetElement.cpp
content/html/content/src/HTMLFrameSetElement.h
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
dom/base/nsIJSEventListener.h
dom/src/events/nsJSEventListener.cpp
dom/webidl/EventHandler.webidl
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -903,18 +903,18 @@ nsEventListenerManager::CompileEventHand
     context->BindCompiledEventHandler(mTarget, scope, handler, &boundHandler);
     if (!boundHandler) {
       listener->ForgetHandler();
     } else if (listener->EventName() == nsGkAtoms::onerror && win) {
       nsRefPtr<OnErrorEventHandlerNonNull> handlerCallback =
         new OnErrorEventHandlerNonNull(boundHandler);
       listener->SetHandler(handlerCallback);
     } else if (listener->EventName() == nsGkAtoms::onbeforeunload && win) {
-      nsRefPtr<BeforeUnloadEventHandlerNonNull> handlerCallback =
-        new BeforeUnloadEventHandlerNonNull(boundHandler);
+      nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handlerCallback =
+        new OnBeforeUnloadEventHandlerNonNull(boundHandler);
       listener->SetHandler(handlerCallback);
     } else {
       nsRefPtr<EventHandlerNonNull> handlerCallback =
         new EventHandlerNonNull(boundHandler);
       listener->SetHandler(handlerCallback);
     }
   }
 
@@ -1250,17 +1250,17 @@ nsEventListenerManager::SetEventHandler(
   // handlers.
   SetEventHandlerInternal(nullptr, JS::NullPtr(), nsGkAtoms::onerror,
                           EmptyString(), nsEventHandler(aHandler),
                           !mIsMainThreadELM ||
                           !nsContentUtils::IsCallerChrome());
 }
 
 void
-nsEventListenerManager::SetEventHandler(BeforeUnloadEventHandlerNonNull* aHandler)
+nsEventListenerManager::SetEventHandler(OnBeforeUnloadEventHandlerNonNull* aHandler)
 {
   if (!aHandler) {
     RemoveEventHandler(nsGkAtoms::onbeforeunload, EmptyString());
     return;
   }
 
   // Untrusted events are always permitted for non-chrome script
   // handlers.
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -455,17 +455,17 @@ public:
   /**
    * Set the "inline" event listener for aEventName to aHandler.  If
    * aHandler is null, this will actually remove the event listener
    */
   void SetEventHandler(nsIAtom* aEventName,
                        const nsAString& aTypeString,
                        mozilla::dom::EventHandlerNonNull* aHandler);
   void SetEventHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler);
-  void SetEventHandler(mozilla::dom::BeforeUnloadEventHandlerNonNull* aHandler);
+  void SetEventHandler(mozilla::dom::OnBeforeUnloadEventHandlerNonNull* aHandler);
 
   /**
    * Get the value of the "inline" event listener for aEventName.
    * This may cause lazy compilation if the listener is uncompiled.
    *
    * Note: It's the caller's responsibility to make sure to call the right one
    * of these methods.  In particular, "onerror" events use
    * OnErrorEventHandlerNonNull for some event targets and EventHandlerNonNull
@@ -479,21 +479,21 @@ public:
     return handler ? handler->EventHandler() : nullptr;
   }
   mozilla::dom::OnErrorEventHandlerNonNull* GetOnErrorEventHandler()
   {
     const nsEventHandler* handler =
       GetEventHandlerInternal(nsGkAtoms::onerror, EmptyString());
     return handler ? handler->OnErrorEventHandler() : nullptr;
   }
-  mozilla::dom::BeforeUnloadEventHandlerNonNull* GetOnBeforeUnloadEventHandler()
+  mozilla::dom::OnBeforeUnloadEventHandlerNonNull* GetOnBeforeUnloadEventHandler()
   {
     const nsEventHandler* handler =
       GetEventHandlerInternal(nsGkAtoms::onbeforeunload, EmptyString());
-    return handler ? handler->BeforeUnloadEventHandler() : nullptr;
+    return handler ? handler->OnBeforeUnloadEventHandler() : nullptr;
   }
 
 protected:
   /**
    * Helper method for implementing the various Get*EventHandler above.  Will
    * return null if we don't have an event handler for this event name.
    */
   const nsEventHandler* GetEventHandlerInternal(nsIAtom* aEventName,
--- a/content/html/content/src/HTMLBodyElement.cpp
+++ b/content/html/content/src/HTMLBodyElement.cpp
@@ -534,17 +534,17 @@ HTMLBodyElement::IsEventAttributeName(ns
     nsCOMPtr<nsISupports> supports = do_QueryInterface(win);                   \
     nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports);        \
     return globalWin->SetOn##name_(handler);                                   \
   }                                                                            \
   FORWARDED_EVENT_HELPER(name_, HTMLBodyElement, type_, type_*)
 #define WINDOW_EVENT(name_, id_, type_, struct_)                               \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                         \
-  WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
+  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "nsEventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
 #undef WINDOW_EVENT
 #undef WINDOW_EVENT_HELPER
 #undef ERROR_EVENT
 #undef FORWARDED_EVENT
 #undef FORWARDED_EVENT_HELPER
 #undef EVENT
--- a/content/html/content/src/HTMLBodyElement.h
+++ b/content/html/content/src/HTMLBodyElement.h
@@ -8,17 +8,17 @@
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMHTMLBodyElement.h"
 #include "nsIStyleRule.h"
 
 namespace mozilla {
 namespace dom {
 
-class BeforeUnloadEventHandlerNonNull;
+class OnBeforeUnloadEventHandlerNonNull;
 class HTMLBodyElement;
 
 class BodyRule: public nsIStyleRule
 {
 public:
   BodyRule(HTMLBodyElement* aPart);
   virtual ~BodyRule();
 
@@ -59,17 +59,17 @@ public:
   NS_IMETHOD GetOn##name_(JSContext *cx, JS::Value *vp);                \
   NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
 #define WINDOW_EVENT_HELPER(name_, type_)                               \
   type_* GetOn##name_();                                                \
   void SetOn##name_(type_* handler);
 #define WINDOW_EVENT(name_, id_, type_, struct_)                        \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                  \
-  WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
+  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "nsEventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
 #undef WINDOW_EVENT
 #undef WINDOW_EVENT_HELPER
 #undef FORWARDED_EVENT
 #undef EVENT
 
   void GetText(nsString& aText)
--- a/content/html/content/src/HTMLFrameSetElement.cpp
+++ b/content/html/content/src/HTMLFrameSetElement.cpp
@@ -393,17 +393,17 @@ HTMLFrameSetElement::IsEventAttributeNam
     nsCOMPtr<nsISupports> supports = do_QueryInterface(win);                   \
     nsGlobalWindow* globalWin = nsGlobalWindow::FromSupports(supports);        \
     return globalWin->SetOn##name_(handler);                                   \
   }                                                                            \
   FORWARDED_EVENT_HELPER(name_, HTMLFrameSetElement, type_, type_*)
 #define WINDOW_EVENT(name_, id_, type_, struct_)                               \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                         \
-  WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
+  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "nsEventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
 #undef WINDOW_EVENT
 #undef WINDOW_EVENT_HELPER
 #undef ERROR_EVENT
 #undef FORWARDED_EVENT
 #undef FORWARDED_EVENT_HELPER
 #undef EVENT
--- a/content/html/content/src/HTMLFrameSetElement.h
+++ b/content/html/content/src/HTMLFrameSetElement.h
@@ -35,17 +35,17 @@ struct nsFramesetSpec {
  */
 #define NS_MAX_FRAMESET_SPEC_COUNT 16000
 
 //----------------------------------------------------------------------
 
 namespace mozilla {
 namespace dom {
 
-class BeforeUnloadEventHandlerNonNull;
+class OnBeforeUnloadEventHandlerNonNull;
 
 class HTMLFrameSetElement MOZ_FINAL : public nsGenericHTMLElement,
                                       public nsIDOMHTMLFrameSetElement
 {
 public:
   HTMLFrameSetElement(already_AddRefed<nsINodeInfo> aNodeInfo)
     : nsGenericHTMLElement(aNodeInfo),
       mNumRows(0),
@@ -89,17 +89,17 @@ public:
   NS_IMETHOD GetOn##name_(JSContext *cx, JS::Value *vp);                \
   NS_IMETHOD SetOn##name_(JSContext *cx, const JS::Value &v);
 #define WINDOW_EVENT_HELPER(name_, type_)                               \
   type_* GetOn##name_();                                                \
   void SetOn##name_(type_* handler);
 #define WINDOW_EVENT(name_, id_, type_, struct_)                        \
   WINDOW_EVENT_HELPER(name_, EventHandlerNonNull)
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                  \
-  WINDOW_EVENT_HELPER(name_, BeforeUnloadEventHandlerNonNull)
+  WINDOW_EVENT_HELPER(name_, OnBeforeUnloadEventHandlerNonNull)
 #include "nsEventNameList.h" // IWYU pragma: keep
 #undef BEFOREUNLOAD_EVENT
 #undef WINDOW_EVENT
 #undef WINDOW_EVENT_HELPER
 #undef FORWARDED_EVENT
 #undef EVENT
 
   // These override the SetAttr methods in nsGenericHTMLElement (need
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -12117,38 +12117,38 @@ nsGlobalWindow::DisableNetworkEvent(uint
     elm->SetEventHandler(handler);                                           \
     return NS_OK;                                                            \
   }
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                       \
   NS_IMETHODIMP nsGlobalWindow::GetOn##name_(JSContext *cx,                  \
                                              JS::Value *vp) {                \
     nsEventListenerManager *elm = GetExistingListenerManager();              \
     if (elm) {                                                               \
-      BeforeUnloadEventHandlerNonNull* h =                                   \
+      OnBeforeUnloadEventHandlerNonNull* h =                                 \
         elm->GetOnBeforeUnloadEventHandler();                                \
       if (h) {                                                               \
         *vp = JS::ObjectValue(*h->Callable());                               \
         return NS_OK;                                                        \
       }                                                                      \
     }                                                                        \
     *vp = JSVAL_NULL;                                                        \
     return NS_OK;                                                            \
   }                                                                          \
   NS_IMETHODIMP nsGlobalWindow::SetOn##name_(JSContext *cx,                  \
                                              const JS::Value &v) {           \
     nsEventListenerManager *elm = GetOrCreateListenerManager();              \
     if (!elm) {                                                              \
       return NS_ERROR_OUT_OF_MEMORY;                                         \
     }                                                                        \
                                                                              \
-    nsRefPtr<BeforeUnloadEventHandlerNonNull> handler;                       \
+    nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handler;                     \
     JSObject *callable;                                                      \
     if (v.isObject() &&                                                      \
         JS_ObjectIsCallable(cx, callable = &v.toObject())) {                 \
-      handler = new BeforeUnloadEventHandlerNonNull(callable);               \
+      handler = new OnBeforeUnloadEventHandlerNonNull(callable);             \
     }                                                                        \
     elm->SetEventHandler(handler);                                           \
     return NS_OK;                                                            \
   }
 #define WINDOW_ONLY_EVENT EVENT
 #define TOUCH_EVENT EVENT
 #include "nsEventNameList.h"
 #undef TOUCH_EVENT
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -735,22 +735,22 @@ public:
   void SetOn##name_(mozilla::dom::OnErrorEventHandlerNonNull* handler)        \
   {                                                                           \
     nsEventListenerManager *elm = GetOrCreateListenerManager();               \
     if (elm) {                                                                \
       elm->SetEventHandler(handler);                                          \
     }                                                                         \
   }
 #define BEFOREUNLOAD_EVENT(name_, id_, type_, struct_)                        \
-  mozilla::dom::BeforeUnloadEventHandlerNonNull* GetOn##name_()               \
+  mozilla::dom::OnBeforeUnloadEventHandlerNonNull* GetOn##name_()             \
   {                                                                           \
     nsEventListenerManager *elm = GetExistingListenerManager();               \
     return elm ? elm->GetOnBeforeUnloadEventHandler() : nullptr;              \
   }                                                                           \
-  void SetOn##name_(mozilla::dom::BeforeUnloadEventHandlerNonNull* handler)   \
+  void SetOn##name_(mozilla::dom::OnBeforeUnloadEventHandlerNonNull* handler) \
   {                                                                           \
     nsEventListenerManager *elm = GetOrCreateListenerManager();               \
     if (elm) {                                                                \
       elm->SetEventHandler(handler);                                          \
     }                                                                         \
   }
 #define WINDOW_ONLY_EVENT EVENT
 #define TOUCH_EVENT EVENT
--- a/dom/base/nsIJSEventListener.h
+++ b/dom/base/nsIJSEventListener.h
@@ -16,18 +16,18 @@
 #define NS_IJSEVENTLISTENER_IID \
 { 0x92f9212b, 0xa6aa, 0x4867, \
   { 0x93, 0x8a, 0x56, 0xbe, 0x17, 0x67, 0x4f, 0xd4 } }
 
 class nsEventHandler
 {
 public:
   typedef mozilla::dom::EventHandlerNonNull EventHandlerNonNull;
-  typedef mozilla::dom::BeforeUnloadEventHandlerNonNull
-    BeforeUnloadEventHandlerNonNull;
+  typedef mozilla::dom::OnBeforeUnloadEventHandlerNonNull
+    OnBeforeUnloadEventHandlerNonNull;
   typedef mozilla::dom::OnErrorEventHandlerNonNull OnErrorEventHandlerNonNull;
   typedef mozilla::dom::CallbackFunction CallbackFunction;
 
   enum HandlerType {
     eUnset = 0,
     eNormal = 0x1,
     eOnError = 0x2,
     eOnBeforeUnload = 0x3,
@@ -43,17 +43,17 @@ public:
     Assign(aHandler, eNormal);
   }
 
   nsEventHandler(OnErrorEventHandlerNonNull* aHandler)
   {
     Assign(aHandler, eOnError);
   }
 
-  nsEventHandler(BeforeUnloadEventHandlerNonNull* aHandler)
+  nsEventHandler(OnBeforeUnloadEventHandlerNonNull* aHandler)
   {
     Assign(aHandler, eOnBeforeUnload);
   }
 
   nsEventHandler(const nsEventHandler& aOther)
   {
     if (aOther.HasEventHandler()) {
       // Have to make sure we take our own ref
@@ -94,23 +94,23 @@ public:
   }
 
   void SetHandler(EventHandlerNonNull* aHandler)
   {
     ReleaseHandler();
     Assign(aHandler, eNormal);
   }
 
-  BeforeUnloadEventHandlerNonNull* BeforeUnloadEventHandler() const
+  OnBeforeUnloadEventHandlerNonNull* OnBeforeUnloadEventHandler() const
   {
     MOZ_ASSERT(Type() == eOnBeforeUnload);
-    return reinterpret_cast<BeforeUnloadEventHandlerNonNull*>(Ptr());
+    return reinterpret_cast<OnBeforeUnloadEventHandlerNonNull*>(Ptr());
   }
 
-  void SetHandler(BeforeUnloadEventHandlerNonNull* aHandler)
+  void SetHandler(OnBeforeUnloadEventHandlerNonNull* aHandler)
   {
     ReleaseHandler();
     Assign(aHandler, eOnBeforeUnload);
   }
 
   OnErrorEventHandlerNonNull* OnErrorEventHandler() const
   {
     MOZ_ASSERT(Type() == eOnError);
@@ -232,17 +232,17 @@ public:
     mHandler.SetHandler(aHandler);
     mContext = aContext;
     UpdateScopeObject(aScopeObject);
   }
   void SetHandler(mozilla::dom::EventHandlerNonNull* aHandler)
   {
     mHandler.SetHandler(aHandler);
   }
-  void SetHandler(mozilla::dom::BeforeUnloadEventHandlerNonNull* aHandler)
+  void SetHandler(mozilla::dom::OnBeforeUnloadEventHandlerNonNull* aHandler)
   {
     mHandler.SetHandler(aHandler);
   }
   void SetHandler(mozilla::dom::OnErrorEventHandlerNonNull* aHandler)
   {
     mHandler.SetHandler(aHandler);
   }
 
--- a/dom/src/events/nsJSEventListener.cpp
+++ b/dom/src/events/nsJSEventListener.cpp
@@ -204,18 +204,18 @@ nsJSEventListener::HandleEvent(nsIDOMEve
       aEvent->PreventDefault();
     }
     return NS_OK;
   }
 
   if (mHandler.Type() == nsEventHandler::eOnBeforeUnload) {
     MOZ_ASSERT(mEventName == nsGkAtoms::onbeforeunload);
 
-    nsRefPtr<BeforeUnloadEventHandlerNonNull> handler =
-      mHandler.BeforeUnloadEventHandler();
+    nsRefPtr<OnBeforeUnloadEventHandlerNonNull> handler =
+      mHandler.OnBeforeUnloadEventHandler();
     ErrorResult rv;
     nsString retval;
     handler->Call(mTarget, *(aEvent->InternalDOMEvent()), retval, rv);
     if (rv.Failed()) {
       return rv.ErrorCode();
     }
 
     nsCOMPtr<nsIDOMBeforeUnloadEvent> beforeUnload = do_QueryInterface(aEvent);
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -10,18 +10,18 @@
  * Opera Software ASA. You are granted a license to use, reproduce
  * and create derivative works of this document.
  */
 [TreatNonCallableAsNull]
 callback EventHandlerNonNull = any (Event event);
 typedef EventHandlerNonNull? EventHandler;
 
 [TreatNonCallableAsNull]
-callback BeforeUnloadEventHandlerNonNull = DOMString? (Event event);
-typedef BeforeUnloadEventHandlerNonNull? BeforeUnloadEventHandler;
+callback OnBeforeUnloadEventHandlerNonNull = DOMString? (Event event);
+typedef OnBeforeUnloadEventHandlerNonNull? OnBeforeUnloadEventHandler;
 
 [TreatNonCallableAsNull]
 callback OnErrorEventHandlerNonNull = boolean ((Event or DOMString) event, optional DOMString source, optional unsigned long lineno, optional unsigned long column);
 typedef OnErrorEventHandlerNonNull? OnErrorEventHandler;
 
 [NoInterfaceObject]
 interface GlobalEventHandlers {
            attribute EventHandler onabort;
@@ -98,17 +98,17 @@ interface NodeEventHandlers {
            attribute EventHandler onload;
            attribute EventHandler onscroll;
 };
 
 [NoInterfaceObject]
 interface WindowEventHandlers {
            attribute EventHandler onafterprint;
            attribute EventHandler onbeforeprint;
-           attribute BeforeUnloadEventHandler onbeforeunload;
+           attribute OnBeforeUnloadEventHandler onbeforeunload;
   //       For now, onerror comes from NodeEventHandlers
   //       When we convert Window to WebIDL this may need to change.
   //       [SetterThrows]
   //       attribute OnErrorEventHandler onerror;
            //(Not implemented)[SetterThrows]
            //(Not implemented)attribute EventHandler onfullscreenchange;
            //(Not implemented)[SetterThrows]
            //(Not implemented)attribute EventHandler onfullscreenerror;