Event.h shouldn't need to know about every ifdef and feature that uses events
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2011 00:00:37 +0000 (00:00 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2011 00:00:37 +0000 (00:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=70483

Reviewed by Eric Seidel.

This patch expands make_event_factory.pl to create a
DOM_EVENT_INTERFACES_FOR_EACH macro that we can use to generate code
for each Event interface.  We then apply that macro to removing a large
number of virtual functions on Event.  Instead of having a Boolean
virtual function for each subclass of Event, we have a single virtual
interfaceName function, which returns an AtomicString.  We then use the
AtomicString to jump through a HashMap to find the appropriate
JavaScript wrapper type.

This patch does not remove all of the Boolean virtual functions because
I got exhausted making all of these edits, but I did remove all the
ones that involve ifdefs.  A future patch will remove more.

* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventCustom.cpp:
(WebCore::toJS):
* bindings/v8/custom/V8EventCustom.cpp:
(WebCore::toV8):
* dom/BeforeLoadEvent.h:
(WebCore::BeforeLoadEvent::interfaceName):
(WebCore::BeforeLoadEvent::isBeforeLoadEvent):
* dom/BeforeTextInsertedEvent.cpp:
(WebCore::BeforeTextInsertedEvent::interfaceName):
* dom/BeforeTextInsertedEvent.h:
* dom/ClipboardEvent.cpp:
(WebCore::ClipboardEvent::interfaceName):
* dom/ClipboardEvent.h:
* dom/CompositionEvent.cpp:
(WebCore::CompositionEvent::interfaceName):
* dom/CompositionEvent.h:
* dom/CustomEvent.cpp:
(WebCore::CustomEvent::interfaceName):
* dom/CustomEvent.h:
* dom/DeviceMotionEvent.cpp:
(WebCore::DeviceMotionEvent::interfaceName):
* dom/DeviceMotionEvent.h:
* dom/DeviceOrientationEvent.cpp:
(WebCore::DeviceOrientationEvent::interfaceName):
* dom/DeviceOrientationEvent.h:
* dom/ErrorEvent.cpp:
(WebCore::ErrorEvent::interfaceName):
* dom/ErrorEvent.h:
* dom/Event.cpp:
(WebCore::Event::interfaceName):
* dom/Event.h:
* dom/EventNames.cpp:
(WebCore::EventNames::EventNames):
* dom/EventNames.h:
* dom/HashChangeEvent.h:
(WebCore::HashChangeEvent::interfaceName):
* dom/KeyboardEvent.cpp:
(WebCore::KeyboardEvent::interfaceName):
* dom/KeyboardEvent.h:
* dom/MessageEvent.cpp:
(WebCore::MessageEvent::interfaceName):
* dom/MessageEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::interfaceName):
* dom/MouseEvent.h:
* dom/MutationEvent.cpp:
(WebCore::MutationEvent::interfaceName):
* dom/MutationEvent.h:
* dom/OverflowEvent.cpp:
(WebCore::OverflowEvent::interfaceName):
* dom/OverflowEvent.h:
* dom/PageTransitionEvent.cpp:
(WebCore::PageTransitionEvent::interfaceName):
* dom/PageTransitionEvent.h:
* dom/PopStateEvent.cpp:
(WebCore::PopStateEvent::interfaceName):
* dom/PopStateEvent.h:
* dom/ProgressEvent.cpp:
(WebCore::ProgressEvent::interfaceName):
* dom/ProgressEvent.h:
* dom/TextEvent.cpp:
(WebCore::TextEvent::interfaceName):
* dom/TextEvent.h:
* dom/TouchEvent.cpp:
(WebCore::TouchEvent::interfaceName):
* dom/TouchEvent.h:
* dom/UIEvent.h:
* dom/WebKitAnimationEvent.cpp:
(WebCore::WebKitAnimationEvent::interfaceName):
* dom/WebKitAnimationEvent.h:
* dom/WebKitTransitionEvent.cpp:
(WebCore::WebKitTransitionEvent::interfaceName):
* dom/WebKitTransitionEvent.h:
* dom/WheelEvent.cpp:
(WebCore::WheelEvent::interfaceName):
* dom/WheelEvent.h:
* dom/make_event_factory.pl:
(printFactoryFile):
(printMacroFile):
(printHeadersFile):
* html/canvas/WebGLContextEvent.cpp:
(WebCore::WebGLContextEvent::interfaceName):
* html/canvas/WebGLContextEvent.h:
* inspector/InspectorDOMStorageResource.cpp:
(WebCore::InspectorDOMStorageResource::handleEvent):
* p2p/MediaStreamEvent.cpp:
(WebCore::MediaStreamEvent::interfaceName):
* p2p/MediaStreamEvent.h:
* page/SpeechInputEvent.cpp:
(WebCore::SpeechInputEvent::interfaceName):
* page/SpeechInputEvent.h:
* storage/IDBVersionChangeEvent.cpp:
(WebCore::IDBVersionChangeEvent::interfaceName):
* storage/IDBVersionChangeEvent.h:
* storage/StorageEvent.cpp:
(WebCore::StorageEvent::interfaceName):
* storage/StorageEvent.h:
* svg/SVGZoomEvent.cpp:
(WebCore::SVGZoomEvent::interfaceName):
* svg/SVGZoomEvent.h:
* webaudio/AudioProcessingEvent.cpp:
(WebCore::AudioProcessingEvent::interfaceName):
* webaudio/AudioProcessingEvent.h:
* webaudio/OfflineAudioCompletionEvent.cpp:
(WebCore::OfflineAudioCompletionEvent::interfaceName):
* webaudio/OfflineAudioCompletionEvent.h:
* websockets/CloseEvent.h:
(WebCore::CloseEvent::interfaceName):
* xml/XMLHttpRequestProgressEvent.h:
(WebCore::XMLHttpRequestProgressEvent::interfaceName):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@98044 268f45cc-cd09-0410-ab3c-d52691b4dbfc

78 files changed:
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSEventCustom.cpp
Source/WebCore/bindings/v8/custom/V8EventCustom.cpp
Source/WebCore/dom/BeforeLoadEvent.h
Source/WebCore/dom/BeforeTextInsertedEvent.cpp
Source/WebCore/dom/BeforeTextInsertedEvent.h
Source/WebCore/dom/ClipboardEvent.cpp
Source/WebCore/dom/ClipboardEvent.h
Source/WebCore/dom/CompositionEvent.cpp
Source/WebCore/dom/CompositionEvent.h
Source/WebCore/dom/CustomEvent.cpp
Source/WebCore/dom/CustomEvent.h
Source/WebCore/dom/DeviceMotionEvent.cpp
Source/WebCore/dom/DeviceMotionEvent.h
Source/WebCore/dom/DeviceOrientationEvent.cpp
Source/WebCore/dom/DeviceOrientationEvent.h
Source/WebCore/dom/ErrorEvent.cpp
Source/WebCore/dom/ErrorEvent.h
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/EventFactory.in
Source/WebCore/dom/EventNames.cpp
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/HashChangeEvent.h
Source/WebCore/dom/KeyboardEvent.cpp
Source/WebCore/dom/KeyboardEvent.h
Source/WebCore/dom/MessageEvent.cpp
Source/WebCore/dom/MessageEvent.h
Source/WebCore/dom/MouseEvent.cpp
Source/WebCore/dom/MouseEvent.h
Source/WebCore/dom/MutationEvent.cpp
Source/WebCore/dom/MutationEvent.h
Source/WebCore/dom/OverflowEvent.cpp
Source/WebCore/dom/OverflowEvent.h
Source/WebCore/dom/PageTransitionEvent.cpp
Source/WebCore/dom/PageTransitionEvent.h
Source/WebCore/dom/PopStateEvent.cpp
Source/WebCore/dom/PopStateEvent.h
Source/WebCore/dom/ProgressEvent.cpp
Source/WebCore/dom/ProgressEvent.h
Source/WebCore/dom/TextEvent.cpp
Source/WebCore/dom/TextEvent.h
Source/WebCore/dom/TouchEvent.cpp
Source/WebCore/dom/TouchEvent.h
Source/WebCore/dom/UIEvent.cpp
Source/WebCore/dom/UIEvent.h
Source/WebCore/dom/WebKitAnimationEvent.cpp
Source/WebCore/dom/WebKitAnimationEvent.h
Source/WebCore/dom/WebKitTransitionEvent.cpp
Source/WebCore/dom/WebKitTransitionEvent.h
Source/WebCore/dom/WheelEvent.cpp
Source/WebCore/dom/WheelEvent.h
Source/WebCore/dom/make_event_factory.pl
Source/WebCore/html/canvas/WebGLContextEvent.cpp
Source/WebCore/html/canvas/WebGLContextEvent.h
Source/WebCore/inspector/InspectorDOMStorageResource.cpp
Source/WebCore/p2p/MediaStreamEvent.cpp
Source/WebCore/p2p/MediaStreamEvent.h
Source/WebCore/page/SpeechInputEvent.cpp
Source/WebCore/page/SpeechInputEvent.h
Source/WebCore/storage/IDBVersionChangeEvent.cpp
Source/WebCore/storage/IDBVersionChangeEvent.h
Source/WebCore/storage/StorageEvent.cpp
Source/WebCore/storage/StorageEvent.h
Source/WebCore/svg/SVGZoomEvent.cpp
Source/WebCore/svg/SVGZoomEvent.h
Source/WebCore/webaudio/AudioProcessingEvent.cpp
Source/WebCore/webaudio/AudioProcessingEvent.h
Source/WebCore/webaudio/OfflineAudioCompletionEvent.cpp
Source/WebCore/webaudio/OfflineAudioCompletionEvent.h
Source/WebCore/websockets/CloseEvent.h
Source/WebCore/xml/XMLHttpRequestProgressEvent.h
Source/WebKit/chromium/src/WebDOMEvent.cpp

index c368f05..518b3f7 100755 (executable)
@@ -1,3 +1,135 @@
+2011-10-20  Adam Barth  <abarth@webkit.org>
+
+        Event.h shouldn't need to know about every ifdef and feature that uses events
+        https://bugs.webkit.org/show_bug.cgi?id=70483
+
+        Reviewed by Eric Seidel.
+
+        This patch expands make_event_factory.pl to create a
+        DOM_EVENT_INTERFACES_FOR_EACH macro that we can use to generate code
+        for each Event interface.  We then apply that macro to removing a large
+        number of virtual functions on Event.  Instead of having a Boolean
+        virtual function for each subclass of Event, we have a single virtual
+        interfaceName function, which returns an AtomicString.  We then use the
+        AtomicString to jump through a HashMap to find the appropriate
+        JavaScript wrapper type.
+
+        This patch does not remove all of the Boolean virtual functions because
+        I got exhausted making all of these edits, but I did remove all the
+        ones that involve ifdefs.  A future patch will remove more.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSEventCustom.cpp:
+        (WebCore::toJS):
+        * bindings/v8/custom/V8EventCustom.cpp:
+        (WebCore::toV8):
+        * dom/BeforeLoadEvent.h:
+        (WebCore::BeforeLoadEvent::interfaceName):
+        (WebCore::BeforeLoadEvent::isBeforeLoadEvent):
+        * dom/BeforeTextInsertedEvent.cpp:
+        (WebCore::BeforeTextInsertedEvent::interfaceName):
+        * dom/BeforeTextInsertedEvent.h:
+        * dom/ClipboardEvent.cpp:
+        (WebCore::ClipboardEvent::interfaceName):
+        * dom/ClipboardEvent.h:
+        * dom/CompositionEvent.cpp:
+        (WebCore::CompositionEvent::interfaceName):
+        * dom/CompositionEvent.h:
+        * dom/CustomEvent.cpp:
+        (WebCore::CustomEvent::interfaceName):
+        * dom/CustomEvent.h:
+        * dom/DeviceMotionEvent.cpp:
+        (WebCore::DeviceMotionEvent::interfaceName):
+        * dom/DeviceMotionEvent.h:
+        * dom/DeviceOrientationEvent.cpp:
+        (WebCore::DeviceOrientationEvent::interfaceName):
+        * dom/DeviceOrientationEvent.h:
+        * dom/ErrorEvent.cpp:
+        (WebCore::ErrorEvent::interfaceName):
+        * dom/ErrorEvent.h:
+        * dom/Event.cpp:
+        (WebCore::Event::interfaceName):
+        * dom/Event.h:
+        * dom/EventNames.cpp:
+        (WebCore::EventNames::EventNames):
+        * dom/EventNames.h:
+        * dom/HashChangeEvent.h:
+        (WebCore::HashChangeEvent::interfaceName):
+        * dom/KeyboardEvent.cpp:
+        (WebCore::KeyboardEvent::interfaceName):
+        * dom/KeyboardEvent.h:
+        * dom/MessageEvent.cpp:
+        (WebCore::MessageEvent::interfaceName):
+        * dom/MessageEvent.h:
+        * dom/MouseEvent.cpp:
+        (WebCore::MouseEvent::interfaceName):
+        * dom/MouseEvent.h:
+        * dom/MutationEvent.cpp:
+        (WebCore::MutationEvent::interfaceName):
+        * dom/MutationEvent.h:
+        * dom/OverflowEvent.cpp:
+        (WebCore::OverflowEvent::interfaceName):
+        * dom/OverflowEvent.h:
+        * dom/PageTransitionEvent.cpp:
+        (WebCore::PageTransitionEvent::interfaceName):
+        * dom/PageTransitionEvent.h:
+        * dom/PopStateEvent.cpp:
+        (WebCore::PopStateEvent::interfaceName):
+        * dom/PopStateEvent.h:
+        * dom/ProgressEvent.cpp:
+        (WebCore::ProgressEvent::interfaceName):
+        * dom/ProgressEvent.h:
+        * dom/TextEvent.cpp:
+        (WebCore::TextEvent::interfaceName):
+        * dom/TextEvent.h:
+        * dom/TouchEvent.cpp:
+        (WebCore::TouchEvent::interfaceName):
+        * dom/TouchEvent.h:
+        * dom/UIEvent.h:
+        * dom/WebKitAnimationEvent.cpp:
+        (WebCore::WebKitAnimationEvent::interfaceName):
+        * dom/WebKitAnimationEvent.h:
+        * dom/WebKitTransitionEvent.cpp:
+        (WebCore::WebKitTransitionEvent::interfaceName):
+        * dom/WebKitTransitionEvent.h:
+        * dom/WheelEvent.cpp:
+        (WebCore::WheelEvent::interfaceName):
+        * dom/WheelEvent.h:
+        * dom/make_event_factory.pl:
+        (printFactoryFile):
+        (printMacroFile):
+        (printHeadersFile):
+        * html/canvas/WebGLContextEvent.cpp:
+        (WebCore::WebGLContextEvent::interfaceName):
+        * html/canvas/WebGLContextEvent.h:
+        * inspector/InspectorDOMStorageResource.cpp:
+        (WebCore::InspectorDOMStorageResource::handleEvent):
+        * p2p/MediaStreamEvent.cpp:
+        (WebCore::MediaStreamEvent::interfaceName):
+        * p2p/MediaStreamEvent.h:
+        * page/SpeechInputEvent.cpp:
+        (WebCore::SpeechInputEvent::interfaceName):
+        * page/SpeechInputEvent.h:
+        * storage/IDBVersionChangeEvent.cpp:
+        (WebCore::IDBVersionChangeEvent::interfaceName):
+        * storage/IDBVersionChangeEvent.h:
+        * storage/StorageEvent.cpp:
+        (WebCore::StorageEvent::interfaceName):
+        * storage/StorageEvent.h:
+        * svg/SVGZoomEvent.cpp:
+        (WebCore::SVGZoomEvent::interfaceName):
+        * svg/SVGZoomEvent.h:
+        * webaudio/AudioProcessingEvent.cpp:
+        (WebCore::AudioProcessingEvent::interfaceName):
+        * webaudio/AudioProcessingEvent.h:
+        * webaudio/OfflineAudioCompletionEvent.cpp:
+        (WebCore::OfflineAudioCompletionEvent::interfaceName):
+        * webaudio/OfflineAudioCompletionEvent.h:
+        * websockets/CloseEvent.h:
+        (WebCore::CloseEvent::interfaceName):
+        * xml/XMLHttpRequestProgressEvent.h:
+        (WebCore::XMLHttpRequestProgressEvent::interfaceName):
+
 2011-10-20  Nat Duca  <nduca@chromium.org>
 
         [chromium] Route onSwapBuffersComplete from LayerRenderer to CCScheduler.
index f1bfa26..b376859 100644 (file)
@@ -10,6 +10,8 @@ webcore_built_sources += \
        DerivedSources/WebCore/CSSValueKeywords.cpp \
        DerivedSources/WebCore/ColorData.cpp \
        DerivedSources/WebCore/EventFactory.cpp \
+       DerivedSources/WebCore/EventHeaders.h \
+       DerivedSources/WebCore/EventInterfaces.h \
        DerivedSources/WebCore/HTMLElementFactory.cpp \
        DerivedSources/WebCore/HTMLElementFactory.h \
        DerivedSources/WebCore/HTMLEntityTable.cpp \
index ee4c225..22a210a 100644 (file)
           ],
           'outputs': [
             '<(SHARED_INTERMEDIATE_DIR)/webkit/EventFactory.cpp',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/EventHeaders.h',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/EventInterfaces.h',
           ],
           'action': [
             'python',
index 77943d8..3461335 100644 (file)
             '<(PRODUCT_DIR)/DerivedSources/WebCore/DOMXPathExpression.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/DOMXPathNSResolver.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/DOMXPathResult.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/EventHeaders.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/EventInterfaces.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLNames.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSCSSStyleDeclaration.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/JSDOMWindow.h',
index f3d0598..445790b 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventHeaders.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventInterfaces.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\HTMLElementFactory.h"
                                >
                        </File>
index f54bc0a..b5162d2 100644 (file)
                97059978107D975200A50A7C /* PolicyCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059974107D975200A50A7C /* PolicyCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97059979107D975200A50A7C /* PolicyChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97059975107D975200A50A7C /* PolicyChecker.cpp */; };
                9705997A107D975200A50A7C /* PolicyChecker.h in Headers */ = {isa = PBXBuildFile; fileRef = 97059976107D975200A50A7C /* PolicyChecker.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B7289144FFAC600F00A37 /* EventInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 970B72A5145008EB00F00A37 /* EventHeaders.h */; };
                971491DA12FD65E8001BFEB1 /* URLString.h in Headers */ = {isa = PBXBuildFile; fileRef = 971491D912FD65E8001BFEB1 /* URLString.h */; settings = {ATTRIBUTES = (Private, ); }; };
                97205AAF123928CA00B17380 /* FTPDirectoryDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97205AAD123928CA00B17380 /* FTPDirectoryDocument.cpp */; };
                97205AB0123928CA00B17380 /* FTPDirectoryDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 97205AAE123928CA00B17380 /* FTPDirectoryDocument.h */; };
                97059974107D975200A50A7C /* PolicyCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyCallback.h; sourceTree = "<group>"; };
                97059975107D975200A50A7C /* PolicyChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PolicyChecker.cpp; sourceTree = "<group>"; };
                97059976107D975200A50A7C /* PolicyChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PolicyChecker.h; sourceTree = "<group>"; };
+               970B7289144FFAC600F00A37 /* EventInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventInterfaces.h; sourceTree = "<group>"; };
+               970B72A5145008EB00F00A37 /* EventHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventHeaders.h; sourceTree = "<group>"; };
                971491D912FD65E8001BFEB1 /* URLString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = URLString.h; sourceTree = "<group>"; };
                97205AAD123928CA00B17380 /* FTPDirectoryDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FTPDirectoryDocument.cpp; sourceTree = "<group>"; };
                97205AAE123928CA00B17380 /* FTPDirectoryDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTPDirectoryDocument.h; sourceTree = "<group>"; };
                                6565814709D13043000E61D7 /* CSSValueKeywords.gperf */,
                                6565814809D13043000E61D7 /* CSSValueKeywords.h */,
                                9766504E144FBFFE00F6BB51 /* EventFactory.cpp */,
