Title: [281265] branches/safari-612.1.29-branch/Source/WebCore
Revision
281265
Author
repst...@apple.com
Date
2021-08-19 13:42:15 -0700 (Thu, 19 Aug 2021)

Log Message

Revert "Port HTMLDetailsElement to use modern event handling code"

This reverts commit r281230.

Modified Paths

Diff

Modified: branches/safari-612.1.29-branch/Source/WebCore/ChangeLog (281264 => 281265)


--- branches/safari-612.1.29-branch/Source/WebCore/ChangeLog	2021-08-19 20:36:11 UTC (rev 281264)
+++ branches/safari-612.1.29-branch/Source/WebCore/ChangeLog	2021-08-19 20:42:15 UTC (rev 281265)
@@ -20,23 +20,6 @@
 
 2021-08-19  Tim Nguyen  <n...@apple.com>
 
-        Port HTMLDetailsElement to use modern event handling code
-        https://bugs.webkit.org/show_bug.cgi?id=228863
-
-        Reviewed by Antti Koivisto.
-
-        No behaviour change, follows: https://html.spec.whatwg.org/#details-notification-task-steps
-
-        * html/HTMLDetailsElement.cpp:
-        (WebCore::HTMLDetailsElement::parseAttribute):
-        (WebCore::HTMLDetailsElement::toggleOpen):
-        (WebCore::detailToggleEventSender): Deleted.
-        (WebCore::HTMLDetailsElement::~HTMLDetailsElement): Deleted.
-        (WebCore::HTMLDetailsElement::dispatchPendingEvent): Deleted.
-        * html/HTMLDetailsElement.h:
-
-2021-08-19  Tim Nguyen  <n...@apple.com>
-
         Implement ::backdrop pseudo element
         https://bugs.webkit.org/show_bug.cgi?id=227801
 

Modified: branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.cpp (281264 => 281265)


--- branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.cpp	2021-08-19 20:36:11 UTC (rev 281264)
+++ branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.cpp	2021-08-19 20:42:15 UTC (rev 281265)
@@ -24,8 +24,8 @@
 
 #include "AXObjectCache.h"
 #include "ElementIterator.h"
-#include "EventLoop.h"
 #include "EventNames.h"
+#include "EventSender.h"
 #include "HTMLSlotElement.h"
 #include "HTMLSummaryElement.h"
 #include "LocalizedStrings.h"
@@ -43,6 +43,12 @@
 
 using namespace HTMLNames;
 
+static DetailEventSender& detailToggleEventSender()
+{
+    static NeverDestroyed<DetailEventSender> sharedToggleEventSender(eventNames().toggleEvent);
+    return sharedToggleEventSender;
+}
+
 static const AtomString& summarySlotName()
 {
     static MainThreadNeverDestroyed<const AtomString> summarySlot("summarySlot");
@@ -92,6 +98,11 @@
     ASSERT(hasTagName(detailsTag));
 }
 
+HTMLDetailsElement::~HTMLDetailsElement()
+{
+    detailToggleEventSender().cancelEvent(*this);
+}
+
 RenderPtr<RenderElement> HTMLDetailsElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
     return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
@@ -128,6 +139,12 @@
     return slot == m_summarySlot;
 }
 
+void HTMLDetailsElement::dispatchPendingEvent(DetailEventSender* eventSender)
+{
+    ASSERT_UNUSED(eventSender, eventSender == &detailToggleEventSender());
+    dispatchEvent(Event::create(eventNames().toggleEvent, Event::CanBubble::No, Event::IsCancelable::No));
+}
+
 void HTMLDetailsElement::parseAttribute(const QualifiedName& name, const AtomString& value)
 {
     if (name == openAttr) {
@@ -141,15 +158,9 @@
             else
                 root->removeChild(*m_defaultSlot);
 
-            // https://html.spec.whatwg.org/#details-notification-task-steps
-            if (m_isToggleEventTaskQueued)
-                return;
-
-            document().eventLoop().queueTask(TaskSource::DOMManipulation, [protectedThis = GCReachableRef { *this }] {
-                protectedThis->dispatchEvent(Event::create(eventNames().toggleEvent, Event::CanBubble::No, Event::IsCancelable::No));
-                protectedThis->m_isToggleEventTaskQueued = false;
-            });
-            m_isToggleEventTaskQueued = true;
+            // https://html.spec.whatwg.org/#details-notification-task-steps.
+            detailToggleEventSender().cancelEvent(*this);
+            detailToggleEventSender().dispatchEventSoon(*this);
         }
     } else
         HTMLElement::parseAttribute(name, value);
@@ -158,7 +169,7 @@
 
 void HTMLDetailsElement::toggleOpen()
 {
-    setBooleanAttribute(openAttr, !m_isOpen);
+    setAttributeWithoutSynchronization(openAttr, m_isOpen ? nullAtom() : emptyAtom());
 
     // We need to post to the document because toggling this element will delete it.
     if (AXObjectCache* cache = document().existingAXObjectCache())

Modified: branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.h (281264 => 281265)


--- branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.h	2021-08-19 20:36:11 UTC (rev 281264)
+++ branches/safari-612.1.29-branch/Source/WebCore/html/HTMLDetailsElement.h	2021-08-19 20:42:15 UTC (rev 281265)
@@ -27,10 +27,14 @@
 
 class HTMLSlotElement;
 
+template<typename T> class EventSender;
+using DetailEventSender = EventSender<HTMLDetailsElement>;
+
 class HTMLDetailsElement final : public HTMLElement {
     WTF_MAKE_ISO_ALLOCATED(HTMLDetailsElement);
 public:
     static Ref<HTMLDetailsElement> create(const QualifiedName& tagName, Document&);
+    ~HTMLDetailsElement();
 
     void toggleOpen();
 
@@ -37,6 +41,8 @@
     bool isOpen() const { return m_isOpen; }
     bool isActiveSummary(const HTMLSummaryElement&) const;
 
+    void dispatchPendingEvent(DetailEventSender*);
+    
 private:
     HTMLDetailsElement(const QualifiedName&, Document&);
 
@@ -51,7 +57,6 @@
     HTMLSlotElement* m_summarySlot { nullptr };
     HTMLSummaryElement* m_defaultSummary { nullptr };
     RefPtr<HTMLSlotElement> m_defaultSlot;
-    bool m_isToggleEventTaskQueued { false };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to