Skip to content
Permalink
Browse files
Port <dialog> close event to modern event handling code
https://bugs.webkit.org/show_bug.cgi?id=227915

Reviewed by Chris Dumez.

* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::close):
(WebCore::dialogCloseEventSender): Deleted.
(WebCore::HTMLDialogElement::~HTMLDialogElement): Deleted.
(WebCore::HTMLDialogElement::dispatchPendingEvent): Deleted.
* html/HTMLDialogElement.h:


Canonical link: https://commits.webkit.org/239784@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280049 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
nt1m committed Jul 19, 2021
1 parent dd768ca commit 468a7823edd2bf0804ff64bfd5526007fefa223a
Showing 3 changed files with 18 additions and 26 deletions.
@@ -1,3 +1,17 @@
2021-07-19 Tim Nguyen <ntim@apple.com>

Port <dialog> close event to modern event handling code
https://bugs.webkit.org/show_bug.cgi?id=227915

Reviewed by Chris Dumez.

* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::close):
(WebCore::dialogCloseEventSender): Deleted.
(WebCore::HTMLDialogElement::~HTMLDialogElement): Deleted.
(WebCore::HTMLDialogElement::dispatchPendingEvent): Deleted.
* html/HTMLDialogElement.h:

2021-07-19 Chris Dumez <cdumez@apple.com>

HTMLImageElement.decoding should reflect the decoding content attribute, limited to only known values
@@ -25,8 +25,8 @@

#include "config.h"
#include "HTMLDialogElement.h"
#include "EventLoop.h"
#include "EventNames.h"
#include "EventSender.h"

#include "HTMLNames.h"
#include <wtf/IsoMallocInlines.h>
@@ -37,22 +37,11 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLDialogElement);

using namespace HTMLNames;

static DialogEventSender& dialogCloseEventSender()
{
static NeverDestroyed<DialogEventSender> sharedCloseEventSender(eventNames().closeEvent);
return sharedCloseEventSender;
}

HTMLDialogElement::HTMLDialogElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
}

HTMLDialogElement::~HTMLDialogElement()
{
dialogCloseEventSender().cancelEvent(*this);
}

void HTMLDialogElement::show()
{
// If the element already has an open attribute, then return.
@@ -101,14 +90,9 @@ void HTMLDialogElement::close(const String& result)

// FIXME: Add step 6 from spec. (webkit.org/b/227537)

dialogCloseEventSender().cancelEvent(*this);
dialogCloseEventSender().dispatchEventSoon(*this);
}

void HTMLDialogElement::dispatchPendingEvent(DialogEventSender* eventSender)
{
ASSERT_UNUSED(eventSender, eventSender == &dialogCloseEventSender());
dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
document().eventLoop().queueTask(TaskSource::UserInteraction, [protectedThis = GCReachableRef { *this }] {
protectedThis->dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
});
}

}
@@ -29,14 +29,10 @@

namespace WebCore {

template<typename T> class EventSender;
using DialogEventSender = EventSender<HTMLDialogElement>;

class HTMLDialogElement final : public HTMLElement {
WTF_MAKE_ISO_ALLOCATED(HTMLDialogElement);
public:
template<typename... Args> static Ref<HTMLDialogElement> create(Args&&... args) { return adoptRef(*new HTMLDialogElement(std::forward<Args>(args)...)); }
~HTMLDialogElement();

bool isOpen() const { return hasAttribute(HTMLNames::openAttr); }

@@ -47,8 +43,6 @@ class HTMLDialogElement final : public HTMLElement {
ExceptionOr<void> showModal();
void close(const String&);

void dispatchPendingEvent(DialogEventSender*);

bool isModal() const { return m_isModal; };

private:

0 comments on commit 468a782

Please sign in to comment.