+                               970B72A5145008EB00F00A37 /* EventHeaders.h */,
+                               970B7289144FFAC600F00A37 /* EventInterfaces.h */,
                                A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */,
                                A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */,
                                A8BC04911214F69600B5F122 /* HTMLEntityTable.cpp */,
                                97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
                                A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */,
                                A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */,
+                               970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
+                               970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index fde60b1..6da1acb 100644 (file)
 #include "JSEvent.h"
 
 #include "Clipboard.h"
-#include "CompositionEvent.h"
-#include "CustomEvent.h"
-#include "DeviceMotionEvent.h"
-#include "DeviceOrientationEvent.h"
 #include "Event.h"
-#include "JSBeforeLoadEvent.h"
+#include "EventHeaders.h"
+#include "EventInterfaces.h"
+#include "EventNames.h"
 #include "JSClipboard.h"
-#include "JSCustomEvent.h"
-#include "JSCompositionEvent.h"
-#include "JSDeviceMotionEvent.h"
-#include "JSDeviceOrientationEvent.h"
-#include "JSErrorEvent.h"
-#include "JSHashChangeEvent.h"
-#include "JSKeyboardEvent.h"
-#include "JSMessageEvent.h"
-#include "JSMouseEvent.h"
-#include "JSMutationEvent.h"
-#include "JSOverflowEvent.h"
-#include "JSPageTransitionEvent.h"
-#include "JSPopStateEvent.h"
-#include "JSProgressEvent.h"
-#include "JSSpeechInputEvent.h"
-#include "JSStorageEvent.h"
-#include "JSTextEvent.h"
-#include "JSUIEvent.h"
-#include "JSWebKitAnimationEvent.h"
-#include "JSWebKitTransitionEvent.h"
-#include "JSWheelEvent.h"
-#include "JSXMLHttpRequestProgressEvent.h"
-#include "BeforeLoadEvent.h"
-#include "ErrorEvent.h"
-#include "HashChangeEvent.h"
-#include "KeyboardEvent.h"
-#include "MessageEvent.h"
-#include "MouseEvent.h"
-#include "MutationEvent.h"
-#include "OverflowEvent.h"
-#include "PageTransitionEvent.h"
-#include "PopStateEvent.h"
-#include "ProgressEvent.h"
-#include "SpeechInputEvent.h"
-#include "StorageEvent.h"
-#include "TextEvent.h"
-#include "UIEvent.h"
-#include "WebKitAnimationEvent.h"
-#include "WebKitTransitionEvent.h"
-#include "WheelEvent.h"
-#include "XMLHttpRequestProgressEvent.h"
 #include <runtime/JSLock.h>
