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

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: Rename detail to details 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
« no previous file with comments | « Source/core/html/HTMLDetailsElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « Source/core/html/HTMLDetailsElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698