Commit 090fa4b0 authored by abarth@webkit.org's avatar 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):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@98044 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a5f4996c
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.
......
......@@ -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 \
......
......@@ -707,6 +707,8 @@
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventFactory.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventHeaders.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventInterfaces.h',
],
'action': [
'python',
......
......@@ -409,6 +409,8 @@
'<(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',
......
......@@ -545,6 +545,14 @@
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventFactory.cpp"
>
</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"
>
......@@ -3213,6 +3213,8 @@
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 */; };
......@@ -10401,6 +10403,8 @@
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>"; };
......@@ -15276,6 +15280,8 @@
6565814709D13043000E61D7 /* CSSValueKeywords.gperf */,
6565814809D13043000E61D7 /* CSSValueKeywords.h */,
9766504E144FBFFE00F6BB51 /* EventFactory.cpp */,
970B72A5145008EB00F00A37 /* EventHeaders.h */,
970B7289144FFAC600F00A37 /* EventInterfaces.h */,
A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */,
A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */,
A8BC04911214F69600B5F122 /* HTMLEntityTable.cpp */,
......@@ -24696,6 +24702,8 @@
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;
};
......@@ -30,92 +30,14 @@
#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
......@@ -33,50 +33,13 @@
#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
......@@ -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()
{
......
......@@ -39,4 +39,10 @@ BeforeTextInsertedEvent::~BeforeTextInsertedEvent()
{
}
const AtomicString& BeforeTextInsertedEvent::interfaceName() const
{
// Notice that there is no BeforeTextInsertedEvent.idl.
return eventNames().interfaceForEvent;
}
}
......@@ -39,8 +39,9 @@ public:
return adoptRef(new BeforeTextInsertedEvent(text));
}