-
-#if ENABLE(SVG)
-#include "JSSVGZoomEvent.h"
-#include "SVGZoomEvent.h"
-#endif
-
-#if ENABLE(TOUCH_EVENTS)
-#include "JSTouchEvent.h"
-#include "TouchEvent.h"
-#endif
-
-#if ENABLE(INDEXED_DATABASE)
-#include "IDBVersionChangeEvent.h"
-#include "JSIDBVersionChangeEvent.h"
-#endif
-
-#if ENABLE(WEB_AUDIO)
-#include "AudioProcessingEvent.h"
-#include "JSAudioProcessingEvent.h"
-#include "JSOfflineAudioCompletionEvent.h"
-#include "OfflineAudioCompletionEvent.h"
-#endif
-
-#if ENABLE(WEB_SOCKETS)
-#include "CloseEvent.h"
-#include "JSCloseEvent.h"
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-#include "JSMediaStreamEvent.h"
-#include "MediaStreamEvent.h"
-#endif
-
-#if ENABLE(WEBGL)
-#include "JSWebGLContextEvent.h"
-#include "WebGLContextEvent.h"
-#endif
+#include <wtf/HashMap.h>
+#include <wtf/text/AtomicString.h>
 
 using namespace JSC;
 
@@ -126,6 +48,17 @@ JSValue JSEvent::clipboardData(ExecState* exec) const
     return impl()->isClipboardEvent() ? toJS(exec, globalObject(), impl()->clipboardData()) : jsUndefined();
 }
 
+#define DECLARE_EVENT_WRAPPER(interfaceName) \
+    static JSDOMWrapper* create##interfaceName##Wrapper(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) \
+    { \
+        return CREATE_DOM_WRAPPER(exec, globalObject, interfaceName, event); \
+    } \
+
+DOM_EVENT_INTERFACES_FOR_EACH(DECLARE_EVENT_WRAPPER)
+
+#define ADD_WRAPPER_TO_MAP(interfaceName) \
+    map.add(eventNames().interfaceFor##interfaceName.impl(), create##interfaceName##Wrapper);
+
 JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event)
 {
     JSLock lock(SilenceAssertionsOnly);
@@ -137,94 +70,19 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event)
     if (wrapper)
         return wrapper;
 
-    if (event->isUIEvent()) {
-        if (event->isKeyboardEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, KeyboardEvent, event);
-        else if (event->isTextEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, TextEvent, event);
-        else if (event->isMouseEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, MouseEvent, event);
-        else if (event->isWheelEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WheelEvent, event);
-#if ENABLE(SVG)
-        else if (event->isSVGZoomEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, SVGZoomEvent, event);
-#endif
-        else if (event->isCompositionEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, CompositionEvent, event);
-#if ENABLE(TOUCH_EVENTS)
-        else if (event->isTouchEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, TouchEvent, event);
-#endif
-        else
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, UIEvent, event);
-    } else if (event->isMutationEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, MutationEvent, event);
-    else if (event->isOverflowEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, OverflowEvent, event);
-    else if (event->isMessageEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, MessageEvent, event);
-    else if (event->isPageTransitionEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, PageTransitionEvent, event);
-    else if (event->isProgressEvent()) {
-        if (event->isXMLHttpRequestProgressEvent())
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, XMLHttpRequestProgressEvent, event);
-        else
-            wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ProgressEvent, event);
-    } else if (event->isBeforeLoadEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, BeforeLoadEvent, event);
-    else if (event->isStorageEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, StorageEvent, event);
-#if ENABLE(INDEXED_DATABASE)
-    else if (event->isIDBVersionChangeEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, IDBVersionChangeEvent, event);
-#endif
-    else if (event->isWebKitAnimationEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WebKitAnimationEvent, event);
-    else if (event->isWebKitTransitionEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WebKitTransitionEvent, event);
-#if ENABLE(WORKERS)
-    else if (event->isErrorEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ErrorEvent, event);
-#endif
-    else if (event->isHashChangeEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, HashChangeEvent, event);
-    else if (event->isPopStateEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, PopStateEvent, event);
-    else if (event->isCustomEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, CustomEvent, event);
-#if ENABLE(DEVICE_ORIENTATION)
-    else if (event->isDeviceMotionEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, DeviceMotionEvent, event);
-    else if (event->isDeviceOrientationEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, DeviceOrientationEvent, event);
-#endif
-#if ENABLE(WEB_AUDIO)
-    else if (event->isAudioProcessingEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, AudioProcessingEvent, event);
-    else if (event->isOfflineAudioCompletionEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, OfflineAudioCompletionEvent, event);
-#endif
-#if ENABLE(INPUT_SPEECH)
-    else if (event->isSpeechInputEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, SpeechInputEvent, event);
-#endif
-#if ENABLE(WEB_SOCKETS)
-    else if (event->isCloseEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, CloseEvent, event);
-#endif
-#if ENABLE(MEDIA_STREAM)
-    else if (event->isMediaStreamEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, MediaStreamEvent, event);
-#endif
-#if ENABLE(WEBGL)
-    else if (event->isWebGLContextEvent())
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, WebGLContextEvent, event);
-#endif
-    else
-        wrapper = CREATE_DOM_WRAPPER(exec, globalObject, Event, event);
-
-    return wrapper;
+    typedef JSDOMWrapper* (*CreateEventWrapperFunction)(ExecState*, JSDOMGlobalObject*, Event*);
+    typedef HashMap<WTF::AtomicStringImpl*, CreateEventWrapperFunction> FunctionMap;
+
+    DEFINE_STATIC_LOCAL(FunctionMap, map, ());
+    if (map.isEmpty()) {
+        DOM_EVENT_INTERFACES_FOR_EACH(ADD_WRAPPER_TO_MAP)
+    }
+
+    CreateEventWrapperFunction createWrapperFunction = map.get(event->interfaceName().impl());
+    if (createWrapperFunction)
+        return createWrapperFunction(exec, globalObject, event);
+
+    return CREATE_DOM_WRAPPER(exec, globalObject, Event, event);
 }
 
 } // namespace WebCore
index bcf7d6f..c60def8 100644 (file)
 
 #include "Clipboard.h"
 #include "ClipboardEvent.h"
-#include "CustomEvent.h"
 #include "Event.h"
-#include "V8BeforeLoadEvent.h"
+#include "EventHeaders.h"
+#include "EventInterfaces.h"
+#include "EventNames.h"
 #include "V8Binding.h"
 #include "V8Clipboard.h"
-#include "V8CloseEvent.h"
-#include "V8CompositionEvent.h"
-#include "V8CustomEvent.h"
-#include "V8DeviceMotionEvent.h"
-#include "V8DeviceOrientationEvent.h"
-#include "V8ErrorEvent.h"
-#include "V8HashChangeEvent.h"
-#include "V8IDBVersionChangeEvent.h"
-#include "V8KeyboardEvent.h"
-#include "V8MessageEvent.h"
-#include "V8MouseEvent.h"
-#include "V8MutationEvent.h"
-#include "V8OverflowEvent.h"
-#include "V8PageTransitionEvent.h"
-#include "V8PopStateEvent.h"
-#include "V8ProgressEvent.h"
 #include "V8Proxy.h"
