Index: Source/core/html/HTMLDetailsElement.cpp |
diff --git a/Source/core/html/HTMLDetailsElement.cpp b/Source/core/html/HTMLDetailsElement.cpp |
index e88582f38346562b1a90eb2a2c08632017d8e353..fed6facc156a2b44dc138f4b314faa482b0d4b6c 100644 |
--- a/Source/core/html/HTMLDetailsElement.cpp |
+++ b/Source/core/html/HTMLDetailsElement.cpp |
@@ -27,6 +27,7 @@ |
#include "bindings/v8/ExceptionStatePlaceholder.h" |
#include "core/dom/Text.h" |
#include "core/dom/shadow/ShadowRoot.h" |
+#include "core/events/EventSender.h" |
#include "core/html/HTMLContentElement.h" |
#include "core/html/HTMLDivElement.h" |
#include "core/html/HTMLSummaryElement.h" |
@@ -38,6 +39,12 @@ namespace WebCore { |
using namespace HTMLNames; |
+static DetailsEventSender& detailsToggleEventSender() |
+{ |
+ DEFINE_STATIC_LOCAL(DetailsEventSender, sharedToggleEventSender, (EventTypeNames::toggle)); |
+ return sharedToggleEventSender; |
+} |
+ |
PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(Document& document) |
{ |
RefPtr<HTMLDetailsElement> details = adoptRef(new HTMLDetailsElement(document)); |
@@ -52,6 +59,18 @@ HTMLDetailsElement::HTMLDetailsElement(Document& document) |
ScriptWrappable::init(this); |
} |
+HTMLDetailsElement::~HTMLDetailsElement() |
+{ |
+ detailsToggleEventSender().cancelEvent(this); |
+} |
+ |
+void HTMLDetailsElement::dispatchPendingEvent(DetailsEventSender* eventSender) |
+{ |
+ ASSERT_UNUSED(eventSender, eventSender == &detailsToggleEventSender()); |
+ dispatchEvent(Event::create(EventTypeNames::toggle)); |
+} |
+ |
+ |
RenderObject* HTMLDetailsElement::createRenderer(RenderStyle*) |
{ |
return new RenderBlockFlow(this); |
@@ -94,6 +113,11 @@ void HTMLDetailsElement::parseAttribute(const QualifiedName& name, const AtomicS |
m_isOpen = !value.isNull(); |
if (m_isOpen == oldValue) |
return; |
+ |
+ // Dispatch toggle event asynchronously. |
+ detailsToggleEventSender().cancelEvent(this); |
+ detailsToggleEventSender().dispatchEventSoon(this); |
+ |
Element* content = ensureUserAgentShadowRoot().getElementById(ShadowElementNames::detailsContent()); |
ASSERT(content); |
if (m_isOpen) |