Source/WebCore/ChangeLog

 12021-07-19 Tim Nguyen <ntim@apple.com>
 2
 3 Port <dialog> close event to modern event handling code
 4 https://bugs.webkit.org/show_bug.cgi?id=227915
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * html/HTMLDialogElement.cpp:
 9 (WebCore::HTMLDialogElement::HTMLDialogElement):
 10 (WebCore::HTMLDialogElement::create):
 11 (WebCore::HTMLDialogElement::close):
 12 (WebCore::dialogCloseEventSender): Deleted.
 13 (WebCore::HTMLDialogElement::~HTMLDialogElement): Deleted.
 14 (WebCore::HTMLDialogElement::dispatchPendingEvent): Deleted.
 15 * html/HTMLDialogElement.h:
 16
1172021-07-17 Alan Bujtas <zalan@apple.com>
218
319 [LFC][IFC] Move InlineLevelBox class to its own file

Source/WebCore/html/HTMLDialogElement.cpp

2626#include "config.h"
2727#include "HTMLDialogElement.h"
2828#include "EventNames.h"
29 #include "EventSender.h"
3029
3130#include "HTMLNames.h"
3231#include <wtf/IsoMallocInlines.h>

@@WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLDialogElement);
3736
3837using namespace HTMLNames;
3938
40 static DialogEventSender& dialogCloseEventSender()
41 {
42  static NeverDestroyed<DialogEventSender> sharedCloseEventSender(eventNames().closeEvent);
43  return sharedCloseEventSender;
44 }
45 
4639HTMLDialogElement::HTMLDialogElement(const QualifiedName& tagName, Document& document)
4740 : HTMLElement(tagName, document)
 41 , ActiveDOMObject(document)
4842{
4943}
5044
51 HTMLDialogElement::~HTMLDialogElement()
 45Ref<HTMLDialogElement> HTMLDialogElement::create(const QualifiedName& tagName, Document& document)
5246{
53  dialogCloseEventSender().cancelEvent(*this);
 47 auto dialogElement = adoptRef(*new HTMLDialogElement(tagName, document));
 48 dialogElement->suspendIfNeeded();
 49 return dialogElement;
5450}
5551
5652void HTMLDialogElement::show()

@@void HTMLDialogElement::close(const String& result)
10197
10298 // FIXME: Add step 6 from spec. (webkit.org/b/227537)
10399
104  dialogCloseEventSender().cancelEvent(*this);
105  dialogCloseEventSender().dispatchEventSoon(*this);
106 }
107 
108 void HTMLDialogElement::dispatchPendingEvent(DialogEventSender* eventSender)
109 {
110  ASSERT_UNUSED(eventSender, eventSender == &dialogCloseEventSender());
111  dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
 100 queueTaskToDispatchEvent(*this, TaskSource::UserInteraction, Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
112101}
113102
114103}

Source/WebCore/html/HTMLDialogElement.h

2525
2626#pragma once
2727
 28#include "ActiveDOMObject.h"
2829#include "HTMLElement.h"
2930
3031namespace WebCore {
3132
32 template<typename T> class EventSender;
33 using DialogEventSender = EventSender<HTMLDialogElement>;
34 
35 class HTMLDialogElement final : public HTMLElement {
 33class HTMLDialogElement final : public HTMLElement, public ActiveDOMObject {
3634 WTF_MAKE_ISO_ALLOCATED(HTMLDialogElement);
3735public:
38  template<typename... Args> static Ref<HTMLDialogElement> create(Args&&... args) { return adoptRef(*new HTMLDialogElement(std::forward<Args>(args)...)); }
39  ~HTMLDialogElement();
 36 static Ref<HTMLDialogElement> create(const QualifiedName&, Document&);
4037
4138 bool isOpen() const { return hasAttribute(HTMLNames::openAttr); }
4239

@@public:
4744 ExceptionOr<void> showModal();
4845 void close(const String&);
4946
50  void dispatchPendingEvent(DialogEventSender*);
51 
5247 bool isModal() const { return m_isModal; };
5348
5449private:

@@private:
5651
5752 String m_returnValue;
5853 bool m_isModal { false };
 54
 55 const char* activeDOMObjectName() const final { return "HTMLMarqueeElement"; }
5956};
6057
6158} // namespace WebCore