-#include "V8SpeechInputEvent.h"
-#include "V8StorageEvent.h"
-#include "V8TextEvent.h"
-#include "V8TouchEvent.h"
-#include "V8UIEvent.h"
-#include "V8WebKitAnimationEvent.h"
-#include "V8WebKitTransitionEvent.h"
-#include "V8WheelEvent.h"
-#include "V8XMLHttpRequestProgressEvent.h"
-
-#if ENABLE(SVG)
-#include "V8SVGZoomEvent.h"
-#endif
-
-#if ENABLE(WEB_AUDIO)
-#include "V8AudioProcessingEvent.h"
-#include "V8OfflineAudioCompletionEvent.h"
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-#include "V8MediaStreamEvent.h"
-#endif
 
 namespace WebCore {
 
@@ -106,90 +69,35 @@ v8::Handle<v8::Value> V8Event::clipboardDataAccessorGetter(v8::Local<v8::String>
     return v8::Undefined();
 }
 
-v8::Handle<v8::Value> toV8(Event* impl)
+#define DECLARE_EVENT_WRAPPER(interfaceName) \
+    static v8::Handle<v8::Value> toV8##interfaceName(Event* event) \
+    { \
+        return toV8(static_cast<interfaceName*>(event)); \
+    } \
+
+DOM_EVENT_INTERFACES_FOR_EACH(DECLARE_EVENT_WRAPPER)
+
+#define ADD_WRAPPER_TO_MAP(interfaceName) \
+    map.add(eventNames().interfaceFor##interfaceName.impl(), toV8##interfaceName);
+
+v8::Handle<v8::Value> toV8(Event* event)
 {
-    if (!impl)
+    if (!event)
         return v8::Null();
-    if (impl->isUIEvent()) {
-        if (impl->isKeyboardEvent())
-            return toV8(static_cast<KeyboardEvent*>(impl));
-        if (impl->isTextEvent())
-            return toV8(static_cast<TextEvent*>(impl));
-        if (impl->isMouseEvent())
-            return toV8(static_cast<MouseEvent*>(impl));
-        if (impl->isWheelEvent())
-            return toV8(static_cast<WheelEvent*>(impl));
-#if ENABLE(SVG)
-        if (impl->isSVGZoomEvent())
-            return toV8(static_cast<SVGZoomEvent*>(impl));
-#endif
-        if (impl->isCompositionEvent())
-            return toV8(static_cast<CompositionEvent*>(impl));
-#if ENABLE(TOUCH_EVENTS)
-        if (impl->isTouchEvent())
-            return toV8(static_cast<TouchEvent*>(impl));
-#endif
-        return toV8(static_cast<UIEvent*>(impl));
-    }
-    if (impl->isHashChangeEvent())
-        return toV8(static_cast<HashChangeEvent*>(impl));
-    if (impl->isMutationEvent())
-        return toV8(static_cast<MutationEvent*>(impl));
-    if (impl->isOverflowEvent())
-        return toV8(static_cast<OverflowEvent*>(impl));
-    if (impl->isMessageEvent())
-        return toV8(static_cast<MessageEvent*>(impl));
-    if (impl->isPageTransitionEvent())
-        return toV8(static_cast<PageTransitionEvent*>(impl));
-    if (impl->isPopStateEvent())
-        return toV8(static_cast<PopStateEvent*>(impl));
-    if (impl->isProgressEvent()) {
-        if (impl->isXMLHttpRequestProgressEvent())
-            return toV8(static_cast<XMLHttpRequestProgressEvent*>(impl));
-        return toV8(static_cast<ProgressEvent*>(impl));
+
+    typedef v8::Handle<v8::Value> (*ToV8Function)(Event*);
+    typedef HashMap<WTF::AtomicStringImpl*, ToV8Function> FunctionMap;
+
+    DEFINE_STATIC_LOCAL(FunctionMap, map, ());
+    if (map.isEmpty()) {
+        DOM_EVENT_INTERFACES_FOR_EACH(ADD_WRAPPER_TO_MAP)
     }
-    if (impl->isWebKitAnimationEvent())
-        return toV8(static_cast<WebKitAnimationEvent*>(impl));
-    if (impl->isWebKitTransitionEvent())
-        return toV8(static_cast<WebKitTransitionEvent*>(impl));
-#if ENABLE(WORKERS)
-    if (impl->isErrorEvent())
-        return toV8(static_cast<ErrorEvent*>(impl));
-#endif
-    if (impl->isStorageEvent())
-        return toV8(static_cast<StorageEvent*>(impl));
-#if ENABLE(INDEXED_DATABASE)
-    if (impl->isIDBVersionChangeEvent())
-        return toV8(static_cast<IDBVersionChangeEvent*>(impl));
-#endif
-    if (impl->isBeforeLoadEvent())
-        return toV8(static_cast<BeforeLoadEvent*>(impl));
-#if ENABLE(DEVICE_ORIENTATION)
-    if (impl->isDeviceMotionEvent())
-        return toV8(static_cast<DeviceMotionEvent*>(impl));
-    if (impl->isDeviceOrientationEvent())
-        return toV8(static_cast<DeviceOrientationEvent*>(impl));
-#endif
-#if ENABLE(WEB_AUDIO)
-    if (impl->isAudioProcessingEvent())
-        return toV8(static_cast<AudioProcessingEvent*>(impl));
-    if (impl->isOfflineAudioCompletionEvent())
-        return toV8(static_cast<OfflineAudioCompletionEvent*>(impl));
-#endif
-#if ENABLE(INPUT_SPEECH)
-    if (impl->isSpeechInputEvent())
-        return toV8(static_cast<SpeechInputEvent*>(impl));
-#endif
-    if (impl->isCustomEvent())
-        return toV8(static_cast<CustomEvent*>(impl));
-#if ENABLE(WEB_SOCKETS)
-    if (impl->isCloseEvent())
-        return toV8(static_cast<CloseEvent*>(impl));
-#endif
-#if ENABLE(MEDIA_STREAM)
-    if (impl->isMediaStreamEvent())
-        return toV8(static_cast<MediaStreamEvent*>(impl));
-#endif
-    return V8Event::wrap(impl);
+
+    ToV8Function specializedToV8 = map.get(event->interfaceName().impl());
+    if (specializedToV8)
+        return specializedToV8(event);
+
+    return V8Event::wrap(event);
 }
+
 } // namespace WebCore
index b3c32e7..166fb67 100644 (file)
@@ -42,8 +42,6 @@ struct BeforeLoadEventInit : public EventInit {
 
 class BeforeLoadEvent : public Event {
 public:
-    virtual bool isBeforeLoadEvent() const { return true; }
-
     static PassRefPtr<BeforeLoadEvent> create()
     {
         return adoptRef(new BeforeLoadEvent);
@@ -71,6 +69,9 @@ public:
 
     const String& url() const { return m_url; }
 
+    virtual const AtomicString& interfaceName() const { return eventNames().interfaceForBeforeLoadEvent; }
+    virtual bool isBeforeLoadEvent() const { return true; }
+
 private:
     BeforeLoadEvent()
     {
index 472eefc..a1f8fb8 100644 (file)
@@ -39,4 +39,10 @@ BeforeTextInsertedEvent::~BeforeTextInsertedEvent()
 {
 }
 
+const AtomicString& BeforeTextInsertedEvent::interfaceName() const
+{
+    // Notice that there is no BeforeTextInsertedEvent.idl.
+    return eventNames().interfaceForEvent;
+}
+
 }
index a6966ff..6e45f23 100644 (file)
@@ -39,8 +39,9 @@ public:
         return adoptRef(new BeforeTextInsertedEvent(text));
     }
 
+    virtual const AtomicString& interfaceName() const;
     virtual bool isBeforeTextInsertedEvent() const { return true; }
-  
+
     const String& text() const { return m_text; }
     void setText(const String& s) { m_text = s; }
 
index b64703d..51ed426 100644 (file)
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "ClipboardEvent.h"
 
+#include "EventNames.h"
+
 namespace WebCore {
 
 ClipboardEvent::ClipboardEvent()
@@ -38,6 +40,12 @@ ClipboardEvent::~ClipboardEvent()
 {
 }
 
+const AtomicString& ClipboardEvent::interfaceName() const
+{
+    // Notice that there is no ClipboardEvent.idl.
+    return eventNames().interfaceForEvent;
+}
+
 bool ClipboardEvent::isClipboardEvent() const
 {
     return true;
index 42741e6..6e14fb2 100644 (file)
@@ -44,6 +44,7 @@ namespace WebCore {
 
         Clipboard* clipboard() const { return m_clipboard.get(); }
 
+        virtual const AtomicString& interfaceName() const;
         virtual bool isClipboardEvent() const;
 
     private:
index 508d5e6..db9ffb4 100644 (file)
@@ -55,6 +55,11 @@ void CompositionEvent::initCompositionEvent(const AtomicString& type, bool canBu
     m_data = data;
 }
 
+const AtomicString& CompositionEvent::interfaceName() const
+{
+    return eventNames().interfaceForCompositionEvent;
+}
+
 bool CompositionEvent::isCompositionEvent() const
 {
     return true;
index 4ff01ae..5473573 100644 (file)
@@ -42,11 +42,12 @@ namespace WebCore {
           return adoptRef(new CompositionEvent(type, view, data));
         }
         virtual ~CompositionEvent();
-    
+
         void initCompositionEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<AbstractView>, const String& data);
-    
+
         String data() const { return m_data; }
 
+        virtual const AtomicString& interfaceName() const;
         virtual bool isCompositionEvent() const;
 
     private:
index 25a0446..5f0a5a9 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "CustomEvent.h"
 
+#include "EventNames.h"
+
 namespace WebCore {
 
 CustomEventInit::CustomEventInit()
@@ -57,9 +59,9 @@ void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool
     m_detail = detail;
 }
 
-bool CustomEvent::isCustomEvent() const
+const AtomicString& CustomEvent::interfaceName() const
 {
-    return true;
+    return eventNames().interfaceForCustomEvent;
 }
 
 } // namespace WebCore
index 0eeb6e7..6a60e9e 100644 (file)
@@ -53,7 +53,7 @@ public:
 
     void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, ScriptValue detail);
 
-    virtual bool isCustomEvent() const;
+    virtual const AtomicString& interfaceName() const;
 
     ScriptValue detail() const { return m_detail; }
 
index 860cca2..b29fcbe 100644 (file)
@@ -27,6 +27,7 @@
 #include "DeviceMotionEvent.h"
 
 #include "DeviceMotionData.h"
+#include "EventNames.h"
 
 namespace WebCore {
 
@@ -54,4 +55,16 @@ void DeviceMotionEvent::initDeviceMotionEvent(const AtomicString& type, bool bub
     m_deviceMotionData = deviceMotionData;
 }
 
+const AtomicString& DeviceMotionEvent::interfaceName() const
+{
+#if ENABLE(DEVICE_ORIENTATION)
+    return eventNames().interfaceForDeviceMotionEvent;
+#else
+    // FIXME: ENABLE(DEVICE_ORIENTATION) seems to be in a strange state where
+    // it is half-guarded by #ifdefs. DeviceMotionEvent.idl is guarded
+    // but DeviceMotionEvent.cpp itself is required by ungarded code.
+    return eventNames().interfaceForEvent;
+#endif
+}
+
 } // namespace WebCore
index f32c93b..301ffdd 100644 (file)
@@ -46,10 +46,10 @@ public:
 
     void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData*);
 
-    virtual bool isDeviceMotionEvent() const { return true; }
-
     DeviceMotionData* deviceMotionData() const { return m_deviceMotionData.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     DeviceMotionEvent();
     DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*);
index 932cb75..7decc7c 100644 (file)
@@ -27,6 +27,7 @@
 #include "DeviceOrientationEvent.h"
 
 #include "DeviceOrientation.h"
+#include "EventNames.h"
 
 namespace WebCore {
 
@@ -54,4 +55,16 @@ void DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type
     m_orientation = orientation;
 }
 
+const AtomicString& DeviceOrientationEvent::interfaceName() const
+{
+#if ENABLE(DEVICE_ORIENTATION)
+    return eventNames().interfaceForDeviceOrientationEvent;
+#else
+    // FIXME: ENABLE(DEVICE_ORIENTATION) seems to be in a strange state where
+    // it is half-guarded by #ifdefs. DeviceOrientationEvent.idl is guarded
+    // but DeviceOrientationEvent.cpp itself is required by ungarded code.
+    return eventNames().interfaceForEvent;
+#endif
+}
+
 } // namespace WebCore
index bfdf8fb..d959843 100644 (file)
@@ -46,10 +46,10 @@ public:
 
     void initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientation*);
 
-    virtual bool isDeviceOrientationEvent() const { return true; }
-
     DeviceOrientation* orientation() const { return m_orientation.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     DeviceOrientationEvent();
     DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientation*);
index 2ec6cb2..ecef772 100644 (file)
@@ -29,7 +29,6 @@
  */
 
 #include "config.h"
-
 #include "ErrorEvent.h"
 
 #include "EventNames.h"
@@ -84,4 +83,9 @@ bool ErrorEvent::isErrorEvent() const
     return true;
 }
 
+const AtomicString& ErrorEvent::interfaceName() const
+{
+    return eventNames().interfaceForErrorEvent;
+}
+
 } // namespace WebCore
index f8ade80..5acf01a 100644 (file)
@@ -66,6 +66,7 @@ public:
     const String& filename() const { return m_fileName; }
     unsigned lineno() const { return m_lineNumber; }
 
+    virtual const AtomicString& interfaceName() const;
     virtual bool isErrorEvent() const;
 
 private:
index 119d991..7d74b1b 100644 (file)
@@ -24,6 +24,7 @@
 #include "Event.h"
 
 #include "EventDispatcher.h"
+#include "EventNames.h"
 #include "EventTarget.h"
 #include "UserGestureIndicator.h"
 #include <wtf/CurrentTime.h>
@@ -96,9 +97,9 @@ void Event::initEvent(const AtomicString& eventTypeArg, bool canBubbleArg, bool
     m_cancelable = cancelableArg;
 }
 
-bool Event::isCustomEvent() const
+const AtomicString& Event::interfaceName() const
 {
-    return false;
+    return eventNames().interfaceForEvent;
 }
 
 bool Event::isUIEvent() const
@@ -166,41 +167,16 @@ bool Event::isPageTransitionEvent() const
     return false;
 }
 
-bool Event::isPopStateEvent() const
-{
-    return false;
-}
-
 bool Event::isProgressEvent() const
 {
     return false;
 }
 
-bool Event::isWebKitAnimationEvent() const
-{
-    return false;
-}
-
-bool Event::isWebKitTransitionEvent() const
-{
-    return false;
-}
-
-bool Event::isXMLHttpRequestProgressEvent() const
-{
-    return false;
-}
-
 bool Event::isBeforeLoadEvent() const
 {
     return false;
 }
 
-bool Event::isHashChangeEvent() const
-{
-    return false;
-}
-
 #if ENABLE(SVG)
 bool Event::isSVGZoomEvent() const
 {
@@ -208,83 +184,11 @@ bool Event::isSVGZoomEvent() const
 }
 #endif
 
-bool Event::isStorageEvent() const
-{
-    return false;
-}
-
-#if ENABLE(INDEXED_DATABASE)
-bool Event::isIDBVersionChangeEvent() const
-{
-    return false;
-}
-#endif
-
 bool Event::isErrorEvent() const
 {
     return false;
 }
 
