Reviewed by Eric.
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Sep 2008 00:01:11 +0000 (00:01 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Sep 2008 00:01:11 +0000 (00:01 +0000)
Fixes: https://bugs.webkit.org/show_bug.cgi?id=20865
Prepare HTMLScriptElement & SVGScriptElement unification, and unification of event handling.

Several renames:
dispatchHTMLEvent -> dispatchEventForType
setHTMLEventListener -> setEventListenerForType
getHTMLEventListener -> eventListenerForType
removeHTMLEventListener -> removeEventListenerForType
isHTMLEventListener -> isAttachedToEventTargetNode
...

Similar renames for the dispatch/get/set/*Window*Event functions.
Kill JSSVGLazyEventListener and merge with JSLazyEventListener.

Most important change: Rename setHTMLEventListener to setEventListenerForTypeAndAttribute,
as there exists a generic createEventListener() method now, taking care of JSLazyEventListener creation.

setHTMLEventListener() used createHTMLEventListener() before and was HTML specific.
SVG is able to use the code as well now. This affects most files in html/.

No functional changes.

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

49 files changed:
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bindings/js/JSDOMWindowBase.cpp
WebCore/bindings/js/JSDOMWindowBase.h
WebCore/bindings/js/JSEventListener.cpp
WebCore/bindings/js/JSEventListener.h
WebCore/bindings/js/JSEventTargetNode.cpp
WebCore/bindings/js/JSSVGLazyEventListener.cpp [deleted file]
WebCore/bindings/js/JSSVGLazyEventListener.h [deleted file]
WebCore/bindings/js/ScriptController.cpp
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/dom/EventListener.h
WebCore/dom/EventTargetNode.cpp
WebCore/dom/EventTargetNode.h
WebCore/dom/XMLTokenizer.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/html/HTMLBodyElement.cpp
WebCore/html/HTMLButtonElement.cpp
WebCore/html/HTMLElement.cpp
WebCore/html/HTMLElement.h
WebCore/html/HTMLFormControlElement.cpp
WebCore/html/HTMLFormElement.cpp
WebCore/html/HTMLFrameElementBase.cpp
WebCore/html/HTMLFrameSetElement.cpp
WebCore/html/HTMLImageElement.cpp
WebCore/html/HTMLImageLoader.cpp
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLMediaElement.cpp
WebCore/html/HTMLObjectElement.cpp
WebCore/html/HTMLScriptElement.cpp
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLTextAreaElement.cpp
WebCore/html/HTMLTokenizer.cpp
WebCore/page/AccessibilityRenderObject.cpp
WebCore/page/EventHandler.cpp
WebCore/page/Frame.cpp
WebCore/page/Page.cpp
WebCore/rendering/RenderListBox.cpp
WebCore/rendering/RenderTextControl.cpp
WebCore/svg/SVGDocumentExtensions.cpp
WebCore/svg/SVGDocumentExtensions.h
WebCore/svg/SVGElement.cpp
WebCore/svg/SVGElement.h
WebCore/svg/SVGSVGElement.cpp
WebCore/svg/SVGSVGElement.h

index 30db236..ec8d0f7 100644 (file)
@@ -1,3 +1,165 @@
+2008-09-15  Nikolas Zimmermann  <zimmermann@kde.org>
+
+        Reviewed by Eric.
+
+        Fixes: https://bugs.webkit.org/show_bug.cgi?id=20865
+        Prepare HTMLScriptElement & SVGScriptElement unification, and unification of event handling.
+
+        Several renames:
+        dispatchHTMLEvent -> dispatchEventForType
+        setHTMLEventListener -> setEventListenerForType
+        getHTMLEventListener -> eventListenerForType
+        removeHTMLEventListener -> removeEventListenerForType
+        isHTMLEventListener -> isAttachedToEventTargetNode
+        ...
+
+        Similar renames for the dispatch/get/set/*Window*Event functions.
+        Kill JSSVGLazyEventListener and merge with JSLazyEventListener.
+
+        Most important change: Rename setHTMLEventListener to setEventListenerForTypeAndAttribute,
+        as there exists a generic createEventListener() method now, taking care of JSLazyEventListener creation.
+
+        setHTMLEventListener() used createHTMLEventListener() before and was HTML specific.
+        SVG is able to use the code as well now. This affects most files in html/.
+
+        No functional changes.
+
+        * GNUmakefile.am:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::JSDOMWindowBase::~JSDOMWindowBase):
+        (WebCore::JSDOMWindowBase::setListener):
+        (WebCore::JSDOMWindowBase::getListener):
+        (WebCore::JSDOMWindowBase::findJSEventListener):
+        (WebCore::JSDOMWindowBase::findOrCreateJSEventListener):
+        (WebCore::JSDOMWindowBase::findJSUnprotectedEventListener):
+        (WebCore::JSDOMWindowBase::findOrCreateJSUnprotectedEventListener):
+        (WebCore::JSDOMWindowBase::jsEventListenersAttachedToEventTargetNodes):
+        (WebCore::JSDOMWindowBase::jsUnprotectedEventListenersAttachedToEventTargetNodes):
+        * bindings/js/JSDOMWindowBase.h:
+        * bindings/js/JSEventListener.cpp:
+        (WebCore::JSAbstractEventListener::handleEvent):
+        (WebCore::JSAbstractEventListener::isAttachedToEventTargetNode):
+        (WebCore::JSUnprotectedEventListener::JSUnprotectedEventListener):
+        (WebCore::JSUnprotectedEventListener::~JSUnprotectedEventListener):
+        (WebCore::JSEventListener::JSEventListener):
+        (WebCore::JSEventListener::~JSEventListener):
+        (WebCore::JSLazyEventListener::JSLazyEventListener):
+        (WebCore::eventParameterName):
+        (WebCore::JSLazyEventListener::parseCode):
+        (WebCore::getNodeEventListener):
+        * bindings/js/JSEventListener.h:
+        (WebCore::JSAbstractEventListener::JSAbstractEventListener):
+        (WebCore::JSUnprotectedEventListener::create):
+        (WebCore::JSEventListener::create):
+        (WebCore::JSLazyEventListener::):
+        (WebCore::JSLazyEventListener::create):
+        * bindings/js/JSEventTargetNode.cpp:
+        (WebCore::JSEventTargetNode::setListener):
+        (WebCore::JSEventTargetNode::getListener):
+        * bindings/js/JSSVGLazyEventListener.cpp: Removed.
+        * bindings/js/JSSVGLazyEventListener.h: Removed.
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::createHTMLEventHandler):
+        (WebCore::ScriptController::createSVGEventHandler):
+        * dom/Document.cpp:
+        (WebCore::Document::setFocusedNode):
+        (WebCore::Document::handleWindowEvent):
+        (WebCore::Document::setWindowEventListenerForType):
+        (WebCore::Document::windowEventListenerForType):
+        (WebCore::Document::removeWindowEventListenerForType):
+        (WebCore::Document::addWindowEventListener):
+        (WebCore::Document::hasWindowEventListener):
+        (WebCore::Document::removePendingFrameBeforeUnloadEventCount):
+        (WebCore::Document::createEventListener):
+        (WebCore::Document::setWindowEventListenerForTypeAndAttribute):
+        * dom/Document.h:
+        * dom/EventListener.h:
+        (WebCore::EventListener::isAttachedToEventTargetNode):
+        * dom/EventTargetNode.cpp:
+        (WebCore::EventTargetNode::dispatchFocusEvent):
+        (WebCore::EventTargetNode::dispatchBlurEvent):
+        (WebCore::EventTargetNode::dispatchEventForType):
+        (WebCore::EventTargetNode::removeEventListenerForType):
+        (WebCore::EventTargetNode::setEventListenerForType):
+        (WebCore::EventTargetNode::setEventListenerForTypeAndAttribute):
+        (WebCore::EventTargetNode::eventListenerForType):
+        * dom/EventTargetNode.h:
+        * dom/XMLTokenizer.cpp:
+        (WebCore::XMLTokenizer::notifyFinished):
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplacementFragment::ReplacementFragment):
+        * html/HTMLBodyElement.cpp:
+        (WebCore::HTMLBodyElement::parseMappedAttribute):
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::parseMappedAttribute):
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::parseMappedAttribute):
+        (WebCore::HTMLElement::checkDTD):
+        * html/HTMLElement.h:
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::onChange):
+        * html/HTMLFormElement.cpp:
+        (WebCore::HTMLFormElement::prepareSubmit):
+        (WebCore::HTMLFormElement::reset):
+        (WebCore::HTMLFormElement::parseMappedAttribute):
+        * html/HTMLFrameElementBase.cpp:
+        (WebCore::HTMLFrameElementBase::parseMappedAttribute):
+        * html/HTMLFrameSetElement.cpp:
+        (WebCore::HTMLFrameSetElement::parseMappedAttribute):
+        * html/HTMLImageElement.cpp:
+        (WebCore::HTMLImageElement::parseMappedAttribute):
+        * html/HTMLImageLoader.cpp:
+        (WebCore::HTMLImageLoader::dispatchLoadEvent):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::parseMappedAttribute):
+        (WebCore::HTMLInputElement::setValueFromRenderer):
+        (WebCore::HTMLInputElement::onSearch):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::asyncEventTimerFired):
+        (WebCore::HTMLMediaElement::load):
+        (WebCore::HTMLMediaElement::mediaPlayerNetworkStateChanged):
+        (WebCore::HTMLMediaElement::setReadyState):
+        (WebCore::HTMLMediaElement::seek):
+        (WebCore::HTMLMediaElement::mediaPlayerTimeChanged):
+        (WebCore::HTMLMediaElement::willSaveToCache):
+        * html/HTMLObjectElement.cpp:
+        (WebCore::HTMLObjectElement::parseMappedAttribute):
+        * html/HTMLScriptElement.cpp:
+        (WebCore::HTMLScriptElement::parseMappedAttribute):
+        (WebCore::HTMLScriptElement::dispatchLoadEvent):
+        (WebCore::HTMLScriptElement::dispatchErrorEvent):
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::parseMappedAttribute):
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::parseMappedAttribute):
+        * html/HTMLTokenizer.cpp:
+        (WebCore::HTMLTokenizer::notifyFinished):
+        * page/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::mouseButtonListener):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::canMouseDownStartSelect):
+        (WebCore::EventHandler::canMouseDragExtendSelect):
+        * page/Frame.cpp:
+        (WebCore::Frame::sendScrollEvent):
+        * page/Page.cpp:
+        (WebCore::networkStateChanged):
+        * rendering/RenderListBox.cpp:
+        (WebCore::RenderListBox::valueChanged):
+        * rendering/RenderTextControl.cpp:
+        (WebCore::RenderTextControl::selectionChanged):
+        * svg/SVGDocumentExtensions.cpp:
+        * svg/SVGDocumentExtensions.h:
+        * svg/SVGElement.cpp:
+        (WebCore::SVGElement::parseMappedAttribute):
+        (WebCore::SVGElement::finishParsingChildren):
+        * svg/SVGElement.h:
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::parseMappedAttribute):
+        * svg/SVGSVGElement.h:
+
 2008-09-15  Dave Hyatt  <hyatt@apple.com>
 
         Convert PlatformScrollbarWin to use ScrollbarTheme for hit testing.  PlatformScrollbarQt/Gtk still
index 206ee6c..033da11 100644 (file)
@@ -2844,8 +2844,6 @@ webcore_cppflags += \
        -I\$(top_srcdir)/WebCore/svg/graphics/filters
 
 webcore_sources += \
-       WebCore/bindings/js/JSSVGLazyEventListener.cpp \
-       WebCore/bindings/js/JSSVGLazyEventListener.h \
        WebCore/bindings/js/JSSVGLengthCustom.cpp \
        WebCore/bindings/js/JSSVGMatrixCustom.cpp \
        WebCore/bindings/js/JSSVGPODTypeWrapper.h \
index e243e62..9ff9fd6 100644 (file)
@@ -1427,7 +1427,6 @@ contains(DEFINES, ENABLE_SVG=1) {
         css/SVGCSSStyleSelector.cpp \
         rendering/SVGRenderStyle.cpp \
         rendering/SVGRenderStyleDefs.cpp \
-        bindings/js/JSSVGLazyEventListener.cpp \
         svg/SVGZoomEvent.cpp \
         rendering/PointerEventsHitRules.cpp \
         svg/FilterEffect.cpp \
index 3130c4c..7cb84f6 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
-                                       RelativePath="..\bindings\js\JSSVGLazyEventListener.cpp"\r
-                                       >\r
-                               </File>\r
-                               <File\r
-                                       RelativePath="..\bindings\js\JSSVGLazyEventListener.h"\r
-                                       >\r
-                               </File>\r
-                               <File\r
                                        RelativePath="..\bindings\js\JSSVGLengthCustom.cpp"\r
                                        >\r
                                </File>\r
index d6089d8..90fe456 100644 (file)
                B20111070AB7740500DB0E68 /* JSSVGAElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */; };
                B20111080AB7740500DB0E68 /* JSSVGAElement.h in Headers */ = {isa = PBXBuildFile; fileRef = B20111060AB7740500DB0E68 /* JSSVGAElement.h */; };
                B21127A60B3186770009BE53 /* JSSVGPODTypeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */; };
