Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug draft
authorTim Nguyen <ntim.bugs@gmail.com>
Fri, 23 Dec 2016 13:48:55 +0100
changeset 453432 2faeafb8d7f2b19484cc90c7f88f574eabb2ee77
parent 453431 20976971ceb8e58a3751c021b024ebf7d0bb4570
child 453433 2098f5b8b0eca14941ab5e9f8baeefebe25421c0
push id39672
push userbmo:ntim.bugs@gmail.com
push dateFri, 23 Dec 2016 12:49:39 +0000
reviewerssmaug
bugs1322938
milestone53.0a1
Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug MozReview-Commit-ID: C7VcslI0ts6
dom/events/EventNameList.h
dom/html/HTMLDialogElement.cpp
dom/html/HTMLDialogElement.h
dom/webidl/EventHandler.webidl
widget/EventMessageList.h
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -167,16 +167,20 @@ EVENT(change,
 EVENT(auxclick,
       eMouseAuxClick,
       EventNameType_All,
       eMouseEventClass)
 EVENT(click,
       eMouseClick,
       EventNameType_All,
       eMouseEventClass)
+EVENT(close,
+      eClose,
+      EventNameType_HTML,
+      eBasicEventClass)
 EVENT(contextmenu,
       eContextMenu,
       EventNameType_HTMLXUL,
       eMouseEventClass)
 NON_IDL_EVENT(mouselongtap,
       eMouseLongTap,
       EventNameType_HTMLXUL,
       eMouseEventClass)
@@ -1085,9 +1089,8 @@ NON_IDL_EVENT(complete,
 
 #ifdef MESSAGE_TO_EVENT
 #undef EVENT
 #undef WINDOW_ONLY_EVENT
 #undef TOUCH_EVENT
 #undef DOCUMENT_ONLY_EVENT
 #undef NON_IDL_EVENT
 #endif /* MESSAGE_TO_EVENT */
-
--- a/dom/html/HTMLDialogElement.cpp
+++ b/dom/html/HTMLDialogElement.cpp
@@ -25,16 +25,19 @@ HTMLDialogElement::Close(const mozilla::
     return;
   }
   if (aReturnValue.WasPassed()) {
     SetReturnValue(aReturnValue.Value());
   }
   ErrorResult ignored;
   SetOpen(false, ignored);
   ignored.SuppressException();
+  RefPtr<AsyncEventDispatcher> eventDispatcher =
+    new AsyncEventDispatcher(this, NS_LITERAL_STRING("close"), false);
+  eventDispatcher->PostDOMEvent();
 }
 
 void
 HTMLDialogElement::Show()
 {
   if (Open()) {
     return;
   }
--- a/dom/html/HTMLDialogElement.h
+++ b/dom/html/HTMLDialogElement.h
@@ -2,16 +2,17 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HTMLDialogElement_h
 #define HTMLDialogElement_h
 
+#include "mozilla/AsyncEventDispatcher.h"
 #include "mozilla/Attributes.h"
 #include "nsGenericHTMLElement.h"
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLDialogElement final : public nsGenericHTMLElement
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -33,17 +33,17 @@ interface GlobalEventHandlers {
 //         attribute OnErrorEventHandler onerror;
            attribute EventHandler onfocus;
            //(Not implemented)attribute EventHandler oncancel;
            attribute EventHandler onauxclick;
            attribute EventHandler oncanplay;
            attribute EventHandler oncanplaythrough;
            attribute EventHandler onchange;
            attribute EventHandler onclick;
-           //(Not implemented)attribute EventHandler onclose;
+           attribute EventHandler onclose;
            attribute EventHandler oncontextmenu;
            //(Not implemented)attribute EventHandler oncuechange;
            attribute EventHandler ondblclick;
            attribute EventHandler ondrag;
            attribute EventHandler ondragend;
            attribute EventHandler ondragenter;
            attribute EventHandler ondragexit;
            attribute EventHandler ondragleave;
--- a/widget/EventMessageList.h
+++ b/widget/EventMessageList.h
@@ -437,12 +437,15 @@ NS_EVENT_MESSAGE(eEditorInput)
 
 // selection events
 NS_EVENT_MESSAGE(eSelectStart)
 NS_EVENT_MESSAGE(eSelectionChange)
 
 // Details element events.
 NS_EVENT_MESSAGE(eToggle)
 
+// Dialog element events.
+NS_EVENT_MESSAGE(eClose)
+
 #ifdef UNDEF_NS_EVENT_MESSAGE_FIRST_LAST
 #undef UNDEF_NS_EVENT_MESSAGE_FIRST_LAST
 #undef NS_EVENT_MESSAGE_FIRST_LAST
 #endif