-#if ENABLE(TOUCH_EVENTS)
-bool Event::isTouchEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(DEVICE_ORIENTATION)
-bool Event::isDeviceMotionEvent() const
-{
-    return false;
-}
-
-bool Event::isDeviceOrientationEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(WEB_AUDIO)
-bool Event::isAudioProcessingEvent() const
-{
-    return false;
-}
-
-bool Event::isOfflineAudioCompletionEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(INPUT_SPEECH)
-bool Event::isSpeechInputEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(WEB_SOCKETS)
-bool Event::isCloseEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-bool Event::isMediaStreamEvent() const
-{
-    return false;
-}
-#endif
-
-#if ENABLE(WEBGL)
-bool Event::isWebGLContextEvent() const
-{
-    return false;
-}
-#endif
-
-
 bool Event::storesResultAsString() const
 {
     return false;
index 1628be8..c027a78 100644 (file)
@@ -112,58 +112,31 @@ namespace WebCore {
 
         Clipboard* clipboardData() const { return isClipboardEvent() ? clipboard() : 0; }
 
-        virtual bool isCustomEvent() const;
+        virtual const AtomicString& interfaceName() const;
+
+        // These are needed for the CPP bindings.
         virtual bool isUIEvent() const;
         virtual bool isMouseEvent() const;
         virtual bool isMutationEvent() const;
+
+        virtual bool isDragEvent() const; // a subset of mouse events
+
+        // FIXME: Remove these! Callers should use interfaceName() instead.
         virtual bool isKeyboardEvent() const;
         virtual bool isTextEvent() const;
         virtual bool isCompositionEvent() const;
-        virtual bool isDragEvent() const; // a subset of mouse events
         virtual bool isClipboardEvent() const;
         virtual bool isMessageEvent() const;
         virtual bool isWheelEvent() const;
         virtual bool isBeforeTextInsertedEvent() const;
         virtual bool isOverflowEvent() const;
         virtual bool isPageTransitionEvent() const;
-        virtual bool isPopStateEvent() const;
         virtual bool isProgressEvent() const;
-        virtual bool isXMLHttpRequestProgressEvent() const;
-        virtual bool isWebKitAnimationEvent() const;
-        virtual bool isWebKitTransitionEvent() const;
         virtual bool isBeforeLoadEvent() const;
-        virtual bool isHashChangeEvent() const;
 #if ENABLE(SVG)
         virtual bool isSVGZoomEvent() const;
 #endif
-        virtual bool isStorageEvent() const;
-#if ENABLE(INDEXED_DATABASE)
-        virtual bool isIDBVersionChangeEvent() const;
-#endif
-#if ENABLE(WEB_AUDIO)
-        virtual bool isAudioProcessingEvent() const;
-        virtual bool isOfflineAudioCompletionEvent() const;
-#endif
         virtual bool isErrorEvent() const;
-#if ENABLE(TOUCH_EVENTS)
-        virtual bool isTouchEvent() const;
-#endif
-#if ENABLE(DEVICE_ORIENTATION)
-        virtual bool isDeviceMotionEvent() const;
-        virtual bool isDeviceOrientationEvent() const;
-#endif
-#if ENABLE(INPUT_SPEECH)
-        virtual bool isSpeechInputEvent() const;
-#endif
-#if ENABLE(WEB_SOCKETS)
-        virtual bool isCloseEvent() const;
-#endif
-#if ENABLE(MEDIA_STREAM)
-        virtual bool isMediaStreamEvent() const;
-#endif
-#if ENABLE(WEBGL)
-        virtual bool isWebGLContextEvent() const;
-#endif
 
         bool propagationStopped() const { return m_propagationStopped || m_immediatePropagationStopped; }
         bool immediatePropagationStopped() const { return m_immediatePropagationStopped; }
index 533873e..8e5e3ba 100644 (file)
@@ -36,6 +36,7 @@ StorageEvent
 SVGEvents interfaceName=Event, conditional=SVG
 SVGZoomEvent conditional=SVG
 SVGZoomEvents interfaceName=SVGZoomEvent, conditional=SVG
+IDBVersionChangeEvent conditional=INDEXED_DATABASE
 TouchEvent conditional=TOUCH_EVENTS
 DeviceMotionEvent conditional=DEVICE_ORIENTATION
 DeviceOrientationEvent conditional=DEVICE_ORIENTATION
index 900b8ef..228b9ee 100644 (file)
@@ -25,9 +25,14 @@ namespace WebCore {
 
 #define INITIALIZE_EVENT_NAME(name) \
     , name##Event(#name)
+
+#define INITIALIZE_EVENT_INTERFACE(name) \
+    , interfaceFor##name(#name)
+
 EventNames::EventNames()
     : dummy(0)
 DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_EVENT_NAME)
+DOM_EVENT_INTERFACES_FOR_EACH(INITIALIZE_EVENT_INTERFACE)
 {
 }
 
index a2ca142..749f72e 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef EventNames_h
 #define EventNames_h
 
+#include "EventInterfaces.h"
 #include "ThreadGlobalData.h"
 #include <wtf/text/AtomicString.h>
 
@@ -201,6 +202,10 @@ namespace WebCore {
         #define DOM_EVENT_NAMES_DECLARE(name) AtomicString name##Event;
         DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_DECLARE)
         #undef DOM_EVENT_NAMES_DECLARE
+
+        #define DOM_EVENT_INTERFACE_DECLARE(name) AtomicString interfaceFor##name;
+        DOM_EVENT_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
+        #undef DOM_EVENT_INTERFACE_DECLARE
     };
 
     inline EventNames& eventNames()
index 709b71a..84cd3e7 100644 (file)
@@ -37,8 +37,6 @@ struct HashChangeEventInit : public EventInit {
 
 class HashChangeEvent : public Event {
 public:
-    virtual bool isHashChangeEvent() const { return true; }
-
     static PassRefPtr<HashChangeEvent> create()
     {
         return adoptRef(new HashChangeEvent);
@@ -68,6 +66,8 @@ public:
     const String& oldURL() const { return m_oldURL; }
     const String& newURL() const { return m_newURL; }
 
+    virtual const AtomicString& interfaceName() const { return eventNames().interfaceForHashChangeEvent; }
+
 private:
     HashChangeEvent()
     {
index 1c8c9ea..8f71f95 100644 (file)
@@ -139,6 +139,11 @@ int KeyboardEvent::charCode() const
     return static_cast<int>(text.characterStartingAt(0));
 }
 
+const AtomicString& KeyboardEvent::interfaceName() const
+{
+    return eventNames().interfaceForKeyboardEvent;
+}
+
 bool KeyboardEvent::isKeyboardEvent() const
 {
     return true;
index 7c14055..abefe22 100644 (file)
@@ -87,7 +87,8 @@ namespace WebCore {
 
         int keyCode() const; // key code for keydown and keyup, character for keypress
         int charCode() const; // character code for keypress, 0 for keydown and keyup
-    
+
+        virtual const AtomicString& interfaceName() const;
         virtual bool isKeyboardEvent() const;
         virtual int which() const;
 
index 48219e2..e29d445 100644 (file)
@@ -164,6 +164,11 @@ void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bo
     initMessageEvent(type, canBubble, cancelable, data, origin, lastEventId, source, ports.release());
 }
 
+const AtomicString& MessageEvent::interfaceName() const
+{
+    return eventNames().interfaceForMessageEvent;
+}
+
 bool MessageEvent::isMessageEvent() const
 {
     return true;
index 478a07f..f9fe69c 100644 (file)
@@ -97,6 +97,7 @@ public:
     // FIXME: remove this when we update the ObjC bindings (bug #28774).
     void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow* source, MessagePort*);
 
+    virtual const AtomicString& interfaceName() const;
     virtual bool isMessageEvent() const;
 
     enum DataType {
index 0e71ef5..3e3dd32 100644 (file)
@@ -92,6 +92,11 @@ void MouseEvent::initMouseEvent(const AtomicString& type, bool canBubble, bool c
     // FIXME: m_clipboard is not set to 0 here.
 }
 
+const AtomicString& MouseEvent::interfaceName() const
+{
+    return eventNames().interfaceForMouseEvent;
+}
+
 bool MouseEvent::isMouseEvent() const
 {
     return true;
index 43e7b32..370054f 100644 (file)
@@ -71,6 +71,8 @@ class PlatformMouseEvent;
 
         Clipboard* dataTransfer() const { return isDragEvent() ? m_clipboard.get() : 0; }
 
+        virtual const AtomicString& interfaceName() const;
+
         virtual bool isMouseEvent() const;
         virtual bool isDragEvent() const;
         virtual int which() const;
index 890742f..78b702b 100644 (file)
@@ -23,6 +23,8 @@
 #include "config.h"
 #include "MutationEvent.h"
 
+#include "EventNames.h"
+
 namespace WebCore {
 
 MutationEvent::MutationEvent()
@@ -62,6 +64,11 @@ void MutationEvent::initMutationEvent(const AtomicString& type, bool canBubble,
     m_attrChange = attrChange;
 }
 
+const AtomicString& MutationEvent::interfaceName() const
+{
+    return eventNames().interfaceForMutationEvent;
+}
+
 bool MutationEvent::isMutationEvent() const
 {
     return true;
index f2ba759..c37bb35 100644 (file)
@@ -60,6 +60,7 @@ namespace WebCore {
         String attrName() const { return m_attrName; }
         unsigned short attrChange() const { return m_attrChange; }
 
+        virtual const AtomicString& interfaceName() const;
         virtual bool isMutationEvent() const;
 
     private:
index b05d001..a980731 100644 (file)
@@ -68,6 +68,11 @@ OverflowEvent::OverflowEvent(const AtomicString& type, const OverflowEventInit&
 {
 }
 
+const AtomicString& OverflowEvent::interfaceName() const
+{
+    return eventNames().interfaceForOverflowEvent;
+}
+
 bool OverflowEvent::isOverflowEvent() const
 {
     return true;
index 3e867fd..800ba88 100644 (file)
@@ -65,6 +65,7 @@ public:
     bool horizontalOverflow() const { return m_horizontalOverflow; }
     bool verticalOverflow() const { return m_verticalOverflow; }
 
+    virtual const AtomicString& interfaceName() const;
     virtual bool isOverflowEvent() const;
 
 private:
index fa7d95d..036edb3 100644 (file)
@@ -69,4 +69,9 @@ void PageTransitionEvent::initPageTransitionEvent(const AtomicString& type,
     m_persisted = persisted;
 }
 
+const AtomicString& PageTransitionEvent::interfaceName() const
+{
+    return eventNames().interfaceForPageTransitionEvent;
+}
+
 } // namespace WebCore
index 2ac6858..ab6dd78 100644 (file)
@@ -58,6 +58,7 @@ public:
                                  bool cancelableArg,
                                  bool persisted);
 
+    virtual const AtomicString& interfaceName() const;
     virtual bool isPageTransitionEvent() const { return true; }
 
     bool persisted() const { return m_persisted; }
index 4e027f0..66a7914 100644 (file)
@@ -95,4 +95,9 @@ void PopStateEvent::initPopStateEvent(const AtomicString& type, bool canBubble,
     m_state = state;
 }
 
+const AtomicString& PopStateEvent::interfaceName() const
+{
+    return eventNames().interfaceForPopStateEvent;
+}
+
 } // namespace WebCore
index 030534b..8b3461f 100644 (file)
@@ -47,11 +47,12 @@ public:
     static PassRefPtr<PopStateEvent> create(PassRefPtr<SerializedScriptValue>);
     static PassRefPtr<PopStateEvent> create(const AtomicString&, const PopStateEventInit&);
     void initPopStateEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue&);
-    bool isPopStateEvent() const { return true; }
 
     SerializedScriptValue* serializedState() const { return m_serializedState.get(); }
     ScriptValue state() const { return m_state; }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     PopStateEvent();
     PopStateEvent(const AtomicString&, const PopStateEventInit&);
index 6d8e14e..64f0a7b 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "ProgressEvent.h"
 
+#include "EventNames.h"
+
 namespace WebCore {
 
 ProgressEventInit::ProgressEventInit()
@@ -71,4 +73,9 @@ void ProgressEvent::initProgressEvent(const AtomicString& typeArg, bool canBubbl
     m_total = totalArg;
 }
 
+const AtomicString& ProgressEvent::interfaceName() const
+{
+    return eventNames().interfaceForProgressEvent;
+}
+
 }
index c6c505e..10fe52f 100644 (file)
@@ -60,6 +60,8 @@ public:
     unsigned long long loaded() const { return m_loaded; }
     unsigned long long total() const { return m_total; }
 
+    virtual const AtomicString& interfaceName() const;
+
 protected:
     ProgressEvent();
     ProgressEvent(const AtomicString& type, bool lengthComputable, unsigned long long loaded, unsigned long long total);
index 90f4e7b..e3cac85 100644 (file)
@@ -99,6 +99,11 @@ void TextEvent::initTextEvent(const AtomicString& type, bool canBubble, bool can
     m_data = data;
 }
 
+const AtomicString& TextEvent::interfaceName() const
+{
+    return eventNames().interfaceForTextEvent;
+}
+
 bool TextEvent::isTextEvent() const
 {
     return true;
index cf4c8f2..05eb5e3 100644 (file)
@@ -49,6 +49,7 @@ namespace WebCore {
     
         String data() const { return m_data; }
 
+        virtual const AtomicString& interfaceName() const;
         virtual bool isTextEvent() const;
 
         bool isLineBreak() const { return m_inputType == TextEventInputLineBreak; }
index 638a444..65b4585 100644 (file)
@@ -28,6 +28,8 @@
 #if ENABLE(TOUCH_EVENTS)
 
 #include "TouchEvent.h"
+
+#include "EventNames.h"
 #include "TouchList.h"
 
 namespace WebCore {
@@ -73,6 +75,11 @@ void TouchEvent::initTouchEvent(TouchList* touches, TouchList* targetTouches,
     initCoordinates(IntPoint(clientX, clientY));
 }
 
+const AtomicString& TouchEvent::interfaceName() const
+{
+    return eventNames().interfaceForTouchEvent;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(TOUCH_EVENTS)
index 26fc5fc..a4f0975 100644 (file)
@@ -63,6 +63,8 @@ public:
     TouchList* targetTouches() const { return m_targetTouches.get(); }
     TouchList* changedTouches() const { return m_changedTouches.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     TouchEvent();
     TouchEvent(TouchList* touches, TouchList* targetTouches,
@@ -71,8 +73,6 @@ private:
             int pageY,
             bool ctrlKey, bool altKey, bool shiftKey, bool metaKey);
 
-    virtual bool isTouchEvent() const { return true; }
-
     RefPtr<TouchList> m_touches;
     RefPtr<TouchList> m_targetTouches;
     RefPtr<TouchList> m_changedTouches;
index 335a189..9a08046 100644 (file)
@@ -61,6 +61,11 @@ bool UIEvent::isUIEvent() const
     return true;
 }
 
+const AtomicString& UIEvent::interfaceName() const
+{
+    return eventNames().interfaceForUIEvent;
+}
+
 int UIEvent::keyCode() const
 {
     return 0;
index 9e767de..d1294c9 100644 (file)
@@ -48,7 +48,8 @@ namespace WebCore {
 
         AbstractView* view() const { return m_view.get(); }
         int detail() const { return m_detail; }
-        
+
+        virtual const AtomicString& interfaceName() const;
         virtual bool isUIEvent() const;
 
         virtual int keyCode() const;
index 6c8d121..ee93e40 100644 (file)
@@ -84,4 +84,9 @@ double WebKitAnimationEvent::elapsedTime() const
     return m_elapsedTime;
 }
 
+const AtomicString& WebKitAnimationEvent::interfaceName() const
+{
+    return eventNames().interfaceForWebKitAnimationEvent;
+}
+
 } // namespace WebCore
index d9df2f7..5ed884a 100644 (file)
@@ -63,7 +63,7 @@ public:
     const String& animationName() const;
     double elapsedTime() const;
 
-    virtual bool isWebKitAnimationEvent() const { return true; }
+    virtual const AtomicString& interfaceName() const;
 
 private:
     WebKitAnimationEvent();
index fd962a2..5c44910 100644 (file)
@@ -85,4 +85,9 @@ double WebKitTransitionEvent::elapsedTime() const
     return m_elapsedTime;
 }
 
+const AtomicString& WebKitTransitionEvent::interfaceName() const
+{
+    return eventNames().interfaceForWebKitTransitionEvent;
+}
+
 } // namespace WebCore
index 6809448..719a648 100644 (file)
@@ -63,7 +63,7 @@ public:
     const String& propertyName() const;
     double elapsedTime() const;
 
-    virtual bool isWebKitTransitionEvent() const { return true; }
+    virtual const AtomicString& interfaceName() const;
 
 private:
     WebKitTransitionEvent();
index b8a5e0b..a936ed6 100644 (file)
@@ -84,6 +84,11 @@ void WheelEvent::initWebKitWheelEvent(int rawDeltaX, int rawDeltaY, PassRefPtr<A
                    ctrlKey, altKey, shiftKey, metaKey);
 }
 
+const AtomicString& WheelEvent::interfaceName() const
+{
+    return eventNames().interfaceForWheelEvent;
+}
+
 bool WheelEvent::isWheelEvent() const
 {
     return true;
index 9cbf7c6..1a5c84e 100644 (file)
@@ -69,6 +69,8 @@ namespace WebCore {
         // Needed for Objective-C legacy support
         bool isHorizontal() const { return m_wheelDelta.x(); }
 
+        virtual const AtomicString& interfaceName() const;
+
     private:
         WheelEvent();
         WheelEvent(const FloatPoint& wheelTicks, const FloatPoint& rawDelta,
index 1d9293a..4766d9f 100644 (file)
@@ -40,6 +40,9 @@ use IO::File;
 use InFilesParser;
 
 sub readEvents($);
+sub printFactoryFile($);
+sub printMacroFile($);
+sub printHeadersFile($);
 
 my $eventsFile = "";
 my $outputDir = ".";
@@ -58,7 +61,9 @@ die "You must specify --events <file>" unless length($eventsFile);
 
 my %events = %{readEvents($eventsFile)};
 
-printCppFile("$outputDir/EventFactory.cpp");
+printFactoryFile("$outputDir/EventFactory.cpp");
+printMacroFile("$outputDir/EventInterfaces.h");
+printHeadersFile("$outputDir/EventHeaders.h");
 
 sub defaultEventPropertyHash
 {
@@ -119,51 +124,139 @@ sub interfaceForEvent($)
     return $interfaceName;
 }
 
-sub printCppFile
+sub printFactoryFile($)
 {
-    my $cppPath = shift;
+    my $path = shift;
     my $F;
 
-    open F, ">$cppPath";
+    open F, ">$path";
 
     printLicenseHeader($F);
 
     print F "#include \"config.h\"\n";
-    print F "#include \"EventFactory.h\"\n\n";
-
-    my %includedInterfaces = ();
+    print F "#include \"EventFactory.h\"\n";
+    print F "\n";
+    print F "#include \"EventHeaders.h\"\n";
+    print F "\n";
+    print F "namespace WebCore {\n";
+    print F "\n";
+    print F "PassRefPtr<Event> EventFactory::create(const String& eventType)\n";
+    print F "{\n";
 
     for my $eventName (sort keys %parsedEvents) {
         my $conditional = $parsedEvents{$eventName}{"conditional"};
         my $interfaceName = interfaceForEvent($eventName);
 
-        next if defined($includedInterfaces{$interfaceName});
-        $includedInterfaces{$interfaceName} = 1;
-
         print F "#if ENABLE($conditional)\n" if $conditional;
-        print F "#include \"$interfaceName.h\"\n";
+        print F "    if (eventType == \"$eventName\")\n";
+        print F "        return ${interfaceName}::create();\n";
         print F "#endif\n" if $conditional;
     }
 
-    print F "\nnamespace WebCore {\n\n";
+    print F "    return 0;\n";
+    print F "}\n";
+    print F "\n";
+    print F "} // namespace WebCore\n";
+    close F;
+}
 
-    print F "PassRefPtr<Event> EventFactory::create(const String& eventType)\n";
-    print F "{\n";
+sub printMacroFile($)
+{
+    my $path = shift;
+    my $F;
+
+    open F, ">$path";
+
+    printLicenseHeader($F);
+
+    print F "#ifndef EventInterfaces_h\n";
+    print F "#define EventInterfaces_h\n";
+    print F "\n";
+
+    my %unconditionalInterfaces = ();
+    my %interfacesByConditional = ();
 
     for my $eventName (sort keys %parsedEvents) {
         my $conditional = $parsedEvents{$eventName}{"conditional"};
         my $interfaceName = interfaceForEvent($eventName);
 
+        if ($conditional) {
+            if (!defined($interfacesByConditional{$conditional})) {
+                $interfacesByConditional{$conditional} = ();
+            }
+            $interfacesByConditional{$conditional}{$interfaceName} = 1;
+        } else {
+            $unconditionalInterfaces{$interfaceName} = 1
+        }
+    }
+
+    for my $conditional (sort keys %interfacesByConditional) {
+        print F "#if ENABLE($conditional)\n";
+        print F "#define DOM_EVENT_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
+
+        for my $interface (sort keys %{ $interfacesByConditional{$conditional} }) {
+            next if defined($unconditionalInterfaces{$interface});
+            print F "    macro($interface) \\\n";
+        }
+
+        print F "// End of DOM_EVENT_INTERFACES_FOR_EACH_$conditional\n";
+        print F "#else\n";
+        print F "#define DOM_EVENT_INTERFACES_FOR_EACH_$conditional(macro)\n";
+        print F "#endif\n";
+        print F "\n";
+    }
+
+    print F "#define DOM_EVENT_INTERFACES_FOR_EACH(macro) \\\n";
+    print F "    \\\n";
+    for my $interface (sort keys %unconditionalInterfaces) {
+            print F "    macro($interface) \\\n";
+    }
+    print F "    \\\n";
+    for my $conditional (sort keys %interfacesByConditional) {
+        print F "    DOM_EVENT_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
+    }
+
+    print F "\n";
+    print F "#endif // EventInterfaces_h\n";
+
+    close F;
+}
+
+sub printHeadersFile($)
+{
+    my $path = shift;
+    my $F;
+
+    open F, ">$path";
+
+    printLicenseHeader($F);
+
+    print F "#ifndef EventHeaders_h\n";
+    print F "#define EventHeaders_h\n";
+    print F "\n";
+
+    my %includedInterfaces = ();
+
+    for my $eventName (sort keys %parsedEvents) {
+        my $conditional = $parsedEvents{$eventName}{"conditional"};
+        my $interfaceName = interfaceForEvent($eventName);
+
+        next if defined($includedInterfaces{$interfaceName});
+        $includedInterfaces{$interfaceName} = 1;
+
         print F "#if ENABLE($conditional)\n" if $conditional;
-        print F "    if (eventType == \"$eventName\")\n";
-        print F "        return ${interfaceName}::create();\n";
+        print F "#include \"$interfaceName.h\"\n";
+        print F "#if USE(JSC)\n";
+        print F "#include \"JS$interfaceName.h\"\n";
+        print F "#elif USE(V8)\n";
+        print F "#include \"V8$interfaceName.h\"\n";
+        print F "#endif\n";
         print F "#endif\n" if $conditional;
     }
 
-    print F "    return 0;\n";
-    print F "}\n";
+    print F "\n";
+    print F "#endif // EventHeaders_h\n";
 
-    print F "\n} // namespace WebCore\n";
     close F;
 }
 
index b09de63..6211738 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebGLContextEvent.h"
 
+#include "EventNames.h"
+
 namespace WebCore {
 
 WebGLContextEvent::WebGLContextEvent()
@@ -51,9 +53,9 @@ void WebGLContextEvent::initEvent(const AtomicString& type, bool canBubble, bool
     m_statusMessage = statusMessage;
 }
 
-bool WebGLContextEvent::isWebGLContextEvent() const
+const AtomicString& WebGLContextEvent::interfaceName() const
 {
-    return true;
+    return eventNames().interfaceForWebGLContextEvent;
 }
 
 } // namespace WebCore
index ac82d5e..bdf3225 100644 (file)
@@ -44,10 +44,10 @@ public:
 
     void initEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& statusMessage);
 
-    virtual bool isWebGLContextEvent() const;
-
     const String& statusMessage() const { return m_statusMessage; }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     WebGLContextEvent();
     WebGLContextEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& statusMessage);
index 8d85f71..4370249 100644 (file)
@@ -102,7 +102,7 @@ void InspectorDOMStorageResource::startReportingChangesToFrontend()
 void InspectorDOMStorageResource::handleEvent(ScriptExecutionContext*, Event* event)
 {
     ASSERT(m_frontend);
-    if (event->type() != eventNames().storageEvent || !event->isStorageEvent())
+    if (event->type() != eventNames().storageEvent || event->interfaceName() != eventNames().interfaceForStorageEvent)
         return;
 
     StorageEvent* storageEvent = static_cast<StorageEvent*>(event);
index 7c00212..b188c73 100644 (file)
@@ -72,6 +72,11 @@ PassRefPtr<MediaStream> MediaStreamEvent::stream() const
     return m_stream;
 }
 
+const AtomicString& MediaStreamEvent::interfaceName() const
+{
+    return eventNames().interfaceForMediaStreamEvent;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(MEDIA_STREAM)
index e4e25f5..b972e46 100644 (file)
@@ -43,11 +43,10 @@ public:
 
     void initMediaStreamEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<MediaStream>);
 
-    // From EventTarget.
-    virtual bool isMediaStreamEvent() const { return true; }
-
     PassRefPtr<MediaStream> stream() const;
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     MediaStreamEvent();
     MediaStreamEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<MediaStream>);
index 4abe8b1..23e34bf 100644 (file)
  */
 
 #include "config.h"
-#include "SpeechInputEvent.h"
 
 #if ENABLE(INPUT_SPEECH)
 
+#include "SpeechInputEvent.h"
+
+#include "EventNames.h"
+
 namespace WebCore {
 
 PassRefPtr<SpeechInputEvent> SpeechInputEvent::create()
@@ -59,6 +62,11 @@ SpeechInputEvent::~SpeechInputEvent()
 {
 }
 
+const AtomicString& SpeechInputEvent::interfaceName() const
+{
+    return eventNames().interfaceForSpeechInputEvent;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INPUT_SPEECH)
index b4c447e..67b9cce 100644 (file)
@@ -43,10 +43,10 @@ public:
     static PassRefPtr<SpeechInputEvent> create(const AtomicString& eventType, const SpeechInputResultArray& results);
     ~SpeechInputEvent();
 
-    virtual bool isSpeechInputEvent() const { return true; }
-
     SpeechInputResultList* results() const { return m_results.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     SpeechInputEvent();
     SpeechInputEvent(const AtomicString& eventType, const SpeechInputResultArray& results);
index 5fd9d8b..a299d74 100644 (file)
@@ -53,6 +53,11 @@ String IDBVersionChangeEvent::version()
     return m_version;
 }
 
+const AtomicString& IDBVersionChangeEvent::interfaceName() const
+{
+    return eventNames().interfaceForIDBVersionChangeEvent;
+}
+
 } // namespace WebCore
 
 #endif
index efd360f..dae9f23 100644 (file)
@@ -39,14 +39,13 @@ class IDBAny;
 
 class IDBVersionChangeEvent : public Event {
 public:
-    static PassRefPtr<IDBVersionChangeEvent> create(const String& version, const AtomicString& eventType);
-    // FIXME: Need to allow creation of these events from JS.
+    static PassRefPtr<IDBVersionChangeEvent> create(const String& version = String(), const AtomicString& eventType = AtomicString());
     virtual ~IDBVersionChangeEvent();
 
-    virtual bool isIDBVersionChangeEvent() const { return true; }
-
     virtual String version();
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     IDBVersionChangeEvent(const String& version, const AtomicString& eventType);
 
index cb7a364..e129746 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "StorageEvent.h"
 
+#include "EventNames.h"
 #include "Storage.h"
 
 namespace WebCore {
@@ -72,4 +73,9 @@ void StorageEvent::initStorageEvent(const AtomicString& type, bool canBubble, bo
     m_storageArea = storageArea;
 }
 
+const AtomicString& StorageEvent::interfaceName() const
+{
+    return eventNames().interfaceForStorageEvent;
+}
+
 } // namespace WebCore
index 5dd6a24..248b777 100644 (file)
@@ -50,7 +50,7 @@ namespace WebCore {
         // Needed once we support init<blank>EventNS
         // void initStorageEventNS(in DOMString namespaceURI, in DOMString typeArg, in boolean canBubbleArg, in boolean cancelableArg, in DOMString keyArg, in DOMString oldValueArg, in DOMString newValueArg, in DOMString urlArg, Storage storageAreaArg);
 
-        virtual bool isStorageEvent() const { return true; }
+        virtual const AtomicString& interfaceName() const;
 
     private:
         StorageEvent();
index 784c32b..b6320b8 100644 (file)
  */
 
 #include "config.h"
+
 #if ENABLE(SVG)
+
 #include "SVGZoomEvent.h"
+#include "EventNames.h"
 
 namespace WebCore {
 
@@ -71,8 +74,11 @@ bool SVGZoomEvent::isSVGZoomEvent() const
     return true;
 }
 
+const AtomicString& SVGZoomEvent::interfaceName() const
+{
+    return eventNames().interfaceForSVGZoomEvent;
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SVG)
-
-// vim:ts=4:noet
index d8d77ad..1b6ed71 100644 (file)
@@ -45,6 +45,8 @@ public:
 
     FloatPoint newTranslate() const;
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     SVGZoomEvent();
 
index e94c9d0..fd5431c 100644 (file)
@@ -58,9 +58,9 @@ AudioProcessingEvent::~AudioProcessingEvent()
 {
 }
 
-bool AudioProcessingEvent::isAudioProcessingEvent() const
+const AtomicString& AudioProcessingEvent::interfaceName() const
 {
-    return true;
+    return eventNames().interfaceForAudioProcessingEvent;
 }
 
 } // namespace WebCore
index 297c1b6..3a4a144 100644 (file)
@@ -41,11 +41,11 @@ public:
     
     virtual ~AudioProcessingEvent();
 
-    virtual bool isAudioProcessingEvent() const;
-
     AudioBuffer* inputBuffer() { return m_inputBuffer.get(); }
     AudioBuffer* outputBuffer() { return m_outputBuffer.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     AudioProcessingEvent();
     AudioProcessingEvent(PassRefPtr<AudioBuffer> inputBuffer, PassRefPtr<AudioBuffer> outputBuffer);
index 858d0c6..7f8243f 100644 (file)
@@ -58,9 +58,9 @@ OfflineAudioCompletionEvent::~OfflineAudioCompletionEvent()
 {
 }
 
-bool OfflineAudioCompletionEvent::isOfflineAudioCompletionEvent() const
+const AtomicString& OfflineAudioCompletionEvent::interfaceName() const
 {
-    return true;
+    return eventNames().interfaceForOfflineAudioCompletionEvent;
 }
 
 } // namespace WebCore
index 6c0a262..409aeaf 100644 (file)
@@ -41,10 +41,10 @@ public:
     
     virtual ~OfflineAudioCompletionEvent();
 
-    virtual bool isOfflineAudioCompletionEvent() const;
-
     AudioBuffer* renderedBuffer() { return m_renderedBuffer.get(); }
 
+    virtual const AtomicString& interfaceName() const;
+
 private:
     OfflineAudioCompletionEvent();
     OfflineAudioCompletionEvent(PassRefPtr<AudioBuffer> renderedBuffer);
index 5015423..3334330 100644 (file)
@@ -50,8 +50,6 @@ struct CloseEventInit : public EventInit {
 
 class CloseEvent : public Event {
 public:
-    virtual bool isCloseEvent() const { return true; }
-
     static PassRefPtr<CloseEvent> create()
     {
         return adoptRef(new CloseEvent());
@@ -78,6 +76,8 @@ public:
     unsigned short code() const { return m_code; }
     String reason() const { return m_reason; }
 
+    virtual const AtomicString& interfaceName() const { return eventNames().interfaceForCloseEvent; }
+
 private:
     CloseEvent()
         : Event(eventNames().closeEvent, false, false)
index 009f1c0..d887a26 100644 (file)
@@ -27,6 +27,7 @@
 #ifndef XMLHttpRequestProgressEvent_h
 #define XMLHttpRequestProgressEvent_h
 
+#include "EventNames.h"
 #include "ProgressEvent.h"
 
 namespace WebCore {
@@ -46,9 +47,9 @@ public:
     unsigned long long position() const { return loaded(); }
     unsigned long long totalSize() const { return total(); }
 
-private:
-    virtual bool isXMLHttpRequestProgressEvent() const { return true; }
+    virtual const AtomicString& interfaceName() const { return eventNames().interfaceForXMLHttpRequestProgressEvent; }
 
+private:
     XMLHttpRequestProgressEvent() { }
     XMLHttpRequestProgressEvent(const AtomicString& type, bool lengthComputable, unsigned long long loaded, unsigned long long total)
         : ProgressEvent(type, lengthComputable, loaded, total)
index 48e5268..ccb6751 100644 (file)
@@ -32,6 +32,7 @@
 #include "WebDOMEvent.h"
 
 #include "Event.h"
+#include "EventNames.h"
 #include "Node.h"
 #include <wtf/PassRefPtr.h>
 
@@ -183,7 +184,7 @@ bool WebDOMEvent::isPageTransitionEvent() const
 bool WebDOMEvent::isPopStateEvent() const
 {
     ASSERT(m_private);
-    return m_private->isPopStateEvent();
+    return m_private->interfaceName() == WebCore::eventNames().interfaceForPopStateEvent;
 }
 
 bool WebDOMEvent::isProgressEvent() const
@@ -195,19 +196,19 @@ bool WebDOMEvent::isProgressEvent() const
 bool WebDOMEvent::isXMLHttpRequestProgressEvent() const
 {
     ASSERT(m_private);
-    return m_private->isXMLHttpRequestProgressEvent();
+    return m_private->interfaceName() == WebCore::eventNames().interfaceForXMLHttpRequestProgressEvent;
 }
 
 bool WebDOMEvent::isWebKitAnimationEvent() const
 {
     ASSERT(m_private);
-    return m_private->isWebKitAnimationEvent();
+    return m_private->interfaceName() == WebCore::eventNames().interfaceForWebKitAnimationEvent;
 }
 
 bool WebDOMEvent::isWebKitTransitionEvent() const
 {
     ASSERT(m_private);
-    return m_private->isWebKitTransitionEvent();
+    return m_private->interfaceName() == WebCore::eventNames().interfaceForWebKitTransitionEvent;
 }
 
 bool WebDOMEvent::isBeforeLoadEvent() const