| Index: Source/core/dom/Document.cpp
|
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
|
| index 9a539716bb24931040285c6e207c7d8fd6825959..e85cb0dc76fbb6521cb8987528bb1c3bb45c2b82 100644
|
| --- a/Source/core/dom/Document.cpp
|
| +++ b/Source/core/dom/Document.cpp
|
| @@ -3914,12 +3914,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;
|
| }
|
|
|