| 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;
|
| }
|
|
|