Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug
authorTim Nguyen <ntim.bugs@gmail.com>
Fri, 23 Dec 2016 16:01:50 +0100
changeset 455490 96351402aff967812e18ca35c1619375ef9b94de
parent 455489 73c4baa877dd55e8e591e95dd6ece01ccee0689f
child 455491 01002f848bdde42ea0b67e7d0e1b9bcef5e492cd
push id40256
push userbmo:ntim.bugs@gmail.com
push dateTue, 03 Jan 2017 22:40:23 +0000
reviewerssmaug
bugs1322938
milestone53.0a1
Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug MozReview-Commit-ID: 7OKlKFb3lok
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
@@ -438,12 +438,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