-               B22277B10D00BEDC0071B782 /* JSSVGLazyEventListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */; };
-               B22277B20D00BEDC0071B782 /* JSSVGLazyEventListener.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */; };
                B22279620D00BF220071B782 /* ColorDistance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B22277CB0D00BF1F0071B782 /* ColorDistance.cpp */; };
                B22279630D00BF220071B782 /* ColorDistance.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CC0D00BF1F0071B782 /* ColorDistance.h */; };
                B22279640D00BF220071B782 /* GradientAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = B22277CD0D00BF1F0071B782 /* GradientAttributes.h */; };
                B20111050AB7740500DB0E68 /* JSSVGAElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGAElement.cpp; sourceTree = "<group>"; };
                B20111060AB7740500DB0E68 /* JSSVGAElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGAElement.h; sourceTree = "<group>"; };
                B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGPODTypeWrapper.h; sourceTree = "<group>"; };
-               B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSSVGLazyEventListener.cpp; sourceTree = "<group>"; };
-               B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSSVGLazyEventListener.h; sourceTree = "<group>"; };
                B22277CB0D00BF1F0071B782 /* ColorDistance.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = ColorDistance.cpp; sourceTree = "<group>"; };
                B22277CC0D00BF1F0071B782 /* ColorDistance.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ColorDistance.h; sourceTree = "<group>"; };
                B22277CD0D00BF1F0071B782 /* GradientAttributes.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GradientAttributes.h; sourceTree = "<group>"; };
                                C09158890DB4209200E55AF4 /* JSQuarantinedObjectWrapper.h */,
                                BC3452410D7E00EA0016574A /* JSRGBColor.cpp */,
                                BC3452420D7E00EA0016574A /* JSRGBColor.h */,
-                               B22277AF0D00BEDC0071B782 /* JSSVGLazyEventListener.cpp */,
-                               B22277B00D00BEDC0071B782 /* JSSVGLazyEventListener.h */,
                                B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
                                BC348BE70DB80354004ABAB9 /* JSXMLHttpRequestConstructor.cpp */,
                                BC348BE80DB80354004ABAB9 /* JSXMLHttpRequestConstructor.h */,
                                B2FA3D9B0AB75A6F000E5AC4 /* JSSVGGElement.h in Headers */,
                                B2FA3D9D0AB75A6F000E5AC4 /* JSSVGGradientElement.h in Headers */,
                                B2FA3D9F0AB75A6F000E5AC4 /* JSSVGImageElement.h in Headers */,
-                               B22277B20D00BEDC0071B782 /* JSSVGLazyEventListener.h in Headers */,
                                B2FA3DA10AB75A6F000E5AC4 /* JSSVGLength.h in Headers */,
                                B2FA3DA30AB75A6F000E5AC4 /* JSSVGLengthList.h in Headers */,
                                B2FA3DA70AB75A6F000E5AC4 /* JSSVGLineElement.h in Headers */,
                                B2FA3D9A0AB75A6F000E5AC4 /* JSSVGGElement.cpp in Sources */,
                                B2FA3D9C0AB75A6F000E5AC4 /* JSSVGGradientElement.cpp in Sources */,
                                B2FA3D9E0AB75A6F000E5AC4 /* JSSVGImageElement.cpp in Sources */,
-                               B22277B10D00BEDC0071B782 /* JSSVGLazyEventListener.cpp in Sources */,
                                B2FA3DA00AB75A6F000E5AC4 /* JSSVGLength.cpp in Sources */,
                                B2FA3DA20AB75A6F000E5AC4 /* JSSVGLengthList.cpp in Sources */,
                                B2FA3DA60AB75A6F000E5AC4 /* JSSVGLineElement.cpp in Sources */,
index 6a5db94..f2b6fc2 100644 (file)
@@ -232,13 +232,13 @@ JSDOMWindowBase::~JSDOMWindowBase()
     clearAllTimeouts();
 
     // Clear any backpointers to the window
-
     ListenersMap::iterator i2 = d()->jsEventListeners.begin();
     ListenersMap::iterator e2 = d()->jsEventListeners.end();
     for (; i2 != e2; ++i2)
         i2->second->clearWindow();
-    i2 = d()->jsHTMLEventListeners.begin();
-    e2 = d()->jsHTMLEventListeners.end();
+
+    i2 = d()->jsEventListenersAttachedToEventTargetNodes.begin();
+    e2 = d()->jsEventListenersAttachedToEventTargetNodes.end();
     for (; i2 != e2; ++i2)
         i2->second->clearWindow();
 
@@ -246,8 +246,9 @@ JSDOMWindowBase::~JSDOMWindowBase()
     UnprotectedListenersMap::iterator e1 = d()->jsUnprotectedEventListeners.end();
     for (; i1 != e1; ++i1)
         i1->second->clearWindow();
-    i1 = d()->jsUnprotectedHTMLEventListeners.begin();
-    e1 = d()->jsUnprotectedHTMLEventListeners.end();
+
+    i1 = d()->jsUnprotectedEventListenersAttachedToEventTargetNodes.begin();
+    e1 = d()->jsUnprotectedEventListenersAttachedToEventTargetNodes.end();
     for (; i1 != e1; ++i1)
         i1->second->clearWindow();
 }
@@ -839,7 +840,7 @@ void JSDOMWindowBase::setListener(ExecState* exec, const AtomicString& eventType
     if (!doc)
         return;
 
-    doc->setHTMLWindowEventListener(eventType, findOrCreateJSEventListener(exec, func, true));
+    doc->setWindowEventListenerForType(eventType, findOrCreateJSEventListener(exec, func, true));
 }
 
 JSValue* JSDOMWindowBase::getListener(ExecState* exec, const AtomicString& eventType) const
@@ -849,55 +850,52 @@ JSValue* JSDOMWindowBase::getListener(ExecState* exec, const AtomicString& event
     if (!doc)
         return jsUndefined();
 
-    EventListener* listener = doc->getHTMLWindowEventListener(eventType);
+    EventListener* listener = doc->windowEventListenerForType(eventType);
     if (listener && static_cast<JSEventListener*>(listener)->listenerObj())
         return static_cast<JSEventListener*>(listener)->listenerObj();
     return jsNull();
 }
 
-JSEventListener* JSDOMWindowBase::findJSEventListener(JSValue* val, bool html)
+JSEventListener* JSDOMWindowBase::findJSEventListener(JSValue* val, bool attachedToEventTargetNode)
 {
     if (!val->isObject())
         return 0;
     JSObject* object = static_cast<JSObject*>(val);
-    ListenersMap& listeners = html ? d()->jsHTMLEventListeners : d()->jsEventListeners;
+    ListenersMap& listeners = attachedToEventTargetNode ? d()->jsEventListenersAttachedToEventTargetNodes : d()->jsEventListeners;
     return listeners.get(object);
 }
 
-PassRefPtr<JSEventListener> JSDOMWindowBase::findOrCreateJSEventListener(ExecState* exec, JSValue* val, bool html)
+PassRefPtr<JSEventListener> JSDOMWindowBase::findOrCreateJSEventListener(ExecState* exec, JSValue* val, bool attachedToEventTargetNode)
 {
-    JSEventListener* listener = findJSEventListener(val, html);
-    if (listener)
+    if (JSEventListener* listener = findJSEventListener(val, attachedToEventTargetNode))
         return listener;
 
     if (!val->isObject())
         return 0;
-    JSObject* object = static_cast<JSObject*>(val);
 
-    // Note that the JSEventListener constructor adds it to our jsEventListeners list
-    return JSEventListener::create(object, static_cast<JSDOMWindow*>(this), html).get();
+    // The JSEventListener constructor adds it to our jsEventListeners map.
+    return JSEventListener::create(static_cast<JSObject*>(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
 }
 
-JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool html)
+JSUnprotectedEventListener* JSDOMWindowBase::findJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool attachedToEventTargetNode)
 {
     if (!val->isObject())
         return 0;
-    JSObject* object = static_cast<JSObject*>(val);
-    UnprotectedListenersMap& listeners = html ? d()->jsUnprotectedHTMLEventListeners : d()->jsUnprotectedEventListeners;
-    return listeners.get(object);
+
+    UnprotectedListenersMap& listeners = attachedToEventTargetNode ? d()->jsUnprotectedEventListenersAttachedToEventTargetNodes : d()->jsUnprotectedEventListeners;
+    return listeners.get(static_cast<JSObject*>(val));
 }
 
-PassRefPtr<JSUnprotectedEventListener> JSDOMWindowBase::findOrCreateJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool html)
+PassRefPtr<JSUnprotectedEventListener> JSDOMWindowBase::findOrCreateJSUnprotectedEventListener(ExecState* exec, JSValue* val, bool attachedToEventTargetNode)
 {
-    JSUnprotectedEventListener* listener = findJSUnprotectedEventListener(exec, val, html);
-    if (listener)
+    if (JSUnprotectedEventListener* listener = findJSUnprotectedEventListener(exec, val, attachedToEventTargetNode))
         return listener;
+
     if (!val->isObject())
         return 0;
-    JSObject* object = static_cast<JSObject*>(val);
 
     // The JSUnprotectedEventListener constructor adds it to our jsUnprotectedEventListeners map.
-    return JSUnprotectedEventListener::create(object, static_cast<JSDOMWindow*>(this), html).get();
+    return JSUnprotectedEventListener::create(static_cast<JSObject*>(val), static_cast<JSDOMWindow*>(this), attachedToEventTargetNode).get();
 }
 
 void JSDOMWindowBase::clearHelperObjectProperties()
@@ -1322,9 +1320,9 @@ JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsEventListeners()
     return d()->jsEventListeners;
 }
 
-JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsHTMLEventListeners()
+JSDOMWindowBase::ListenersMap& JSDOMWindowBase::jsEventListenersAttachedToEventTargetNodes()
 {
-    return d()->jsHTMLEventListeners;
+    return d()->jsEventListenersAttachedToEventTargetNodes;
 }
 
 JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventListeners()
@@ -1332,9 +1330,9 @@ JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventLis
     return d()->jsUnprotectedEventListeners;
 }
 
-JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedHTMLEventListeners()
+JSDOMWindowBase::UnprotectedListenersMap& JSDOMWindowBase::jsUnprotectedEventListenersAttachedToEventTargetNodes()
 {
-    return d()->jsUnprotectedHTMLEventListeners;
+    return d()->jsUnprotectedEventListenersAttachedToEventTargetNodes;
 }
 
 void DOMWindowTimer::fired()
index aa013e9..89a1134 100644 (file)
@@ -78,16 +78,16 @@ namespace WebCore {
         void timerFired(DOMWindowTimer*);
 
         // Finds a wrapper of a JS EventListener, returns 0 if no existing one.
-        JSEventListener* findJSEventListener(JSC::JSValue*, bool html = false);
+        JSEventListener* findJSEventListener(JSC::JSValue*, bool attachedToEventTargetNode = false);
 
         // Finds or creates a wrapper of a JS EventListener. JS EventListener object is GC-protected.
-        PassRefPtr<JSEventListener> findOrCreateJSEventListener(JSC::ExecState*, JSC::JSValue*, bool html = false);
+        PassRefPtr<JSEventListener> findOrCreateJSEventListener(JSC::ExecState*, JSC::JSValue*, bool attachedToEventTargetNode = false);
 
         // Finds a wrapper of a GC-unprotected JS EventListener, returns 0 if no existing one.
-        JSUnprotectedEventListener* findJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool html = false);
+        JSUnprotectedEventListener* findJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool attachedToEventTargetNode = false);
 
         // Finds or creates a wrapper of a JS EventListener. JS EventListener object is *NOT* GC-protected.
-        PassRefPtr<JSUnprotectedEventListener> findOrCreateJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool html = false);
+        PassRefPtr<JSUnprotectedEventListener> findOrCreateJSUnprotectedEventListener(JSC::ExecState*, JSC::JSValue*, bool attachedToEventTargetNode = false);
 
         void clear();
 
@@ -101,9 +101,9 @@ namespace WebCore {
         typedef HashMap<JSC::JSObject*, JSUnprotectedEventListener*> UnprotectedListenersMap;
 
         ListenersMap& jsEventListeners();
-        ListenersMap& jsHTMLEventListeners();
+        ListenersMap& jsEventListenersAttachedToEventTargetNodes();
         UnprotectedListenersMap& jsUnprotectedEventListeners();
-        UnprotectedListenersMap& jsUnprotectedHTMLEventListeners();
+        UnprotectedListenersMap& jsUnprotectedEventListenersAttachedToEventTargetNodes();
 
         virtual const JSC::ClassInfo* classInfo() const { return &s_info; }
         static const JSC::ClassInfo s_info;
@@ -155,9 +155,9 @@ namespace WebCore {
             RefPtr<DOMWindow> impl;
 
             JSDOMWindowBase::ListenersMap jsEventListeners;
-            JSDOMWindowBase::ListenersMap jsHTMLEventListeners;
+            JSDOMWindowBase::ListenersMap jsEventListenersAttachedToEventTargetNodes;
             JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListeners;
-            JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedHTMLEventListeners;
+            JSDOMWindowBase::UnprotectedListenersMap jsUnprotectedEventListenersAttachedToEventTargetNodes;
             Event* evt;
             JSC::JSValue** returnValueSlot;
             JSDOMWindowShell* shell;
index e7829f2..24cbf87 100644 (file)
@@ -105,7 +105,7 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
         else {
             if (!retval->isUndefinedOrNull() && event->storesResultAsString())
                 event->storeResult(retval->toString(exec));
-            if (m_isHTML) {
+            if (m_isAttachedToEventTargetNode) {
                 bool retvalbool;
                 if (retval->getBoolean(retvalbool) && !retvalbool)
                     event->preventDefault();
@@ -117,21 +117,21 @@ void JSAbstractEventListener::handleEvent(Event* event, bool isWindowEvent)
     }
 }
 
-bool JSAbstractEventListener::isHTMLEventListener() const
+bool JSAbstractEventListener::isAttachedToEventTargetNode() const
 {
-    return m_isHTML;
+    return m_isAttachedToEventTargetNode;
 }
 
 // -------------------------------------------------------------------------
 
-JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* window, bool isHTML)
-    : JSAbstractEventListener(isHTML)
+JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOMWindow* window, bool isAttachedToEventTargetNode)
+    : JSAbstractEventListener(isAttachedToEventTargetNode)
     , m_listener(listener)
     , m_window(window)
 {
     if (m_listener) {
-        JSDOMWindow::UnprotectedListenersMap& listeners = isHTML
-            ? window->jsUnprotectedHTMLEventListeners() : window->jsUnprotectedEventListeners();
+        JSDOMWindow::UnprotectedListenersMap& listeners = isAttachedToEventTargetNode
+            ? window->jsUnprotectedEventListenersAttachedToEventTargetNodes() : window->jsUnprotectedEventListeners();
         listeners.set(m_listener, this);
     }
 }
@@ -139,8 +139,8 @@ JSUnprotectedEventListener::JSUnprotectedEventListener(JSObject* listener, JSDOM
 JSUnprotectedEventListener::~JSUnprotectedEventListener()
 {
     if (m_listener && m_window) {
-        JSDOMWindow::UnprotectedListenersMap& listeners = isHTMLEventListener()
-            ? m_window->jsUnprotectedHTMLEventListeners() : m_window->jsUnprotectedEventListeners();
+        JSDOMWindow::UnprotectedListenersMap& listeners = isAttachedToEventTargetNode()
+            ? m_window->jsUnprotectedEventListenersAttachedToEventTargetNodes() : m_window->jsUnprotectedEventListeners();
         listeners.remove(m_listener);
     }
 }
@@ -172,14 +172,14 @@ static WTF::RefCountedLeakCounter eventListenerCounter("EventListener");
 
 // -------------------------------------------------------------------------
 
-JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool isHTML)
-    : JSAbstractEventListener(isHTML)
+JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool isAttachedToEventTargetNode)
+    : JSAbstractEventListener(isAttachedToEventTargetNode)
     , m_listener(listener)
     , m_window(window)
 {
     if (m_listener) {
-        JSDOMWindow::ListenersMap& listeners = isHTML
-            ? m_window->jsHTMLEventListeners() : m_window->jsEventListeners();
+        JSDOMWindow::ListenersMap& listeners = isAttachedToEventTargetNode
+            ? m_window->jsEventListenersAttachedToEventTargetNodes() : m_window->jsEventListeners();
         listeners.set(m_listener, this);
     }
 #ifndef NDEBUG
@@ -190,8 +190,8 @@ JSEventListener::JSEventListener(JSObject* listener, JSDOMWindow* window, bool i
 JSEventListener::~JSEventListener()
 {
     if (m_listener && m_window) {
-        JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
-            ? m_window->jsHTMLEventListeners() : m_window->jsEventListeners();
+        JSDOMWindow::ListenersMap& listeners = isAttachedToEventTargetNode()
+            ? m_window->jsEventListenersAttachedToEventTargetNodes() : m_window->jsEventListeners();
         listeners.remove(m_listener);
     }
 #ifndef NDEBUG
@@ -216,13 +216,14 @@ void JSEventListener::clearWindow()
 
 // -------------------------------------------------------------------------
 
-JSLazyEventListener::JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
+JSLazyEventListener::JSLazyEventListener(LazyEventListenerType type, const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
     : JSEventListener(0, window, true)
     , m_functionName(functionName)
     , m_code(code)
     , m_parsed(false)
     , m_lineNumber(lineNumber)
     , m_originalNode(node)
+    , m_type(type)
 {
     // We don't retain the original node because we assume it
     // will stay alive as long as this handler object is around
@@ -242,10 +243,24 @@ JSObject* JSLazyEventListener::listenerObj() const
     return m_listener;
 }
 
-JSValue* JSLazyEventListener::eventParameterName() const
+// Helper function
+inline JSValue* eventParameterName(JSLazyEventListener::LazyEventListenerType type, ExecState* exec)
 {
-    static ProtectedPtr<JSValue> eventString = jsNontrivialString(window()->globalExec(), "event");
-    return eventString.get();
+    switch (type) {
+    case JSLazyEventListener::HTMLLazyEventListener: {
+        static ProtectedPtr<JSValue> htmlEventString = jsString(exec, "event");
+        return htmlEventString.get();
+    }
+#if ENABLE(SVG)
+    case JSLazyEventListener::SVGLazyEventListener: {
+        static ProtectedPtr<JSValue> svgEventString = jsString(exec, "evt");
+        return svgEventString.get();
+    }
+#endif
+    default:
+        ASSERT_NOT_REACHED();
+        return jsUndefined();
+    }
 }
 
 void JSLazyEventListener::parseCode() const
@@ -266,7 +281,7 @@ void JSLazyEventListener::parseCode() const
 
     ArgList args;
     UString sourceURL(frame->loader()->url().string());
-    args.append(eventParameterName());
+    args.append(eventParameterName(m_type, exec));
     args.append(jsString(exec, m_code));
 
     // FIXME: Passing the document's URL to construct is not always correct, since this event listener might
@@ -297,15 +312,15 @@ void JSLazyEventListener::parseCode() const
     m_code = String();
 
     if (m_listener) {
-        JSDOMWindow::ListenersMap& listeners = isHTMLEventListener()
-            ? window()->jsHTMLEventListeners() : window()->jsEventListeners();
+        JSDOMWindow::ListenersMap& listeners = isAttachedToEventTargetNode()
+            ? window()->jsEventListenersAttachedToEventTargetNodes() : window()->jsEventListeners();
         listeners.set(m_listener, const_cast<JSLazyEventListener*>(this));
     }
 }
 
 JSValue* getNodeEventListener(EventTargetNode* n, const AtomicString& eventType)
 {
-    if (JSAbstractEventListener* listener = static_cast<JSAbstractEventListener*>(n->getHTMLEventListener(eventType))) {
+    if (JSAbstractEventListener* listener = static_cast<JSAbstractEventListener*>(n->eventListenerForType(eventType))) {
         if (JSValue* obj = listener->listenerObj())
             return obj;
     }
index cd4e7cf..a6ee2d7 100644 (file)
@@ -33,25 +33,25 @@ namespace WebCore {
     class JSAbstractEventListener : public EventListener {
     public:
         virtual void handleEvent(Event*, bool isWindowEvent);
-        virtual bool isHTMLEventListener() const;
+        virtual bool isAttachedToEventTargetNode() const;
         virtual JSC::JSObject* listenerObj() const = 0;
         virtual JSDOMWindow* window() const = 0;
 
     protected:
-        JSAbstractEventListener(bool isHTML)
-            : m_isHTML(isHTML)
+        JSAbstractEventListener(bool isAttachedToEventTargetNode)
+            : m_isAttachedToEventTargetNode(isAttachedToEventTargetNode)
         {
         }
 
     private:
-        bool m_isHTML;
+        bool m_isAttachedToEventTargetNode;
     };
 
     class JSUnprotectedEventListener : public JSAbstractEventListener {
     public:
-        static PassRefPtr<JSUnprotectedEventListener> create(JSC::JSObject* listener, JSDOMWindow* window, bool isHTML)
+        static PassRefPtr<JSUnprotectedEventListener> create(JSC::JSObject* listener, JSDOMWindow* window, bool isAttachedToEventTargetNode)
         {
-            return adoptRef(new JSUnprotectedEventListener(listener, window, isHTML));
+            return adoptRef(new JSUnprotectedEventListener(listener, window, isAttachedToEventTargetNode));
         }
         virtual ~JSUnprotectedEventListener();
 
@@ -61,7 +61,7 @@ namespace WebCore {
         void mark();
 
     private:
-        JSUnprotectedEventListener(JSC::JSObject* listener, JSDOMWindow*, bool isHTML);
+        JSUnprotectedEventListener(JSC::JSObject* listener, JSDOMWindow*, bool isAttachedToEventTargetNode);
 
         JSC::JSObject* m_listener;
         JSDOMWindow* m_window;
@@ -69,9 +69,9 @@ namespace WebCore {
 
     class JSEventListener : public JSAbstractEventListener {
     public:
-        static PassRefPtr<JSEventListener> create(JSC::JSObject* listener, JSDOMWindow* window, bool isHTML)
+        static PassRefPtr<JSEventListener> create(JSC::JSObject* listener, JSDOMWindow* window, bool isAttachedToEventTargetNode)
         {
-            return adoptRef(new JSEventListener(listener, window, isHTML));
+            return adoptRef(new JSEventListener(listener, window, isAttachedToEventTargetNode));
         }
         virtual ~JSEventListener();
 
@@ -80,7 +80,7 @@ namespace WebCore {
         void clearWindow();
 
     protected:
-        JSEventListener(JSC::JSObject* listener, JSDOMWindow*, bool isHTML);
+        JSEventListener(JSC::JSObject* listener, JSDOMWindow*, bool isAttachedToEventTargetNode);
 
         mutable JSC::ProtectedPtr<JSC::JSObject> m_listener;
 
@@ -90,17 +90,23 @@ namespace WebCore {
 
     class JSLazyEventListener : public JSEventListener {
     public:
-        static PassRefPtr<JSLazyEventListener> create(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
+        enum LazyEventListenerType {
+            HTMLLazyEventListener
+#if ENABLE(SVG)
+            , SVGLazyEventListener
+#endif
+        };
+
+        static PassRefPtr<JSLazyEventListener> create(LazyEventListenerType type, const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
         {
-            return adoptRef(new JSLazyEventListener(functionName, code, window, node, lineNumber));
+            return adoptRef(new JSLazyEventListener(type, functionName, code, window, node, lineNumber));
         }
         virtual JSC::JSObject* listenerObj() const;
 
     protected:
-        JSLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber);
+        JSLazyEventListener(LazyEventListenerType type, const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber);
 
     private:
-        virtual JSC::JSValue* eventParameterName() const;
         void parseCode() const;
 
         mutable String m_functionName;
@@ -108,6 +114,8 @@ namespace WebCore {
         mutable bool m_parsed;
         int m_lineNumber;
         Node* m_originalNode;
+
+        LazyEventListenerType m_type;
     };
 
     JSC::JSValue* getNodeEventListener(Node*, const AtomicString& eventType);
index 2ae4e2d..8a32fd6 100644 (file)
@@ -45,12 +45,12 @@ void JSEventTargetNode::setListener(ExecState* exec, const AtomicString& eventTy
 {
     Frame* frame = impl()->document()->frame();
     if (frame)
-        EventTargetNodeCast(impl())->setHTMLEventListener(eventType, toJSDOMWindow(frame)->findOrCreateJSEventListener(exec, func, true));
+        EventTargetNodeCast(impl())->setEventListenerForType(eventType, toJSDOMWindow(frame)->findOrCreateJSEventListener(exec, func, true));
 }
 
 JSValue* JSEventTargetNode::getListener(const AtomicString& eventType) const
 {
-    EventListener* listener = EventTargetNodeCast(impl())->getHTMLEventListener(eventType);
+    EventListener* listener = EventTargetNodeCast(impl())->eventListenerForType(eventType);
     JSEventListener* jsListener = static_cast<JSEventListener*>(listener);
     if (jsListener && jsListener->listenerObj())
         return jsListener->listenerObj();
diff --git a/WebCore/bindings/js/JSSVGLazyEventListener.cpp b/WebCore/bindings/js/JSSVGLazyEventListener.cpp
deleted file mode 100644 (file)
index 14dc4f7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-    Copyright (C) 2006 Apple Computer, Inc.
-                  
-    This file is part of the WebKit project
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#include "config.h"
-#if ENABLE(SVG)
-
-#include "JSSVGLazyEventListener.h"
-
-#include "JSDOMWindow.h"
-
-using namespace JSC;
-
-namespace WebCore {
-
-JSSVGLazyEventListener::JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
-    : JSLazyEventListener(functionName, code, window, node, lineNumber)
-{
-}
-
-JSValue* JSSVGLazyEventListener::eventParameterName() const
-{
-    static ProtectedPtr<JSValue> eventString = jsNontrivialString(window()->globalExec(), "evt");
-    return eventString.get();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
diff --git a/WebCore/bindings/js/JSSVGLazyEventListener.h b/WebCore/bindings/js/JSSVGLazyEventListener.h
deleted file mode 100644 (file)
index 63815a3..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-    Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public License
-    along with this library; see the file COPYING.LIB.  If not, write to
-    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-    Boston, MA 02110-1301, USA.
-*/
-
-#ifndef JSSVGLazyEventListener_h
-#define JSSVGLazyEventListener_h
-
-#include "JSEventListener.h"
-
-#if ENABLE(SVG)
-
-namespace WebCore {
-
-    class JSSVGLazyEventListener : public JSLazyEventListener {
-    public:
-        static PassRefPtr<JSSVGLazyEventListener> create(const String& functionName, const String& code, JSDOMWindow* window, Node* node, int lineNumber)
-        {
-            return adoptRef(new JSSVGLazyEventListener(functionName, code, window, node, lineNumber));
-        }
-
-    private:
-        JSSVGLazyEventListener(const String& functionName, const String& code, JSDOMWindow*, Node*, int lineNumber);
-
-        virtual JSC::JSValue* eventParameterName() const;
-    };
-
-} // namespace WebCore
-
-#endif // ENABLE(SVG)
-
-#endif // JSSVGLazyEventListener_h
index 10946fb..9a1cd60 100644 (file)
 #include "HTMLPlugInElement.h"
 #endif
 
-#if ENABLE(SVG)
-#include "JSSVGLazyEventListener.h"
-#endif
-
 using namespace JSC;
 using namespace WebCore::EventNames;
 
@@ -150,7 +146,7 @@ PassRefPtr<EventListener> ScriptController::createHTMLEventHandler(const String&
 {
     initScriptIfNeeded();
     JSLock lock(false);
-    return JSLazyEventListener::create(functionName, code, m_windowShell->window(), node, m_handlerLineno);
+    return JSLazyEventListener::create(JSLazyEventListener::HTMLLazyEventListener, functionName, code, m_windowShell->window(), node, m_handlerLineno);
 }
 
 #if ENABLE(SVG)
@@ -158,7 +154,7 @@ PassRefPtr<EventListener> ScriptController::createSVGEventHandler(const String&
 {
     initScriptIfNeeded();
     JSLock lock(false);
-    return JSSVGLazyEventListener::create(functionName, code, m_windowShell->window(), node, m_handlerLineno);
+    return JSLazyEventListener::create(JSLazyEventListener::SVGLazyEventListener, functionName, code, m_windowShell->window(), node, m_handlerLineno);
 }
 #endif
 
index f17bed7..7df046f 100644 (file)
@@ -2419,9 +2419,9 @@ bool Document::setFocusedNode(PassRefPtr<Node> newFocusedNode)
         oldFocusedNode->setFocus(false);
                 
         // Dispatch a change event for text fields or textareas that have been edited
-        RenderObject *r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer());
+        RenderObjectr = static_cast<RenderObject*>(oldFocusedNode.get()->renderer());
         if (r && (r->isTextArea() || r->isTextField()) && r->isEdited()) {
-            EventTargetNodeCast(oldFocusedNode.get())->dispatchHTMLEvent(changeEvent, true, false);
+            EventTargetNodeCast(oldFocusedNode.get())->dispatchEventForType(changeEvent, true, false);
             if ((r = static_cast<RenderObject*>(oldFocusedNode.get()->renderer())))
                 r->setEdited(false);
         }
@@ -2652,7 +2652,7 @@ CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&)
     return 0;
 }
 
-void Document::handleWindowEvent(Event *evt, bool useCapture)
+void Document::handleWindowEvent(Eventevt, bool useCapture)
 {
     if (m_windowEventListeners.isEmpty())
         return;
@@ -2666,29 +2666,29 @@ void Document::handleWindowEvent(Event *evt, bool useCapture)
             (*it)->listener()->handleEvent(evt, true);
 }
 
-void Document::setHTMLWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener> listener)
+void Document::setWindowEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener> listener)
 {
     // If we already have it we don't want removeWindowEventListener to delete it
-    removeHTMLWindowEventListener(eventType);
+    removeWindowEventListenerForType(eventType);
     if (listener)
         addWindowEventListener(eventType, listener, false);
 }
 
-EventListener *Document::getHTMLWindowEventListener(const AtomicString& eventType)
+EventListener* Document::windowEventListenerForType(const AtomicString& eventType)
 {
     RegisteredEventListenerList::iterator it = m_windowEventListeners.begin();
     for (; it != m_windowEventListeners.end(); ++it) {
-        if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener())
+        if ((*it)->eventType() == eventType && (*it)->listener()->isAttachedToEventTargetNode())
             return (*it)->listener();
     }
     return 0;
 }
 
-void Document::removeHTMLWindowEventListener(const AtomicString& eventType)
+void Document::removeWindowEventListenerForType(const AtomicString& eventType)
 {
     RegisteredEventListenerList::iterator it = m_windowEventListeners.begin();
     for (; it != m_windowEventListeners.end(); ++it) {
-        if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) {
+        if ((*it)->eventType() == eventType && (*it)->listener()->isAttachedToEventTargetNode()) {
             if (eventType == unloadEvent)
                 removePendingFrameUnloadEventCount();
             else if (eventType == beforeunloadEvent)
@@ -2699,7 +2699,7 @@ void Document::removeHTMLWindowEventListener(const AtomicString& eventType)
     }
 }
 
-void Document::addWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener> listener, bool useCapture)
+void Document::addWindowEventListener(const AtomicStringeventType, PassRefPtr<EventListener> listener, bool useCapture)
 {
     if (eventType == unloadEvent)
         addPendingFrameUnloadEventCount();
@@ -2727,13 +2727,12 @@ void Document::removeWindowEventListener(const AtomicString& eventType, EventLis
     }
 }
 
-bool Document::hasWindowEventListener(const AtomicString &eventType)
+bool Document::hasWindowEventListener(const AtomicStringeventType)
 {
     RegisteredEventListenerList::iterator it = m_windowEventListeners.begin();
     for (; it != m_windowEventListeners.end(); ++it)
-        if ((*it)->eventType() == eventType) {
+        if ((*it)->eventType() == eventType)
             return true;
-        }
     return false;
 }
 
@@ -2755,24 +2754,30 @@ void Document::addPendingFrameBeforeUnloadEventCount()
          m_frame->eventHandler()->addPendingFrameBeforeUnloadEventCount();
 }
 
-    void Document::removePendingFrameBeforeUnloadEventCount() 
+void Document::removePendingFrameBeforeUnloadEventCount() 
 {
     if (m_frame)
         m_frame->eventHandler()->removePendingFrameBeforeUnloadEventCount();
 }
 
-PassRefPtr<EventListener> Document::createHTMLEventListener(const String& functionName, const String& code, Node *node)
+PassRefPtr<EventListener> Document::createEventListener(const String& functionName, const String& code, Node* node)
 {
-    if (Frame* frm = frame())
-        if (frm->script()->isEnabled())
-            return frm->script()->createHTMLEventHandler(functionName, code, node);
-    return 0;
+    Frame* frm = frame();
+    if (!frm || !frm->script()->isEnabled())
+        return 0;
+
+#if ENABLE(SVG)
+    if (node ? node->isSVGElement() : isSVGDocument())
+        return frm->script()->createSVGEventHandler(functionName, code, node);
+#endif
+
+    // We may want to treat compound document event handlers in a different way, in future.
+    return frm->script()->createHTMLEventHandler(functionName, code, node);
 }
 
-void Document::setHTMLWindowEventListener(const AtomicString& eventType, Attribute* attr)
+void Document::setWindowEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute* attr)
 {
-    setHTMLWindowEventListener(eventType,
-        createHTMLEventListener(attr->localName().string(), attr->value(), 0));
+    setWindowEventListenerForType(eventType, createEventListener(attr->localName().string(), attr->value(), 0));
 }
 
 void Document::dispatchImageLoadEventSoon(HTMLImageLoader *image)
index 58adb3b..3d29ced 100644 (file)
@@ -553,11 +553,11 @@ public:
     CSSStyleDeclaration* getOverrideStyle(Element*, const String& pseudoElt);
 
     void handleWindowEvent(Event*, bool useCapture);
-    void setHTMLWindowEventListener(const AtomicString &eventType, PassRefPtr<EventListener>);
-    EventListener* getHTMLWindowEventListener(const AtomicString &eventType);
-    void removeHTMLWindowEventListener(const AtomicString &eventType);
+    void setWindowEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener>);
+    EventListener* windowEventListenerForType(const AtomicString& eventType);
+    void removeWindowEventListenerForType(const AtomicString& eventType);
 
-    void setHTMLWindowEventListener(const AtomicString& eventType, Attribute*);
+    void setWindowEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute*);
 
     void addWindowEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
     void removeWindowEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
@@ -568,8 +568,8 @@ public:
     void addPendingFrameBeforeUnloadEventCount();
     void removePendingFrameBeforeUnloadEventCount();
 
-    PassRefPtr<EventListener> createHTMLEventListener(const String& functionName, const String& code, Node*);
-    
+    PassRefPtr<EventListener> createEventListener(const String& functionName, const String& code, Node*);
+
     /**
      * Searches through the document, starting from fromNode, for the next selectable element that comes after fromNode.
      * The order followed is as specified in section 17.11.1 of the HTML4 spec, which is elements with tab indexes
index 37e86ba..350f095 100644 (file)
@@ -31,7 +31,7 @@ namespace WebCore {
     public:
         virtual ~EventListener() { }
         virtual void handleEvent(Event*, bool isWindowEvent = false) = 0;
-        virtual bool isHTMLEventListener() const { return false; }
+        virtual bool isAttachedToEventTargetNode() const { return false; }
     };
 
 }
index 76617c6..6efcfe0 100644 (file)
@@ -378,15 +378,15 @@ bool EventTargetNode::dispatchWebKitTransitionEvent(const AtomicString& eventTyp
 
 void EventTargetNode::dispatchFocusEvent()
 {
-    dispatchHTMLEvent(focusEvent, false, false);
+    dispatchEventForType(focusEvent, false, false);
 }
 
 void EventTargetNode::dispatchBlurEvent()
 {
-    dispatchHTMLEvent(blurEvent, false, false);
+    dispatchEventForType(blurEvent, false, false);
 }
 
-bool EventTargetNode::dispatchHTMLEvent(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg)
+bool EventTargetNode::dispatchEventForType(const AtomicString& eventType, bool canBubbleArg, bool cancelableArg)
 {
     ASSERT(!eventDispatchForbidden());
     ExceptionCode ec = 0;
@@ -409,14 +409,14 @@ void EventTargetNode::dispatchStorageEvent(const AtomicString &eventType, const
 #endif
 }
 
-void EventTargetNode::removeHTMLEventListener(const AtomicString &eventType)
+void EventTargetNode::removeEventListenerForType(const AtomicString& eventType)
 {
     if (!m_regdListeners) // nothing to remove
         return;
     
     RegisteredEventListenerList::Iterator end = m_regdListeners->end();
     for (RegisteredEventListenerList::Iterator it = m_regdListeners->begin(); it != end; ++it)
-        if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener()) {
+        if ((*it)->eventType() == eventType && (*it)->listener()->isAttachedToEventTargetNode()) {
             it = m_regdListeners->remove(it);
             // removed last
             if (m_regdListeners->isEmpty() && !inDocument())
@@ -425,22 +425,27 @@ void EventTargetNode::removeHTMLEventListener(const AtomicString &eventType)
         }
 }
 
-void EventTargetNode::setHTMLEventListener(const AtomicString &eventType, PassRefPtr<EventListener> listener)
+void EventTargetNode::setEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener> listener)
 {
-    // In case we are the only one holding a reference to it, we don't want removeHTMLEventListener to destroy it.
-    removeHTMLEventListener(eventType);
+    // In case we are the only one holding a reference to it, we don't want removeEventListenerForType to destroy it.
+    removeEventListenerForType(eventType);
     if (listener)
         addEventListener(eventType, listener, false);
 }
 
-EventListener *EventTargetNode::getHTMLEventListener(const AtomicString &eventType)
+void EventTargetNode::setEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute* attr)
+{
+    setEventListenerForType(eventType, document()->createEventListener(attr->localName().string(), attr->value(), this));
+}
+
+EventListener* EventTargetNode::eventListenerForType(const AtomicString& eventType)
 {
     if (!m_regdListeners)
         return 0;
     
     RegisteredEventListenerList::Iterator end = m_regdListeners->end();
     for (RegisteredEventListenerList::Iterator it = m_regdListeners->begin(); it != end; ++it)
-        if ((*it)->eventType() == eventType && (*it)->listener()->isHTMLEventListener())
+        if ((*it)->eventType() == eventType && (*it)->listener()->isAttachedToEventTargetNode())
             return (*it)->listener();
     return 0;
 }
index 0282f87..c6a9693 100644 (file)
@@ -3,7 +3,7 @@
  *           (C) 1999 Antti Koivisto (koivisto@kde.org)
  *           (C) 2001 Dirk Mueller (mueller@kde.org)
  * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
- *           (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
+ *           (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -30,6 +30,7 @@
 
 namespace WebCore {
 
+class Attribute;
 class Frame;
 
 class EventTargetNode : public Node,
@@ -46,10 +47,11 @@ public:
     virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&, bool tempEvent = false);
     void removeAllEventListeners();
 
-    void setHTMLEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
-    void removeHTMLEventListener(const AtomicString& eventType);
-    bool dispatchHTMLEvent(const AtomicString& eventType, bool canBubble, bool cancelable);
-    EventListener* getHTMLEventListener(const AtomicString& eventType);
+    void setEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener>);
+    void setEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute*);
+    void removeEventListenerForType(const AtomicString& eventType);
+    bool dispatchEventForType(const AtomicString& eventType, bool canBubble, bool cancelable);
+    EventListener* eventListenerForType(const AtomicString& eventType);
 
     bool dispatchSubtreeModifiedEvent();
     void dispatchWindowEvent(PassRefPtr<Event>);
index 801800a..38e2667 100644 (file)
@@ -1527,10 +1527,10 @@ void XMLTokenizer::notifyFinished(CachedResource* finishedObj)
     m_scriptElement = 0;
     
     if (errorOccurred) 
-        EventTargetNodeCast(e.get())->dispatchHTMLEvent(errorEvent, true, false);
+        EventTargetNodeCast(e.get())->dispatchEventForType(errorEvent, true, false);
     else {
         m_view->frame()->loader()->executeScript(cachedScriptUrl, 1, scriptSource);
-        EventTargetNodeCast(e.get())->dispatchHTMLEvent(loadEvent, false, false);
+        EventTargetNodeCast(e.get())->dispatchEventForType(loadEvent, false, false);
     }
     
     m_scriptElement = 0;
index 3a6d4b1..68b781b 100644 (file)
@@ -123,7 +123,7 @@ ReplacementFragment::ReplacementFragment(Document* document, DocumentFragment* f
     
     Node* shadowAncestorNode = editableRoot->shadowAncestorNode();
     
-    if (!editableRoot->getHTMLEventListener(webkitBeforeTextInsertedEvent) &&
+    if (!editableRoot->eventListenerForType(webkitBeforeTextInsertedEvent) &&
         // FIXME: Remove these checks once textareas and textfields actually register an event handler.
         !(shadowAncestorNode && shadowAncestorNode->renderer() && shadowAncestorNode->renderer()->isTextField()) &&
         !(shadowAncestorNode && shadowAncestorNode->renderer() && shadowAncestorNode->renderer()->isTextArea()) &&
index e8f7763..f714ce0 100644 (file)
@@ -130,25 +130,25 @@ void HTMLBodyElement::parseMappedAttribute(MappedAttribute *attr)
         
         if (attached())
             document()->recalcStyle(Force);
-    } else if (attr->name() == onloadAttr) {
-        document()->setHTMLWindowEventListener(loadEvent, attr);
-    } else if (attr->name() == onbeforeunloadAttr) {
-        document()->setHTMLWindowEventListener(beforeunloadEvent, attr);
-    } else if (attr->name() == onunloadAttr) {
-        document()->setHTMLWindowEventListener(unloadEvent, attr);
-    } else if (attr->name() == onblurAttr) {
-        document()->setHTMLWindowEventListener(blurEvent, attr);
-    } else if (attr->name() == onfocusAttr) {
-        document()->setHTMLWindowEventListener(focusEvent, attr);
-    } else if (attr->name() == onresizeAttr) {
-        document()->setHTMLWindowEventListener(resizeEvent, attr);
-    } else if (attr->name() == onscrollAttr) {
-        document()->setHTMLWindowEventListener(scrollEvent, attr);
-    else if (attr->name() == onstorageAttr) {
+    } else if (attr->name() == onloadAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(loadEvent, attr);
+    else if (attr->name() == onbeforeunloadAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(beforeunloadEvent, attr);
+    else if (attr->name() == onunloadAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(unloadEvent, attr);
+    else if (attr->name() == onblurAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(blurEvent, attr);
+    else if (attr->name() == onfocusAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(focusEvent, attr);
+    else if (attr->name() == onresizeAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(resizeEvent, attr);
+    else if (attr->name() == onscrollAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(scrollEvent, attr);
+    else if (attr->name() == onstorageAttr) {
         // The HTML5 spec currently specifies that storage events are fired only at the body element of
         // an HTMLDocument, which is why the onstorage attribute differs from the ones before it.
         // The spec might change on this, and then so should we!
-        setHTMLEventListener(storageEvent, attr);
+        setEventListenerForTypeAndAttribute(storageEvent, attr);
     } else
         HTMLElement::parseMappedAttribute(attr);
 }
index 190916b..af1ac99 100644 (file)
@@ -88,9 +88,9 @@ void HTMLButtonElement::parseMappedAttribute(MappedAttribute* attr)
         // Don't map 'align' attribute.  This matches what Firefox and IE do, but not Opera.
         // See http://bugs.webkit.org/show_bug.cgi?id=12071
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(focusEvent, attr);
+        setEventListenerForTypeAndAttribute(focusEvent, attr);
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(blurEvent, attr);
+        setEventListenerForTypeAndAttribute(blurEvent, attr);
     } else
         HTMLFormControlElement::parseMappedAttribute(attr);
 }
index eae99f0..6fa7842 100644 (file)
@@ -158,75 +158,75 @@ void HTMLElement::parseMappedAttribute(MappedAttribute *attr)
     }
 // standard events
     else if (attr->name() == onclickAttr) {
-        setHTMLEventListener(clickEvent, attr);
+        setEventListenerForTypeAndAttribute(clickEvent, attr);
     } else if (attr->name() == oncontextmenuAttr) {
-        setHTMLEventListener(contextmenuEvent, attr);
+        setEventListenerForTypeAndAttribute(contextmenuEvent, attr);
     } else if (attr->name() == ondblclickAttr) {
-        setHTMLEventListener(dblclickEvent, attr);
+        setEventListenerForTypeAndAttribute(dblclickEvent, attr);
     } else if (attr->name() == onmousedownAttr) {
-        setHTMLEventListener(mousedownEvent, attr);
+        setEventListenerForTypeAndAttribute(mousedownEvent, attr);
     } else if (attr->name() == onmousemoveAttr) {
-        setHTMLEventListener(mousemoveEvent, attr);
+        setEventListenerForTypeAndAttribute(mousemoveEvent, attr);
     } else if (attr->name() == onmouseoutAttr) {
-        setHTMLEventListener(mouseoutEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseoutEvent, attr);
     } else if (attr->name() == onmouseoverAttr) {
-        setHTMLEventListener(mouseoverEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseoverEvent, attr);
     } else if (attr->name() == onmouseupAttr) {
-        setHTMLEventListener(mouseupEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseupEvent, attr);
     } else if (attr->name() == onmousewheelAttr) {
-        setHTMLEventListener(mousewheelEvent, attr);
+        setEventListenerForTypeAndAttribute(mousewheelEvent, attr);
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(focusEvent, attr);
+        setEventListenerForTypeAndAttribute(focusEvent, attr);
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(blurEvent, attr);
+        setEventListenerForTypeAndAttribute(blurEvent, attr);
     } else if (attr->name() == onkeydownAttr) {
-        setHTMLEventListener(keydownEvent, attr);
+        setEventListenerForTypeAndAttribute(keydownEvent, attr);
     } else if (attr->name() == onkeypressAttr) {
-        setHTMLEventListener(keypressEvent, attr);
+        setEventListenerForTypeAndAttribute(keypressEvent, attr);
     } else if (attr->name() == onkeyupAttr) {
-        setHTMLEventListener(keyupEvent, attr);
+        setEventListenerForTypeAndAttribute(keyupEvent, attr);
     } else if (attr->name() == onscrollAttr) {
-        setHTMLEventListener(scrollEvent, attr);
+        setEventListenerForTypeAndAttribute(scrollEvent, attr);
     } else if (attr->name() == onbeforecutAttr) {
-        setHTMLEventListener(beforecutEvent, attr);
+        setEventListenerForTypeAndAttribute(beforecutEvent, attr);
     } else if (attr->name() == oncutAttr) {
-        setHTMLEventListener(cutEvent, attr);
+        setEventListenerForTypeAndAttribute(cutEvent, attr);
     } else if (attr->name() == onbeforecopyAttr) {
-        setHTMLEventListener(beforecopyEvent, attr);
+        setEventListenerForTypeAndAttribute(beforecopyEvent, attr);
     } else if (attr->name() == oncopyAttr) {
-        setHTMLEventListener(copyEvent, attr);
+        setEventListenerForTypeAndAttribute(copyEvent, attr);
     } else if (attr->name() == onbeforepasteAttr) {
-        setHTMLEventListener(beforepasteEvent, attr);
+        setEventListenerForTypeAndAttribute(beforepasteEvent, attr);
     } else if (attr->name() == onpasteAttr) {
-        setHTMLEventListener(pasteEvent, attr);
+        setEventListenerForTypeAndAttribute(pasteEvent, attr);
     } else if (attr->name() == ondragenterAttr) {
-        setHTMLEventListener(dragenterEvent, attr);
+        setEventListenerForTypeAndAttribute(dragenterEvent, attr);
     } else if (attr->name() == ondragoverAttr) {
-        setHTMLEventListener(dragoverEvent, attr);
+        setEventListenerForTypeAndAttribute(dragoverEvent, attr);
     } else if (attr->name() == ondragleaveAttr) {
-        setHTMLEventListener(dragleaveEvent, attr);
+        setEventListenerForTypeAndAttribute(dragleaveEvent, attr);
     } else if (attr->name() == ondropAttr) {
-        setHTMLEventListener(dropEvent, attr);
+        setEventListenerForTypeAndAttribute(dropEvent, attr);
     } else if (attr->name() == ondragstartAttr) {
-        setHTMLEventListener(dragstartEvent, attr);
+        setEventListenerForTypeAndAttribute(dragstartEvent, attr);
     } else if (attr->name() == ondragAttr) {
-        setHTMLEventListener(dragEvent, attr);
+        setEventListenerForTypeAndAttribute(dragEvent, attr);
     } else if (attr->name() == ondragendAttr) {
-        setHTMLEventListener(dragendEvent, attr);
+        setEventListenerForTypeAndAttribute(dragendEvent, attr);
     } else if (attr->name() == onselectstartAttr) {
-        setHTMLEventListener(selectstartEvent, attr);
+        setEventListenerForTypeAndAttribute(selectstartEvent, attr);
     } else if (attr->name() == onsubmitAttr) {
-        setHTMLEventListener(submitEvent, attr);
+        setEventListenerForTypeAndAttribute(submitEvent, attr);
     } else if (attr->name() == onerrorAttr) {
-        setHTMLEventListener(errorEvent, attr);
+        setEventListenerForTypeAndAttribute(errorEvent, attr);
     } else if (attr->name() == onwebkitanimationstartAttr) {
-        setHTMLEventListener(webkitAnimationStartEvent, attr);
+        setEventListenerForTypeAndAttribute(webkitAnimationStartEvent, attr);
     } else if (attr->name() == onwebkitanimationiterationAttr) {
-        setHTMLEventListener(webkitAnimationIterationEvent, attr);
+        setEventListenerForTypeAndAttribute(webkitAnimationIterationEvent, attr);
     } else if (attr->name() == onwebkitanimationendAttr) {
-        setHTMLEventListener(webkitAnimationEndEvent, attr);
+        setEventListenerForTypeAndAttribute(webkitAnimationEndEvent, attr);
     } else if (attr->name() == onwebkittransitionendAttr) {
-        setHTMLEventListener(webkitTransitionEndEvent, attr);
+        setEventListenerForTypeAndAttribute(webkitTransitionEndEvent, attr);
     }
 }
 
@@ -973,12 +973,6 @@ bool HTMLElement::checkDTD(const Node* newChild)
         return true;
     return inEitherTagList(newChild);
 }
-
-void HTMLElement::setHTMLEventListener(const AtomicString& eventType, Attribute* attr)
-{
-    Element::setHTMLEventListener(eventType,
-        document()->createHTMLEventListener(attr->localName().string(), attr->value(), this));
-}
     
 bool HTMLElement::rendererIsNeeded(RenderStyle *style)
 {
index d5269d5..d231ab6 100644 (file)
@@ -98,8 +98,6 @@ public:
     static bool inBlockTagList(const Node*);
     static bool isRecognizedTagName(const QualifiedName&);
 
-    void setHTMLEventListener(const AtomicString& eventType, Attribute*);
-
     virtual bool rendererIsNeeded(RenderStyle*);
     virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
 
index 9c7f2da..9acee93 100644 (file)
@@ -161,7 +161,7 @@ void HTMLFormControlElement::setName(const AtomicString &value)
 
 void HTMLFormControlElement::onChange()
 {
-    dispatchHTMLEvent(changeEvent, true, false);
+    dispatchEventForType(changeEvent, true, false);
 }
 
 bool HTMLFormControlElement::disabled() const
index 1ee974f..ee54587 100644 (file)
@@ -359,7 +359,7 @@ bool HTMLFormElement::prepareSubmit(Event* event)
     m_insubmit = true;
     m_doingsubmit = false;
 
-    if (dispatchHTMLEvent(submitEvent, true, true) && !m_doingsubmit)
+    if (dispatchEventForType(submitEvent, true, true) && !m_doingsubmit)
         m_doingsubmit = true;
 
     m_insubmit = false;
@@ -514,7 +514,7 @@ void HTMLFormElement::reset()
 
     // ### DOM2 labels this event as not cancelable, however
     // common browsers( sick! ) allow it be cancelled.
-    if ( !dispatchHTMLEvent(resetEvent,true, true) ) {
+    if ( !dispatchEventForType(resetEvent,true, true) ) {
         m_inreset = false;
         return;
     }
@@ -551,9 +551,9 @@ void HTMLFormElement::parseMappedAttribute(MappedAttribute* attr)
         else
             document()->unregisterForCacheCallbacks(this);
     } else if (attr->name() == onsubmitAttr)
-        setHTMLEventListener(submitEvent, attr);
+        setEventListenerForTypeAndAttribute(submitEvent, attr);
     else if (attr->name() == onresetAttr)
-        setHTMLEventListener(resetEvent, attr);
+        setEventListenerForTypeAndAttribute(resetEvent, attr);
     else if (attr->name() == nameAttr) {
         const AtomicString& newName = attr->value();
         if (inDocument() && document()->isHTMLDocument()) {
index 051492c..b10738e 100644 (file)
@@ -141,10 +141,10 @@ void HTMLFrameElementBase::parseMappedAttribute(MappedAttribute *attr)
         if (contentFrame())
             contentFrame()->setInViewSourceMode(viewSourceMode());
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(loadEvent, attr);
+        setEventListenerForTypeAndAttribute(loadEvent, attr);
     } else if (attr->name() == onbeforeunloadAttr) {
         // FIXME: should <frame> elements have beforeunload handlers?
-        setHTMLEventListener(beforeunloadEvent, attr);
+        setEventListenerForTypeAndAttribute(beforeunloadEvent, attr);
     } else
         HTMLFrameOwnerElement::parseMappedAttribute(attr);
 }
index 1bd15a9..aacfb93 100644 (file)
@@ -126,11 +126,11 @@ void HTMLFrameSetElement::parseMappedAttribute(MappedAttribute *attr)
             m_borderColorSet = true;
         }
     } else if (attr->name() == onloadAttr) {
-        document()->setHTMLWindowEventListener(loadEvent, attr);
+        document()->setWindowEventListenerForTypeAndAttribute(loadEvent, attr);
     } else if (attr->name() == onbeforeunloadAttr) {
-        document()->setHTMLWindowEventListener(beforeunloadEvent, attr);
+        document()->setWindowEventListenerForTypeAndAttribute(beforeunloadEvent, attr);
     } else if (attr->name() == onunloadAttr) {
-        document()->setHTMLWindowEventListener(unloadEvent, attr);
+        document()->setWindowEventListenerForTypeAndAttribute(unloadEvent, attr);
     } else
         HTMLElement::parseMappedAttribute(attr);
 }
index 1ab678d..41867e4 100644 (file)
@@ -122,9 +122,9 @@ void HTMLImageElement::parseMappedAttribute(MappedAttribute* attr)
     } else if (attrName == ismapAttr)
         ismap = true;
     else if (attrName == onabortAttr)
-        setHTMLEventListener(abortEvent, attr);
+        setEventListenerForTypeAndAttribute(abortEvent, attr);
     else if (attrName == onloadAttr)
-        setHTMLEventListener(loadEvent, attr);
+        setEventListenerForTypeAndAttribute(loadEvent, attr);
     else if (attrName == compositeAttr) {
         if (!parseCompositeOperator(attr->value(), m_compositeOperator))
             m_compositeOperator = CompositeSourceOver;
index 6e9ec5a..fab264d 100644 (file)
@@ -129,7 +129,7 @@ void HTMLImageLoader::dispatchLoadEvent()
 {
     if (!haveFiredLoadEvent() && image()) {
         setHaveFiredLoadEvent(true);
-        element()->dispatchHTMLEvent(image()->errorOccurred() ? errorEvent : loadEvent, false, false);
+        element()->dispatchEventForType(image()->errorOccurred() ? errorEvent : loadEvent, false, false);
     }
 }
 
index 6961ad2..d482e24 100644 (file)
@@ -665,20 +665,20 @@ void HTMLInputElement::parseMappedAttribute(MappedAttribute *attr)
         if (respectHeightAndWidthAttrs())
             addCSSLength(attr, CSSPropertyHeight, attr->value());
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(focusEvent, attr);
+        setEventListenerForTypeAndAttribute(focusEvent, attr);
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(blurEvent, attr);
+        setEventListenerForTypeAndAttribute(blurEvent, attr);
     } else if (attr->name() == onselectAttr) {
-        setHTMLEventListener(selectEvent, attr);
+        setEventListenerForTypeAndAttribute(selectEvent, attr);
     } else if (attr->name() == onchangeAttr) {
-        setHTMLEventListener(changeEvent, attr);
+        setEventListenerForTypeAndAttribute(changeEvent, attr);
     } else if (attr->name() == oninputAttr) {
-        setHTMLEventListener(inputEvent, attr);
+        setEventListenerForTypeAndAttribute(inputEvent, attr);
     }
     // Search field and slider attributes all just cause updateFromElement to be called through style
     // recalcing.
     else if (attr->name() == onsearchAttr) {
-        setHTMLEventListener(searchEvent, attr);
+        setEventListenerForTypeAndAttribute(searchEvent, attr);
     } else if (attr->name() == resultsAttr) {
         int oldResults = m_maxResults;
         m_maxResults = !attr->isNull() ? min(attr->value().toInt(), maxSavedResults) : -1;
@@ -1042,7 +1042,7 @@ void HTMLInputElement::setValueFromRenderer(const String& value)
     setValueMatchesRenderer();
 
     // Fire the "input" DOM event.
-    dispatchHTMLEvent(inputEvent, true, false);
+    dispatchEventForType(inputEvent, true, false);
 }
 
 bool HTMLInputElement::storesValueSeparateFromAttribute() const
@@ -1580,7 +1580,7 @@ void HTMLInputElement::onSearch()
     ASSERT(isSearchField());
     if (renderer())
         static_cast<RenderTextControl*>(renderer())->stopSearchEventTimer();
-    dispatchHTMLEvent(searchEvent, true, false);
+    dispatchEventForType(searchEvent, true, false);
 }
 
 Selection HTMLInputElement::selection() const
index 8b52399..63b5304 100644 (file)
@@ -186,7 +186,7 @@ void HTMLMediaElement::asyncEventTimerFired(Timer<HTMLMediaElement>*)
     m_asyncEventsToDispatch.swap(asyncEventsToDispatch);
     unsigned count = asyncEventsToDispatch.size();
     for (unsigned n = 0; n < count; ++n)
-        dispatchHTMLEvent(asyncEventsToDispatch[n], false, true);
+        dispatchEventForType(asyncEventsToDispatch[n], false, true);
 }
 
 String serializeTimeOffset(float time)
@@ -302,7 +302,7 @@ void HTMLMediaElement::load(ExceptionCode& ec)
             m_player->seek(0);
         }
         m_currentLoop = 0;
-        dispatchHTMLEvent(emptiedEvent, false, true);
+        dispatchEventForType(emptiedEvent, false, true);
         if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel)
             goto end;
     }
@@ -377,7 +377,7 @@ void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*)
         if (isVideo())
             static_cast<HTMLVideoElement*>(this)->updatePosterImage();
 
-        dispatchHTMLEvent(emptiedEvent, false, true);
+        dispatchEventForType(emptiedEvent, false, true);
         return;
     }
     
@@ -388,11 +388,11 @@ void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*)
         m_player->seek(effectiveStart());
         m_networkState = LOADED_METADATA;
         
-        dispatchHTMLEvent(durationchangeEvent, false, true);
+        dispatchEventForType(durationchangeEvent, false, true);
         if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel)
             return;
         
-        dispatchHTMLEvent(loadedmetadataEvent, false, true);
+        dispatchEventForType(loadedmetadataEvent, false, true);
         if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel)
             return;
     }
@@ -414,11 +414,11 @@ void HTMLMediaElement::mediaPlayerNetworkStateChanged(MediaPlayer*)
             static_cast<RenderVideo*>(renderer())->videoSizeChanged();
         }
         
-        dispatchHTMLEvent(loadedfirstframeEvent, false, true);
+        dispatchEventForType(loadedfirstframeEvent, false, true);
         if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel)
             return;
         
-        dispatchHTMLEvent(canshowcurrentframeEvent, false, true);
+        dispatchEventForType(canshowcurrentframeEvent, false, true);
         if (m_loadNestingLevel < m_terminateLoadBelowNestingLevel)
             return;
     }
@@ -455,25 +455,25 @@ void HTMLMediaElement::setReadyState(ReadyState state)
         return;
     
     if (state == DATA_UNAVAILABLE) {
-        dispatchHTMLEvent(dataunavailableEvent, false, true);
+        dispatchEventForType(dataunavailableEvent, false, true);
         if (wasActivelyPlaying) {
-            dispatchHTMLEvent(timeupdateEvent, false, true);
-            dispatchHTMLEvent(waitingEvent, false, true);
+            dispatchEventForType(timeupdateEvent, false, true);
+            dispatchEventForType(waitingEvent, false, true);
         }
     } else if (state == CAN_SHOW_CURRENT_FRAME) {
         if (m_loadedFirstFrame)
-            dispatchHTMLEvent(canshowcurrentframeEvent, false, true);
+            dispatchEventForType(canshowcurrentframeEvent, false, true);
         if (wasActivelyPlaying) {
-            dispatchHTMLEvent(timeupdateEvent, false, true);
-            dispatchHTMLEvent(waitingEvent, false, true);
+            dispatchEventForType(timeupdateEvent, false, true);
+            dispatchEventForType(waitingEvent, false, true);
         }
     } else if (state == CAN_PLAY) {
-        dispatchHTMLEvent(canplayEvent, false, true);
+        dispatchEventForType(canplayEvent, false, true);
     } else if (state == CAN_PLAY_THROUGH) {
-        dispatchHTMLEvent(canplaythroughEvent, false, true);
+        dispatchEventForType(canplaythroughEvent, false, true);
         if (m_autoplaying && m_paused && autoplay()) {
             m_paused = false;
-            dispatchHTMLEvent(playEvent, false, true);
+            dispatchEventForType(playEvent, false, true);
         }
     }
     updatePlayState();
@@ -541,7 +541,7 @@ void HTMLMediaElement::seek(float time, ExceptionCode& ec)
     m_seeking = true;
     
     // 9
-    dispatchHTMLEvent(timeupdateEvent, false, true);
+    dispatchEventForType(timeupdateEvent, false, true);
     
     // 10
     // As soon as the user agent has established whether or not the media data for the new playback position is available, 
@@ -882,12 +882,12 @@ void HTMLMediaElement::mediaPlayerTimeChanged(MediaPlayer*)
         ExceptionCode ec;
         seek(effectiveLoopStart(), ec);
         m_currentLoop++;
-        dispatchHTMLEvent(timeupdateEvent, false, true);
+        dispatchEventForType(timeupdateEvent, false, true);
     }
     
     if (m_currentLoop == playCount() - 1 && currentTime() >= effectiveEnd()) {
-        dispatchHTMLEvent(timeupdateEvent, false, true);
-        dispatchHTMLEvent(endedEvent, false, true);
+        dispatchEventForType(timeupdateEvent, false, true);
+        dispatchEventForType(endedEvent, false, true);
     }
 
     updatePlayState();
@@ -1014,7 +1014,7 @@ void HTMLMediaElement::willSaveToCache()
         if (m_networkState >= LOADING) {
             m_networkState = EMPTY;
             m_readyState = DATA_UNAVAILABLE;
-            dispatchHTMLEvent(emptiedEvent, false, true);
+            dispatchEventForType(emptiedEvent, false, true);
         }
     }
     m_inPageCache = true;
index 95f2b5d..9497818 100644 (file)
@@ -94,7 +94,7 @@ void HTMLObjectElement::parseMappedAttribute(MappedAttribute *attr)
         if (renderer())
           m_needWidgetUpdate = true;
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(loadEvent, attr);
+        setEventListenerForTypeAndAttribute(loadEvent, attr);
     } else if (attr->name() == nameAttr) {
         const AtomicString& newName = attr->value();
         if (isDocNamedItem() && inDocument() && document()->isHTMLDocument()) {
index 078eb40..63b5fd4 100644 (file)
@@ -71,7 +71,7 @@ void HTMLScriptElement::parseMappedAttribute(MappedAttribute* attr)
     if (attrName == srcAttr)
         handleSourceAttribute(m_data, attr->value());
     else if (attrName == onloadAttr)
-        setHTMLEventListener(loadEvent, attr);
+        setEventListenerForTypeAndAttribute(loadEvent, attr);
     else
         HTMLElement::parseMappedAttribute(attr);
 }
@@ -211,15 +211,15 @@ String HTMLScriptElement::languageAttributeValue() const
 {
     return getAttribute(languageAttr).string();
 }
-
 void HTMLScriptElement::dispatchLoadEvent()
 {
-    dispatchHTMLEvent(loadEvent, false, false);
+    dispatchEventForType(loadEvent, false, false);
 }
 
 void HTMLScriptElement::dispatchErrorEvent()
 {
-    dispatchHTMLEvent(errorEvent, true, false);
+    dispatchEventForType(errorEvent, true, false);
 }
 
 }
index cd16463..5d25613 100644 (file)
@@ -374,11 +374,11 @@ void HTMLSelectElement::parseMappedAttribute(MappedAttribute *attr)
         // Don't map 'align' attribute.  This matches what Firefox, Opera and IE do.
         // See http://bugs.webkit.org/show_bug.cgi?id=12072
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(focusEvent, attr);
+        setEventListenerForTypeAndAttribute(focusEvent, attr);
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(blurEvent, attr);
+        setEventListenerForTypeAndAttribute(blurEvent, attr);
     } else if (attr->name() == onchangeAttr) {
-        setHTMLEventListener(changeEvent, attr);
+        setEventListenerForTypeAndAttribute(changeEvent, attr);
     } else
         HTMLFormControlElementWithState::parseMappedAttribute(attr);
 }
index de165b3..0d6f4fd 100644 (file)
@@ -168,13 +168,13 @@ void HTMLTextAreaElement::parseMappedAttribute(MappedAttribute* attr)
         // Don't map 'align' attribute.  This matches what Firefox, Opera and IE do.
         // See http://bugs.webkit.org/show_bug.cgi?id=7075
     } else if (attr->name() == onfocusAttr)
-        setHTMLEventListener(focusEvent, attr);
+        setEventListenerForTypeAndAttribute(focusEvent, attr);
     else if (attr->name() == onblurAttr)
-        setHTMLEventListener(blurEvent, attr);
+        setEventListenerForTypeAndAttribute(blurEvent, attr);
     else if (attr->name() == onselectAttr)
-        setHTMLEventListener(selectEvent, attr);
+        setEventListenerForTypeAndAttribute(selectEvent, attr);
     else if (attr->name() == onchangeAttr)
-        setHTMLEventListener(changeEvent, attr);
+        setEventListenerForTypeAndAttribute(changeEvent, attr);
     else
         HTMLFormControlElementWithState::parseMappedAttribute(attr);
 }
index 13388e7..5caaa0d 100644 (file)
@@ -2002,11 +2002,11 @@ void HTMLTokenizer::notifyFinished(CachedResource*)
 #endif
 
         if (errorOccurred)
-            EventTargetNodeCast(n.get())->dispatchHTMLEvent(errorEvent, true, false);
+            EventTargetNodeCast(n.get())->dispatchEventForType(errorEvent, true, false);
         else {
             if (static_cast<HTMLScriptElement*>(n.get())->shouldExecuteAsJavaScript())
                 m_state = scriptExecution(scriptSource, m_state, cachedScriptUrl);
-            EventTargetNodeCast(n.get())->dispatchHTMLEvent(loadEvent, false, false);
+            EventTargetNodeCast(n.get())->dispatchEventForType(loadEvent, false, false);
         }
 
         // The state of pendingScripts.isEmpty() can change inside the scriptExecution()
index 55ca0b6..3c5ff6b 100644 (file)
@@ -494,7 +494,7 @@ Element* AccessibilityRenderObject::mouseButtonListener() const
     
     // FIXME: Do the continuation search like anchorElement does
     for (EventTargetNode* elt = static_cast<EventTargetNode*>(node); elt; elt = static_cast<EventTargetNode*>(elt->parentNode())) {
-        if (elt->getHTMLEventListener(clickEvent) || elt->getHTMLEventListener(mousedownEvent) || elt->getHTMLEventListener(mouseupEvent))
+        if (elt->eventListenerForType(clickEvent) || elt->eventListenerForType(mousedownEvent) || elt->eventListenerForType(mouseupEvent))
             return static_cast<Element*>(elt);
     }
     
index 264912d..e876d1e 100644 (file)
@@ -1582,7 +1582,7 @@ bool EventHandler::canMouseDownStartSelect(Node* node)
             
     for (RenderObject* curr = node->renderer(); curr; curr = curr->parent())    
         if (Node* node = curr->element())
-            return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
+            return EventTargetNodeCast(node)->dispatchEventForType(selectstartEvent, true, true);
     
     return true;
 }
@@ -1594,7 +1594,7 @@ bool EventHandler::canMouseDragExtendSelect(Node* node)
             
     for (RenderObject* curr = node->renderer(); curr; curr = curr->parent())    
         if (Node* node = curr->element())
-            return EventTargetNodeCast(node)->dispatchHTMLEvent(selectstartEvent, true, true);
+            return EventTargetNodeCast(node)->dispatchEventForType(selectstartEvent, true, true);
     
     return true;
 }
index 1428e99..7ccec23 100644 (file)
@@ -1388,7 +1388,7 @@ void Frame::sendScrollEvent()
     Document* doc = document();
     if (!doc)
         return;
-    doc->dispatchHTMLEvent(scrollEvent, true, false);
+    doc->dispatchEventForType(scrollEvent, true, false);
 }
 
 void Frame::clearTimers(FrameView *view, Document *document)
index 7d75e96..6492fae 100644 (file)
@@ -96,7 +96,7 @@ static void networkStateChanged()
         if (!eventTarget)
             eventTarget = document;
         
-        eventTarget->dispatchHTMLEvent(eventName, false, false);
+        eventTarget->dispatchEventForType(eventName, false, false);
     }
 }
     
index 3bbf92d..85693ea 100644 (file)
@@ -536,7 +536,7 @@ void RenderListBox::valueChanged(Scrollbar*)
         m_indexOffset = newOffset;
         repaint();
         // Fire the scroll DOM event.
-        EventTargetNodeCast(node())->dispatchHTMLEvent(scrollEvent, false, false);
+        EventTargetNodeCast(node())->dispatchEventForType(scrollEvent, false, false);
     }
 }
 
index e4e1075..8fcb48c 100644 (file)
@@ -885,7 +885,7 @@ void RenderTextControl::selectionChanged(bool userTriggered)
         static_cast<HTMLInputElement*>(element)->cacheSelection(selectionStart(), selectionEnd());
     if (Frame* frame = document()->frame())
         if (frame->selection()->isRange() && userTriggered)
-            element->dispatchHTMLEvent(selectEvent, true, false);
+            element->dispatchEventForType(selectEvent, true, false);
 }
 
 void RenderTextControl::autoscroll()
index 6d54050..98e6d68 100644 (file)
@@ -52,14 +52,6 @@ SVGDocumentExtensions::~SVGDocumentExtensions()
     deleteAllValues(m_elementInstances);
 }
 
-PassRefPtr<EventListener> SVGDocumentExtensions::createSVGEventListener(const String& functionName, const String& code, Node *node)
-{
-    if (Frame* frame = m_doc->frame())
-        if (frame->script()->isEnabled())
-            return frame->script()->createSVGEventHandler(functionName, code, node);
-    return 0;
-}
-
 void SVGDocumentExtensions::addTimeContainer(SVGSVGElement* element)
 {
     m_timeContainers.add(element);
index 882190d..a6205a2 100644 (file)
@@ -48,8 +48,6 @@ public:
     SVGDocumentExtensions(Document*);
     ~SVGDocumentExtensions();
     
-    PassRefPtr<EventListener> createSVGEventListener(const String& functionName, const String& code, Node*);
-    
     void addTimeContainer(SVGSVGElement*);
     void removeTimeContainer(SVGSVGElement*);
     
index bcffc8b..6c20914 100644 (file)
@@ -111,35 +111,29 @@ SVGElement* SVGElement::viewportElement() const
     return 0;
 }
 
-void SVGElement::addSVGEventListener(const AtomicString& eventType, const Attribute* attr)
-{
-    Element::setHTMLEventListener(eventType, document()->accessSVGExtensions()->
-        createSVGEventListener(attr->localName().string(), attr->value(), this));
-}
-
 void SVGElement::parseMappedAttribute(MappedAttribute* attr)
 {
     // standard events
     if (attr->name() == onloadAttr)
-        addSVGEventListener(loadEvent, attr);
+        setEventListenerForTypeAndAttribute(loadEvent, attr);
     else if (attr->name() == onclickAttr)
-        addSVGEventListener(clickEvent, attr);
+        setEventListenerForTypeAndAttribute(clickEvent, attr);
     else if (attr->name() == onmousedownAttr)
-        addSVGEventListener(mousedownEvent, attr);
+        setEventListenerForTypeAndAttribute(mousedownEvent, attr);
     else if (attr->name() == onmousemoveAttr)
-        addSVGEventListener(mousemoveEvent, attr);
+        setEventListenerForTypeAndAttribute(mousemoveEvent, attr);
     else if (attr->name() == onmouseoutAttr)
-        addSVGEventListener(mouseoutEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseoutEvent, attr);
     else if (attr->name() == onmouseoverAttr)
-        addSVGEventListener(mouseoverEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseoverEvent, attr);
     else if (attr->name() == onmouseupAttr)
-        addSVGEventListener(mouseupEvent, attr);
+        setEventListenerForTypeAndAttribute(mouseupEvent, attr);
     else if (attr->name() == SVGNames::onfocusinAttr)
-        addSVGEventListener(DOMFocusInEvent, attr);
+        setEventListenerForTypeAndAttribute(DOMFocusInEvent, attr);
     else if (attr->name() == SVGNames::onfocusoutAttr)
-        addSVGEventListener(DOMFocusOutEvent, attr);
+        setEventListenerForTypeAndAttribute(DOMFocusOutEvent, attr);
     else if (attr->name() == SVGNames::onactivateAttr)
-        addSVGEventListener(DOMActivateEvent, attr);
+        setEventListenerForTypeAndAttribute(DOMActivateEvent, attr);
     else
         StyledElement::parseMappedAttribute(attr);
 }
@@ -192,6 +186,8 @@ void SVGElement::sendSVGLoadEventIfPossible(bool sendParentLoadEvents)
 
 void SVGElement::finishParsingChildren()
 {
+    StyledElement::finishParsingChildren();
+
     // finishParsingChildren() is called when the close tag is reached for an element (e.g. </svg>)
     // we send SVGLoad events here if we can, otherwise they'll be sent when any required loads finish
     sendSVGLoadEventIfPossible();
index 2cf8a49..f907a10 100644 (file)
@@ -114,7 +114,6 @@ namespace WebCore {
         }
 
     private:
-        void addSVGEventListener(const AtomicString& eventType, const Attribute*);
         virtual bool haveLoadedRequiredResources();
 
         Node* m_shadowParent;
index 0727579..4cd0a2d 100644 (file)
@@ -207,33 +207,32 @@ void SVGSVGElement::setCurrentTranslate(const FloatPoint &translation)
         document()->renderer()->repaint();
 }
 
-void SVGSVGElement::addSVGWindowEventListener(const AtomicString& eventType, const Attribute* attr)
-{
-    // FIXME: None of these should be window events long term.
-    // Once we propertly support SVGLoad, etc.
-    RefPtr<EventListener> listener = document()->accessSVGExtensions()->
-        createSVGEventListener(attr->localName().string(), attr->value(), this);
-    document()->setHTMLWindowEventListener(eventType, listener.release());
-}
-
 void SVGSVGElement::parseMappedAttribute(MappedAttribute* attr)
 {
     if (!nearestViewportElement()) {
+        bool setListener = true;
+
         // Only handle events if we're the outermost <svg> element
         if (attr->name() == onunloadAttr)
-            addSVGWindowEventListener(unloadEvent, attr);
-        else if (attr->name() == onabortAttr)
-            addSVGWindowEventListener(abortEvent, attr);
-        else if (attr->name() == onerrorAttr)
-            addSVGWindowEventListener(errorEvent, attr);
+            document()->setWindowEventListenerForTypeAndAttribute(unloadEvent, attr);
         else if (attr->name() == onresizeAttr)
-            addSVGWindowEventListener(resizeEvent, attr);
+            document()->setWindowEventListenerForTypeAndAttribute(resizeEvent, attr);
         else if (attr->name() == onscrollAttr)
-            addSVGWindowEventListener(scrollEvent, attr);
+            document()->setWindowEventListenerForTypeAndAttribute(scrollEvent, attr);
         else if (attr->name() == SVGNames::onzoomAttr)
-            addSVGWindowEventListener(zoomEvent, attr);
+            document()->setWindowEventListenerForTypeAndAttribute(zoomEvent, attr);
+        else
+            setListener = false;
+        if (setListener)
+            return;
     }
-    if (attr->name() == SVGNames::xAttr)
+
+    if (attr->name() == onabortAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(abortEvent, attr);
+    else if (attr->name() == onerrorAttr)
+        document()->setWindowEventListenerForTypeAndAttribute(errorEvent, attr);
+    else if (attr->name() == SVGNames::xAttr)
         setXBaseValue(SVGLength(LengthModeWidth, attr->value()));
     else if (attr->name() == SVGNames::yAttr)
         setYBaseValue(SVGLength(LengthModeHeight, attr->value()));
index f90c587..4aa5d3e 100644 (file)
@@ -145,8 +145,6 @@ namespace WebCore
         bool isOutermostSVG() const;
 
     private:
-        void addSVGWindowEventListener(const AtomicString& eventType, const Attribute* attr);   
-
         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::xAttrString, SVGLength, X, x)
         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::yAttrString, SVGLength, Y, y)
         ANIMATED_PROPERTY_DECLARATIONS(SVGSVGElement, SVGNames::svgTagString, SVGNames::widthAttrString, SVGLength, Width, width)