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

Unified Diff: Source/core/dom/Document.cpp

Issue 305723002: Use method registration approach for creating events on core and modules. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline Created 6 years, 7 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/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index d8bae3c9c0648b2e235041b3f80cf4539a4df28d..0056af95da6e475c6a57c8f9563f1f9aadebbda7 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -3922,12 +3922,26 @@ void Document::enqueueResizeEvent()
ensureScriptedAnimationController().enqueuePerFrameEvent(event.release());
}
-PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, ExceptionState& exceptionState)
+Document::EventFactorySet& Document::eventFactories()
+{
+ DEFINE_STATIC_LOCAL(EventFactorySet, s_eventFactory, ());
+ return s_eventFactory;
+}
+
+void Document::registerEventFactory(EventFactoryBase* eventFactory)
{
- RefPtrWillBeRawPtr<Event> event = EventFactory::create(eventType);
- if (event)
- return event.release();
+ ASSERT(!eventFactories().contains(eventFactory));
+ eventFactories().add(eventFactory);
+}
+PassRefPtrWillBeRawPtr<Event> Document::createEvent(const String& eventType, ExceptionState& exceptionState)
+{
+ RefPtrWillBeRawPtr<Event> event = nullptr;
+ for (EventFactorySet::const_iterator it = eventFactories().begin(); it != eventFactories().end(); ++it) {
+ event = (*it)->create(eventType);
+ if (event)
+ return event.release();
+ }
exceptionState.throwDOMException(NotSupportedError, "The provided event type ('" + eventType + "') is invalid.");
return nullptr;
}
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698