mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-08-24 05:13:07 +09:00
Issue #2472 - Part 6: Fire cancel event and close modal <dialog> on [ESC]
This implementation is different than Mozilla, not indirectly queueing cancel tasks to be arbitrarily ordered, but rather synchronously close in reverse top layer order.
This commit is contained in:
parent
7d34b285e0
commit
87a7cf7332
6 changed files with 49 additions and 0 deletions
|
|
@ -111,6 +111,27 @@ HTMLDialogElement::ShowModal(ErrorResult& aError)
|
|||
aError.SuppressException();
|
||||
}
|
||||
|
||||
void HTMLDialogElement::CancelDialog() {
|
||||
// 1) Let close be the result of firing an event named cancel at dialog, with
|
||||
// the cancelable attribute initialized to true.
|
||||
bool defaultAction = true;
|
||||
nsContentUtils::DispatchTrustedEvent(
|
||||
OwnerDoc(),
|
||||
static_cast<nsIContent*>(this),
|
||||
NS_LITERAL_STRING("cancel"),
|
||||
false, /* can bubble */
|
||||
true, /* can cancel */
|
||||
&defaultAction);
|
||||
|
||||
// 2) If close is true and dialog has an open attribute, then close the dialog
|
||||
// with no return value.
|
||||
if (defaultAction) {
|
||||
Optional<nsAString> retValue;
|
||||
Close(retValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
JSObject*
|
||||
HTMLDialogElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue