EventTarget.h shouldn't need to know about every feature and ifdef
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 20:44:03 +0000 (20:44 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Oct 2011 20:44:03 +0000 (20:44 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@98388 268f45cc-cd09-0410-ab3c-d52691b4dbfc

75 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/CodeGenerators.pri
Source/WebCore/DerivedSources.make
Source/WebCore/GNUmakefile.am
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gyp/WebCore.gyp
Source/WebCore/WebCore.gyp/scripts/action_makenames.py
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSEventTarget.cpp
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/bindings/objc/DOM.mm
Source/WebCore/bindings/v8/V8DOMWrapper.cpp
Source/WebCore/dom/EventNames.cpp
Source/WebCore/dom/EventNames.h
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/dom/EventTarget.h
Source/WebCore/dom/EventTargetFactory.in [new file with mode: 0644]
Source/WebCore/dom/MessagePort.cpp
Source/WebCore/dom/MessagePort.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/Node.h
Source/WebCore/dom/make_event_factory.pl
Source/WebCore/fileapi/FileReader.cpp
Source/WebCore/fileapi/FileReader.h
Source/WebCore/fileapi/FileWriter.cpp
Source/WebCore/fileapi/FileWriter.h
Source/WebCore/loader/appcache/DOMApplicationCache.cpp
Source/WebCore/loader/appcache/DOMApplicationCache.h
Source/WebCore/mediastream/LocalMediaStream.cpp
Source/WebCore/mediastream/LocalMediaStream.h
Source/WebCore/mediastream/MediaStream.cpp
Source/WebCore/mediastream/MediaStream.h
Source/WebCore/mediastream/PeerConnection.cpp
Source/WebCore/mediastream/PeerConnection.h
Source/WebCore/notifications/Notification.cpp
Source/WebCore/notifications/Notification.h
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebCore/page/EventSource.cpp
Source/WebCore/page/EventSource.h
Source/WebCore/storage/IDBDatabase.cpp
Source/WebCore/storage/IDBDatabase.h
Source/WebCore/storage/IDBRequest.cpp
Source/WebCore/storage/IDBRequest.h
Source/WebCore/storage/IDBTransaction.cpp
Source/WebCore/storage/IDBTransaction.h
Source/WebCore/storage/IDBVersionChangeRequest.cpp
Source/WebCore/storage/IDBVersionChangeRequest.h
Source/WebCore/svg/SVGElementInstance.cpp
Source/WebCore/svg/SVGElementInstance.h
Source/WebCore/webaudio/AudioContext.cpp
Source/WebCore/webaudio/AudioContext.h
Source/WebCore/webaudio/JavaScriptAudioNode.cpp
Source/WebCore/webaudio/JavaScriptAudioNode.h
Source/WebCore/websockets/WebSocket.cpp
Source/WebCore/websockets/WebSocket.h
Source/WebCore/workers/DedicatedWorkerContext.cpp
Source/WebCore/workers/DedicatedWorkerContext.h
Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
Source/WebCore/workers/SharedWorker.cpp
Source/WebCore/workers/SharedWorker.h
Source/WebCore/workers/SharedWorkerContext.cpp
Source/WebCore/workers/SharedWorkerContext.h
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/Worker.h
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebCore/xml/XMLHttpRequest.h
Source/WebCore/xml/XMLHttpRequestUpload.cpp
Source/WebCore/xml/XMLHttpRequestUpload.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp
Source/cmake/WebKitMacros.cmake

index 31127f9..ac81078 100644 (file)
@@ -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)
 
index d893dfe..55a90ef 100644 (file)
@@ -1,3 +1,134 @@
+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.
index c375422..c443873 100644 (file)
@@ -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
index 91ceca3..f6cbbf0 100644 (file)
@@ -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
index 1382d6c..0c9f30c 100644 (file)
@@ -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
index 15f590e..351162d 100644 (file)
@@ -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 \
index a8e1563..1105eb9 100644 (file)
           ],
         },
         {
+          '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': [
             '../dom/make_names.pl',
         '<(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',
index b024dac..ca5ca59 100644 (file)
@@ -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)
index 5fce744..0fa9692 100644 (file)
             '<(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',
index f598069..f1c2389 100755 (executable)
                                >
                        </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"
                                >
                        </File>
index e265903..aaed5d3 100644 (file)
                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 */; };
                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>"; };
                                9766504E144FBFFE00F6BB51 /* EventFactory.cpp */,
                                970B72A5145008EB00F00A37 /* EventHeaders.h */,
                                970B7289144FFAC600F00A37 /* EventInterfaces.h */,
+                               97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */,
+                               97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.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 */,
+                               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 */,
index c56277e..37e61a9 100644 (file)
@@ -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();
index d4b9d24..11987ff 100644 (file)
@@ -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
index 7c55c6d..55cd093 100644 (file)
@@ -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;
index 1612b0a..1a77d1c 100644 (file)
@@ -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();
 }
 
index 228b9ee..08646f7 100644 (file)
@@ -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)
 {
 }
 
index 749f72e..29f172f 100644 (file)
@@ -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
     };
 
index 6332d0e..21a1725 100644 (file)
@@ -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;
-}
-
-XMLHttpRequestUpload* EventTarget::toXMLHttpRequestUpload()
-{
-    return 0;
-}
-
-DOMApplicationCache* EventTarget::toDOMApplicationCache()
-{
-    return 0;
-}
-
-#if ENABLE(SVG)
-SVGElementInstance* EventTarget::toSVGElementInstance()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(WEB_AUDIO)
-AudioContext* EventTarget::toAudioContext()
-{
-    return 0;
-}
-
-JavaScriptAudioNode* EventTarget::toJavaScriptAudioNode()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(WEB_SOCKETS)
-WebSocket* EventTarget::toWebSocket()
-{
-    return 0;
-}
-#endif
-
-MessagePort* EventTarget::toMessagePort()
-{
-    return 0;
-}
-
-#if ENABLE(WORKERS)
-Worker* EventTarget::toWorker()
-{
-    return 0;
-}
-
-DedicatedWorkerContext* EventTarget::toDedicatedWorkerContext()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(SHARED_WORKERS)
-SharedWorker* EventTarget::toSharedWorker()
-{
-    return 0;
-}
-SharedWorkerContext* EventTarget::toSharedWorkerContext()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(NOTIFICATIONS)
-Notification* EventTarget::toNotification()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(BLOB)
-FileReader* EventTarget::toFileReader()
-{
-    return 0;
-}
-#endif
-#if ENABLE(FILE_SYSTEM)
-FileWriter* EventTarget::toFileWriter()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(INDEXED_DATABASE)
-IDBDatabase* EventTarget::toIDBDatabase()
-{
-    return 0;
-}
-IDBRequest* EventTarget::toIDBRequest()
-{
-    return 0;
-}
-IDBTransaction* EventTarget::toIDBTransaction()
-{
-    return 0;
-}
-IDBVersionChangeRequest* EventTarget::toIDBVersionChangeRequest()
-{
-    return 0;
-}
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-MediaStream* EventTarget::toMediaStream()
-{
-    return 0;
-}
-
-LocalMediaStream* EventTarget::toLocalMediaStream()
-{
-    return 0;
-}
-
-PeerConnection* EventTarget::toPeerConnection()
-{
-    return 0;
-}
-#endif
-
 bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
 {
     EventTargetData* d = ensureEventTargetData();
index d6e4315..c6f1f3d 100644 (file)
@@ -100,58 +100,11 @@ namespace WebCore {
         void ref() { refEventTarget(); }
         void deref() { derefEventTarget(); }
 
-        virtual EventSource* toEventSource();
-        virtual MessagePort* toMessagePort();
+        virtual const AtomicString& interfaceName() const = 0;
+        virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
+
         virtual Node* toNode();
         virtual DOMWindow* toDOMWindow();
-        virtual XMLHttpRequest* toXMLHttpRequest();
-        virtual XMLHttpRequestUpload* toXMLHttpRequestUpload();
-        virtual DOMApplicationCache* toDOMApplicationCache();
-#if ENABLE(SVG)
-        virtual SVGElementInstance* toSVGElementInstance();
-#endif
-#if ENABLE(WORKERS)
-        virtual Worker* toWorker();
-        virtual DedicatedWorkerContext* toDedicatedWorkerContext();
-#endif
-#if ENABLE(SHARED_WORKERS)
-        virtual SharedWorker* toSharedWorker();
-        virtual SharedWorkerContext* toSharedWorkerContext();
-#endif
-
-#if ENABLE(WEB_AUDIO)
-        virtual AudioContext* toAudioContext();
-        virtual JavaScriptAudioNode* toJavaScriptAudioNode();
-#endif
-
-#if ENABLE(WEB_SOCKETS)
-        virtual WebSocket* toWebSocket();
-#endif
-
-#if ENABLE(NOTIFICATIONS)
-        virtual Notification* toNotification();
-#endif
-#if ENABLE(BLOB)
-        virtual FileReader* toFileReader();
-#endif
-#if ENABLE(FILE_SYSTEM)
-        virtual FileWriter* toFileWriter();
-#endif
-
-#if ENABLE(INDEXED_DATABASE)
-        virtual IDBDatabase* toIDBDatabase();
-        virtual IDBRequest* toIDBRequest();
-        virtual IDBTransaction* toIDBTransaction();
-        virtual IDBVersionChangeRequest* toIDBVersionChangeRequest();
-#endif
-
-#if ENABLE(MEDIA_STREAM)
-        virtual MediaStream* toMediaStream();
-        virtual LocalMediaStream* toLocalMediaStream();
-        virtual PeerConnection* toPeerConnection();
-#endif
-
-        virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
 
         virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
         virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
diff --git a/Source/WebCore/dom/EventTargetFactory.in b/Source/WebCore/dom/EventTargetFactory.in
new file mode 100644 (file)
index 0000000..d5e0e78
--- /dev/null
@@ -0,0 +1,27 @@
+namespace="EventTarget"
+
+EventSource
+MessagePort
+Node
+DOMWindow
+XMLHttpRequest
+XMLHttpRequestUpload
+DOMApplicationCache
+SVGElementInstance conditional=SVG
+Worker conditional=WORKERS
+DedicatedWorkerContext conditional=WORKERS
+SharedWorker conditional=SHARED_WORKERS
+SharedWorkerContext conditional=SHARED_WORKERS
+AudioContext conditional=WEB_AUDIO
+JavaScriptAudioNode conditional=WEB_AUDIO
+WebSocket conditional=WEB_SOCKETS
+Notification conditional=NOTIFICATIONS
+FileReader conditional=BLOB
+FileWriter conditional=FILE_SYSTEM
+IDBDatabase conditional=INDEXED_DATABASE
+IDBRequest conditional=INDEXED_DATABASE
+IDBTransaction conditional=INDEXED_DATABASE
+IDBVersionChangeRequest conditional=INDEXED_DATABASE
+MediaStream conditional=MEDIA_STREAM
+LocalMediaStream conditional=MEDIA_STREAM
+PeerConnection conditional=MEDIA_STREAM
index 664d8bc..ade249c 100644 (file)
@@ -159,6 +159,11 @@ void MessagePort::contextDestroyed()
     m_scriptExecutionContext = 0;
 }
 
+const AtomicString& MessagePort::interfaceName() const
+{
+    return eventNames().interfaceForMessagePort;
+}
+
 ScriptExecutionContext* MessagePort::scriptExecutionContext() const
 {
     return m_scriptExecutionContext;
index 3a840fe..a75a0d6 100644 (file)
@@ -82,10 +82,9 @@ namespace WebCore {
 
         void contextDestroyed();
 
+        virtual const AtomicString& interfaceName() const;
         virtual ScriptExecutionContext* scriptExecutionContext() const;
 
-        virtual MessagePort* toMessagePort() { return this; }
-
         void dispatchMessages();
 
         using RefCounted<MessagePort>::ref;
index 5478a15..9294de6 100644 (file)
@@ -575,6 +575,11 @@ void Node::setShadowHost(Element* host)
     setParent(host);
 }
 
+Node* Node::toNode()
+{
+    return this;
+}
+
 HTMLInputElement* Node::toInputElement()
 {
     // If one of the below ASSERTs trigger, you are calling this function
@@ -2514,7 +2519,10 @@ Node* Node::enclosingLinkEventParentOrSelf()
     return 0;
 }
 
-// --------
+const AtomicString& Node::interfaceName() const
+{
+    return eventNames().interfaceForNode;
+}
 
 ScriptExecutionContext* Node::scriptExecutionContext() const
 {
index cf57651..7fc9585 100644 (file)
@@ -535,10 +535,10 @@ public:
 
     unsigned short compareDocumentPosition(Node*);
 
-    virtual Node* toNode() { return this; }
-
+    virtual Node* toNode();
     virtual HTMLInputElement* toInputElement();
 
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
     virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
index 4766d9f..ab3ad70 100644 (file)
@@ -47,6 +47,7 @@ sub printHeadersFile($);
 my $eventsFile = "";
 my $outputDir = ".";
 my %parsedEvents = ();
+my $namespace;
 
 require Config;
 
@@ -61,9 +62,9 @@ die "You must specify --events <file>" unless length($eventsFile);
 
 my %events = %{readEvents($eventsFile)};
 
-printFactoryFile("$outputDir/EventFactory.cpp");
-printMacroFile("$outputDir/EventInterfaces.h");
-printHeadersFile("$outputDir/EventHeaders.h");
+printFactoryFile("$outputDir/${namespace}Factory.cpp") if $namespace eq "Event";
+printMacroFile("$outputDir/${namespace}Interfaces.h");
+printHeadersFile("$outputDir/${namespace}Headers.h");
 
 sub defaultEventPropertyHash
 {
@@ -89,7 +90,8 @@ sub parametersHandler
 {
     my ($parameter, $value) = @_;
 
-    die "Unknown parameter $parameter for events\n" unless $parameter eq "namespace";
+    die "Unknown parameter $parameter\n" unless $parameter eq "namespace";
+    $namespace = $value;
 }
 
 sub readNames($$$)
@@ -124,6 +126,16 @@ sub interfaceForEvent($)
     return $interfaceName;
 }
 
+sub toMacroStyle($)
+{
+    my ($camelCase) = @_;
+
+    return "EVENT" if $camelCase eq "Event";
+    return "EVENT_TARGET" if $camelCase eq "EventTarget";
+
+    die "Ok, you got me. This script is really just a giant hack.";
+}
+
 sub printFactoryFile($)
 {
     my $path = shift;
@@ -134,13 +146,13 @@ sub printFactoryFile($)
     printLicenseHeader($F);
 
     print F "#include \"config.h\"\n";
-    print F "#include \"EventFactory.h\"\n";
+    print F "#include \"${namespace}Factory.h\"\n";
     print F "\n";
-    print F "#include \"EventHeaders.h\"\n";
+    print F "#include \"${namespace}Headers.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 "PassRefPtr<$namespace> ${namespace}Factory::create(const String& type)\n";
     print F "{\n";
 
     for my $eventName (sort keys %parsedEvents) {
@@ -148,7 +160,7 @@ sub printFactoryFile($)
         my $interfaceName = interfaceForEvent($eventName);
 
         print F "#if ENABLE($conditional)\n" if $conditional;
-        print F "    if (eventType == \"$eventName\")\n";
+        print F "    if (type == \"$eventName\")\n";
         print F "        return ${interfaceName}::create();\n";
         print F "#endif\n" if $conditional;
     }
@@ -169,8 +181,8 @@ sub printMacroFile($)
 
     printLicenseHeader($F);
 
-    print F "#ifndef EventInterfaces_h\n";
-    print F "#define EventInterfaces_h\n";
+    print F "#ifndef ${namespace}Interfaces_h\n";
+    print F "#define ${namespace}Interfaces_h\n";
     print F "\n";
 
     my %unconditionalInterfaces = ();
@@ -190,34 +202,36 @@ sub printMacroFile($)
         }
     }
 
+    my $macroStyledNamespace = toMacroStyle($namespace);
+
     for my $conditional (sort keys %interfacesByConditional) {
         print F "#if ENABLE($conditional)\n";
-        print F "#define DOM_EVENT_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
+        print F "#define DOM_${macroStyledNamespace}_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 "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional\n";
         print F "#else\n";
-        print F "#define DOM_EVENT_INTERFACES_FOR_EACH_$conditional(macro)\n";
+        print F "#define DOM_${macroStyledNamespace}_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 "#define DOM_${macroStyledNamespace}_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 "    DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
     }
 
     print F "\n";
-    print F "#endif // EventInterfaces_h\n";
+    print F "#endif // ${namespace}Interfaces_h\n";
 
     close F;
 }
@@ -231,8 +245,8 @@ sub printHeadersFile($)
 
     printLicenseHeader($F);
 
-    print F "#ifndef EventHeaders_h\n";
-    print F "#define EventHeaders_h\n";
+    print F "#ifndef ${namespace}Headers_h\n";
+    print F "#define ${namespace}Headers_h\n";
     print F "\n";
 
     my %includedInterfaces = ();
@@ -255,7 +269,7 @@ sub printHeadersFile($)
     }
 
     print F "\n";
-    print F "#endif // EventHeaders_h\n";
+    print F "#endif // ${namespace}Headers_h\n";
 
     close F;
 }
@@ -267,7 +281,7 @@ sub printLicenseHeader($)
     print F "/*
  * THIS FILE WAS AUTOMATICALLY GENERATED, DO NOT EDIT.
  *
- * This file was generated by the dom/make_events.pl script.
+ * This file was generated by the dom/make_event_factory.pl script.
  *
  * Copyright (C) 2011 Google Inc.  All rights reserved.
  *
index df9db01..585b013 100644 (file)
@@ -62,6 +62,11 @@ FileReader::~FileReader()
     terminate();
 }
 
+const AtomicString& FileReader::interfaceName() const
+{
+    return eventNames().interfaceForFileReader;
+}
+
 bool FileReader::hasPendingActivity() const
 {
     return m_state == LOADING || ActiveDOMObject::hasPendingActivity();
index 8acc9da..18718f2 100644 (file)
@@ -85,7 +85,7 @@ public:
     virtual bool hasPendingActivity() const;
 
     // EventTarget
-    virtual FileReader* toFileReader() { return this; }
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
 
     // FileReaderLoaderClient
index a5da692..2b25cfa 100644 (file)
@@ -65,6 +65,11 @@ FileWriter::~FileWriter()
         stop();
 }
 
+const AtomicString& FileWriter::interfaceName() const
+{
+    return eventNames().interfaceForFileWriter;
+}
+
 bool FileWriter::hasPendingActivity() const
 {
     return m_readyState == WRITING || ActiveDOMObject::hasPendingActivity();
index c2500eb..c500358 100644 (file)
@@ -76,7 +76,7 @@ public:
     virtual void stop();
 
     // EventTarget
-    virtual FileWriter* toFileWriter() { return this; }
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
 
     using RefCounted<FileWriterBase>::ref;
index 29f07ef..72c9fc9 100644 (file)
@@ -84,6 +84,11 @@ void DOMApplicationCache::swapCache(ExceptionCode& ec)
         ec = INVALID_STATE_ERR;
 }
 
+const AtomicString& DOMApplicationCache::interfaceName() const
+{
+    return eventNames().interfaceForDOMApplicationCache;
+}
+
 ScriptExecutionContext* DOMApplicationCache::scriptExecutionContext() const
 {
     if (m_frame)
index 9e93bf1..022841c 100644 (file)
@@ -69,8 +69,8 @@ public:
     DEFINE_ATTRIBUTE_EVENT_LISTENER(cached);
     DEFINE_ATTRIBUTE_EVENT_LISTENER(obsolete);
 
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
-    DOMApplicationCache* toDOMApplicationCache() { return this; }
 
     static const AtomicString& toEventType(ApplicationCacheHost::EventID id);
 
index 937da6c..bd47e16 100644 (file)
@@ -65,9 +65,9 @@ LocalMediaStream::~LocalMediaStream()
 {
 }
 
-LocalMediaStream* LocalMediaStream::toLocalMediaStream()
+const AtomicString& LocalMediaStream::interfaceName() const
 {
-    return this;
+    return eventNames().interfaceForLocalMediaStream;
 }
 
 } // namespace WebCore
index 278526f..a01652d 100644 (file)
@@ -40,8 +40,8 @@ public:
 
     void stop();
 
-    // EventTarget.
-    virtual LocalMediaStream* toLocalMediaStream();
+    // EventTarget
+    virtual const AtomicString& interfaceName() const;
 
 private:
     LocalMediaStream(ScriptExecutionContext*, const MediaStreamSourceVector&);
index a53c897..fcdbf5f 100644 (file)
@@ -64,11 +64,6 @@ MediaStream::ReadyState MediaStream::readyState() const
     return m_descriptor->ended() ? ENDED : LIVE;
 }
 
-MediaStream* MediaStream::toMediaStream()
-{
-    return this;
-}
-
 void MediaStream::streamEnded()
 {
     if (readyState() == ENDED)
@@ -79,6 +74,11 @@ void MediaStream::streamEnded()
     dispatchEvent(Event::create(eventNames().endedEvent, false, false));
 }
 
+const AtomicString& MediaStream::interfaceName() const
+{
+    return eventNames().interfaceForMediaStream;
+}
+
 ScriptExecutionContext* MediaStream::scriptExecutionContext() const
 {
     return m_scriptExecutionContext.get();
index c33b54d..1ee389b 100644 (file)
@@ -60,8 +60,8 @@ public:
 
     MediaStreamDescriptor* descriptor() const { return m_descriptor.get(); }
 
-    // EventTarget implementation.
-    virtual MediaStream* toMediaStream();
+    // EventTarget
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
     using RefCounted<MediaStream>::ref;
index aca1d7c..7b5ae67 100644 (file)
@@ -236,9 +236,9 @@ void PeerConnection::remoteStreamRemoved(MediaStreamDescriptor* streamDescriptor
     dispatchEvent(MediaStreamEvent::create(eventNames().removestreamEvent, false, false, stream.release()));
 }
 
-PeerConnection* PeerConnection::toPeerConnection()
+const AtomicString& PeerConnection::interfaceName() const
 {
-    return this;
+    return eventNames().interfaceForPeerConnection;
 }
 
 ScriptExecutionContext* PeerConnection::scriptExecutionContext() const
index 9250ff6..7f4b2f5 100644 (file)
@@ -79,9 +79,7 @@ public:
     virtual void remoteStreamRemoved(MediaStreamDescriptor*);
 
     // EventTarget
-    virtual PeerConnection* toPeerConnection();
-
-    // EventTarget implementation.
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
     // ActiveDOMObject
index c9f66a4..dddf71a 100644 (file)
@@ -104,6 +104,11 @@ PassRefPtr<Notification> Notification::create(const NotificationContents& conten
     return adoptRef(new Notification(contents, context, ec, provider));
 }
 
+const AtomicString& Notification::interfaceName() const
+{
+    return eventNames().interfaceForNotification;
+}
+
 void Notification::show() 
 {
 #if PLATFORM(QT)
index 8557de0..508c85f 100644 (file)
@@ -83,13 +83,13 @@ namespace WebCore {
         DEFINE_ATTRIBUTE_EVENT_LISTENER(error);
         DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
         DEFINE_ATTRIBUTE_EVENT_LISTENER(click);
-    
+
         using RefCounted<Notification>::ref;
         using RefCounted<Notification>::deref;
-    
+
         // EventTarget interface
+        virtual const AtomicString& interfaceName() const;
         virtual ScriptExecutionContext* scriptExecutionContext() const { return ActiveDOMObject::scriptExecutionContext(); }
-        virtual Notification* toNotification() { return this; }
 
         // ActiveDOMObject interface
         virtual void contextDestroyed();
index f4c1005..8816243 100644 (file)
@@ -446,11 +446,21 @@ DOMWindow::~DOMWindow()
     removeAllBeforeUnloadEventListeners(this);
 }
 
+const AtomicString& DOMWindow::interfaceName() const
+{
+    return eventNames().interfaceForDOMWindow;
+}
+
 ScriptExecutionContext* DOMWindow::scriptExecutionContext() const
 {
     return document();
 }
 
+DOMWindow* DOMWindow::toDOMWindow()
+{
+    return this;
+}
+
 PassRefPtr<MediaQueryList> DOMWindow::matchMedia(const String& media)
 {
     return document() ? document()->mediaQueryMatcher()->matchMedia(media) : 0;
index bce16f8..b503f6e 100644 (file)
@@ -85,9 +85,11 @@ namespace WebCore {
         static PassRefPtr<DOMWindow> create(Frame* frame) { return adoptRef(new DOMWindow(frame)); }
         virtual ~DOMWindow();
 
-        virtual DOMWindow* toDOMWindow() { return this; }
+        virtual const AtomicString& interfaceName() const;
         virtual ScriptExecutionContext* scriptExecutionContext() const;
 
+        virtual DOMWindow* toDOMWindow();
+
         Frame* frame() const { return m_frame; }
         void disconnectFrame();
 
index 211e7da..1c81697 100644 (file)
@@ -186,6 +186,11 @@ void EventSource::close()
     m_state = CLOSED;
 }
 
+const AtomicString& EventSource::interfaceName() const
+{
+    return eventNames().interfaceForEventSource;
+}
+
 ScriptExecutionContext* EventSource::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index b7b9fc1..df1bc56 100644 (file)
@@ -75,7 +75,7 @@ namespace WebCore {
         using RefCounted<EventSource>::ref;
         using RefCounted<EventSource>::deref;
 
-        virtual EventSource* toEventSource() { return this; }
+        virtual const AtomicString& interfaceName() const;
         virtual ScriptExecutionContext* scriptExecutionContext() const;
 
         virtual void stop();
index 7c99d97..7cbaf5b 100644 (file)
@@ -218,6 +218,11 @@ void IDBDatabase::stop()
     m_stopped = true;
 }
 
+const AtomicString& IDBDatabase::interfaceName() const
+{
+    return eventNames().interfaceForIDBDatabase;
+}
+
 ScriptExecutionContext* IDBDatabase::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index 9d4883e..4f2fc4b 100644 (file)
@@ -82,10 +82,9 @@ public:
     virtual void stop();
 
     // EventTarget
-    virtual IDBDatabase* toIDBDatabase() { return this; }
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
-
     void open();
     void enqueueEvent(PassRefPtr<Event>);
     bool dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) { return EventTarget::dispatchEvent(event, ec); }
index 6430d25..90a61da 100644 (file)
@@ -261,6 +261,11 @@ void IDBRequest::onBlocked()
     ASSERT_NOT_REACHED();
 }
 
+const AtomicString& IDBRequest::interfaceName() const
+{
+    return eventNames().interfaceForIDBRequest;
+}
+
 ScriptExecutionContext* IDBRequest::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index 0fa006a..fca1341 100644 (file)
@@ -87,7 +87,7 @@ public:
     virtual bool hasPendingActivity() const;
 
     // EventTarget
-    virtual IDBRequest* toIDBRequest() { return this; }
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
     virtual bool dispatchEvent(PassRefPtr<Event>);
     bool dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) { return EventTarget::dispatchEvent(event, ec); }
index 1a4e7f3..5959f39 100644 (file)
@@ -138,6 +138,11 @@ bool IDBTransaction::hasPendingActivity() const
     return !m_finished || ActiveDOMObject::hasPendingActivity();
 }
 
+const AtomicString& IDBTransaction::interfaceName() const
+{
+    return eventNames().interfaceForIDBTransaction;
+}
+
 ScriptExecutionContext* IDBTransaction::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index c49f4c4..be695c5 100644 (file)
@@ -74,7 +74,7 @@ public:
     virtual void onComplete();
 
     // EventTarget
-    virtual IDBTransaction* toIDBTransaction() { return this; }
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
     virtual bool dispatchEvent(PassRefPtr<Event>);
     bool dispatchEvent(PassRefPtr<Event> event, ExceptionCode& ec) { return EventTarget::dispatchEvent(event, ec); }
index 8c5416e..081d24c 100644 (file)
@@ -48,6 +48,11 @@ IDBVersionChangeRequest::~IDBVersionChangeRequest()
 {
 }
 
+const AtomicString& IDBVersionChangeRequest::interfaceName() const
+{
+    return eventNames().interfaceForIDBVersionChangeRequest;
+}
+
 void IDBVersionChangeRequest::onBlocked()
 {
     ASSERT(!m_errorCode && m_errorMessage.isNull() && !m_result);
index 32cf4c0..ce284e9 100644 (file)
@@ -39,6 +39,9 @@ public:
 
     virtual void onBlocked();
 
+    // EventTarget
+    virtual const AtomicString& interfaceName() const;
+
     DEFINE_ATTRIBUTE_EVENT_LISTENER(blocked);
 
 private:
index 1a4e4a8..d081d9f 100644 (file)
@@ -121,6 +121,11 @@ void SVGElementInstance::invalidateAllInstancesOfElement(SVGElement* element)
     element->document()->updateLayoutIgnorePendingStylesheets();
 }
 
+const AtomicString& SVGElementInstance::interfaceName() const
+{
+    return eventNames().interfaceForSVGElementInstance;
+}
+
 ScriptExecutionContext* SVGElementInstance::scriptExecutionContext() const
 {
     return m_element->document();
index e72d15a..3951343 100644 (file)
@@ -47,6 +47,7 @@ public:
 
     virtual ~SVGElementInstance();
 
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
     virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
@@ -139,7 +140,6 @@ private:
     SVGElementInstance(SVGUseElement*, SVGUseElement*, PassRefPtr<SVGElement> originalElement);
 
     virtual Node* toNode() { return shadowTreeElement(); }
-    virtual SVGElementInstance* toSVGElementInstance() { return this; }
 
     void appendChild(PassRefPtr<SVGElementInstance> child);
     void setShadowTreeElement(SVGElement*);
index 9e82180..db5686d 100644 (file)
@@ -731,14 +731,14 @@ void AudioContext::handleDirtyAudioNodeOutputs()
     m_dirtyAudioNodeOutputs.clear();
 }
 
-ScriptExecutionContext* AudioContext::scriptExecutionContext() const
+const AtomicString& AudioContext::interfaceName() const
 {
-    return document();
+    return eventNames().interfaceForAudioContext;
 }
 
-AudioContext* AudioContext::toAudioContext()
+ScriptExecutionContext* AudioContext::scriptExecutionContext() const
 {
-    return this;
+    return document();
 }
 
 void AudioContext::startRendering()
index fa73d70..29ee33b 100644 (file)
@@ -208,8 +208,8 @@ public:
     void markAudioNodeOutputDirty(AudioNodeOutput*);
 
     // EventTarget
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
-    virtual AudioContext* toAudioContext();
     virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
     virtual EventTargetData* ensureEventTargetData() { return &m_eventTargetData; }
 
index 05e21b7..92e1fc3 100644 (file)
@@ -119,11 +119,6 @@ void JavaScriptAudioNode::uninitialize()
     AudioNode::uninitialize();
 }
 
-JavaScriptAudioNode* JavaScriptAudioNode::toJavaScriptAudioNode()
-{
-    return this;
-}
-
 void JavaScriptAudioNode::process(size_t framesToProcess)
 {
     // Discussion about inputs and outputs:
@@ -262,6 +257,11 @@ void JavaScriptAudioNode::reset()
     }
 }
 
+const AtomicString& JavaScriptAudioNode::interfaceName() const
+{
+    return eventNames().interfaceForJavaScriptAudioNode;
+}
+
 ScriptExecutionContext* JavaScriptAudioNode::scriptExecutionContext() const
 {
     return const_cast<JavaScriptAudioNode*>(this)->context()->document();
index 5a299c4..3c5d186 100644 (file)
@@ -63,8 +63,8 @@ public:
     virtual void uninitialize();
 
     // EventTarget
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
-    virtual JavaScriptAudioNode* toJavaScriptAudioNode();
     virtual EventTargetData* eventTargetData() { return &m_eventTargetData; }
     virtual EventTargetData* ensureEventTargetData()  { return &m_eventTargetData; }
 
index 9e0f735..e6beb91 100644 (file)
@@ -407,6 +407,11 @@ void WebSocket::setBinaryType(const String& binaryType, ExceptionCode& ec)
     return;
 }
 
+const AtomicString& WebSocket::interfaceName() const
+{
+    return eventNames().interfaceForWebSocket;
+}
+
 ScriptExecutionContext* WebSocket::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index 1932571..263bca0 100644 (file)
@@ -90,9 +90,9 @@ public:
     DEFINE_ATTRIBUTE_EVENT_LISTENER(close);
 
     // EventTarget
-    virtual WebSocket* toWebSocket() { return this; }
-
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
+
     virtual void contextDestroyed();
     virtual bool canSuspend() const;
     virtual void suspend(ReasonForSuspension);
index 54b5ba8..ec3eca8 100644 (file)
@@ -46,6 +46,11 @@ DedicatedWorkerContext::DedicatedWorkerContext(const KURL& url, const String& us
 {
 }
 
+const AtomicString& DedicatedWorkerContext::interfaceName() const
+{
+    return eventNames().interfaceForDedicatedWorkerContext;
+}
+
 // FIXME: remove this when we update the ObjC bindings (bug #28774).
 void DedicatedWorkerContext::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, ExceptionCode& ec)
 {
index dba52ae..4edf64f 100644 (file)
@@ -54,7 +54,8 @@ namespace WebCore {
         virtual void importScripts(const Vector<String>& urls, ExceptionCode&);
 
         // EventTarget
-        virtual DedicatedWorkerContext* toDedicatedWorkerContext() { return this; }
+        virtual const AtomicString& interfaceName() const;
+
         void postMessage(PassRefPtr<SerializedScriptValue>, ExceptionCode&);
         void postMessage(PassRefPtr<SerializedScriptValue>, const MessagePortArray*, ExceptionCode&);
         // FIXME: remove this when we update the ObjC bindings (bug #28774).
index 6aad249..821abce 100644 (file)
@@ -259,7 +259,7 @@ private:
         // Since close() stops the thread event loop, this should not ever get called while closing.
         ASSERT(!workerContext->isClosing());
         ASSERT(workerContext->isSharedWorkerContext());
-        workerContext->toSharedWorkerContext()->dispatchEvent(createConnectEvent(port));
+        workerContext->dispatchEvent(createConnectEvent(port));
     }
 
     OwnPtr<MessagePortChannel> m_channel;
index c98fb5f..ff0792c 100644 (file)
@@ -73,6 +73,11 @@ SharedWorker::~SharedWorker()
 {
 }
 
+const AtomicString& SharedWorker::interfaceName() const
+{
+    return eventNames().interfaceForSharedWorker;
+}
+
 } // namespace WebCore
 
 #endif  // ENABLE(SHARED_WORKERS)
index 5a6be2a..00362ba 100644 (file)
@@ -45,6 +45,8 @@ namespace WebCore {
 
         MessagePort* port() const { return m_port.get(); }
 
+        virtual const AtomicString& interfaceName() const;
+
     private:
         SharedWorker(ScriptExecutionContext*);
 
index 308f44d..9cd1721 100644 (file)
@@ -59,6 +59,11 @@ SharedWorkerContext::~SharedWorkerContext()
 {
 }
 
+const AtomicString& SharedWorkerContext::interfaceName() const
+{
+    return eventNames().interfaceForSharedWorkerContext;
+}
+
 SharedWorkerThread* SharedWorkerContext::thread()
 {
     return static_cast<SharedWorkerThread*>(Base::thread());
index 59a7605..607feac 100644 (file)
@@ -52,7 +52,7 @@ namespace WebCore {
         virtual bool isSharedWorkerContext() const { return true; }
 
         // EventTarget
-        virtual SharedWorkerContext* toSharedWorkerContext() { return this; }
+        virtual const AtomicString& interfaceName() const;
 
         // Setters/Getters for attributes in SharedWorkerContext.idl
         DEFINE_ATTRIBUTE_EVENT_LISTENER(connect);
index ec8af34..b3236a7 100644 (file)
@@ -85,6 +85,11 @@ Worker::~Worker()
     m_contextProxy->workerObjectDestroyed();
 }
 
+const AtomicString& Worker::interfaceName() const
+{
+    return eventNames().interfaceForWorker;
+}
+
 // FIXME: remove this when we update the ObjC bindings (bug #28774).
 void Worker::postMessage(PassRefPtr<SerializedScriptValue> message, MessagePort* port, ExceptionCode& ec)
 {
index 212b52b..cea1a64 100644 (file)
@@ -54,7 +54,7 @@ namespace WebCore {
         static PassRefPtr<Worker> create(ScriptExecutionContext*, const String& url, ExceptionCode&);
         virtual ~Worker();
 
-        virtual Worker* toWorker() { return this; }
+        virtual const AtomicString& interfaceName() const;
 
         void postMessage(PassRefPtr<SerializedScriptValue> message, ExceptionCode&);
         void postMessage(PassRefPtr<SerializedScriptValue> message, const MessagePortArray*, ExceptionCode&);
index e1a752c..59b5b99 100644 (file)
@@ -1118,6 +1118,11 @@ void XMLHttpRequest::contextDestroyed()
     ActiveDOMObject::contextDestroyed();
 }
 
+const AtomicString& XMLHttpRequest::interfaceName() const
+{
+    return eventNames().interfaceForXMLHttpRequest;
+}
+
 ScriptExecutionContext* XMLHttpRequest::scriptExecutionContext() const
 {
     return ActiveDOMObject::scriptExecutionContext();
index ca76353..e2b1428 100644 (file)
@@ -69,14 +69,13 @@ public:
         ResponseTypeArrayBuffer
     };
 
-    virtual XMLHttpRequest* toXMLHttpRequest() { return this; }
-
     virtual void contextDestroyed();
     virtual bool canSuspend() const;
     virtual void suspend(ReasonForSuspension);
     virtual void resume();
     virtual void stop();
 
+    virtual const AtomicString& interfaceName() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
 
     const KURL& url() const { return m_url; }
index f279c4b..3f1cafa 100644 (file)
@@ -41,6 +41,11 @@ XMLHttpRequestUpload::XMLHttpRequestUpload(XMLHttpRequest* xmlHttpRequest)
 {
 }
 
+const AtomicString& XMLHttpRequestUpload::interfaceName() const
+{
+    return eventNames().interfaceForXMLHttpRequestUpload;
+}
+
 ScriptExecutionContext* XMLHttpRequestUpload::scriptExecutionContext() const
 {
     return m_xmlHttpRequest->scriptExecutionContext();
index f74fe15..7f45861 100644 (file)
@@ -54,8 +54,7 @@ namespace WebCore {
         void deref() { m_xmlHttpRequest->deref(); }
         XMLHttpRequest* xmlHttpRequest() const { return m_xmlHttpRequest; }
 
-        virtual XMLHttpRequestUpload* toXMLHttpRequestUpload() { return this; }
-
+        virtual const AtomicString& interfaceName() const;
         ScriptExecutionContext* scriptExecutionContext() const;
 
         DEFINE_ATTRIBUTE_EVENT_LISTENER(abort);
index 8c18a99..977bf20 100644 (file)
@@ -1,3 +1,15 @@
+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 cast isn't needed because dispatchEvent is a virtual function.
+
+        * src/WebSharedWorkerImpl.cpp:
+        (WebKit::WebSharedWorkerImpl::connectTask):
+
 2011-10-25  Michal Mocny  <mmocny@google.com>
 
         [chromium] WebGraphicsContext3D setVisibilityCHROMIUM extension changed to pure virtual.
index 71f017e..3fc9e29 100644 (file)
@@ -92,7 +92,7 @@ void WebSharedWorkerImpl::connectTask(ScriptExecutionContext* context, PassOwnPt
     ASSERT(context->isWorkerContext());
     WorkerContext* workerContext = static_cast<WorkerContext*>(context);
     ASSERT(workerContext->isSharedWorkerContext());
-    workerContext->toSharedWorkerContext()->dispatchEvent(createConnectEvent(port));
+    workerContext->dispatchEvent(createConnectEvent(port));
 }
 
 void WebSharedWorkerImpl::startWorkerContext(const WebURL& url, const WebString& name, const WebString& userAgent, const WebString& sourceCode, long long)
index 2548952..f1fe700 100644 (file)
@@ -37,15 +37,13 @@ MACRO (GENERATE_FONT_NAMES _infile)
 ENDMACRO ()
 
 
-MACRO (GENERATE_EVENT_FACTORY _infile)
+MACRO (GENERATE_EVENT_FACTORY _infile _outfile)
     SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_event_factory.pl)
-    SET(_arguments  --events ${_infile})
-    SET(_outputfiles ${DERIVED_SOURCES_WEBCORE_DIR}/EventFactory.cpp)
 
     ADD_CUSTOM_COMMAND(
-        OUTPUT  ${_outputfiles}
+        OUTPUT  ${DERIVED_SOURCES_WEBCORE_DIR}/${_outfile}
         DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_infile}
-        COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR} ${_arguments}
+        COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --events ${_infile} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR}
         VERBATIM)
 ENDMACRO ()