Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug
☠☠ backed out by 6a9625f2382a ☠ ☠
authorTim Nguyen <ntim.bugs@gmail.com>
Fri, 23 Dec 2016 16:01:50 +0100
changeset 327288 b6bdaf0dd932
parent 327287 4b6ed4bb4263
child 327289 91c8b6d99e35
push id31122
push userphilringnalda@gmail.com
push dateSun, 25 Dec 2016 00:51:37 +0000
treeherdermozilla-central@1156db49e976 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1322938
milestone53.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 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
@@ -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