Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: Source/core/html/HTMLDetailsElement.cpp

Issue 249573002: HTMLDetailsElement should fire a 'toggle' event (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/html/HTMLDetailsElement.cpp
diff --git a/Source/core/html/HTMLDetailsElement.cpp b/Source/core/html/HTMLDetailsElement.cpp
index e88582f38346562b1a90eb2a2c08632017d8e353..0ae3e6c26dbd737293bfefe4738996b64ff05fe2 100644
--- a/Source/core/html/HTMLDetailsElement.cpp
+++ b/Source/core/html/HTMLDetailsElement.cpp
@@ -47,11 +47,24 @@ PassRefPtr<HTMLDetailsElement> HTMLDetailsElement::create(Document& document)
HTMLDetailsElement::HTMLDetailsElement(Document& document)
: HTMLElement(detailsTag, document)
+ , m_toggleEventTimer(this, &HTMLDetailsElement::toggleEventTimerFired)
, m_isOpen(false)
{
ScriptWrappable::init(this);
}
+void HTMLDetailsElement::toggleEventTimerFired(Timer<HTMLDetailsElement> *)
+{
+ dispatchEvent(Event::create(EventTypeNames::toggle));
+}
+
+void HTMLDetailsElement::dispatchToggleEventAsync()
+{
+ if (m_toggleEventTimer.isActive())
+ m_toggleEventTimer.stop();
+ m_toggleEventTimer.startOneShot(0, FROM_HERE);
+}
+
RenderObject* HTMLDetailsElement::createRenderer(RenderStyle*)
{
return new RenderBlockFlow(this);
@@ -94,6 +107,10 @@ void HTMLDetailsElement::parseAttribute(const QualifiedName& name, const AtomicS
m_isOpen = !value.isNull();
if (m_isOpen == oldValue)
return;
+
+ // Dispatch toggle event asynchronously.
+ dispatchToggleEventAsync();
+
Element* content = ensureUserAgentShadowRoot().getElementById(ShadowElementNames::detailsContent());
ASSERT(content);
if (m_isOpen)
« LayoutTests/fast/html/details-open-toggle-event.html ('K') | « Source/core/html/HTMLDetailsElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698