Commit 8233b467 authored by abarth@webkit.org's avatar abarth@webkit.org

EventTarget.h shouldn't need to know about every feature and ifdef

https://bugs.webkit.org/show_bug.cgi?id=70659

Reviewed by Darin Adler.

Source/WebCore: 

This patch follows the approach of Event.h and introduces an
interfaceName virtual function that returns the name of the DOM
interface for the concrete type of the object.  This function lets us
remove a large number of fake dynamic casts.

* CMakeLists.txt:
* CodeGenerators.pri:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gyp/WebCore.gyp:
* WebCore.gyp/scripts/action_makenames.py:
    - Teach action_makenames how to handle the new "in" file.
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventTarget.cpp:
(WebCore::toJS):
    - Use the new autogenerated macro to remove a large amount of
      feature-specific code.
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::initScript):
* bindings/objc/DOM.mm:
(kit):
    - The SVGElementInstance branch was never taken previously because
      SVGElementInstance::toNode returns a non-NULL value. This code
      was introduced in http://trac.webkit.org/changeset/42618 and
      doesn't appear to have ever worked as the author intended.
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::convertEventTargetToV8Object):
    - Use the new autogenerated macro to remove a large amount of
      feature-specific code.
* dom/EventNames.cpp:
(WebCore::EventNames::EventNames):
* dom/EventNames.h:
* dom/EventTarget.cpp:
* dom/EventTarget.h:
* dom/EventTargetFactory.in: Added.
    - Add a new "in" file that lists all the EventTargets.
* dom/LocalMediaStream.cpp:
(WebCore::LocalMediaStream::interfaceName):
* dom/LocalMediaStream.h:
* dom/MediaStream.cpp:
(WebCore::MediaStream::interfaceName):
* dom/MediaStream.h:
* dom/MessagePort.cpp:
(WebCore::MessagePort::interfaceName):
* dom/MessagePort.h:
* dom/Node.cpp:
(WebCore::Node::toNode):
(WebCore::Node::interfaceName):
* dom/Node.h:
* dom/make_event_factory.pl:
    - Generalize make_event_factory.pl to be able to generate
      interfaces for different namespaces.
* fileapi/FileReader.cpp:
(WebCore::FileReader::interfaceName):
* fileapi/FileReader.h:
* fileapi/FileWriter.cpp:
(WebCore::FileWriter::interfaceName):
* fileapi/FileWriter.h:
* loader/appcache/DOMApplicationCache.cpp:
(WebCore::DOMApplicationCache::interfaceName):
* loader/appcache/DOMApplicationCache.h:
* notifications/Notification.cpp:
(WebCore::Notification::interfaceName):
* notifications/Notification.h:
(WebCore::Notification::scriptExecutionContext):
* p2p/PeerConnection.cpp:
(WebCore::PeerConnection::interfaceName):
* p2p/PeerConnection.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::interfaceName):
(WebCore::DOMWindow::toDOMWindow):
* page/DOMWindow.h:
* page/EventSource.cpp:
(WebCore::EventSource::interfaceName):
* page/EventSource.h:
* storage/IDBDatabase.cpp:
(WebCore::IDBDatabase::interfaceName):
* storage/IDBDatabase.h:
* storage/IDBRequest.cpp:
(WebCore::IDBRequest::interfaceName):
* storage/IDBRequest.h:
* storage/IDBTransaction.cpp:
(WebCore::IDBTransaction::interfaceName):
* storage/IDBTransaction.h:
* storage/IDBVersionChangeRequest.cpp:
(WebCore::IDBVersionChangeRequest::interfaceName):
* storage/IDBVersionChangeRequest.h:
* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::interfaceName):
* svg/SVGElementInstance.h:
(WebCore::SVGElementInstance::toNode):
* webaudio/AudioContext.cpp:
(WebCore::AudioContext::interfaceName):
(WebCore::AudioContext::scriptExecutionContext):
* webaudio/AudioContext.h:
* webaudio/JavaScriptAudioNode.cpp:
(WebCore::JavaScriptAudioNode::interfaceName):
* webaudio/JavaScriptAudioNode.h:
* websockets/WebSocket.cpp:
(WebCore::WebSocket::interfaceName):
* websockets/WebSocket.h:
* workers/DedicatedWorkerContext.cpp:
(WebCore::DedicatedWorkerContext::interfaceName):
* workers/DedicatedWorkerContext.h:
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerConnectTask::performTask):
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::interfaceName):
* workers/SharedWorker.h:
* workers/SharedWorkerContext.cpp:
(WebCore::SharedWorkerContext::interfaceName):
* workers/SharedWorkerContext.h:
* workers/Worker.cpp:
(WebCore::Worker::interfaceName):
* workers/Worker.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::interfaceName):
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequestUpload.cpp:
(WebCore::XMLHttpRequestUpload::interfaceName):
* xml/XMLHttpRequestUpload.h:

Source/WebKit/chromium: 

This cast isn't needed because dispatchEvent is a virtual function.

* src/WebSharedWorkerImpl.cpp:
(WebKit::WebSharedWorkerImpl::connectTask):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@98388 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d77aa863
......@@ -2313,10 +2313,14 @@ GENERATE_DOM_NAMES(HTML ${WEBCORE_DIR}/html/HTMLAttributeNames.in ${WEBCORE_DIR}
LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/HTMLNames.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/HTMLElementFactory.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/JSHTMLElementWrapperFactory.cpp)
GENERATE_EVENT_FACTORY(${WEBCORE_DIR}/dom/EventFactory.in)
GENERATE_EVENT_FACTORY(${WEBCORE_DIR}/dom/EventFactory.in EventFactory.cpp)
LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/EventFactory.cpp)
GENERATE_EVENT_FACTORY(${WEBCORE_DIR}/dom/EventTargetFactory.in EventTargetInterfaces.h)
ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/dom/EventNames.cpp EventTargetInterfaces.h)
GENERATE_FONT_NAMES(${WEBCORE_DIR}/css/WebKitFontFamilyNames.in)
LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitFontFamilyNames.cpp)
......
2011-10-25 Adam Barth <abarth@webkit.org>
EventTarget.h shouldn't need to know about every feature and ifdef
https://bugs.webkit.org/show_bug.cgi?id=70659
Reviewed by Darin Adler.
This patch follows the approach of Event.h and introduces an
interfaceName virtual function that returns the name of the DOM
interface for the concrete type of the object. This function lets us
remove a large number of fake dynamic casts.
* CMakeLists.txt:
* CodeGenerators.pri:
* DerivedSources.make:
* GNUmakefile.am:
* WebCore.gyp/WebCore.gyp:
* WebCore.gyp/scripts/action_makenames.py:
- Teach action_makenames how to handle the new "in" file.
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventTarget.cpp:
(WebCore::toJS):
- Use the new autogenerated macro to remove a large amount of
feature-specific code.
* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::initScript):
* bindings/objc/DOM.mm:
(kit):
- The SVGElementInstance branch was never taken previously because
SVGElementInstance::toNode returns a non-NULL value. This code
was introduced in http://trac.webkit.org/changeset/42618 and
doesn't appear to have ever worked as the author intended.
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::convertEventTargetToV8Object):
- Use the new autogenerated macro to remove a large amount of
feature-specific code.
* dom/EventNames.cpp:
(WebCore::EventNames::EventNames):
* dom/EventNames.h:
* dom/EventTarget.cpp:
* dom/EventTarget.h:
* dom/EventTargetFactory.in: Added.
- Add a new "in" file that lists all the EventTargets.
* dom/LocalMediaStream.cpp:
(WebCore::LocalMediaStream::interfaceName):
* dom/LocalMediaStream.h:
* dom/MediaStream.cpp:
(WebCore::MediaStream::interfaceName):
* dom/MediaStream.h:
* dom/MessagePort.cpp:
(WebCore::MessagePort::interfaceName):
* dom/MessagePort.h:
* dom/Node.cpp:
(WebCore::Node::toNode):
(WebCore::Node::interfaceName):
* dom/Node.h:
* dom/make_event_factory.pl:
- Generalize make_event_factory.pl to be able to generate
interfaces for different namespaces.
* fileapi/FileReader.cpp:
(WebCore::FileReader::interfaceName):
* fileapi/FileReader.h:
* fileapi/FileWriter.cpp:
(WebCore::FileWriter::interfaceName):
* fileapi/FileWriter.h:
* loader/appcache/DOMApplicationCache.cpp:
(WebCore::DOMApplicationCache::interfaceName):
* loader/appcache/DOMApplicationCache.h:
* notifications/Notification.cpp:
(WebCore::Notification::interfaceName):
* notifications/Notification.h:
(WebCore::Notification::scriptExecutionContext):
* p2p/PeerConnection.cpp:
(WebCore::PeerConnection::interfaceName):
* p2p/PeerConnection.h:
* page/DOMWindow.cpp:
(WebCore::DOMWindow::interfaceName):
(WebCore::DOMWindow::toDOMWindow):
* page/DOMWindow.h:
* page/EventSource.cpp:
(WebCore::EventSource::interfaceName):
* page/EventSource.h:
* storage/IDBDatabase.cpp:
(WebCore::IDBDatabase::interfaceName):
* storage/IDBDatabase.h:
* storage/IDBRequest.cpp:
(WebCore::IDBRequest::interfaceName):
* storage/IDBRequest.h:
* storage/IDBTransaction.cpp:
(WebCore::IDBTransaction::interfaceName):
* storage/IDBTransaction.h:
* storage/IDBVersionChangeRequest.cpp:
(WebCore::IDBVersionChangeRequest::interfaceName):
* storage/IDBVersionChangeRequest.h:
* svg/SVGElementInstance.cpp:
(WebCore::SVGElementInstance::interfaceName):
* svg/SVGElementInstance.h:
(WebCore::SVGElementInstance::toNode):
* webaudio/AudioContext.cpp:
(WebCore::AudioContext::interfaceName):
(WebCore::AudioContext::scriptExecutionContext):
* webaudio/AudioContext.h:
* webaudio/JavaScriptAudioNode.cpp:
(WebCore::JavaScriptAudioNode::interfaceName):
* webaudio/JavaScriptAudioNode.h:
* websockets/WebSocket.cpp:
(WebCore::WebSocket::interfaceName):
* websockets/WebSocket.h:
* workers/DedicatedWorkerContext.cpp:
(WebCore::DedicatedWorkerContext::interfaceName):
* workers/DedicatedWorkerContext.h:
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerConnectTask::performTask):
* workers/SharedWorker.cpp:
(WebCore::SharedWorker::interfaceName):
* workers/SharedWorker.h:
* workers/SharedWorkerContext.cpp:
(WebCore::SharedWorkerContext::interfaceName):
* workers/SharedWorkerContext.h:
* workers/Worker.cpp:
(WebCore::Worker::interfaceName):
* workers/Worker.h:
* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::interfaceName):
* xml/XMLHttpRequest.h:
* xml/XMLHttpRequestUpload.cpp:
(WebCore::XMLHttpRequestUpload::interfaceName):
* xml/XMLHttpRequestUpload.h:
2011-10-25 Pavel Podivilov <podivilov@chromium.org>
Fix several minor problems in idls.
......
......@@ -34,6 +34,8 @@ HTML_ENTITIES = $$PWD/html/parser/HTMLEntityNames.in
EVENT_FACTORY = $$PWD/dom/EventFactory.in
EVENT_TARGET_FACTORY = $$PWD/dom/EventTargetFactory.in
COLORDATA_GPERF = $$PWD/platform/ColorData.gperf
WALDOCSSPROPS = $$PWD/css/CSSPropertyNames.in
......@@ -760,6 +762,14 @@ eventfactory.commands = perl -I$$PWD/bindings/scripts $$eventfactory.wkScript --
eventfactory.depends = $$PWD/dom/make_event_factory.pl $$EVENT_FACTORY
addExtraCompiler(eventfactory)
# GENERATOR 5-F:
eventtargetfactory.output = $${WC_GENERATED_SOURCES_DIR}/EventTargetInterfaces.h
eventtargetfactory.input = EVENT_TARGET_FACTORY
eventtargetfactory.wkScript = $$PWD/dom/make_event_factory.pl
eventtargetfactory.commands = perl -I$$PWD/bindings/scripts $$eventfactory.wkScript --events $$EVENT_TARGET_FACTORY --outputDir $$WC_GENERATED_SOURCES_DIR
eventtargetfactory.depends = $$PWD/dom/make_event_factory.pl $$EVENT_TARGET_FACTORY
addExtraCompiler(eventtargetfactory)
# GENERATOR 8-A:
entities.output = $${WC_GENERATED_SOURCES_DIR}/HTMLEntityTable.cpp
entities.input = HTML_ENTITIES
......
......@@ -587,6 +587,7 @@ all : \
CSSValueKeywords.h \
ColorData.cpp \
EventFactory.cpp \
EventTargetInterfaces.h \
HTMLElementFactory.cpp \
HTMLEntityTable.cpp \
HTMLNames.cpp \
......@@ -847,11 +848,14 @@ XLinkNames.cpp : dom/make_names.pl svg/xlinkattrs.in
# --------
# Register event constructors
# Register event constructors and targets
EventFactory.cpp : dom/make_event_factory.pl dom/EventFactory.in
EventFactory.cpp EventHeaders.h EventInterfaces.h : dom/make_event_factory.pl dom/EventFactory.in
perl -I $(WebCore)/bindings/scripts $< --events $(WebCore)/dom/EventFactory.in
EventTargetHeaders.h EventTargetInterfaces.h : dom/make_event_factory.pl dom/EventTargetFactory.in
perl -I $(WebCore)/bindings/scripts $< --events $(WebCore)/dom/EventTargetFactory.in
# --------
# MathML tag and attribute names, and element factory
......
......@@ -684,6 +684,9 @@ DerivedSources/WebCore/XMLNames.cpp DerivedSources/WebCore/XMLNames.h: $(WebCore
DerivedSources/WebCore/EventFactory.cpp DerivedSources/WebCore/EventHeaders.h DerivedSources/WebCore/EventInterfaces.h: $(WebCore)/dom/make_event_factory.pl $(WebCore)/dom/EventFactory.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --events $(WebCore)/dom/EventFactory.in --outputDir "$(GENSOURCES_WEBCORE)"
DerivedSources/WebCore/EventTargetHeaders.h DerivedSources/WebCore/EventTargetInterfaces.h: $(WebCore)/dom/make_event_factory.pl $(WebCore)/dom/EventTargetFactory.in
$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --events $(WebCore)/dom/EventTargetFactory.in --outputDir "$(GENSOURCES_WEBCORE)"
# All Web Inspector generated files are created with this one call to CodeGeneratorInspector.py
DerivedSources/WebCore/InspectorProtocolVersion.h : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/generate-inspector-protocol-version
$(PYTHON) $(WebCore)/inspector/generate-inspector-protocol-version -o $(GENSOURCES_WEBCORE)/InspectorProtocolVersion.h $(WebCore)/inspector/Inspector.json
......
......@@ -12,6 +12,8 @@ webcore_built_sources += \
DerivedSources/WebCore/EventFactory.cpp \
DerivedSources/WebCore/EventHeaders.h \
DerivedSources/WebCore/EventInterfaces.h \
DerivedSources/WebCore/EventTargetHeaders.h \
DerivedSources/WebCore/EventTargetInterfaces.h \
DerivedSources/WebCore/HTMLElementFactory.cpp \
DerivedSources/WebCore/HTMLElementFactory.h \
DerivedSources/WebCore/HTMLEntityTable.cpp \
......
......@@ -677,6 +677,24 @@
'<@(_inputs)',
],
},
{
'action_name': 'EventTargetFactory',
'inputs': [
'../dom/make_event_factory.pl',
'../dom/EventTargetFactory.in',
],
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetHeaders.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetInterfaces.h',
],
'action': [
'python',
'scripts/action_makenames.py',
'<@(_outputs)',
'--',
'<@(_inputs)',
],
},
{
'action_name': 'MathMLNames',
'inputs': [
......@@ -994,6 +1012,10 @@
'<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLElementFactory.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/HTMLNames.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventFactory.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventHeaders.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventInterfaces.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetHeaders.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetInterfaces.h',
'<(SHARED_INTERMEDIATE_DIR)/webkit/UserAgentStyleSheetsData.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/XLinkNames.cpp',
......
......@@ -129,7 +129,7 @@ def main(args):
or inputBasename.endswith('attrs.in'):
assert attrInput == None
attrInput = inputAbsPosix
elif inputBasename.endswith('EventFactory.in'):
elif inputBasename.endswith('EventFactory.in') or inputBasename.endswith('EventTargetFactory.in'):
eventsInput = inputAbsPosix
elif inputBasename.endswith('Names.in'):
options.append(inputAbsPosix)
......
......@@ -7053,6 +7053,10 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/DebuggerScriptSource.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/DocTypeStrings.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventFactory.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventHeaders.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventInterfaces.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventTargetHeaders.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventTargetInterfaces.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLElementFactory.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLElementFactory.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLEntityTable.cpp',
......
......@@ -553,6 +553,14 @@
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventInterfaces.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventTargetHeaders.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\EventTargetInterfaces.h"
>
</File>
<File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\HTMLElementFactory.h"
>
......@@ -3270,6 +3270,8 @@
978AD67514130A8D00C7CAE3 /* HTMLSpanElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 978AD67214130A8D00C7CAE3 /* HTMLSpanElement.h */; };
979F43D31075E44A0000F83B /* NavigationScheduler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 979F43D11075E44A0000F83B /* NavigationScheduler.cpp */; };
979F43D41075E44A0000F83B /* NavigationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 979F43D21075E44A0000F83B /* NavigationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */; };
97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */; settings = {ATTRIBUTES = (Private, ); }; };
97B1F02E13B025CA00F5103F /* SharedBufferChunkReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37569E0013AF172C00CDBA8E /* SharedBufferChunkReader.cpp */; };
97B1F02F13B025D200F5103F /* SharedBufferChunkReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 37569E0213AF172C00CDBA8E /* SharedBufferChunkReader.h */; };
97BC84831236FD93000C6161 /* TextDocumentParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 97BC84811236FD93000C6161 /* TextDocumentParser.cpp */; };
......@@ -10402,6 +10404,8 @@
978AD67314130A8D00C7CAE3 /* HTMLSpanElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = HTMLSpanElement.idl; sourceTree = "<group>"; };
979F43D11075E44A0000F83B /* NavigationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NavigationScheduler.cpp; sourceTree = "<group>"; };
979F43D21075E44A0000F83B /* NavigationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NavigationScheduler.h; sourceTree = "<group>"; };
97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetHeaders.h; sourceTree = "<group>"; };
97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventTargetInterfaces.h; sourceTree = "<group>"; };
97BC84811236FD93000C6161 /* TextDocumentParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TextDocumentParser.cpp; path = parser/TextDocumentParser.cpp; sourceTree = "<group>"; };
97BC84821236FD93000C6161 /* TextDocumentParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextDocumentParser.h; path = parser/TextDocumentParser.h; sourceTree = "<group>"; };
97BC849A12370A4B000C6161 /* HTMLInputStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLInputStream.h; path = parser/HTMLInputStream.h; sourceTree = "<group>"; };
......@@ -15145,6 +15149,8 @@
9766504E144FBFFE00F6BB51 /* EventFactory.cpp */,
970B72A5145008EB00F00A37 /* EventHeaders.h */,
970B7289144FFAC600F00A37 /* EventInterfaces.h */,
97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */,
97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */,
A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */,
A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */,
A8BC04911214F69600B5F122 /* HTMLEntityTable.cpp */,
......@@ -24479,6 +24485,8 @@
97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */,
A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */,
97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */,
97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */,
970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
970B72A6145008EB00F00A37 /* EventHeaders.h in Headers */,
9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
......@@ -28,6 +28,8 @@
#include "DOMWindow.h"
#include "Document.h"
#include "EventTargetHeaders.h"
#include "EventTargetInterfaces.h"
#include "JSDOMWindow.h"
#include "JSDOMWindowShell.h"
#include "JSEventListener.h"
......@@ -105,94 +107,28 @@ using namespace JSC;
namespace WebCore {
#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
if (eventNames().interfaceFor##interfaceName == desiredInterface) \
return toJS(exec, globalObject, static_cast<interfaceName*>(target));
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* target)
{
if (!target)
return jsNull();
if (EventSource* eventSource = target->toEventSource())
return toJS(exec, globalObject, eventSource);
#if ENABLE(SVG)
// SVGElementInstance supports both toSVGElementInstance and toNode since so much mouse handling code depends on toNode returning a valid node.
if (SVGElementInstance* instance = target->toSVGElementInstance())
return toJS(exec, globalObject, instance);
#endif
if (Node* node = target->toNode())
return toJS(exec, globalObject, node);
if (DOMWindow* domWindow = target->toDOMWindow())
return toJS(exec, globalObject, domWindow);
if (XMLHttpRequest* xhr = target->toXMLHttpRequest())
return toJS(exec, globalObject, xhr);
if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload())
return toJS(exec, globalObject, upload);
if (DOMApplicationCache* cache = target->toDOMApplicationCache())
return toJS(exec, globalObject, cache);
if (MessagePort* messagePort = target->toMessagePort())
return toJS(exec, globalObject, messagePort);
AtomicString desiredInterface = target->interfaceName();
// FIXME: Why can't we use toJS for these cases?
#if ENABLE(WORKERS)
if (Worker* worker = target->toWorker())
return toJS(exec, globalObject, worker);
if (DedicatedWorkerContext* workerContext = target->toDedicatedWorkerContext())
return toJSDOMGlobalObject(workerContext, exec);
if (eventNames().interfaceForDedicatedWorkerContext == desiredInterface)
return toJSDOMGlobalObject(static_cast<DedicatedWorkerContext*>(target), exec);
#endif
#if ENABLE(SHARED_WORKERS)
if (SharedWorker* sharedWorker = target->toSharedWorker())
return toJS(exec, globalObject, sharedWorker);
if (SharedWorkerContext* workerContext = target->toSharedWorkerContext())
return toJSDOMGlobalObject(workerContext, exec);
#endif
#if ENABLE(NOTIFICATIONS)
if (Notification* notification = target->toNotification())
return toJS(exec, globalObject, notification);
#endif
#if ENABLE(INDEXED_DATABASE)
if (IDBDatabase* idbDatabase = target->toIDBDatabase())
return toJS(exec, globalObject, idbDatabase);
if (IDBRequest* idbRequest = target->toIDBRequest())
return toJS(exec, globalObject, idbRequest);
if (IDBTransaction* idbTransaction = target->toIDBTransaction())
return toJS(exec, globalObject, idbTransaction);
#endif
#if ENABLE(WEB_AUDIO)
if (JavaScriptAudioNode* jsAudioNode = target->toJavaScriptAudioNode())
return toJS(exec, globalObject, jsAudioNode);
if (AudioContext* audioContext = target->toAudioContext())
return toJS(exec, globalObject, audioContext);
#endif
#if ENABLE(WEB_SOCKETS)
if (WebSocket* webSocket = target->toWebSocket())
return toJS(exec, globalObject, webSocket);
#endif
#if ENABLE(BLOB)
if (FileReader* fileReader = target->toFileReader())
return toJS(exec, globalObject, fileReader);
if (eventNames().interfaceForSharedWorkerContext == desiredInterface)
return toJSDOMGlobalObject(static_cast<SharedWorkerContext*>(target), exec);
#endif
#if ENABLE(MEDIA_STREAM)
if (LocalMediaStream* stream = target->toLocalMediaStream())
return toJS(exec, globalObject, stream);
if (MediaStream* stream = target->toMediaStream())
return toJS(exec, globalObject, stream);
#endif
DOM_EVENT_TARGET_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)
ASSERT_NOT_REACHED();
return jsNull();
......
......@@ -86,7 +86,7 @@ void WorkerScriptController::initScript()
Strong<JSDedicatedWorkerContextPrototype> dedicatedContextPrototype(*m_globalData, JSDedicatedWorkerContextPrototype::create(*m_globalData, 0, dedicatedContextPrototypeStructure));
Structure* structure = JSDedicatedWorkerContext::createStructure(*m_globalData, 0, dedicatedContextPrototype.get());
m_workerContextWrapper.set(*m_globalData, JSDedicatedWorkerContext::create(*m_globalData, structure, m_workerContext->toDedicatedWorkerContext()));
m_workerContextWrapper.set(*m_globalData, JSDedicatedWorkerContext::create(*m_globalData, structure, static_cast<DedicatedWorkerContext*>(m_workerContext)));
workerContextPrototypeStructure->setGlobalObject(*m_globalData, m_workerContextWrapper.get());
dedicatedContextPrototypeStructure->setGlobalObject(*m_globalData, m_workerContextWrapper.get());
ASSERT(structure->globalObject() == m_workerContextWrapper);
......@@ -100,7 +100,7 @@ void WorkerScriptController::initScript()
Strong<JSSharedWorkerContextPrototype> sharedContextPrototype(*m_globalData, JSSharedWorkerContextPrototype::create(*m_globalData, 0, sharedContextPrototypeStructure));
Structure* structure = JSSharedWorkerContext::createStructure(*m_globalData, 0, sharedContextPrototype.get());
m_workerContextWrapper.set(*m_globalData, JSSharedWorkerContext::create(*m_globalData, structure, m_workerContext->toSharedWorkerContext()));
m_workerContextWrapper.set(*m_globalData, JSSharedWorkerContext::create(*m_globalData, structure, static_cast<SharedWorkerContext*>(m_workerContext)));
workerContextPrototype->structure()->setGlobalObject(*m_globalData, m_workerContextWrapper.get());
sharedContextPrototype->structure()->setGlobalObject(*m_globalData, m_workerContextWrapper.get());
#endif
......
......@@ -343,11 +343,6 @@ id <DOMEventTarget> kit(WebCore::EventTarget* eventTarget)
if (WebCore::Node* node = eventTarget->toNode())
return kit(node);
#if ENABLE(SVG_DOM_OBJC_BINDINGS)
if (WebCore::SVGElementInstance* svgElementInstance = eventTarget->toSVGElementInstance())
return kit(svgElementInstance);
#endif
// We don't have an ObjC binding for XMLHttpRequest.
return nil;
......
......@@ -35,6 +35,8 @@
#include "CSSMutableStyleDeclaration.h"
#include "DOMDataStore.h"
#include "DocumentLoader.h"
#include "EventTargetHeaders.h"
#include "EventTargetInterfaces.h"
#include "FrameLoaderClient.h"
#include "Notification.h"
#include "V8AbstractEventListener.h"
......@@ -331,114 +333,20 @@ v8::Handle<v8::Object> V8DOMWrapper::getWrapperSlow(Node* node)
return domNodeMap.get(node);
}
#define TRY_TO_WRAP_WITH_INTERFACE(interfaceName) \
if (eventNames().interfaceFor##interfaceName == desiredInterface) \
return toV8(static_cast<interfaceName*>(target));
// A JS object of type EventTarget is limited to a small number of possible classes.
// Check EventTarget.h for new type conversion methods
v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* target)
{
if (!target)
return v8::Null();
#if ENABLE(SVG)
if (SVGElementInstance* instance = target->toSVGElementInstance())
return toV8(instance);
#endif
#if ENABLE(WORKERS)
if (Worker* worker = target->toWorker())
return toV8(worker);
if (DedicatedWorkerContext* workerContext = target->toDedicatedWorkerContext())
return toV8(workerContext);
#endif // WORKERS
#if ENABLE(SHARED_WORKERS)
if (SharedWorker* sharedWorker = target->toSharedWorker())
return toV8(sharedWorker);
if (SharedWorkerContext* sharedWorkerContext = target->toSharedWorkerContext())
return toV8(sharedWorkerContext);
#endif // SHARED_WORKERS
#if ENABLE(NOTIFICATIONS)
if (Notification* notification = target->toNotification())
return toV8(notification);
#endif
#if ENABLE(INDEXED_DATABASE)
if (IDBDatabase* idbDatabase = target->toIDBDatabase())
return toV8(idbDatabase);
if (IDBRequest* idbRequest = target->toIDBRequest())
return toV8(idbRequest);
if (IDBTransaction* idbTransaction = target->toIDBTransaction())
return toV8(idbTransaction);
#endif
#if ENABLE(WEB_SOCKETS)
if (WebSocket* webSocket = target->toWebSocket())
return toV8(webSocket);
#endif
if (Node* node = target->toNode())
return toV8(node);
if (DOMWindow* domWindow = target->toDOMWindow())
return toV8(domWindow);
// XMLHttpRequest is created within its JS counterpart.
if (XMLHttpRequest* xmlHttpRequest = target->toXMLHttpRequest()) {
v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(xmlHttpRequest);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
// MessagePort is created within its JS counterpart
if (MessagePort* port = target->toMessagePort()) {
v8::Handle<v8::Object> wrapper = getActiveDOMObjectMap().get(port);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
if (XMLHttpRequestUpload* upload = target->toXMLHttpRequestUpload()) {
v8::Handle<v8::Object> wrapper = getDOMObjectMap().get(upload);
ASSERT(!wrapper.IsEmpty());
return wrapper;
}
if (DOMApplicationCache* domAppCache = target->toDOMApplicationCache())
return toV8(domAppCache);
if (EventSource* eventSource = target->toEventSource())
return toV8(eventSource);
#if ENABLE(BLOB)
if (FileReader* fileReader = target->toFileReader())
return toV8(fileReader);
#endif
#if ENABLE(FILE_SYSTEM)
if (FileWriter* fileWriter = target->toFileWriter())
return toV8(fileWriter);
#endif
#if ENABLE(WEB_AUDIO)
if (JavaScriptAudioNode* jsAudioNode = target->toJavaScriptAudioNode())
return toV8(jsAudioNode);
if (AudioContext* audioContext = target->toAudioContext())
return toV8(audioContext);
#endif
#if ENABLE(MEDIA_STREAM)
if (LocalMediaStream* stream = target->toLocalMediaStream())
return toV8(stream);
if (MediaStream* stream = target->toMediaStream())
return toV8(stream);
if (PeerConnection* peerConnection = target->toPeerConnection())
return toV8(peerConnection);
#endif
AtomicString desiredInterface = target->interfaceName();
DOM_EVENT_TARGET_INTERFACES_FOR_EACH(TRY_TO_WRAP_WITH_INTERFACE)
ASSERT(0);
ASSERT_NOT_REACHED();
return notHandledByInterceptor();
}
......
......@@ -33,6 +33,7 @@ EventNames::EventNames()
: dummy(0)
DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_EVENT_NAME)
DOM_EVENT_INTERFACES_FOR_EACH(INITIALIZE_EVENT_INTERFACE)
DOM_EVENT_TARGET_INTERFACES_FOR_EACH(INITIALIZE_EVENT_INTERFACE)
{
}
......
......@@ -23,6 +23,7 @@
#define EventNames_h
#include "EventInterfaces.h"
#include "EventTargetInterfaces.h"
#include "ThreadGlobalData.h"
#include <wtf/text/AtomicString.h>
......@@ -205,6 +206,7 @@ namespace WebCore {
#define DOM_EVENT_INTERFACE_DECLARE(name) AtomicString interfaceFor##name;
DOM_EVENT_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
DOM_EVENT_TARGET_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
#undef DOM_EVENT_INTERFACE_DECLARE
};
......
......@@ -80,11 +80,6 @@ EventTarget::~EventTarget()
{
}
EventSource* EventTarget::toEventSource()
{
return 0;
}
Node* EventTarget::toNode()
{
return 0;
......@@ -95,131 +90,6 @@ DOMWindow* EventTarget::toDOMWindow()
return 0;
}
XMLHttpRequest* EventTarget::toXMLHttpRequest()
{
return 0;