Bug 1322938 - Emit close event when HTMLDialogElement.prototype.close() is called. r=smaug
MozReview-Commit-ID: C7VcslI0ts6
--- 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