Reviewed by Maciej.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2005 04:38:45 +0000 (04:38 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Aug 2005 04:38:45 +0000 (04:38 +0000)
        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4540
          event handlers for all custom events called when any custom event is set

        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt: Updated results
        to expect success.

        * khtml/xml/EventNames.h: Added.
        * khtml/xml/EventNames.cpp: Added.
        * ForwardingHeaders/xml/EventNames.h: Added.
        * WebCore.xcodeproj/project.pbxproj: Added EventNames.h and EventNames.cpp.

        * khtml/xml/dom2_eventsimpl.h: Removed EventId type. Made a few more functions inline.
        * khtml/xml/dom2_eventsimpl.cpp:
        (DOM::EventImpl::EventImpl):
        (DOM::EventImpl::~EventImpl):
        (DOM::EventImpl::initEvent):
        (DOM::UIEventImpl::UIEventImpl):
        (DOM::UIEventImpl::initUIEvent):
        (DOM::MouseRelatedEventImpl::MouseRelatedEventImpl):
        (DOM::MouseEventImpl::MouseEventImpl):
        (DOM::MouseEventImpl::initMouseEvent):
        (DOM::MouseEventImpl::isDragEvent):
        (DOM::KeyboardEventImpl::KeyboardEventImpl):
        (DOM::KeyboardEventImpl::initKeyboardEvent):
        (DOM::KeyboardEventImpl::keyCode):
        (DOM::MutationEventImpl::MutationEventImpl):
        (DOM::MutationEventImpl::initMutationEvent):
        (DOM::ClipboardEventImpl::ClipboardEventImpl):
        (DOM::WheelEventImpl::WheelEventImpl):
        (DOM::RegisteredEventListener::RegisteredEventListener):
        (DOM::RegisteredEventListener::~RegisteredEventListener):
        Updated to use the new AtomicString type rather than a type string and separate ID.

        * khtml/xml/dom_atomicstring.h: Implemented the constructor that takes an NSString.

        * khtml/ecma/kjs_binding.cpp:
        (KJS::ScriptInterpreter::wasRunByUserGesture):
        * khtml/ecma/kjs_dom.cpp:
        (KJS::DOMNode::getValueProperty):
        (KJS::DOMNode::putValueProperty):
        (KJS::DOMNode::setListener):
        (KJS::DOMNode::getListener):
        (KJS::DOMNodeProtoFunc::callAsFunction):
        * khtml/ecma/kjs_dom.h:
        * khtml/ecma/kjs_events.cpp:
        (KJS::getNodeEventListener):
        (KJS::DOMEvent::getValueProperty):
        (KJS::DOMEventProtoFunc::callAsFunction):
        (KJS::DOMUIEventProtoFunc::callAsFunction):
        (KJS::DOMMouseEvent::getValueProperty):
        (KJS::DOMMouseEventProtoFunc::callAsFunction):
        (KJS::DOMKeyboardEventProtoFunc::callAsFunction):
        (KJS::DOMMutationEventProtoFunc::callAsFunction):
        * khtml/ecma/kjs_events.h:
        * khtml/ecma/kjs_window.cpp:
        (KJS::Window::getValueProperty):
        (KJS::Window::put):
        (KJS::Window::setListener):
        (KJS::Window::getListener):
        (KJS::WindowFunc::callAsFunction):
        * khtml/ecma/kjs_window.h:
        * khtml/html/html_baseimpl.cpp:
        (HTMLBodyElementImpl::parseMappedAttribute):
        (HTMLFrameElementImpl::parseMappedAttribute):
        (HTMLFrameSetElementImpl::parseMappedAttribute):
        (HTMLFrameSetElementImpl::detach):
        * khtml/html/html_elementimpl.cpp:
        (HTMLElementImpl::parseMappedAttribute):
        (HTMLElementImpl::click):
        (inlineTagList):
        (blockTagList):
        * khtml/html/html_formimpl.cpp:
        (DOM::HTMLFormElementImpl::prepareSubmit):
        (DOM::HTMLFormElementImpl::reset):
        (DOM::HTMLFormElementImpl::parseMappedAttribute):
        (DOM::HTMLGenericFormElementImpl::onSelect):
        (DOM::HTMLGenericFormElementImpl::onChange):
        (DOM::HTMLGenericFormElementImpl::defaultEventHandler):
        (DOM::HTMLButtonElementImpl::parseMappedAttribute):
        (DOM::HTMLButtonElementImpl::defaultEventHandler):
        (DOM::HTMLInputElementImpl::parseMappedAttribute):
        (DOM::HTMLInputElementImpl::setValueFromRenderer):
        (DOM::HTMLInputElementImpl::preDispatchEventHandler):
        (DOM::HTMLInputElementImpl::defaultEventHandler):
        (DOM::HTMLLabelElementImpl::parseMappedAttribute):
        (DOM::HTMLSelectElementImpl::parseMappedAttribute):
        (DOM::HTMLSelectElementImpl::defaultEventHandler):
        (DOM::HTMLTextAreaElementImpl::parseMappedAttribute):
        * khtml/html/html_imageimpl.cpp:
        (HTMLImageLoader::dispatchLoadEvent):
        (HTMLImageElementImpl::parseMappedAttribute):
        * khtml/html/html_inlineimpl.cpp:
        (DOM::HTMLAnchorElementImpl::defaultEventHandler):
        * khtml/html/html_objectimpl.cpp:
        (DOM::HTMLObjectElementImpl::parseMappedAttribute):
        (DOM::HTMLObjectElementImpl::attach):
        (DOM::HTMLObjectElementImpl::detach):
        (DOM::HTMLObjectElementImpl::recalcStyle):
        * khtml/khtml_part.cpp:
        (KHTMLPart::init):
        (KHTMLPart::stopLoading):
        * khtml/khtmlview.cpp:
        (KHTMLView::resizeEvent):
        (KHTMLView::viewportMousePressEvent):
        (KHTMLView::viewportMouseDoubleClickEvent):
        (KHTMLView::viewportMouseMoveEvent):
        (KHTMLView::viewportMouseReleaseEvent):
        (KHTMLView::dispatchDragEvent):
        (KHTMLView::updateDragAndDrop):
        (KHTMLView::cancelDragAndDrop):
        (KHTMLView::performDragAndDrop):
        (KHTMLView::dispatchMouseEvent):
        * khtml/khtmlview.h:
        * khtml/rendering/render_form.cpp:
        (RenderFormElement::slotClicked):
        (RenderLineEdit::slotPerformSearch):
        (RenderSlider::slotSliderValueChanged):
        * khtml/rendering/render_frames.cpp:
        (RenderFrameSet::userResize):
        * khtml/rendering/render_layer.cpp:
        (khtml::RenderLayer::scrollToOffset):
        * khtml/rendering/render_object.cpp:
        (RenderObject::shouldSelect):
        * khtml/rendering/render_replaced.cpp:
        (RenderWidget::sendConsumedMouseUp):
        (RenderWidget::eventFilter):
        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::implicitClose):
        (DocumentImpl::setFocusNode):
        (DocumentImpl::defaultEventHandler):
        (DocumentImpl::setHTMLWindowEventListener):
        (DocumentImpl::getHTMLWindowEventListener):
        (DocumentImpl::removeHTMLWindowEventListener):
        (DocumentImpl::addWindowEventListener):
        (DocumentImpl::removeWindowEventListener):
        (DocumentImpl::hasWindowEventListener):
        * khtml/xml/dom_docimpl.h:
        * khtml/xml/dom_elementimpl.cpp:
        (ElementImpl::dispatchAttrRemovalEvent):
        (ElementImpl::dispatchAttrAdditionEvent):
        * khtml/xml/dom_nodeimpl.cpp:
        (DOM::NodeImpl::addEventListener):
        (DOM::NodeImpl::removeEventListener):
        (DOM::NodeImpl::removeHTMLEventListener):
        (DOM::NodeImpl::setHTMLEventListener):
        (DOM::NodeImpl::getHTMLEventListener):
        (DOM::NodeImpl::dispatchHTMLEvent):
        (DOM::NodeImpl::dispatchWindowEvent):
        (DOM::NodeImpl::dispatchMouseEvent):
        (DOM::NodeImpl::dispatchUIEvent):
        (DOM::NodeImpl::dispatchSubtreeModifiedEvent):
        (DOM::NodeImpl::handleLocalEvents):
        (DOM::ContainerNodeImpl::removeChild):
        (DOM::ContainerNodeImpl::dispatchChildInsertedEvents):
        (DOM::ContainerNodeImpl::dispatchChildRemovalEvents):
        * khtml/xml/dom_nodeimpl.h:
        * khtml/xml/dom_textimpl.cpp:
        (CharacterDataImpl::dispatchModifiedEvent):
        * kwq/KWQAccObject.mm:
        (-[KWQAccObject mouseButtonListener]):
        * kwq/KWQKHTMLPart.h:
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::canCachePage):
        (KWQKHTMLPart::sendScrollEvent):
        (KWQKHTMLPart::dispatchDragSrcEvent):
        (KWQKHTMLPart::khtmlMouseMoveEvent):
        (KWQKHTMLPart::dragSourceMovedTo):
        (KWQKHTMLPart::dragSourceEndedAt):
        (KWQKHTMLPart::dispatchCPPEvent):
        (KWQKHTMLPart::mayCut):
        (KWQKHTMLPart::mayCopy):
        (KWQKHTMLPart::mayPaste):
        (KWQKHTMLPart::tryCut):
        (KWQKHTMLPart::tryCopy):
        (KWQKHTMLPart::tryPaste):
        (KWQKHTMLPart::sendContextMenuEvent):
        (KWQKHTMLPart::setWindowHasFocus):
        * kwq/KWQTextArea.mm:
        (-[KWQTextAreaTextView dispatchHTMLEvent:]):
        (-[KWQTextAreaTextView cut:]):
        (-[KWQTextAreaTextView copy:]):
        (-[KWQTextAreaTextView paste:]):
        (-[KWQTextAreaTextView pasteAsPlainText:]):
        (-[KWQTextAreaTextView pasteAsRichText:]):
        Use the new namespace, types, and use AtomicString instead of event ID.

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

40 files changed:
LayoutTests/dom/html/level2/events/dispatchEvent12-expected.txt
WebCore/ChangeLog-2005-12-19
WebCore/ForwardingHeaders/xml/EventNames.h [new file with mode: 0644]
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/khtml/ecma/kjs_binding.cpp
WebCore/khtml/ecma/kjs_dom.cpp
WebCore/khtml/ecma/kjs_dom.h
WebCore/khtml/ecma/kjs_events.cpp
WebCore/khtml/ecma/kjs_events.h
WebCore/khtml/ecma/kjs_window.cpp
WebCore/khtml/ecma/kjs_window.h
WebCore/khtml/html/html_baseimpl.cpp
WebCore/khtml/html/html_elementimpl.cpp
WebCore/khtml/html/html_formimpl.cpp
WebCore/khtml/html/html_imageimpl.cpp
WebCore/khtml/html/html_inlineimpl.cpp
WebCore/khtml/html/html_objectimpl.cpp
WebCore/khtml/khtml_part.cpp
WebCore/khtml/khtmlview.cpp
WebCore/khtml/khtmlview.h
WebCore/khtml/rendering/render_form.cpp
WebCore/khtml/rendering/render_frames.cpp
WebCore/khtml/rendering/render_layer.cpp
WebCore/khtml/rendering/render_object.cpp
WebCore/khtml/rendering/render_replaced.cpp
WebCore/khtml/xml/EventNames.cpp [new file with mode: 0644]
WebCore/khtml/xml/EventNames.h [new file with mode: 0644]
WebCore/khtml/xml/dom2_eventsimpl.cpp
WebCore/khtml/xml/dom2_eventsimpl.h
WebCore/khtml/xml/dom_atomicstring.h
WebCore/khtml/xml/dom_docimpl.cpp
WebCore/khtml/xml/dom_docimpl.h
WebCore/khtml/xml/dom_elementimpl.cpp
WebCore/khtml/xml/dom_nodeimpl.cpp
WebCore/khtml/xml/dom_nodeimpl.h
WebCore/khtml/xml/dom_textimpl.cpp
WebCore/kwq/KWQAccObject.mm
WebCore/kwq/KWQKHTMLPart.h
WebCore/kwq/KWQKHTMLPart.mm
WebCore/kwq/KWQTextArea.mm

index ec930d61f0c365021fe3d7d200ab02781ffddbc7..a241a227534963af1341dc662a647ce333210334 100644 (file)
@@ -1,3 +1,2 @@
-Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent12     
-Status:        failure
-Detail:        eventCount: assertEquals failed, actual 0, expected 1.
+Test:  http://www.w3.org/2001/DOM-Test-Suite/level2/events/dispatchEvent12
+Status:        Success
index 640d4d9d83a13cab4a3b7c0225aa0fe88ac29935..2e239dc9c5a0db67701dc99749c6fea13e63b3d7 100644 (file)
@@ -1,3 +1,193 @@
+2005-08-30  Darin Adler  <darin@apple.com>
+
+        Reviewed by Maciej.
+
+        - fixed http://bugzilla.opendarwin.org/show_bug.cgi?id=4540
+          event handlers for all custom events called when any custom event is set
+
+        * layout-tests/dom/html/level2/events/dispatchEvent12-expected.txt: Updated results
+        to expect success.
+
+        * khtml/xml/EventNames.h: Added.
+        * khtml/xml/EventNames.cpp: Added.
+        * ForwardingHeaders/xml/EventNames.h: Added.
+        * WebCore.xcodeproj/project.pbxproj: Added EventNames.h and EventNames.cpp.
+
+        * khtml/xml/dom2_eventsimpl.h: Removed EventId type. Made a few more functions inline.
+        * khtml/xml/dom2_eventsimpl.cpp:
+        (DOM::EventImpl::EventImpl):
+        (DOM::EventImpl::~EventImpl):
+        (DOM::EventImpl::initEvent):
+        (DOM::UIEventImpl::UIEventImpl):
+        (DOM::UIEventImpl::initUIEvent):
+        (DOM::MouseRelatedEventImpl::MouseRelatedEventImpl):
+        (DOM::MouseEventImpl::MouseEventImpl):
+        (DOM::MouseEventImpl::initMouseEvent):
+        (DOM::MouseEventImpl::isDragEvent):
+        (DOM::KeyboardEventImpl::KeyboardEventImpl):
+        (DOM::KeyboardEventImpl::initKeyboardEvent):
+        (DOM::KeyboardEventImpl::keyCode):
+        (DOM::MutationEventImpl::MutationEventImpl):
+        (DOM::MutationEventImpl::initMutationEvent):
+        (DOM::ClipboardEventImpl::ClipboardEventImpl):
+        (DOM::WheelEventImpl::WheelEventImpl):
+        (DOM::RegisteredEventListener::RegisteredEventListener):
+        (DOM::RegisteredEventListener::~RegisteredEventListener):
+        Updated to use the new AtomicString type rather than a type string and separate ID.
+
+        * khtml/xml/dom_atomicstring.h: Implemented the constructor that takes an NSString.
+
+        * khtml/ecma/kjs_binding.cpp:
+        (KJS::ScriptInterpreter::wasRunByUserGesture):
+        * khtml/ecma/kjs_dom.cpp:
+        (KJS::DOMNode::getValueProperty):
+        (KJS::DOMNode::putValueProperty):
+        (KJS::DOMNode::setListener):
+        (KJS::DOMNode::getListener):
+        (KJS::DOMNodeProtoFunc::callAsFunction):
+        * khtml/ecma/kjs_dom.h:
+        * khtml/ecma/kjs_events.cpp:
+        (KJS::getNodeEventListener):
+        (KJS::DOMEvent::getValueProperty):
+        (KJS::DOMEventProtoFunc::callAsFunction):
+        (KJS::DOMUIEventProtoFunc::callAsFunction):
+        (KJS::DOMMouseEvent::getValueProperty):
+        (KJS::DOMMouseEventProtoFunc::callAsFunction):
+        (KJS::DOMKeyboardEventProtoFunc::callAsFunction):
+        (KJS::DOMMutationEventProtoFunc::callAsFunction):
+        * khtml/ecma/kjs_events.h:
+        * khtml/ecma/kjs_window.cpp:
+        (KJS::Window::getValueProperty):
+        (KJS::Window::put):
+        (KJS::Window::setListener):
+        (KJS::Window::getListener):
+        (KJS::WindowFunc::callAsFunction):
+        * khtml/ecma/kjs_window.h:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseMappedAttribute):
+        (HTMLFrameElementImpl::parseMappedAttribute):
+        (HTMLFrameSetElementImpl::parseMappedAttribute):
+        (HTMLFrameSetElementImpl::detach):
+        * khtml/html/html_elementimpl.cpp:
+        (HTMLElementImpl::parseMappedAttribute):
+        (HTMLElementImpl::click):
+        (inlineTagList):
+        (blockTagList):
+        * khtml/html/html_formimpl.cpp:
+        (DOM::HTMLFormElementImpl::prepareSubmit):
+        (DOM::HTMLFormElementImpl::reset):
+        (DOM::HTMLFormElementImpl::parseMappedAttribute):
+        (DOM::HTMLGenericFormElementImpl::onSelect):
+        (DOM::HTMLGenericFormElementImpl::onChange):
+        (DOM::HTMLGenericFormElementImpl::defaultEventHandler):
+        (DOM::HTMLButtonElementImpl::parseMappedAttribute):
+        (DOM::HTMLButtonElementImpl::defaultEventHandler):
+        (DOM::HTMLInputElementImpl::parseMappedAttribute):
+        (DOM::HTMLInputElementImpl::setValueFromRenderer):
+        (DOM::HTMLInputElementImpl::preDispatchEventHandler):
+        (DOM::HTMLInputElementImpl::defaultEventHandler):
+        (DOM::HTMLLabelElementImpl::parseMappedAttribute):
+        (DOM::HTMLSelectElementImpl::parseMappedAttribute):
+        (DOM::HTMLSelectElementImpl::defaultEventHandler):
+        (DOM::HTMLTextAreaElementImpl::parseMappedAttribute):
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageLoader::dispatchLoadEvent):
+        (HTMLImageElementImpl::parseMappedAttribute):
+        * khtml/html/html_inlineimpl.cpp:
+        (DOM::HTMLAnchorElementImpl::defaultEventHandler):
+        * khtml/html/html_objectimpl.cpp:
+        (DOM::HTMLObjectElementImpl::parseMappedAttribute):
+        (DOM::HTMLObjectElementImpl::attach):
+        (DOM::HTMLObjectElementImpl::detach):
+        (DOM::HTMLObjectElementImpl::recalcStyle):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::init):
+        (KHTMLPart::stopLoading):
+        * khtml/khtmlview.cpp:
+        (KHTMLView::resizeEvent):
+        (KHTMLView::viewportMousePressEvent):
+        (KHTMLView::viewportMouseDoubleClickEvent):
+        (KHTMLView::viewportMouseMoveEvent):
+        (KHTMLView::viewportMouseReleaseEvent):
+        (KHTMLView::dispatchDragEvent):
+        (KHTMLView::updateDragAndDrop):
+        (KHTMLView::cancelDragAndDrop):
+        (KHTMLView::performDragAndDrop):
+        (KHTMLView::dispatchMouseEvent):
+        * khtml/khtmlview.h:
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::slotClicked):
+        (RenderLineEdit::slotPerformSearch):
+        (RenderSlider::slotSliderValueChanged):
+        * khtml/rendering/render_frames.cpp:
+        (RenderFrameSet::userResize):
+        * khtml/rendering/render_layer.cpp:
+        (khtml::RenderLayer::scrollToOffset):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::shouldSelect):
+        * khtml/rendering/render_replaced.cpp:
+        (RenderWidget::sendConsumedMouseUp):
+        (RenderWidget::eventFilter):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::implicitClose):
+        (DocumentImpl::setFocusNode):
+        (DocumentImpl::defaultEventHandler):
+        (DocumentImpl::setHTMLWindowEventListener):
+        (DocumentImpl::getHTMLWindowEventListener):
+        (DocumentImpl::removeHTMLWindowEventListener):
+        (DocumentImpl::addWindowEventListener):
+        (DocumentImpl::removeWindowEventListener):
+        (DocumentImpl::hasWindowEventListener):
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::dispatchAttrRemovalEvent):
+        (ElementImpl::dispatchAttrAdditionEvent):
+        * khtml/xml/dom_nodeimpl.cpp:
+        (DOM::NodeImpl::addEventListener):
+        (DOM::NodeImpl::removeEventListener):
+        (DOM::NodeImpl::removeHTMLEventListener):
+        (DOM::NodeImpl::setHTMLEventListener):
+        (DOM::NodeImpl::getHTMLEventListener):
+        (DOM::NodeImpl::dispatchHTMLEvent):
+        (DOM::NodeImpl::dispatchWindowEvent):
+        (DOM::NodeImpl::dispatchMouseEvent):
+        (DOM::NodeImpl::dispatchUIEvent):
+        (DOM::NodeImpl::dispatchSubtreeModifiedEvent):
+        (DOM::NodeImpl::handleLocalEvents):
+        (DOM::ContainerNodeImpl::removeChild):
+        (DOM::ContainerNodeImpl::dispatchChildInsertedEvents):
+        (DOM::ContainerNodeImpl::dispatchChildRemovalEvents):
+        * khtml/xml/dom_nodeimpl.h:
+        * khtml/xml/dom_textimpl.cpp:
+        (CharacterDataImpl::dispatchModifiedEvent):
+        * kwq/KWQAccObject.mm:
+        (-[KWQAccObject mouseButtonListener]):
+        * kwq/KWQKHTMLPart.h:
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPart::canCachePage):
+        (KWQKHTMLPart::sendScrollEvent):
+        (KWQKHTMLPart::dispatchDragSrcEvent):
+        (KWQKHTMLPart::khtmlMouseMoveEvent):
+        (KWQKHTMLPart::dragSourceMovedTo):
+        (KWQKHTMLPart::dragSourceEndedAt):
+        (KWQKHTMLPart::dispatchCPPEvent):
+        (KWQKHTMLPart::mayCut):
+        (KWQKHTMLPart::mayCopy):
+        (KWQKHTMLPart::mayPaste):
+        (KWQKHTMLPart::tryCut):
+        (KWQKHTMLPart::tryCopy):
+        (KWQKHTMLPart::tryPaste):
+        (KWQKHTMLPart::sendContextMenuEvent):
+        (KWQKHTMLPart::setWindowHasFocus):
+        * kwq/KWQTextArea.mm:
+        (-[KWQTextAreaTextView dispatchHTMLEvent:]):
+        (-[KWQTextAreaTextView cut:]):
+        (-[KWQTextAreaTextView copy:]):
+        (-[KWQTextAreaTextView paste:]):
+        (-[KWQTextAreaTextView pasteAsPlainText:]):
+        (-[KWQTextAreaTextView pasteAsRichText:]):
+        Use the new namespace, types, and use AtomicString instead of event ID.
+
 2005-08-30  Darin Adler  <darin@apple.com>
 
         Reviewed by John Sullivan.
diff --git a/WebCore/ForwardingHeaders/xml/EventNames.h b/WebCore/ForwardingHeaders/xml/EventNames.h
new file mode 100644 (file)
index 0000000..ff09850
--- /dev/null
@@ -0,0 +1 @@
+#include <EventNames.h>
index 827bab995214ec5e9b9b004f42075fc597c6fd6a..b6bffefb720fcde078968876122fcf42cc6ec74c 100644 (file)
@@ -77,6 +77,8 @@
                7E6FEEDA0898582300C44C3F /* WebCoreScriptDebugger.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEED60898582300C44C3F /* WebCoreScriptDebugger.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7E6FEEDB0898582300C44C3F /* WebCoreScriptDebugger.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E6FEED70898582300C44C3F /* WebCoreScriptDebugger.mm */; };
                937C34ED0868E4B4006F4B22 /* parser.y in Sources */ = {isa = PBXBuildFile; fileRef = 934E43780414294A008635CE /* parser.y */; };
+               939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939885C108B7E3D100E707C4 /* EventNames.cpp */; };
+               939885C408B7E3D100E707C4 /* EventNames.h in Headers */ = {isa = PBXBuildFile; fileRef = 939885C208B7E3D100E707C4 /* EventNames.h */; };
                93F198A708245E59001E9ABC /* css_base.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8F618B040594BA00A80004 /* css_base.h */; };
                93F198A808245E59001E9ABC /* css_ruleimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D16502DE42E6018635CA /* css_ruleimpl.h */; };
                93F198A908245E59001E9ABC /* css_stylesheetimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = F523D16702DE42E6018635CA /* css_stylesheetimpl.h */; };
                9394E0AA03AA60FB008635CE /* KWQFontFamily.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KWQFontFamily.mm; sourceTree = "<group>"; };
                93955A4103D72932008635CE /* KWQRenderTreeDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KWQRenderTreeDebug.h; sourceTree = "<group>"; };
                93955A4203D72932008635CE /* KWQRenderTreeDebug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KWQRenderTreeDebug.cpp; sourceTree = "<group>"; };
+               939885C108B7E3D100E707C4 /* EventNames.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = EventNames.cpp; sourceTree = "<group>"; };
+               939885C208B7E3D100E707C4 /* EventNames.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = EventNames.h; sourceTree = "<group>"; };
                939FF8EC0702B1B100979E5E /* visible_range.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = visible_range.cpp; path = editing/visible_range.cpp; sourceTree = "<group>"; };
                939FF8ED0702B1B100979E5E /* visible_range.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = visible_range.h; path = editing/visible_range.h; sourceTree = "<group>"; };
                93ABCE5D06E1A42E0085925B /* formdata.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = formdata.cpp; sourceTree = "<group>"; };
                F523D32402DE4478018635CA /* xml */ = {
                        isa = PBXGroup;
                        children = (
+                               939885C108B7E3D100E707C4 /* EventNames.cpp */,
+                               939885C208B7E3D100E707C4 /* EventNames.h */,
                                550A0BC7085F6039007353D6 /* dom_qname.cpp */,
                                550A0BC8085F6039007353D6 /* dom_qname.h */,
                                BC3B364505C9D5E200E42902 /* dom_atomicstring.cpp */,
                                BC179894088D975F006068A5 /* render_theme.h in Headers */,
                                BC1798DA088DA4F8006068A5 /* render_theme_mac.h in Headers */,
                                7E6FEED80898582300C44C3F /* WebCoreScriptDebugger.h in Headers */,
+                               939885C408B7E3D100E707C4 /* EventNames.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BC179892088D975F006068A5 /* render_theme_mac.mm in Sources */,
                                BC179893088D975F006068A5 /* render_theme.cpp in Sources */,
                                7E6FEED90898582300C44C3F /* WebCoreScriptDebugger.mm in Sources */,
+                               939885C308B7E3D100E707C4 /* EventNames.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index 7ca5b41a665b3f98f975c76927d80f594fd4a9b7..fad282487d71401f06069894eaec534a7f0ac56a 100644 (file)
 #include "misc/hashmap.h"
 #include "xml/dom_nodeimpl.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "dom/css_stylesheet.h"
 
 #include <kdebug.h>
 
+using namespace DOM::EventNames;
+
+using DOM::AtomicString;
 using DOM::CSSException;
 using DOM::DOMString;
 using DOM::DocumentImpl;
 using DOM::EventException;
 using DOM::NodeImpl;
 using DOM::RangeException;
+
 using khtml::HashMap;
 using khtml::PointerHash;
 
@@ -180,19 +185,18 @@ bool ScriptInterpreter::wasRunByUserGesture() const
 {
   if ( m_evt )
   {
-    int id = m_evt->id();
+    const AtomicString &type = m_evt->type();
     bool eventOk = ( // mouse events
-      id == DOM::EventImpl::CLICK_EVENT || id == DOM::EventImpl::MOUSEDOWN_EVENT ||
-      id == DOM::EventImpl::MOUSEUP_EVENT || id == DOM::EventImpl::KHTML_DBLCLICK_EVENT ||
-      id == DOM::EventImpl::KHTML_CLICK_EVENT ||
+      type == clickEvent || type == mousedownEvent ||
+      type == mouseupEvent || type == khtmlDblclickEvent ||
+      type == khtmlClickEvent ||
       // keyboard events
-      id == DOM::EventImpl::KEYDOWN_EVENT || id == DOM::EventImpl::KEYPRESS_EVENT ||
-      id == DOM::EventImpl::KEYUP_EVENT ||
+      type == keydownEvent || type == keypressEvent ||
+      type == keyupEvent ||
       // other accepted events
-      id == DOM::EventImpl::SELECT_EVENT || id == DOM::EventImpl::CHANGE_EVENT ||
-      id == DOM::EventImpl::FOCUS_EVENT || id == DOM::EventImpl::BLUR_EVENT ||
-      id == DOM::EventImpl::SUBMIT_EVENT );
-    kdDebug(6070) << "Window.open, smart policy: id=" << id << " eventOk=" << eventOk << endl;
+      type == selectEvent || type == changeEvent ||
+      type == focusEvent || type == blurEvent ||
+      type == submitEvent );
     if (eventOk)
       return true;
   } else // no event
index 1f3a3263ee189c767c2c7973d29f5c4c8a67c9be..c56ac02b77c50b16df9ddc43c5bdbe5a0084f58c 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
@@ -30,6 +29,7 @@
 #include "xml/dom_nodeimpl.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom_textimpl.h"
+#include "xml/EventNames.h"
 #include "xml/dom_xmlimpl.h"
 #include "html/html_documentimpl.h"
 #include "css/css_ruleimpl.h"
@@ -53,6 +53,7 @@
 
 using namespace DOM::HTMLNames;
 
+using DOM::AtomicString;
 using DOM::AttrImpl;
 using DOM::CharacterDataImpl;
 using DOM::DocumentImpl;
@@ -63,6 +64,7 @@ using DOM::DOMString;
 using DOM::ElementImpl;
 using DOM::EntityImpl;
 using DOM::EventImpl;
+using namespace DOM::EventNames;
 using DOM::HTMLAppletElementImpl;
 using DOM::HTMLDocumentImpl;
 using DOM::HTMLElementImpl;
@@ -310,91 +312,91 @@ ValueImp *DOMNode::getValueProperty(ExecState *exec, int token) const
   case OwnerDocument:
     return getDOMNode(exec,node.ownerDocument());
   case OnAbort:
-    return getListener(DOM::EventImpl::ABORT_EVENT);
+    return getListener(abortEvent);
   case OnBlur:
-    return getListener(DOM::EventImpl::BLUR_EVENT);
+    return getListener(blurEvent);
   case OnChange:
-    return getListener(DOM::EventImpl::CHANGE_EVENT);
+    return getListener(changeEvent);
   case OnClick:
-    return getListener(DOM::EventImpl::KHTML_CLICK_EVENT);
+    return getListener(khtmlClickEvent);
   case OnContextMenu:
-    return getListener(DOM::EventImpl::CONTEXTMENU_EVENT);
+    return getListener(contextmenuEvent);
   case OnDblClick:
-    return getListener(DOM::EventImpl::KHTML_DBLCLICK_EVENT);
+    return getListener(khtmlDblclickEvent);
   case OnDragDrop:
-    return getListener(DOM::EventImpl::KHTML_DRAGDROP_EVENT);
+    return getListener(khtmlDragdropEvent);
   case OnError:
-    return getListener(DOM::EventImpl::KHTML_ERROR_EVENT);
+    return getListener(khtmlErrorEvent);
   case OnFocus:
-    return getListener(DOM::EventImpl::FOCUS_EVENT);
+    return getListener(focusEvent);
   case OnInput:
-    return getListener(DOM::EventImpl::INPUT_EVENT);
+    return getListener(inputEvent);
   case OnKeyDown:
-    return getListener(DOM::EventImpl::KEYDOWN_EVENT);
+    return getListener(keydownEvent);
   case OnKeyPress:
-    return getListener(DOM::EventImpl::KEYPRESS_EVENT);
+    return getListener(keypressEvent);
   case OnKeyUp:
-    return getListener(DOM::EventImpl::KEYUP_EVENT);
+    return getListener(keyupEvent);
   case OnLoad:
-    return getListener(DOM::EventImpl::LOAD_EVENT);
+    return getListener(loadEvent);
   case OnMouseDown:
-    return getListener(DOM::EventImpl::MOUSEDOWN_EVENT);
+    return getListener(mousedownEvent);
   case OnMouseMove:
-    return getListener(DOM::EventImpl::MOUSEMOVE_EVENT);
+    return getListener(mousemoveEvent);
   case OnMouseOut:
-    return getListener(DOM::EventImpl::MOUSEOUT_EVENT);
+    return getListener(mouseoutEvent);
   case OnMouseOver:
-    return getListener(DOM::EventImpl::MOUSEOVER_EVENT);
+    return getListener(mouseoverEvent);
   case OnMouseUp:
-    return getListener(DOM::EventImpl::MOUSEUP_EVENT);      
+    return getListener(mouseupEvent);      
   case OnMouseWheel:
-    return getListener(DOM::EventImpl::MOUSEWHEEL_EVENT);      
+    return getListener(mousewheelEvent);      
   case OnBeforeCut:
-    return getListener(DOM::EventImpl::BEFORECUT_EVENT);
+    return getListener(beforecutEvent);
   case OnCut:
-    return getListener(DOM::EventImpl::CUT_EVENT);
+    return getListener(cutEvent);
   case OnBeforeCopy:
-    return getListener(DOM::EventImpl::BEFORECOPY_EVENT);
+    return getListener(beforecopyEvent);
   case OnCopy:
-    return getListener(DOM::EventImpl::COPY_EVENT);
+    return getListener(copyEvent);
   case OnBeforePaste:
-    return getListener(DOM::EventImpl::BEFOREPASTE_EVENT);
+    return getListener(beforepasteEvent);
   case OnPaste:
-    return getListener(DOM::EventImpl::PASTE_EVENT);
+    return getListener(pasteEvent);
   case OnDragEnter:
-    return getListener(DOM::EventImpl::DRAGENTER_EVENT);
+    return getListener(dragenterEvent);
   case OnDragOver:
-    return getListener(DOM::EventImpl::DRAGOVER_EVENT);
+    return getListener(dragoverEvent);
   case OnDragLeave:
-    return getListener(DOM::EventImpl::DRAGLEAVE_EVENT);
+    return getListener(dragleaveEvent);
   case OnDrop:
-    return getListener(DOM::EventImpl::DROP_EVENT);
+    return getListener(dropEvent);
   case OnDragStart:
-    return getListener(DOM::EventImpl::DRAGSTART_EVENT);
+    return getListener(dragstartEvent);
   case OnDrag:
-    return getListener(DOM::EventImpl::DRAG_EVENT);
+    return getListener(dragEvent);
   case OnDragEnd:
-    return getListener(DOM::EventImpl::DRAGEND_EVENT);
+    return getListener(dragendEvent);
   case OnMove:
-    return getListener(DOM::EventImpl::KHTML_MOVE_EVENT);
+    return getListener(khtmlMoveEvent);
   case OnReset:
-    return getListener(DOM::EventImpl::RESET_EVENT);
+    return getListener(resetEvent);
   case OnResize:
-    return getListener(DOM::EventImpl::RESIZE_EVENT);
+    return getListener(resizeEvent);
   case OnScroll:
-    return getListener(DOM::EventImpl::SCROLL_EVENT);
+    return getListener(scrollEvent);
 #if APPLE_CHANGES
   case OnSearch:
-    return getListener(DOM::EventImpl::SEARCH_EVENT);
+    return getListener(searchEvent);
 #endif
   case OnSelect:
-    return getListener(DOM::EventImpl::SELECT_EVENT);
+    return getListener(selectEvent);
   case OnSelectStart:
-    return getListener(DOM::EventImpl::SELECTSTART_EVENT);
+    return getListener(selectstartEvent);
   case OnSubmit:
-    return getListener(DOM::EventImpl::SUBMIT_EVENT);
+    return getListener(submitEvent);
   case OnUnload:
-    return getListener(DOM::EventImpl::UNLOAD_EVENT);
+    return getListener(scrollEvent);
   default:
     // no DOM standard, found in IE only
 
@@ -461,130 +463,130 @@ void DOMNode::putValueProperty(ExecState *exec, int token, ValueImp *value, int
     node.setPrefix(value->toString(exec).domString().impl(), exception);
     break;
   case OnAbort:
-    setListener(exec,DOM::EventImpl::ABORT_EVENT,value);
+    setListener(exec,abortEvent,value);
     break;
   case OnBlur:
-    setListener(exec,DOM::EventImpl::BLUR_EVENT,value);
+    setListener(exec,blurEvent,value);
     break;
   case OnChange:
-    setListener(exec,DOM::EventImpl::CHANGE_EVENT,value);
+    setListener(exec,changeEvent,value);
     break;
   case OnClick:
-    setListener(exec,DOM::EventImpl::KHTML_CLICK_EVENT,value);
+    setListener(exec,khtmlClickEvent,value);
     break;
   case OnContextMenu:
-    setListener(exec,DOM::EventImpl::CONTEXTMENU_EVENT,value);
+    setListener(exec,contextmenuEvent,value);
     break;
   case OnDblClick:
-    setListener(exec,DOM::EventImpl::KHTML_DBLCLICK_EVENT,value);
+    setListener(exec,khtmlDblclickEvent,value);
     break;
   case OnDragDrop:
-    setListener(exec,DOM::EventImpl::KHTML_DRAGDROP_EVENT,value);
+    setListener(exec,khtmlDragdropEvent,value);
     break;
   case OnError:
-    setListener(exec,DOM::EventImpl::KHTML_ERROR_EVENT,value);
+    setListener(exec,khtmlErrorEvent,value);
     break;
   case OnFocus:
-    setListener(exec,DOM::EventImpl::FOCUS_EVENT,value);
+    setListener(exec,focusEvent,value);
     break;
   case OnInput:
-    setListener(exec,DOM::EventImpl::INPUT_EVENT,value);
+    setListener(exec,inputEvent,value);
     break;
   case OnKeyDown:
-    setListener(exec,DOM::EventImpl::KEYDOWN_EVENT,value);
+    setListener(exec,keydownEvent,value);
     break;
   case OnKeyPress:
-    setListener(exec,DOM::EventImpl::KEYPRESS_EVENT,value);
+    setListener(exec,keypressEvent,value);
     break;
   case OnKeyUp:
-    setListener(exec,DOM::EventImpl::KEYUP_EVENT,value);
+    setListener(exec,keyupEvent,value);
     break;
   case OnLoad:
-    setListener(exec,DOM::EventImpl::LOAD_EVENT,value);
+    setListener(exec,loadEvent,value);
     break;
   case OnMouseDown:
-    setListener(exec,DOM::EventImpl::MOUSEDOWN_EVENT,value);
+    setListener(exec,mousedownEvent,value);
     break;
   case OnMouseMove:
-    setListener(exec,DOM::EventImpl::MOUSEMOVE_EVENT,value);
+    setListener(exec,mousemoveEvent,value);
     break;
   case OnMouseOut:
-    setListener(exec,DOM::EventImpl::MOUSEOUT_EVENT,value);
+    setListener(exec,mouseoutEvent,value);
     break;
   case OnMouseOver:
-    setListener(exec,DOM::EventImpl::MOUSEOVER_EVENT,value);
+    setListener(exec,mouseoverEvent,value);
     break;
   case OnMouseUp:
-    setListener(exec,DOM::EventImpl::MOUSEUP_EVENT,value);
+    setListener(exec,mouseupEvent,value);
     break;
   case OnMouseWheel:
-    setListener(exec,DOM::EventImpl::MOUSEWHEEL_EVENT,value);
+    setListener(exec,mousewheelEvent,value);
     break;
   case OnBeforeCut:
-    setListener(exec,DOM::EventImpl::BEFORECUT_EVENT,value);
+    setListener(exec,beforecutEvent,value);
     break;
   case OnCut:
-    setListener(exec,DOM::EventImpl::CUT_EVENT,value);
+    setListener(exec,cutEvent,value);
     break;
   case OnBeforeCopy:
-    setListener(exec,DOM::EventImpl::BEFORECOPY_EVENT,value);
+    setListener(exec,beforecopyEvent,value);
     break;
   case OnCopy:
-    setListener(exec,DOM::EventImpl::COPY_EVENT,value);
+    setListener(exec,copyEvent,value);
     break;
   case OnBeforePaste:
-    setListener(exec,DOM::EventImpl::BEFOREPASTE_EVENT,value);
+    setListener(exec,beforepasteEvent,value);
     break;
   case OnPaste:
-    setListener(exec,DOM::EventImpl::PASTE_EVENT,value);
+    setListener(exec,pasteEvent,value);
     break;
   case OnDragEnter:
-    setListener(exec,DOM::EventImpl::DRAGENTER_EVENT,value);
+    setListener(exec,dragenterEvent,value);
     break;
   case OnDragOver:
-    setListener(exec,DOM::EventImpl::DRAGOVER_EVENT,value);
+    setListener(exec,dragoverEvent,value);
     break;
   case OnDragLeave:
-    setListener(exec,DOM::EventImpl::DRAGLEAVE_EVENT,value);
+    setListener(exec,dragleaveEvent,value);
     break;
   case OnDrop:
-    setListener(exec,DOM::EventImpl::DROP_EVENT,value);
+    setListener(exec,dropEvent,value);
     break;
   case OnDragStart:
-    setListener(exec,DOM::EventImpl::DRAGSTART_EVENT,value);
+    setListener(exec,dragstartEvent,value);
     break;
   case OnDrag:
-    setListener(exec,DOM::EventImpl::DRAG_EVENT,value);
+    setListener(exec,dragEvent,value);
     break;
   case OnDragEnd:
-    setListener(exec,DOM::EventImpl::DRAGEND_EVENT,value);
+    setListener(exec,dragendEvent,value);
     break;
   case OnMove:
-    setListener(exec,DOM::EventImpl::KHTML_MOVE_EVENT,value);
+    setListener(exec,khtmlMoveEvent,value);
     break;
   case OnReset:
-    setListener(exec,DOM::EventImpl::RESET_EVENT,value);
+    setListener(exec,resetEvent,value);
     break;
   case OnResize:
-    setListener(exec,DOM::EventImpl::RESIZE_EVENT,value);
+    setListener(exec,resizeEvent,value);
     break;
   case OnScroll:
-    setListener(exec,DOM::EventImpl::SCROLL_EVENT,value);
+    setListener(exec,scrollEvent,value);
     break;
   case OnSearch:
-    setListener(exec,DOM::EventImpl::SEARCH_EVENT,value);
+    setListener(exec,searchEvent,value);
     break;
   case OnSelect:
-    setListener(exec,DOM::EventImpl::SELECT_EVENT,value);
+    setListener(exec,selectEvent,value);
     break;
   case OnSelectStart:
-    setListener(exec,DOM::EventImpl::SELECTSTART_EVENT,value);
+    setListener(exec,selectstartEvent,value);
     break;
   case OnSubmit:
-    setListener(exec,DOM::EventImpl::SUBMIT_EVENT,value);
+    setListener(exec,submitEvent,value);
     break;
   case OnUnload:
-    setListener(exec,DOM::EventImpl::UNLOAD_EVENT,value);
+    setListener(exec,scrollEvent,value);
     break;
   case ScrollTop: {
     khtml::RenderObject *rend = node.renderer();
@@ -618,14 +620,14 @@ UString DOMNode::toString(ExecState *) const
   return "[object " + (m_impl->isElementNode() ? m_impl->nodeName() : className()) + "]";
 }
 
-void DOMNode::setListener(ExecState *exec, int eventId, ValueImp *func) const
+void DOMNode::setListener(ExecState *exec, const AtomicString &eventType, ValueImp *func) const
 {
-  m_impl->setHTMLEventListener(eventId, Window::retrieveActive(exec)->getJSEventListener(func, true));
+  m_impl->setHTMLEventListener(eventType, Window::retrieveActive(exec)->getJSEventListener(func, true));
 }
 
-ValueImp *DOMNode::getListener(int eventId) const
+ValueImp *DOMNode::getListener(const AtomicString &eventType) const
 {
-    DOM::EventListener *listener = m_impl->getHTMLEventListener(eventId);
+    DOM::EventListener *listener = m_impl->getHTMLEventListener(eventType);
     JSEventListener *jsListener = static_cast<JSEventListener*>(listener);
     if ( jsListener && jsListener->listenerObjImp() )
        return jsListener->listenerObj();
@@ -659,13 +661,13 @@ ValueImp *DOMNodeProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj,
     case DOMNode::AddEventListener: {
         JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
         if (listener)
-            node.addEventListener(args[0]->toString(exec).domString(),listener,args[2]->toBoolean(exec));
+            node.addEventListener(AtomicString(args[0]->toString(exec).domString()), listener,args[2]->toBoolean(exec));
         return Undefined();
     }
     case DOMNode::RemoveEventListener: {
         JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
         if (listener)
-            node.removeEventListener(args[0]->toString(exec).domString(),listener,args[2]->toBoolean(exec));
+            node.removeEventListener(AtomicString(args[0]->toString(exec).domString()), listener,args[2]->toBoolean(exec));
         return Undefined();
     }
     case DOMNode::DispatchEvent:
index 1af20decd5097113266ac13bb17f9f3afc7d1225..347d0946d9ac5a9f5468e772555466951d0fbd1f 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
@@ -19,8 +18,8 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef _KJS_DOM_H_
-#define _KJS_DOM_H_
+#ifndef KJS_DOM_H
+#define KJS_DOM_H
 
 #include "kjs_binding.h"
 
@@ -28,6 +27,7 @@
 #include "misc/shared.h"
 
 namespace DOM {
+    class AtomicString;
     class AttrImpl;
     class CharacterDataImpl;
     class DocumentTypeImpl;
@@ -40,7 +40,7 @@ namespace DOM {
     class NotationImpl;
     class ProcessingInstructionImpl;
     class TextImpl;
-};
+}
 
 namespace KJS {
 
@@ -60,8 +60,8 @@ namespace KJS {
 
     virtual ValueImp *toPrimitive(ExecState *exec, Type preferred = UndefinedType) const;
     virtual UString toString(ExecState *exec) const;
-    void setListener(ExecState *exec, int eventId, ValueImp *func) const;
-    ValueImp *getListener(int eventId) const;
+    void setListener(ExecState *exec, const DOM::AtomicString &eventType, ValueImp *func) const;
+    ValueImp *getListener(const DOM::AtomicString &eventType) const;
     virtual void pushEventHandlerScope(ExecState *exec, ScopeChain &scope) const;
 
     enum { NodeName, NodeValue, NodeType, ParentNode, ParentElement,
index bc71d51e73e7b20e1f0e04cf540347f0616490ae..31d08d8ccda00e128de932837619b80ab2896d08 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
  *  License along with this library; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include "khtml_part.h"
-#include "kjs_window.h"
+
+#include <kjs/protected_object.h> // temporary, remove after landing interpreter lock patch
+
 #include "kjs_events.h"
 #include "kjs_events.lut.h"
+
+#include "khtml_part.h"
+#include "kjs_window.h"
 #include "kjs_views.h"
 #include "kjs_proxy.h"
 #include "xml/dom_nodeimpl.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom2_viewsimpl.h"
+#include "xml/EventNames.h"
 #include "rendering/render_object.h"
 #include "misc/loader.h"
 
 #include <kdebug.h>
 
+using namespace DOM::EventNames;
+
+using DOM::AtomicString;
 using DOM::ClipboardEventImpl;
 using DOM::DocumentImpl;
 using DOM::EventImpl;
@@ -344,9 +351,9 @@ void JSLazyEventListener::parseCode() const
   }
 }
 
-ValueImp *getNodeEventListener(NodeImpl *n, int eventId)
+ValueImp *getNodeEventListener(NodeImpl *n, const AtomicString &eventType)
 {
-  JSAbstractEventListener *listener = static_cast<JSAbstractEventListener *>(n->getHTMLEventListener(eventId));
+  JSAbstractEventListener *listener = static_cast<JSAbstractEventListener *>(n->getHTMLEventListener(eventType));
   if (listener)
     if (ValueImp *obj = listener->listenerObjImp())
       return obj;
@@ -454,7 +461,7 @@ ValueImp *DOMEvent::getValueProperty(ExecState *exec, int token) const
   EventImpl &event = *m_impl;
   switch (token) {
   case Type:
-    return String(event.type());
+    return String(event.type().domString());
   case Target:
   case SrcElement: /*MSIE extension - "the object that fired the event"*/
     return getDOMNode(exec, event.target());
@@ -536,7 +543,7 @@ ValueImp *DOMEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp * thisObj
       event.preventDefault();
       return Undefined();
     case DOMEvent::InitEvent:
-      event.initEvent(args[0]->toString(exec).domString(),args[1]->toBoolean(exec),args[2]->toBoolean(exec));
+      event.initEvent(AtomicString(args[0]->toString(exec).domString()), args[1]->toBoolean(exec), args[2]->toBoolean(exec));
       return Undefined();
   };
   return Undefined();
@@ -678,7 +685,7 @@ ValueImp *DOMUIEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thisOb
   UIEventImpl &uiEvent = *static_cast<UIEventImpl *>(static_cast<DOMUIEvent *>(thisObj)->impl());
   switch (id) {
     case DOMUIEvent::InitUIEvent:
-      uiEvent.initUIEvent(args[0]->toString(exec).domString(),
+      uiEvent.initUIEvent(AtomicString(args[0]->toString(exec).domString()),
                           args[1]->toBoolean(exec),
                           args[2]->toBoolean(exec),
                           toAbstractView(args[3]),
@@ -788,15 +795,10 @@ ValueImp *DOMMouseEvent::getValueProperty(ExecState *exec, int token) const
     return Number(event.button());
   case ToElement:
     // MSIE extension - "the object toward which the user is moving the mouse pointer"
-    if (event.id() == DOM::EventImpl::MOUSEOUT_EVENT)
-      return getDOMNode(exec, event.relatedTarget());
-    return getDOMNode(exec,event.target());
+    return getDOMNode(exec, event.type() == mouseoutEvent ? event.relatedTarget() : event.target());
   case FromElement:
-    // MSIE extension - "object from which activation
-    // or the mouse pointer is exiting during the event" (huh?)
-    if (event.id() == DOM::EventImpl::MOUSEOUT_EVENT)
-      return getDOMNode(exec, event.target());
-    /* fall through */
+    // MSIE extension - "object from which activation or the mouse pointer is exiting during the event" (huh?)
+    return getDOMNode(exec, event.type() == mouseoutEvent ? event.target() : event.relatedTarget());
   case RelatedTarget:
     return getDOMNode(exec, event.relatedTarget());
   default:
@@ -812,7 +814,7 @@ ValueImp *DOMMouseEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *thi
   MouseEventImpl &mouseEvent = *static_cast<MouseEventImpl *>(static_cast<DOMMouseEvent *>(thisObj)->impl());
   switch (id) {
     case DOMMouseEvent::InitMouseEvent:
-      mouseEvent.initMouseEvent(args[0]->toString(exec).domString(), // typeArg
+      mouseEvent.initMouseEvent(AtomicString(args[0]->toString(exec).domString()), // typeArg
                                 args[1]->toBoolean(exec), // canBubbleArg
                                 args[2]->toBoolean(exec), // cancelableArg
                                 toAbstractView(args[3]), // viewArg
@@ -905,7 +907,7 @@ ValueImp *DOMKeyboardEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *
   KeyboardEventImpl &event = *static_cast<KeyboardEventImpl *>(static_cast<DOMUIEvent *>(thisObj)->impl());
   switch (id) {
     case DOMKeyboardEvent::InitKeyboardEvent:
-      event.initKeyboardEvent(args[0]->toString(exec).domString(), // typeArg
+      event.initKeyboardEvent(AtomicString(args[0]->toString(exec).domString()), // typeArg
                               args[1]->toBoolean(exec), // canBubbleArg
                               args[2]->toBoolean(exec), // cancelableArg
                               toAbstractView(args[3]), // viewArg
@@ -1008,7 +1010,7 @@ ValueImp *DOMMutationEventProtoFunc::callAsFunction(ExecState *exec, ObjectImp *
   MutationEventImpl &mutationEvent = *static_cast<MutationEventImpl *>(static_cast<DOMEvent *>(thisObj)->impl());
   switch (id) {
     case DOMMutationEvent::InitMutationEvent:
-      mutationEvent.initMutationEvent(args[0]->toString(exec).domString(), // typeArg,
+      mutationEvent.initMutationEvent(AtomicString(args[0]->toString(exec).domString()), // typeArg,
                                       args[1]->toBoolean(exec), // canBubbleArg
                                       args[2]->toBoolean(exec), // cancelableArg
                                       toNode(args[3]), // relatedNodeArg
index c9d6952168efe75ff0a26b5c4b5c5761abc2c31c..8aefa0907cea939859234af5c9f4826e609afbe1 100644 (file)
@@ -95,7 +95,7 @@ namespace KJS {
     DOM::NodeImpl *originalNode;
   };
 
-  ValueImp *getNodeEventListener(DOM::NodeImpl *n, int eventId);
+  ValueImp *getNodeEventListener(DOM::NodeImpl *n, const DOM::AtomicString &eventType);
 
   // Constructor for Event - currently only used for some global vars
   class EventConstructor : public DOMObject {
index bbc9d160b1e7b94d1b63014201458bf3c18e34c7..3f1294e2321ad7baac467124247b03b296e7e9c1 100644 (file)
@@ -65,6 +65,7 @@
 #include "xml/dom_docimpl.h"
 #include "xml/dom_elementimpl.h"
 #include "xml/dom_position.h"
+#include "xml/EventNames.h"
 #include "html/html_documentimpl.h"
 #include "css/css_ruleimpl.h"
 #include "css/css_stylesheetimpl.h"
@@ -76,6 +77,9 @@
 // isnan are not defined.
 #include <cmath>
 
+using namespace DOM::EventNames;
+
+using DOM::AtomicString;
 using DOM::DocumentImpl;
 using DOM::DOMString;
 using DOM::ElementImpl;
@@ -885,59 +889,59 @@ ValueImp *Window::getValueProperty(ExecState *exec, int token) const
      }
      return getDOMNode(exec, m_part->xmlDocImpl());
    case Onabort:
-     return getListener(exec, DOM::EventImpl::ABORT_EVENT);
+     return getListener(exec, abortEvent);
    case Onblur:
-     return getListener(exec, DOM::EventImpl::BLUR_EVENT);
+     return getListener(exec, blurEvent);
    case Onchange:
-     return getListener(exec, DOM::EventImpl::CHANGE_EVENT);
+     return getListener(exec, changeEvent);
    case Onclick:
-     return getListener(exec, DOM::EventImpl::KHTML_CLICK_EVENT);
+     return getListener(exec, khtmlClickEvent);
    case Ondblclick:
-     return getListener(exec, DOM::EventImpl::KHTML_DBLCLICK_EVENT);
+     return getListener(exec, khtmlDblclickEvent);
    case Ondragdrop:
-     return getListener(exec, DOM::EventImpl::KHTML_DRAGDROP_EVENT);
+     return getListener(exec, khtmlDragdropEvent);
    case Onerror:
-     return getListener(exec, DOM::EventImpl::KHTML_ERROR_EVENT);
+     return getListener(exec, khtmlErrorEvent);
    case Onfocus:
-     return getListener(exec, DOM::EventImpl::FOCUS_EVENT);
+     return getListener(exec, focusEvent);
    case Onkeydown:
-     return getListener(exec, DOM::EventImpl::KEYDOWN_EVENT);
+     return getListener(exec, keydownEvent);
    case Onkeypress:
-     return getListener(exec, DOM::EventImpl::KEYPRESS_EVENT);
+     return getListener(exec, keypressEvent);
    case Onkeyup:
-     return getListener(exec, DOM::EventImpl::KEYUP_EVENT);
+     return getListener(exec, keyupEvent);
    case Onload:
-     return getListener(exec, DOM::EventImpl::LOAD_EVENT);
+     return getListener(exec, loadEvent);
    case Onmousedown:
-     return getListener(exec, DOM::EventImpl::MOUSEDOWN_EVENT);
+     return getListener(exec, mousedownEvent);
    case Onmousemove:
-     return getListener(exec, DOM::EventImpl::MOUSEMOVE_EVENT);
+     return getListener(exec, mousemoveEvent);
    case Onmouseout:
-     return getListener(exec, DOM::EventImpl::MOUSEOUT_EVENT);
+     return getListener(exec, mouseoutEvent);
    case Onmouseover:
-     return getListener(exec, DOM::EventImpl::MOUSEOVER_EVENT);
+     return getListener(exec, mouseoverEvent);
    case Onmouseup:
-     return getListener(exec, DOM::EventImpl::MOUSEUP_EVENT);
+     return getListener(exec, mouseupEvent);
    case OnWindowMouseWheel:
-     return getListener(exec, DOM::EventImpl::MOUSEWHEEL_EVENT);
+     return getListener(exec, mousewheelEvent);
    case Onmove:
-     return getListener(exec, DOM::EventImpl::KHTML_MOVE_EVENT);
+     return getListener(exec, khtmlMoveEvent);
    case Onreset:
-     return getListener(exec, DOM::EventImpl::RESET_EVENT);
+     return getListener(exec, resetEvent);
    case Onresize:
-     return getListener(exec,DOM::EventImpl::RESIZE_EVENT);
+     return getListener(exec,resizeEvent);
    case Onscroll:
-     return getListener(exec,DOM::EventImpl::SCROLL_EVENT);
+     return getListener(exec,scrollEvent);
 #if APPLE_CHANGES
    case Onsearch:
-     return getListener(exec,DOM::EventImpl::SEARCH_EVENT);
+     return getListener(exec,searchEvent);
 #endif
    case Onselect:
-     return getListener(exec,DOM::EventImpl::SELECT_EVENT);
+     return getListener(exec,selectEvent);
    case Onsubmit:
-     return getListener(exec,DOM::EventImpl::SUBMIT_EVENT);
+     return getListener(exec,submitEvent);
    case Onunload:
-     return getListener(exec,DOM::EventImpl::UNLOAD_EVENT);
+     return getListener(exec,scrollEvent);
    }
    assert(0);
    return Undefined();
@@ -1123,109 +1127,109 @@ void Window::put(ExecState* exec, const Identifier &propertyName, ValueImp *valu
     }
     case Onabort:
       if (isSafeScript(exec))
-        setListener(exec, DOM::EventImpl::ABORT_EVENT,value);
+        setListener(exec, abortEvent,value);
       return;
     case Onblur:
       if (isSafeScript(exec))
-        setListener(exec, DOM::EventImpl::BLUR_EVENT,value);
+        setListener(exec, blurEvent,value);
       return;
     case Onchange:
       if (isSafeScript(exec))
-        setListener(exec, DOM::EventImpl::CHANGE_EVENT,value);
+        setListener(exec, changeEvent,value);
       return;
     case Onclick:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KHTML_CLICK_EVENT,value);
+        setListener(exec,khtmlClickEvent,value);
       return;
     case Ondblclick:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KHTML_DBLCLICK_EVENT,value);
+        setListener(exec,khtmlDblclickEvent,value);
       return;
     case Ondragdrop:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KHTML_DRAGDROP_EVENT,value);
+        setListener(exec,khtmlDragdropEvent,value);
       return;
     case Onerror:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KHTML_ERROR_EVENT,value);
+        setListener(exec,khtmlErrorEvent,value);
       return;
     case Onfocus:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::FOCUS_EVENT,value);
+        setListener(exec,focusEvent,value);
       return;
     case Onkeydown:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KEYDOWN_EVENT,value);
+        setListener(exec,keydownEvent,value);
       return;
     case Onkeypress:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KEYPRESS_EVENT,value);
+        setListener(exec,keypressEvent,value);
       return;
     case Onkeyup:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KEYUP_EVENT,value);
+        setListener(exec,keyupEvent,value);
       return;
     case Onload:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::LOAD_EVENT,value);
+        setListener(exec,loadEvent,value);
       return;
     case Onmousedown:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::MOUSEDOWN_EVENT,value);
+        setListener(exec,mousedownEvent,value);
       return;
     case Onmousemove:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::MOUSEMOVE_EVENT,value);
+        setListener(exec,mousemoveEvent,value);
       return;
     case Onmouseout:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::MOUSEOUT_EVENT,value);
+        setListener(exec,mouseoutEvent,value);
       return;
     case Onmouseover:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::MOUSEOVER_EVENT,value);
+        setListener(exec,mouseoverEvent,value);
       return;
     case Onmouseup:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::MOUSEUP_EVENT,value);
+        setListener(exec,mouseupEvent,value);
       return;
     case OnWindowMouseWheel:
       if (isSafeScript(exec))
-        setListener(exec, DOM::EventImpl::MOUSEWHEEL_EVENT,value);
+        setListener(exec, mousewheelEvent,value);
       return;
     case Onmove:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::KHTML_MOVE_EVENT,value);
+        setListener(exec,khtmlMoveEvent,value);
       return;
     case Onreset:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::RESET_EVENT,value);
+        setListener(exec,resetEvent,value);
       return;
     case Onresize:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::RESIZE_EVENT,value);
+        setListener(exec,resizeEvent,value);
       return;
     case Onscroll:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::SCROLL_EVENT,value);
+        setListener(exec,scrollEvent,value);
       return;
 #if APPLE_CHANGES
     case Onsearch:
         if (isSafeScript(exec))
-            setListener(exec,DOM::EventImpl::SEARCH_EVENT,value);
+            setListener(exec,searchEvent,value);
         return;
 #endif
     case Onselect:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::SELECT_EVENT,value);
+        setListener(exec,selectEvent,value);
       return;
     case Onsubmit:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::SUBMIT_EVENT,value);
+        setListener(exec,submitEvent,value);
       return;
     case Onunload:
       if (isSafeScript(exec))
-        setListener(exec,DOM::EventImpl::UNLOAD_EVENT,value);
+        setListener(exec,scrollEvent,value);
       return;
     case Name:
       if (isSafeScript(exec))
@@ -1422,7 +1426,7 @@ bool Window::isSafeScript(ExecState *exec) const
   return false;
 }
 
-void Window::setListener(ExecState *exec, int eventId, ValueImp *func)
+void Window::setListener(ExecState *exec, const AtomicString &eventType, ValueImp *func)
 {
   if (!isSafeScript(exec))
     return;
@@ -1430,10 +1434,10 @@ void Window::setListener(ExecState *exec, int eventId, ValueImp *func)
   if (!doc)
     return;
 
-  doc->setHTMLWindowEventListener(eventId,getJSEventListener(func,true));
+  doc->setHTMLWindowEventListener(eventType, getJSEventListener(func,true));
 }
 
-ValueImp *Window::getListener(ExecState *exec, int eventId) const
+ValueImp *Window::getListener(ExecState *exec, const AtomicString &eventType) const
 {
   if (!isSafeScript(exec))
     return Undefined();
@@ -1441,7 +1445,7 @@ ValueImp *Window::getListener(ExecState *exec, int eventId) const
   if (!doc)
     return Undefined();
 
-  DOM::EventListener *listener = doc->getHTMLWindowEventListener(eventId);
+  DOM::EventListener *listener = doc->getHTMLWindowEventListener(eventType);
   if (listener && static_cast<JSEventListener*>(listener)->listenerObjImp())
     return static_cast<JSEventListener*>(listener)->listenerObj();
   else
@@ -1987,28 +1991,20 @@ ValueImp *WindowFunc::callAsFunction(ExecState *exec, ObjectImp *thisObj, const
 
     // Do nothing for now. These are NS-specific legacy calls.
     break;
-  case Window::AddEventListener: {
+  case Window::AddEventListener:
         if (!window->isSafeScript(exec))
            return Undefined();
-        JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
-        if (listener) {
-           DocumentImpl* docimpl = part->xmlDocImpl();
-            if (docimpl)
-                docimpl->addWindowEventListener(DOM::EventImpl::typeToId(args[0]->toString(exec).domString()),listener,args[2]->toBoolean(exec));
-        }
+        if (JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]))
+            if (DocumentImpl *doc = part->xmlDocImpl())
+                doc->addWindowEventListener(AtomicString(args[0]->toString(exec).domString()), listener, args[2]->toBoolean(exec));
         return Undefined();
-    }
-  case Window::RemoveEventListener: {
+  case Window::RemoveEventListener:
         if (!window->isSafeScript(exec))
            return Undefined();
-        JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]);
-        if (listener) {
-           DocumentImpl* docimpl = part->xmlDocImpl();
-            if (docimpl)
-                docimpl->removeWindowEventListener(DOM::EventImpl::typeToId(args[0]->toString(exec).domString()),listener,args[2]->toBoolean(exec));
-        }
+        if (JSEventListener *listener = Window::retrieveActive(exec)->getJSEventListener(args[1]))
+            if (DocumentImpl *doc = part->xmlDocImpl())
+                doc->addWindowEventListener(AtomicString(args[0]->toString(exec).domString()), listener, args[2]->toBoolean(exec));
         return Undefined();
-    }
   case Window::ShowModalDialog:
     return showModalDialog(exec, window, args);
   }
index ad099aed4ace8e6182992481822be3c23b30ff36..8886326d50fdb7169e96ebff238120b7ee38e2d4 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
 /*
  *  This file is part of the KDE libraries
  *  Copyright (C) 2000 Harri Porten (porten@kde.org)
@@ -35,6 +34,7 @@ class KHTMLView;
 class KHTMLPart;
 
 namespace DOM {
+    class AtomicString;
     class NodeImpl;
 }
 
@@ -153,8 +153,8 @@ namespace KJS {
            Onselect, Onsubmit, Onunload,
            Statusbar, Toolbar, FrameElement, ShowModalDialog };
   protected:
-    ValueImp *getListener(ExecState *exec, int eventId) const;
-    void setListener(ExecState *exec, int eventId, ValueImp *func);
+    ValueImp *getListener(ExecState *exec, const DOM::AtomicString &eventType) const;
+    void setListener(ExecState *exec, const DOM::AtomicString &eventType, ValueImp *func);
   private:
     static ValueImp *childFrameGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
     static ValueImp *namedFrameGetter(ExecState *exec, const Identifier&, const PropertySlot& slot);
index fe770adbc72994fcc51ae6945b9997966b226bb2..edb6d0f841a0859b685abaad073cbb65d10a0611 100644 (file)
@@ -24,7 +24,8 @@
  */
 // -------------------------------------------------------------------------
 
-#include "html/html_baseimpl.h"
+#include "html_baseimpl.h"
+
 #include "html/html_documentimpl.h"
 
 #include "khtmlview.h"
 #include "misc/loader.h"
 #include "dom/dom_string.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 
 #include <kurl.h>
 #include <kdebug.h>
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace khtml;
 using namespace HTMLNames;
 
@@ -148,22 +151,22 @@ void HTMLBodyElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
         if (attached())
             getDocument()->recalcStyle(Force);
     } else if (attr->name() == onloadAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::LOAD_EVENT,           
+        getDocument()->setHTMLWindowEventListener(loadEvent,       
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else if (attr->name() == onunloadAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::UNLOAD_EVENT,
+        getDocument()->setHTMLWindowEventListener(unloadEvent,
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else if (attr->name() == onblurAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::BLUR_EVENT,
+        getDocument()->setHTMLWindowEventListener(blurEvent,
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else if (attr->name() == onfocusAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::FOCUS_EVENT,
+        getDocument()->setHTMLWindowEventListener(focusEvent,
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else if (attr->name() == onresizeAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::RESIZE_EVENT,
+        getDocument()->setHTMLWindowEventListener(resizeEvent,
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else if (attr->name() == onscrollAttr) {
-        getDocument()->setHTMLWindowEventListener(EventImpl::SCROLL_EVENT,
+        getDocument()->setHTMLWindowEventListener(scrollEvent,
                                                   getDocument()->createHTMLEventListener(attr->value().qstring(), NULL));
     } else
         HTMLElementImpl::parseMappedAttribute(attr);
@@ -417,11 +420,11 @@ void HTMLFrameElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
             m_scrolling = QScrollView::AlwaysOff;
         // FIXME: If we are already attached, this has no effect.
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(EventImpl::LOAD_EVENT,
-                                getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+        setHTMLEventListener(loadEvent,
+                             getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onunloadAttr) {
-        setHTMLEventListener(EventImpl::UNLOAD_EVENT,
-                                getDocument()->createHTMLEventListener(attr->value().qstring(), this));
+        setHTMLEventListener(unloadEvent,
+                             getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLElementImpl::parseMappedAttribute(attr);
 }
@@ -683,10 +686,10 @@ void HTMLFrameSetElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
         if(!m_border)
             frameborder = false;
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(EventImpl::LOAD_EVENT,
+        setHTMLEventListener(loadEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onunloadAttr) {
-        setHTMLEventListener(EventImpl::UNLOAD_EVENT,
+        setHTMLEventListener(unloadEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLElementImpl::parseMappedAttribute(attr);
@@ -735,7 +738,7 @@ void HTMLFrameSetElementImpl::detach()
 {
     if(attached())
         // ### send the event when we actually get removed from the doc instead of here
-        dispatchHTMLEvent(EventImpl::UNLOAD_EVENT,false,false);
+        dispatchHTMLEvent(unloadEvent,false,false);
 
     HTMLElementImpl::detach();
 }
index ebf84d2ee232208dcfe4ca4f31c1ee781cca4ba5..8cec19b643816fffedfa534b54e8a0aefd8f1b02 100644 (file)
 #include "css/css_ruleimpl.h"
 #include "xml/dom_textimpl.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "editing/markup.h"
 
 #include <kdebug.h>
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace HTMLNames;
 using namespace khtml;
 
@@ -154,88 +156,88 @@ void HTMLElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     }
 // standard events
     else if (attr->name() == onclickAttr) {
-        setHTMLEventListener(EventImpl::KHTML_CLICK_EVENT,
+        setHTMLEventListener(khtmlClickEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == oncontextmenuAttr) {
-       setHTMLEventListener(EventImpl::CONTEXTMENU_EVENT,
+       setHTMLEventListener(contextmenuEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondblclickAttr) {
-       setHTMLEventListener(EventImpl::KHTML_DBLCLICK_EVENT,
+       setHTMLEventListener(khtmlDblclickEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmousedownAttr) {
-        setHTMLEventListener(EventImpl::MOUSEDOWN_EVENT,
+        setHTMLEventListener(mousedownEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmousemoveAttr) {
-        setHTMLEventListener(EventImpl::MOUSEMOVE_EVENT,
+        setHTMLEventListener(mousemoveEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmouseoutAttr) {
-        setHTMLEventListener(EventImpl::MOUSEOUT_EVENT,
+        setHTMLEventListener(mouseoutEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmouseoverAttr) {
-        setHTMLEventListener(EventImpl::MOUSEOVER_EVENT,
+        setHTMLEventListener(mouseoverEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmouseupAttr) {
-        setHTMLEventListener(EventImpl::MOUSEUP_EVENT,
+        setHTMLEventListener(mouseupEvent,
                             getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onmousewheelAttr) {
-        setHTMLEventListener(EventImpl::MOUSEWHEEL_EVENT,
+        setHTMLEventListener(mousewheelEvent,
                             getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::DOMFOCUSIN_EVENT,
+        setHTMLEventListener(DOMFocusInEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onkeydownAttr) {
-        setHTMLEventListener(EventImpl::KEYDOWN_EVENT,
+        setHTMLEventListener(keydownEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onkeypressAttr) {
-        setHTMLEventListener(EventImpl::KEYPRESS_EVENT,
+        setHTMLEventListener(keypressEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onkeyupAttr) {
-        setHTMLEventListener(EventImpl::KEYUP_EVENT,
+        setHTMLEventListener(keyupEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onscrollAttr) {
-        setHTMLEventListener(EventImpl::SCROLL_EVENT,
+        setHTMLEventListener(scrollEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onbeforecutAttr) {
-        setHTMLEventListener(EventImpl::BEFORECUT_EVENT,
+        setHTMLEventListener(beforecutEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == oncutAttr) {
-        setHTMLEventListener(EventImpl::CUT_EVENT,
+        setHTMLEventListener(cutEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onbeforecopyAttr) {
-        setHTMLEventListener(EventImpl::BEFORECOPY_EVENT,
+        setHTMLEventListener(beforecopyEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == oncopyAttr) {
-        setHTMLEventListener(EventImpl::COPY_EVENT,
+        setHTMLEventListener(copyEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onbeforepasteAttr) {
-        setHTMLEventListener(EventImpl::BEFOREPASTE_EVENT,
+        setHTMLEventListener(beforepasteEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onpasteAttr) {
-        setHTMLEventListener(EventImpl::PASTE_EVENT,
+        setHTMLEventListener(pasteEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragenterAttr) {
-        setHTMLEventListener(EventImpl::DRAGENTER_EVENT,
+        setHTMLEventListener(dragenterEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragoverAttr) {
-        setHTMLEventListener(EventImpl::DRAGOVER_EVENT,
+        setHTMLEventListener(dragoverEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragleaveAttr) {
-        setHTMLEventListener(EventImpl::DRAGLEAVE_EVENT,
+        setHTMLEventListener(dragleaveEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondropAttr) {
-        setHTMLEventListener(EventImpl::DROP_EVENT,
+        setHTMLEventListener(dropEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragstartAttr) {
-        setHTMLEventListener(EventImpl::DRAGSTART_EVENT,
+        setHTMLEventListener(dragstartEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragAttr) {
-        setHTMLEventListener(EventImpl::DRAG_EVENT,
+        setHTMLEventListener(dragEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == ondragendAttr) {
-        setHTMLEventListener(EventImpl::DRAGEND_EVENT,
+        setHTMLEventListener(dragendEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onselectstartAttr) {
-        setHTMLEventListener(EventImpl::SELECTSTART_EVENT,
+        setHTMLEventListener(selectstartEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } 
 }
@@ -566,11 +568,11 @@ void HTMLElementImpl::click(bool sendMouseEvents, bool showPressedLook)
     // send mousedown and mouseup before the click, if requested
     if (sendMouseEvents) {
         QMouseEvent pressEvt(QEvent::MouseButtonPress, QPoint(x,y), Qt::LeftButton, 0);
-        dispatchMouseEvent(&pressEvt, EventImpl::MOUSEDOWN_EVENT);
+        dispatchMouseEvent(&pressEvt, mousedownEvent);
         if (r)
             setActive(true, showPressedLook);
         QMouseEvent upEvent(QEvent::MouseButtonRelease, QPoint(x,y), Qt::LeftButton, 0);
-        dispatchMouseEvent(&upEvent, EventImpl::MOUSEUP_EVENT);
+        dispatchMouseEvent(&upEvent, mouseupEvent);
         if (r)
             setActive(false);
     } else if (r) {
@@ -579,8 +581,8 @@ void HTMLElementImpl::click(bool sendMouseEvents, bool showPressedLook)
     }
 
     // always send click
-    QMouseEvent clickEvent(QEvent::MouseButtonRelease, QPoint(x,y), Qt::LeftButton, 0);
-    dispatchMouseEvent(&clickEvent, EventImpl::CLICK_EVENT);
+    QMouseEvent clickMouseEvent(QEvent::MouseButtonRelease, QPoint(x,y), Qt::LeftButton, 0);
+    dispatchMouseEvent(&clickMouseEvent, clickEvent);
 }
 
 // accessKeyAction is used by the accessibility support code
@@ -709,7 +711,8 @@ bool HTMLElementImpl::isRecognizedTagName(const QualifiedName& tagName)
 
 // The terms inline and block are used here loosely.  Don't make the mistake of assuming all inlines or all blocks
 // need to be in these two lists.
-HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* inlineTagList() {
+HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* inlineTagList()
+{
     static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > tagList;
     if (tagList.isEmpty()) {
         tagList.insert(ttTag.localName().impl());
@@ -761,7 +764,8 @@ HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* inlineTagList() {
     return &tagList;
 }
 
-HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* blockTagList() {
+HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> >* blockTagList()
+{
     static HashSet<DOMStringImpl*, PointerHash<DOMStringImpl*> > tagList;
     if (tagList.isEmpty()) {
         tagList.insert(pTag.localName().impl());
index 1e433d67e85afb38699658fe5a17fbc26f6d9cfe..a73a5eec94ae86b20d20e11ca1afaf194652e977 100644 (file)
@@ -41,6 +41,7 @@
 #include "css/csshelper.h"
 #include "xml/dom_textimpl.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "khtml_ext.h"
 
 #include "rendering/render_form.h"
@@ -67,6 +68,7 @@ using namespace khtml;
 
 namespace DOM {
 
+using namespace EventNames;
 using namespace HTMLNames;
 
 struct FormDataListItem {
@@ -507,7 +509,7 @@ bool HTMLFormElementImpl::prepareSubmit()
     m_insubmit = true;
     m_doingsubmit = false;
 
-    if ( dispatchHTMLEvent(EventImpl::SUBMIT_EVENT,false,true) && !m_doingsubmit )
+    if ( dispatchHTMLEvent(submitEvent,false,true) && !m_doingsubmit )
         m_doingsubmit = true;
 
     m_insubmit = false;
@@ -616,7 +618,7 @@ void HTMLFormElementImpl::reset(  )
 
     // ### DOM2 labels this event as not cancelable, however
     // common browsers( sick! ) allow it be cancelled.
-    if ( !dispatchHTMLEvent(EventImpl::RESET_EVENT,true, true) ) {
+    if ( !dispatchHTMLEvent(resetEvent,true, true) ) {
         m_inreset = false;
         return;
     }
@@ -663,10 +665,10 @@ void HTMLFormElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == autocompleteAttr) {
         m_autocomplete = strcasecmp( attr->value(), "off" );
     } else if (attr->name() == onsubmitAttr) {
-        setHTMLEventListener(EventImpl::SUBMIT_EVENT,
+        setHTMLEventListener(submitEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onresetAttr) {
-        setHTMLEventListener(EventImpl::RESET_EVENT,
+        setHTMLEventListener(resetEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == nameAttr) {
         DOMString newNameAttr = attr->value();
@@ -1003,13 +1005,13 @@ void HTMLGenericFormElementImpl::setOverrideName(const DOMString& value)
 void HTMLGenericFormElementImpl::onSelect()
 {
     // ### make this work with new form events architecture
-    dispatchHTMLEvent(EventImpl::SELECT_EVENT,true,false);
+    dispatchHTMLEvent(selectEvent,true,false);
 }
 
 void HTMLGenericFormElementImpl::onChange()
 {
     // ### make this work with new form events architecture
-    dispatchHTMLEvent(EventImpl::CHANGE_EVENT,true,false);
+    dispatchHTMLEvent(changeEvent,true,false);
 }
 
 bool HTMLGenericFormElementImpl::disabled() const
@@ -1082,7 +1084,7 @@ void HTMLGenericFormElementImpl::defaultEventHandler(EventImpl *evt)
     {
         // Report focus in/out changes to the browser extension (editable widgets only)
         KHTMLPart *part = getDocument()->part();
-        if (evt->id()==EventImpl::DOMFOCUSIN_EVENT && isEditable() && part && m_render && m_render->isWidget()) {
+        if (evt->type()==DOMFocusInEvent && isEditable() && part && m_render && m_render->isWidget()) {
             KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(part->browserExtension());
             QWidget *widget = static_cast<RenderWidget*>(m_render)->widget();
             if (ext)
@@ -1093,8 +1095,8 @@ void HTMLGenericFormElementImpl::defaultEventHandler(EventImpl *evt)
        // We don't want this default key event handling, we'll count on
        // Cocoa event dispatch if the event doesn't get blocked.
 #else
-       if (evt->id()==EventImpl::KEYDOWN_EVENT ||
-           evt->id()==EventImpl::KEYUP_EVENT)
+       if (evt->type()==keydownEvent ||
+           evt->type()==keyupEvent)
        {
            KeyboardEventImpl * k = static_cast<KeyboardEventImpl *>(evt);
            if (k->keyVal() == QChar('\n').unicode() && m_render && m_render->isWidget() && k->qKeyEvent)
@@ -1102,7 +1104,7 @@ void HTMLGenericFormElementImpl::defaultEventHandler(EventImpl *evt)
        }
 #endif
 
-       if (evt->id()==EventImpl::DOMFOCUSOUT_EVENT && isEditable() && part && m_render && m_render->isWidget()) {
+       if (evt->type()==DOMFocusOutEvent && isEditable() && part && m_render && m_render->isWidget()) {
            KHTMLPartBrowserExtension *ext = static_cast<KHTMLPartBrowserExtension *>(part->browserExtension());
            QWidget *widget = static_cast<RenderWidget*>(m_render)->widget();
            if (ext)
@@ -1235,10 +1237,10 @@ void HTMLButtonElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == accesskeyAttr) {
         // Do nothing.
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::FOCUS_EVENT,
+        setHTMLEventListener(focusEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(EventImpl::BLUR_EVENT,
+        setHTMLEventListener(blurEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLGenericFormElementImpl::parseMappedAttribute(attr);
@@ -1246,7 +1248,7 @@ void HTMLButtonElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
 
 void HTMLButtonElementImpl::defaultEventHandler(EventImpl *evt)
 {
-    if (m_type != BUTTON && (evt->id() == EventImpl::DOMACTIVATE_EVENT)) {
+    if (m_type != BUTTON && (evt->type() == DOMActivateEvent)) {
 
         if(m_form && m_type == SUBMIT) {
             m_activeSubmit = true;
@@ -1829,25 +1831,25 @@ void HTMLInputElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == heightAttr) {
         addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::FOCUS_EVENT,
+        setHTMLEventListener(focusEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(EventImpl::BLUR_EVENT,
+        setHTMLEventListener(blurEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onselectAttr) {
-        setHTMLEventListener(EventImpl::SELECT_EVENT,
+        setHTMLEventListener(selectEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onchangeAttr) {
-        setHTMLEventListener(EventImpl::CHANGE_EVENT,
+        setHTMLEventListener(changeEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == oninputAttr) {
-        setHTMLEventListener(EventImpl::INPUT_EVENT,
+        setHTMLEventListener(inputEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     }
     // Search field and slider attributes all just cause updateFromElement to be called through style
     // recalcing.
     else if (attr->name() == onsearchAttr) {
-        setHTMLEventListener(EventImpl::SEARCH_EVENT,
+        setHTMLEventListener(searchEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == resultsAttr) {
         m_maxResults = !attr->isNull() ? attr->value().toInt() : -1;
@@ -2235,7 +2237,7 @@ void HTMLInputElementImpl::setValueFromRenderer(const DOMString &value)
     m_valueMatchesRenderer = true;
     
     // Fire the "input" DOM event.
-    dispatchHTMLEvent(EventImpl::INPUT_EVENT, true, false);
+    dispatchHTMLEvent(inputEvent, true, false);
 }
 
 bool HTMLInputElementImpl::storesValueSeparateFromAttribute() const
@@ -2277,7 +2279,7 @@ void HTMLInputElementImpl::focus()
 
 void HTMLInputElementImpl::preDispatchEventHandler(EventImpl *evt)
 {
-    if (evt->isMouseEvent() && evt->id() == EventImpl::CLICK_EVENT && static_cast<MouseEventImpl*>(evt)->button() == 0) {
+    if (evt->isMouseEvent() && evt->type() == clickEvent && static_cast<MouseEventImpl*>(evt)->button() == 0) {
         if (m_type == CHECKBOX || m_type == RADIO)
             setChecked(!checked());
     }
@@ -2286,7 +2288,7 @@ void HTMLInputElementImpl::preDispatchEventHandler(EventImpl *evt)
 void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
 {
     if (evt->isMouseEvent() &&
-        ( evt->id() == EventImpl::KHTML_CLICK_EVENT || evt->id() == EventImpl::KHTML_DBLCLICK_EVENT ) &&
+        ( evt->type() == khtmlClickEvent || evt->type() == khtmlDblclickEvent ) &&
         m_type == IMAGE
         && m_render) {
         // record the mouse position for when we get the DOMActivate event
@@ -2303,7 +2305,7 @@ void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
     // actually submitting the form. For reset inputs, the form is reset. These events are sent when the user clicks
     // on the element, or presses enter while it is the active element. Javacsript code wishing to activate the element
     // must dispatch a DOMActivate event - a click event will not do the job.
-    if (evt->id() == EventImpl::DOMACTIVATE_EVENT) {
+    if (evt->type() == DOMActivateEvent) {
         if (m_type == IMAGE || m_type == SUBMIT || m_type == RESET) {
             if (!m_form)
                 return;
@@ -2323,7 +2325,7 @@ void HTMLInputElementImpl::defaultEventHandler(EventImpl *evt)
 #if APPLE_CHANGES
     // Use key press event here since sending simulated mouse events
     // on key down blocks the proper sending of the key press event.
-    if (evt->id() == EventImpl::KEYPRESS_EVENT && evt->isKeyboardEvent()) {
+    if (evt->type() == keypressEvent && evt->isKeyboardEvent()) {
         bool clickElement = false;
         bool clickDefaultFormButton = false;
 
@@ -2550,10 +2552,10 @@ bool HTMLLabelElementImpl::isFocusable() const
 void HTMLLabelElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
 {
     if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::FOCUS_EVENT,
+        setHTMLEventListener(focusEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(EventImpl::BLUR_EVENT,
+        setHTMLEventListener(blurEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLElementImpl::parseMappedAttribute(attr);
@@ -2971,13 +2973,13 @@ void HTMLSelectElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == accesskeyAttr) {
         // FIXME: ignore for the moment
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::FOCUS_EVENT,
+        setHTMLEventListener(focusEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(EventImpl::BLUR_EVENT,
+        setHTMLEventListener(blurEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onchangeAttr) {
-        setHTMLEventListener(EventImpl::CHANGE_EVENT,
+        setHTMLEventListener(changeEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLGenericFormElementImpl::parseMappedAttribute(attr);
@@ -3156,7 +3158,7 @@ void HTMLSelectElementImpl::defaultEventHandler(EventImpl *evt)
 {
     // Use key press event here since sending simulated mouse events
     // on key down blocks the proper sending of the key press event.
-    if (evt->id() == EventImpl::KEYPRESS_EVENT) {
+    if (evt->type() == keypressEvent) {
     
         if (!m_form || !m_render || !evt->isKeyboardEvent())
             return;
@@ -3578,16 +3580,16 @@ void HTMLTextAreaElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == accesskeyAttr) {
         // ignore for the moment
     } else if (attr->name() == onfocusAttr) {
-        setHTMLEventListener(EventImpl::FOCUS_EVENT,
+        setHTMLEventListener(focusEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onblurAttr) {
-        setHTMLEventListener(EventImpl::BLUR_EVENT,
+        setHTMLEventListener(blurEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onselectAttr) {
-        setHTMLEventListener(EventImpl::SELECT_EVENT,
+        setHTMLEventListener(selectEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onchangeAttr) {
-        setHTMLEventListener(EventImpl::CHANGE_EVENT,
+        setHTMLEventListener(changeEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else
         HTMLGenericFormElementImpl::parseMappedAttribute(attr);
index 5697bceb6f191c17721034af3f32fc37e6687dee..a1736b58360c52397356a129a260d237ab7eef39 100644 (file)
@@ -39,6 +39,7 @@
 #include "css/cssvalues.h"
 #include "css/csshelper.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 
 #include <qstring.h>
 #include <qpoint.h>
@@ -48,6 +49,7 @@
 #include <qpointarray.h>
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace HTMLNames;
 using namespace khtml;
 
@@ -111,9 +113,9 @@ void HTMLImageLoader::dispatchLoadEvent()
     if (!m_firedLoad) {
         m_firedLoad = true;
         if (m_image->isErrorImage())
-            element()->dispatchHTMLEvent(EventImpl::ERROR_EVENT, false, false);
+            element()->dispatchHTMLEvent(errorEvent, false, false);
         else
-            element()->dispatchHTMLEvent(EventImpl::LOAD_EVENT, false, false);
+            element()->dispatchHTMLEvent(loadEvent, false, false);
     }
 }
 
@@ -216,13 +218,13 @@ void HTMLImageElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
     } else if (attr->name() == ismapAttr) {
         ismap = true;
     } else if (attr->name() == onabortAttr) {
-        setHTMLEventListener(EventImpl::ABORT_EVENT,
+        setHTMLEventListener(abortEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onerrorAttr) {
-        setHTMLEventListener(EventImpl::ERROR_EVENT,
+        setHTMLEventListener(errorEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(EventImpl::LOAD_EVENT,
+        setHTMLEventListener(loadEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     }
 #if APPLE_CHANGES
index a0986a8a00a65ac66cab9ac06cfcea9d41f6a928..2aa33fcc68a343f3f04104b85011da8122e09723 100644 (file)
@@ -34,6 +34,7 @@
 #include "css/cssvalues.h"
 #include "css/cssstyleselector.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "rendering/render_br.h"
 #include "rendering/render_image.h"
 
@@ -43,6 +44,7 @@ using namespace khtml;
 
 namespace DOM {
 
+using namespace EventNames;
 using namespace HTMLNames;
 
 HTMLAnchorElementImpl::HTMLAnchorElementImpl(DocumentPtr *doc)
@@ -116,14 +118,14 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
     // React on clicks and on keypresses.
     // Don't make this KEYUP_EVENT again, it makes khtml follow links it shouldn't,
     // when pressing Enter in the combo.
-    if ( ( evt->id() == EventImpl::KHTML_CLICK_EVENT ||
-         ( evt->id() == EventImpl::KEYDOWN_EVENT && m_focused)) && m_isLink) {
+    if ( ( evt->type() == khtmlClickEvent ||
+         ( evt->type() == keydownEvent && m_focused)) && m_isLink) {
         MouseEventImpl *e = 0;
-        if ( evt->id() == EventImpl::KHTML_CLICK_EVENT )
+        if ( evt->type() == khtmlClickEvent )
             e = static_cast<MouseEventImpl*>( evt );
 
         KeyboardEventImpl *k = 0;
-        if (evt->id() == EventImpl::KEYDOWN_EVENT)
+        if (evt->type() == keydownEvent)
             k = static_cast<KeyboardEventImpl *>( evt );
 
         QString utarget;
index 90411e67b83acd2a6a4aa7cd1aa309c82d01dcee..21ed13276ba134fd13bd8088fe004283141bdca8 100644 (file)
@@ -41,6 +41,7 @@
 #include "rendering/render_frames.h"
 #include "rendering/render_image.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 
 #ifndef Q_WS_QWS // We don't have Java in Qt Embedded
 #include "java/kjavaappletwidget.h"
@@ -55,6 +56,7 @@ using namespace khtml;
 
 namespace DOM {
 
+using namespace EventNames;
 using namespace HTMLNames;
 
 // -------------------------------------------------------------------------
@@ -668,10 +670,10 @@ void HTMLObjectElementImpl::parseMappedAttribute(MappedAttributeImpl *attr)
         if (m_render)
           needWidgetUpdate = true;
     } else if (attr->name() == onloadAttr) {
-        setHTMLEventListener(EventImpl::LOAD_EVENT,
+        setHTMLEventListener(loadEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == onunloadAttr) {
-        setHTMLEventListener(EventImpl::UNLOAD_EVENT,
+        setHTMLEventListener(unloadEvent,
                              getDocument()->createHTMLEventListener(attr->value().qstring(), this));
     } else if (attr->name() == nameAttr) {
            DOMString newNameAttr = attr->value();
@@ -751,7 +753,7 @@ void HTMLObjectElementImpl::attach()
                 // this method or recalcStyle (which also calls updateWidget) to be called.
                 needWidgetUpdate = false;
                 static_cast<RenderPartObject*>(m_render)->updateWidget();
-                dispatchHTMLEvent(EventImpl::LOAD_EVENT,false,false);
+                dispatchHTMLEvent(loadEvent,false,false);
             } else {
                 needWidgetUpdate = true;
                 setChanged();
@@ -765,7 +767,7 @@ void HTMLObjectElementImpl::detach()
     // Only bother with an unload event if we had a render object.  - dwh
     if (attached() && m_render && !m_useFallbackContent)
         // ### do this when we are actualy removed from document instead
-        dispatchHTMLEvent(EventImpl::UNLOAD_EVENT,false,false);
+        dispatchHTMLEvent(unloadEvent,false,false);
 
     HTMLElementImpl::detach();
 }
@@ -799,7 +801,7 @@ void HTMLObjectElementImpl::recalcStyle(StyleChange ch)
         // this method or attach (which also calls updateWidget) to be called.
         needWidgetUpdate = false;
         static_cast<RenderPartObject*>(m_render)->updateWidget();
-        dispatchHTMLEvent(EventImpl::LOAD_EVENT,false,false);
+        dispatchHTMLEvent(loadEvent,false,false);
     }
     HTMLElementImpl::recalcStyle(ch);
 }
index 3b58b20b734c7eaf6041a03416650b247a86f636..940e44d0e9897b4b37b1ea274f166619cd7e0c53 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c-basic-offset: 2 -*-
 /* This file is part of the KDE project
  *
  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
@@ -58,6 +57,7 @@
 #include "misc/loader.h"
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom2_rangeimpl.h"
+#include "xml/EventNames.h"
 #include "xml/xml_tokenizer.h"
 
 using namespace DOM;
@@ -112,6 +112,8 @@ using namespace HTMLNames;
 #include <CoreServices/CoreServices.h>
 #endif
 
+using namespace DOM::EventNames;
+
 using khtml::ApplyStyleCommand;
 using khtml::CHARACTER;
 using khtml::ChildFrame;
@@ -209,6 +211,7 @@ void KHTMLPart::init( KHTMLView *view, GUIProfile prof )
 {
   AtomicString::init();
   QualifiedName::init();
+  EventNames::init();
   HTMLNames::init(); // FIXME: We should make this happen only when HTML is used.
   if ( prof == DefaultGUI )
     setXMLFile( "khtml.rc" );
@@ -613,7 +616,7 @@ void KHTMLPart::stopLoading(bool sendUnload)
       HTMLDocumentImpl* hdoc = static_cast<HTMLDocumentImpl*>( d->m_doc );
       
       if ( hdoc->body() && d->m_bLoadEventEmitted && !d->m_bUnloadEventEmitted ) {
-        hdoc->body()->dispatchWindowEvent( EventImpl::UNLOAD_EVENT, false, false );
+        hdoc->body()->dispatchWindowEvent( unloadEvent, false, false );
         if ( d->m_doc )
           d->m_doc->updateRendering();
         d->m_bUnloadEventEmitted = true;
index 83857631da5b6058f95821e99e97c4b4b08701dc..f9df188939aca2cee2350d2c9cb9d6261bc974f9 100644 (file)
@@ -40,6 +40,7 @@
 #include "rendering/render_text.h"
 #include "xml/dom_nodeimpl.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "css/cssstyleselector.h"
 #include "misc/helper.h"
 #include "khtml_settings.h"
 // #define INSTRUMENT_LAYOUT_SCHEDULING 1
 
 using namespace DOM;
+using namespace EventNames;
 using namespace HTMLNames;
 using namespace khtml;
+
 class KHTMLToolTip;
 
 #ifndef QT_NO_TOOLTIP
@@ -428,7 +431,7 @@ void KHTMLView::resizeEvent (QResizeEvent* e)
         layout();
 #endif
     if ( m_part && m_part->xmlDocImpl() )
-        m_part->xmlDocImpl()->dispatchWindowEvent( EventImpl::RESIZE_EVENT, false, false );
+        m_part->xmlDocImpl()->dispatchWindowEvent( EventNames::resizeEvent, false, false );
 
     KApplication::sendPostedEvents(viewport(), QEvent::Paint);
 }
@@ -794,7 +797,7 @@ void KHTMLView::viewportMousePressEvent( QMouseEvent *_mouse )
         d->clickNode->ref();
 #endif    
 
-    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEDOWN_EVENT,mev.innerNode.get(),true,
+    bool swallowEvent = dispatchMouseEvent(mousedownEvent,mev.innerNode.get(),true,
                                            d->clickCount,_mouse,true,DOM::NodeImpl::MousePress);
 
     if (!swallowEvent) {
@@ -841,11 +844,11 @@ void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse )
         return;
 
     d->clickCount = _mouse->clickCount();
-    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEUP_EVENT,mev.innerNode.get(),true,
+    bool swallowEvent = dispatchMouseEvent(mouseupEvent,mev.innerNode.get(),true,
                                            d->clickCount,_mouse,false,DOM::NodeImpl::MouseRelease);
 
     if (mev.innerNode == d->clickNode)
-        dispatchMouseEvent(EventImpl::CLICK_EVENT,mev.innerNode.get(),true,
+        dispatchMouseEvent(clickEvent,mev.innerNode.get(),true,
                           d->clickCount,_mouse,true,DOM::NodeImpl::MouseRelease);
 
     // Qt delivers a release event AND a double click event.
@@ -861,7 +864,7 @@ void KHTMLView::viewportMouseDoubleClickEvent( QMouseEvent *_mouse )
     // single and double-click events as separate (only the detail, i.e. number of clicks differs)
     // In other words an even detail value for a mouse click event means a double click, and an
     // odd detail value means a single click
-    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEDOWN_EVENT,mev.innerNode.get(),true,
+    bool swallowEvent = dispatchMouseEvent(mousedownEvent,mev.innerNode.get(),true,
                                            d->clickCount,_mouse,true,DOM::NodeImpl::MouseDblClick);
 
     if (!swallowEvent) {
@@ -905,7 +908,7 @@ void KHTMLView::viewportMouseMoveEvent( QMouseEvent * _mouse )
         return;
 #endif
 
-    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEMOVE_EVENT,mev.innerNode.get(),false,
+    bool swallowEvent = dispatchMouseEvent(mousemoveEvent,mev.innerNode.get(),false,
                                            0,_mouse,true,DOM::NodeImpl::MouseMove);
 
 #if !APPLE_CHANGES
@@ -1066,7 +1069,7 @@ void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
         return;
 #endif
 
-    bool swallowEvent = dispatchMouseEvent(EventImpl::MOUSEUP_EVENT,mev.innerNode.get(),true,
+    bool swallowEvent = dispatchMouseEvent(mouseupEvent,mev.innerNode.get(),true,
                                            d->clickCount,_mouse,false,DOM::NodeImpl::MouseRelease);
 
     if (d->clickCount > 0 && mev.innerNode == d->clickNode
@@ -1074,7 +1077,7 @@ void KHTMLView::viewportMouseReleaseEvent( QMouseEvent * _mouse )
             && QPoint(d->clickX-xm,d->clickY-ym).manhattanLength() <= QApplication::startDragDistance()
 #endif
         )
-       dispatchMouseEvent(EventImpl::CLICK_EVENT,mev.innerNode.get(),true,
+       dispatchMouseEvent(clickEvent,mev.innerNode.get(),true,
                           d->clickCount,_mouse,true,DOM::NodeImpl::MouseRelease);
 
     if (!swallowEvent) {
@@ -1226,7 +1229,7 @@ void KHTMLView::contentsContextMenuEvent ( QContextMenuEvent *_ce )
 #endif
 }
 
-bool KHTMLView::dispatchDragEvent(int eventId, DOM::NodeImpl *dragTarget, const QPoint &loc, DOM::ClipboardImpl *clipboard)
+bool KHTMLView::dispatchDragEvent(const AtomicString &eventType, DOM::NodeImpl *dragTarget, const QPoint &loc, DOM::ClipboardImpl *clipboard)
 {
     int clientX, clientY;
     viewportToContents(loc.x(), loc.y(), clientX, clientY);
@@ -1244,7 +1247,7 @@ bool KHTMLView::dispatchDragEvent(int eventId, DOM::NodeImpl *dragTarget, const
     bool shiftKey = 0;
     bool metaKey = 0;
     
-    MouseEventImpl *me = new MouseEventImpl(static_cast<EventImpl::EventId>(eventId),
+    MouseEventImpl *me = new MouseEventImpl(eventType,
                                             true, true, m_part->xmlDocImpl()->defaultView(),
                                             0, screenX, screenY, clientX, clientY,
                                             ctrlKey, altKey, shiftKey, metaKey,
@@ -1274,13 +1277,13 @@ bool KHTMLView::updateDragAndDrop(const QPoint &loc, DOM::ClipboardImpl *clipboa
     if (d->dragTarget != newTarget) {
         // note this ordering is explicitly chosen to match WinIE
         if (newTarget) {
-            accept = dispatchDragEvent(EventImpl::DRAGENTER_EVENT, newTarget, loc, clipboard);
+            accept = dispatchDragEvent(dragenterEvent, newTarget, loc, clipboard);
         }
         if (!d->dragTarget.isNull()) {
-            dispatchDragEvent(EventImpl::DRAGLEAVE_EVENT, d->dragTarget.get(), loc, clipboard);
+            dispatchDragEvent(dragleaveEvent, d->dragTarget.get(), loc, clipboard);
         }
     } else if (newTarget) {
-        accept = dispatchDragEvent(EventImpl::DRAGOVER_EVENT, newTarget, loc, clipboard);
+        accept = dispatchDragEvent(dragoverEvent, newTarget, loc, clipboard);
     }
     d->dragTarget.reset(newTarget);
 
@@ -1290,7 +1293,7 @@ bool KHTMLView::updateDragAndDrop(const QPoint &loc, DOM::ClipboardImpl *clipboa
 void KHTMLView::cancelDragAndDrop(const QPoint &loc, DOM::ClipboardImpl *clipboard)
 {
     if (!d->dragTarget.isNull()) {
-        dispatchDragEvent(EventImpl::DRAGLEAVE_EVENT, d->dragTarget.get(), loc, clipboard);
+        dispatchDragEvent(dragleaveEvent, d->dragTarget.get(), loc, clipboard);
     }
     d->dragTarget.reset();
 }
@@ -1299,7 +1302,7 @@ bool KHTMLView::performDragAndDrop(const QPoint &loc, DOM::ClipboardImpl *clipbo
 {
     bool accept = false;
     if (!d->dragTarget.isNull()) {
-        accept = dispatchDragEvent(EventImpl::DROP_EVENT, d->dragTarget.get(), loc, clipboard);
+        accept = dispatchDragEvent(dropEvent, d->dragTarget.get(), loc, clipboard);
     }
     d->dragTarget.reset();
     return accept;
@@ -1791,7 +1794,7 @@ void KHTMLView::addFormCompletionItem(const QString &name, const QString &value)
 
 #endif
 
-bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool cancelable,
+bool KHTMLView::dispatchMouseEvent(const AtomicString &eventType, DOM::NodeImpl *targetNode, bool cancelable,
                                   int detail,QMouseEvent *_mouse, bool setUnder,
                                   int mouseEventType)
 {
@@ -1849,7 +1852,7 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
            // send mouseout event to the old node
            if (oldUnder){
                oldUnder->ref();
-               MouseEventImpl *me = new MouseEventImpl(EventImpl::MOUSEOUT_EVENT,
+               MouseEventImpl *me = new MouseEventImpl(mouseoutEvent,
                                                        true,true,m_part->xmlDocImpl()->defaultView(),
                                                        0,screenX,screenY,clientX,clientY,
                                                        ctrlKey,altKey,shiftKey,metaKey,
@@ -1859,7 +1862,7 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
 
            // send mouseover event to the new node
            if (targetNode) {
-               MouseEventImpl *me = new MouseEventImpl(EventImpl::MOUSEOVER_EVENT,
+               MouseEventImpl *me = new MouseEventImpl(mouseoverEvent,
                                                        true,true,m_part->xmlDocImpl()->defaultView(),
                                                        0,screenX,screenY,clientX,clientY,
                                                        ctrlKey,altKey,shiftKey,metaKey,
@@ -1879,7 +1882,7 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
         // which do a lot of the same stuff.
 
        // send the actual event
-       MouseEventImpl *me = new MouseEventImpl(static_cast<EventImpl::EventId>(eventId),
+       MouseEventImpl *me = new MouseEventImpl(eventType,
                                                true,cancelable,m_part->xmlDocImpl()->defaultView(),
                                                detail,screenX,screenY,clientX,clientY,
                                                ctrlKey,altKey,shiftKey,metaKey,
@@ -1892,12 +1895,12 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
             swallowEvent = true;
        me->deref();
 
-       // Special case: If it's a click event, we also send the KHTML_CLICK or KHTML_DBLCLICK event. This is not part
+       // Special case: If it's a click event, we also send the khtmlClickEvent or khtmlDblclickEvent. This is not part
        // of the DOM specs, but is used for compatibility with the traditional onclick="" and ondblclick="" attributes,
        // as there is no way to tell the difference between single & double clicks using DOM (only the click count is
-       // stored, which is not necessarily the same)
-       if (eventId == EventImpl::CLICK_EVENT) {
-           me = new MouseEventImpl(EventImpl::KHTML_CLICK_EVENT,
+       // stored, which is not necessarily the same).
+       if (eventType == clickEvent) {
+           me = new MouseEventImpl(khtmlClickEvent,
                                    true,cancelable,m_part->xmlDocImpl()->defaultView(),
                                    detail,screenX,screenY,clientX,clientY,
                                    ctrlKey,altKey,shiftKey,metaKey,
@@ -1915,7 +1918,7 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
            me->deref();
 
             if (d->isDoubleClick) {
-                me = new MouseEventImpl(EventImpl::KHTML_DBLCLICK_EVENT,
+                me = new MouseEventImpl(khtmlDblclickEvent,
                                         true,cancelable,m_part->xmlDocImpl()->defaultView(),
                                         detail,screenX,screenY,clientX,clientY,
                                         ctrlKey,altKey,shiftKey,metaKey,
@@ -1931,9 +1934,9 @@ bool KHTMLView::dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool
 
             // Also send a DOMActivate event, which causes things like form submissions to occur.
             if (!defaultPrevented && !targetNode->disabled())
-                targetNode->dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT, detail);
+                targetNode->dispatchUIEvent(DOMActivateEvent, detail);
         }
-        else if (eventId == EventImpl::MOUSEDOWN_EVENT) {
+        else if (eventType == mousedownEvent) {
             // Focus should be shifted on mouse down, not on a click.  -dwh
             // Blur current focus node when a link/button is clicked; this
             // is expected by some sites that rely on onChange handlers running
index 9f6542473bee013f6bb54303f17a912271584372..6c98c5fb5bde0d1d92f1a459125d78327fc4352a 100644 (file)
@@ -282,10 +282,10 @@ private:
     QStringList formCompletionItems(const QString &name) const;
     void addFormCompletionItem(const QString &name, const QString &value);
 
-    bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, bool cancelable,
+    bool dispatchMouseEvent(const DOM::AtomicString &eventType, DOM::NodeImpl *targetNode, bool cancelable,
                            int detail,QMouseEvent *_mouse, bool setUnder,
                            int mouseEventType);
-    bool dispatchDragEvent(int eventId, DOM::NodeImpl *dragTarget, const QPoint &loc, DOM::ClipboardImpl *clipboard);
+    bool dispatchDragEvent(const DOM::AtomicString &eventType, DOM::NodeImpl *dragTarget, const QPoint &loc, DOM::ClipboardImpl *clipboard);
 
     void applyOverflowToViewport(khtml::RenderObject* o, ScrollBarMode& hMode, ScrollBarMode& vMode);
 
index 0b7c4879c0dd1d819e02513fb65be464912749d0..778cc21ac1ae8b78d45ab9e954f04a1a1ffff31d 100644 (file)
@@ -41,6 +41,7 @@
 #include "khtmlview.h"
 #include "khtml_ext.h"
 #include "xml/dom_docimpl.h"
+#include "xml/EventNames.h"
 
 #include <kdebug.h>
 
@@ -51,6 +52,7 @@
 
 using namespace khtml;
 using namespace DOM;
+using namespace EventNames;
 using namespace HTMLNames;
 
 RenderFormElement::RenderFormElement(HTMLGenericFormElementImpl *element)
@@ -189,7 +191,7 @@ void RenderFormElement::slotClicked()
 
 #if APPLE_CHANGES
     QMouseEvent event(QEvent::MouseButtonRelease); // gets "current event"
-    element()->dispatchMouseEvent(&event, EventImpl::CLICK_EVENT, event.clickCount());
+    element()->dispatchMouseEvent(&event, clickEvent, event.clickCount());
 #else
     // We also send the KHTML_CLICK or KHTML_DBLCLICK event for
     // CLICK. This is not part of the DOM specs, but is used for
@@ -199,8 +201,8 @@ void RenderFormElement::slotClicked()
     // stored, which is not necessarily the same)
 
     QMouseEvent e2(QEvent::MouseButtonRelease, m_mousePos, m_button, m_state);
-    element()->dispatchMouseEvent(&e2, EventImpl::CLICK_EVENT, m_clickCount);
-    element()->dispatchMouseEvent(&e2, m_isDoubleClick ? EventImpl::KHTML_DBLCLICK_EVENT : EventImpl::KHTML_CLICK_EVENT, m_clickCount);
+    element()->dispatchMouseEvent(&e2, clickEvent, m_clickCount);
+    element()->dispatchMouseEvent(&e2, m_isDoubleClick ? khtmlDblclickEvent : khtmlClickEvent, m_clickCount);
 #endif
 
     deref(arena);
@@ -510,7 +512,7 @@ void RenderLineEdit::slotReturnPressed()
 void RenderLineEdit::slotPerformSearch()
 {
     // Fire the "search" DOM event.
-    element()->dispatchHTMLEvent(EventImpl::SEARCH_EVENT, true, false);
+    element()->dispatchHTMLEvent(searchEvent, true, false);
 }
 
 void RenderLineEdit::addSearchResult()
@@ -1744,7 +1746,7 @@ void RenderSlider::slotSliderValueChanged()
     element()->setValue(QString::number(val));
     
     // Fire the "input" DOM event.
-    element()->dispatchHTMLEvent(EventImpl::INPUT_EVENT, true, false);
+    element()->dispatchHTMLEvent(inputEvent, true, false);
 }
 
 void RenderSlider::slotClicked()
index 85f2b885edeb52a0aa4c1f10504d1ba5144dd5d3..15def665bf27b5814b00291cab823fa25021d118 100644 (file)
@@ -33,6 +33,7 @@
 #include "html/htmltokenizer.h"
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom_docimpl.h"
+#include "xml/EventNames.h"
 #include "khtmlview.h"
 #include "khtml_part.h"
 #include "render_arena.h"
@@ -50,6 +51,7 @@
 
 using namespace khtml;
 using namespace DOM;
+using namespace EventNames;
 using namespace HTMLNames;
 
 RenderFrameSet::RenderFrameSet( HTMLFrameSetElementImpl *frameSet)
@@ -347,7 +349,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
     int _x = evt->clientX();
     int _y = evt->clientY();
     
-    if ( !m_resizing && evt->id() == EventImpl::MOUSEMOVE_EVENT || evt->id() == EventImpl::MOUSEDOWN_EVENT )
+    if ( !m_resizing && evt->type() == mousemoveEvent || evt->type() == mousedownEvent )
     {
 #ifdef DEBUG_LAYOUT
         kdDebug( 6031 ) << "mouseEvent:check" << endl;
@@ -406,7 +408,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
             cursor = KCursor::sizeVerCursor();
         }
         
-        if(evt->id() == EventImpl::MOUSEDOWN_EVENT)
+        if(evt->type() == mousedownEvent)
         {
             setResizing(true);
             KApplication::setOverrideCursor(cursor);
@@ -420,7 +422,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
     }
     
     // ### check the resize is not going out of bounds.
-    if(m_resizing && evt->id() == EventImpl::MOUSEUP_EVENT)
+    if(m_resizing && evt->type() == mouseupEvent)
     {
         setResizing(false);
         KApplication::restoreOverrideCursor();
@@ -449,7 +451,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
         setNeedsLayout(true);
     }
     
-    else if (m_resizing || evt->id() == EventImpl::MOUSEUP_EVENT) {
+    else if (m_resizing || evt->type() == mouseupEvent) {
 #if APPLE_CHANGES
         KHTMLView *v = canvas()->view();
         QPainter paint;
index fa609d5c7c5978abb10b7a2fbd58f4e97767e672..13dc9701885ca9e403ea561c80db6b02d13e9057 100644 (file)
@@ -42,6 +42,7 @@
  */
 
 #include "render_layer.h"
+
 #include <kdebug.h>
 #include <assert.h>
 #include "khtmlview.h"
@@ -50,6 +51,7 @@
 #include "render_theme.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom2_eventsimpl.h"
+#include "xml/EventNames.h"
 #include "html/html_blockimpl.h"
 
 #include <qscrollbar.h>
 #define PAGE_KEEP   40
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace HTMLNames;
-using namespace khtml;
+
+namespace khtml {
 
 #ifdef APPLE_CHANGES
 QScrollBar* RenderLayer::gScrollBar = 0;
@@ -532,7 +536,7 @@ RenderLayer::scrollToOffset(int x, int y, bool updateScrollbars, bool repaint)
 #endif
 
     // Fire the scroll DOM event.
-    m_object->element()->dispatchHTMLEvent(EventImpl::SCROLL_EVENT, true, false);
+    m_object->element()->dispatchHTMLEvent(scrollEvent, true, false);
 
     // Just schedule a full repaint of our object.
     if (repaint)
@@ -1770,3 +1774,4 @@ void Marquee::timerEvent(QTimerEvent* evt)
     }
 }
 
+}
index 762c7ee854de8497f263964f4be2ab126a42d2f4..16c9696e10044ffed3b6df2f8e8ecbcdc1db7d45 100644 (file)
@@ -33,6 +33,7 @@
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom_position.h"
+#include "xml/EventNames.h"
 #include "css/cssstyleselector.h"
 #include <kdebug.h>
 #include <qpainter.h>
@@ -51,7 +52,9 @@
 #endif
 
 #include <assert.h>
+
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace HTMLNames;
 using namespace khtml;
 
@@ -1594,7 +1597,7 @@ bool RenderObject::shouldSelect() const
     NodeImpl *node = selectStartNode(this);
     if (!node)
         return false;
-    return node->dispatchHTMLEvent(DOM::EventImpl::SELECTSTART_EVENT, true, true);
+    return node->dispatchHTMLEvent(selectstartEvent, true, true);
 }
 
 QColor RenderObject::selectionColor(QPainter *p) const
index 92c54a0eb11eabdea3dc1c38dabcd14cfdbdafea..a345fd85514c323965ba0c3e406d5fc39632b0a9 100644 (file)
 #include "khtml_part.h"
 #include "xml/dom_docimpl.h" // ### remove dependency
 #include "xml/dom_position.h"
+#include "xml/EventNames.h"
 #include <kdebug.h>
 
 using namespace khtml;
 using namespace DOM;
-
+using namespace DOM::EventNames;
 
 RenderReplaced::RenderReplaced(DOM::NodeImpl* node)
     : RenderBox(node)
@@ -358,7 +359,7 @@ void RenderWidget::sendConsumedMouseUp(const QPoint &mousePos, int button, int s
     RenderArena *arena = ref();
     QMouseEvent e( QEvent::MouseButtonRelease, mousePos, button, state);
 
-    element()->dispatchMouseEvent(&e, EventImpl::MOUSEUP_EVENT, 0);
+    element()->dispatchMouseEvent(&e, mouseupEvent, 0);
     deref(arena);
 }
 #endif
@@ -522,20 +523,20 @@ bool RenderWidget::eventFilter(QObject* /*o*/, QEvent* e)
 //         m_state  = _e->state();
 //         QMouseEvent e2(e->type(),QPoint(absX,absY)+_e->pos(),_e->button(),_e->state());
 
-//         elem->dispatchMouseEvent(&e2,EventImpl::MOUSEUP_EVENT,m_clickCount);
+//         elem->dispatchMouseEvent(&e2,mouseupEvent,m_clickCount);
 
 //         if((m_mousePos - e2.pos()).manhattanLength() <= QApplication::startDragDistance()) {
 //             // DOM2 Events section 1.6.2 says that a click is if the mouse was pressed
 //             // and released in the "same screen location"
 //             // As people usually can't click on the same pixel, we're a bit tolerant here
-//             elem->dispatchMouseEvent(&e2,EventImpl::CLICK_EVENT,m_clickCount);
+//             elem->dispatchMouseEvent(&e2,clickEvent,m_clickCount);
 //         }
 
 //         if(!isRenderButton()) {
 //             // ### DOMActivate is also dispatched for thigs like selects & textareas -
 //             // not sure if this is correct
-//             elem->dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT,m_isDoubleClick ? 2 : 1);
-//             elem->dispatchMouseEvent(&e2, m_isDoubleClick ? EventImpl::KHTML_DBLCLICK_EVENT : EventImpl::KHTML_CLICK_EVENT, m_clickCount);
+//             elem->dispatchUIEvent(DOMActivateEvent,m_isDoubleClick ? 2 : 1);
+//             elem->dispatchMouseEvent(&e2, m_isDoubleClick ? khtmlDblclickEvent : khtmlClickEvent, m_clickCount);
 //             m_isDoubleClick = false;
 //         }
 //         else
diff --git a/WebCore/khtml/xml/EventNames.cpp b/WebCore/khtml/xml/EventNames.cpp
new file mode 100644 (file)
index 0000000..60fcdc3
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 2005 Apple Computer, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#define DOM_EVENT_NAMES_HIDE_GLOBALS 1
+
+#include "EventNames.h"
+
+using DOM::AtomicString;
+using DOM::nullAtom;
+
+namespace DOM { namespace EventNames {
+
+// Initialize explicitly to avoid static initialization.
+
+#define DEFINE_GLOBAL(name) void *name##Event[(sizeof(AtomicString) + sizeof(void *) - 1) / sizeof(void *)];
+DOM_EVENT_NAMES_FOR_EACH(DEFINE_GLOBAL)
+
+void init()
+{
+    static bool initialized;
+    if (!initialized) {
+        // Use placement new to initialize the globals.
+        #define INITIALIZE_GLOBAL(name) new (&name##Event) AtomicString(#name);
+        DOM_EVENT_NAMES_FOR_EACH(INITIALIZE_GLOBAL)
+        initialized = true;
+    }
+}
+
+} }
diff --git a/WebCore/khtml/xml/EventNames.h b/WebCore/khtml/xml/EventNames.h
new file mode 100644 (file)
index 0000000..909ef8a
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 2005 Apple Computer, Inc.
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#ifndef DOM_EVENT_NAMES_H
+#define DOM_EVENT_NAMES_H
+
+#include "dom_atomicstring.h"
+
+namespace DOM { namespace EventNames {
+
+#define DOM_EVENT_NAMES_FOR_EACH(macro) \
+    \
+    macro(abort) \
+    macro(beforecopy) \
+    macro(beforecut) \
+    macro(beforepaste) \
+    macro(blur) \
+    macro(change) \
+    macro(click) \
+    macro(contextmenu) \
+    macro(copy) \
+    macro(cut) \
+    macro(drag) \
+    macro(dragend) \
+    macro(dragenter) \
+    macro(dragleave) \
+    macro(dragover) \
+    macro(dragstart) \
+    macro(drop) \
+    macro(error) \
+    macro(focus) \
+    macro(input) \
+    macro(keydown) \
+    macro(keypress) \
+    macro(keyup) \
+    macro(load) \
+    macro(mousedown) \
+    macro(mousemove) \
+    macro(mouseout) \
+    macro(mouseover) \
+    macro(mouseup) \
+    macro(mousewheel) \
+    macro(paste) \
+    macro(readystatechange) \
+    macro(reset) \
+    macro(resize) \
+    macro(scroll) \
+    macro(search) \
+    macro(select) \
+    macro(selectstart) \
+    macro(submit) \
+    macro(textInput) \
+    macro(unload) \
+    \
+    macro(DOMActivate) \
+    macro(DOMAttrModified) \
+    macro(DOMCharacterDataModified) \
+    macro(DOMFocusIn) \
+    macro(DOMFocusOut) \
+    macro(DOMNodeInserted) \
+    macro(DOMNodeInsertedIntoDocument) \
+    macro(DOMNodeRemoved) \
+    macro(DOMNodeRemovedFromDocument) \
+    macro(DOMSubtreeModified) \
+    \
+    macro(khtmlClick) \
+    macro(khtmlDblclick) \
+    macro(khtmlDragdrop) \
+    macro(khtmlError) \
+    macro(khtmlHorizontalmousewheel) \
+    macro(khtmlMove) \
+    macro(khtmlOrigclickMouseup) \
+    \
+// end of DOM_EVENT_NAMES_FOR_EACH
+
+#if !DOM_EVENT_NAMES_HIDE_GLOBALS
+    #define DOM_EVENT_NAMES_DECLARE(name) extern AtomicString name##Event;
+    DOM_EVENT_NAMES_FOR_EACH(DOM_EVENT_NAMES_DECLARE)
+    #undef DOM_EVENT_NAMES_DECLARE
+#endif
+
+    void init();
+
+} }
+
+#endif
index 42c7c7046e53469606c7e9a993b2efcd76905ec1..f74e601ff84d710aeac3956636d404b8be82d5c5 100644 (file)
 #include "xml/dom_nodeimpl.h"
 #include "xml/dom_docimpl.h"
 #include "xml/dom2_viewsimpl.h"
+#include "xml/EventNames.h"
 #include "rendering/render_object.h"
 #include "rendering/render_layer.h"
 
 #include <kdebug.h>
 
-using namespace DOM;
-
 using khtml::RenderObject;
 
+using namespace DOM::EventNames;
+
+namespace DOM {
+
 EventImpl::EventImpl()
 {
-    m_type = 0;
     m_canBubble = false;
     m_cancelable = false;
 
     m_propagationStopped = false;
     m_defaultPrevented = false;
     m_cancelBubble = false;
-    m_id = UNKNOWN_EVENT;
     m_currentTarget = 0;
     m_eventPhase = 0;
     m_target = 0;
@@ -54,19 +55,15 @@ EventImpl::EventImpl()
     m_defaultHandled = false;
 }
 
-EventImpl::EventImpl(EventId _id, bool canBubbleArg, bool cancelableArg)
+EventImpl::EventImpl(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg)
+    : m_type(eventType)
 {
-    DOMString t = EventImpl::idToType(_id);
-    m_type = t.impl();
-    if (m_type)
-       m_type->ref();
     m_canBubble = canBubbleArg;
     m_cancelable = cancelableArg;
 
     m_propagationStopped = false;
     m_defaultPrevented = false;
     m_cancelBubble = false;
-    m_id = _id;
     m_currentTarget = 0;
     m_eventPhase = 0;
     m_target = 0;
@@ -76,22 +73,10 @@ EventImpl::EventImpl(EventId _id, bool canBubbleArg, bool cancelableArg)
 
 EventImpl::~EventImpl()
 {
-    if (m_type)
-        m_type->deref();
     if (m_target)
         m_target->deref();
 }
 
-DOMString EventImpl::type() const
-{
-    return m_type;
-}
-
-NodeImpl *EventImpl::target() const
-{
-    return m_target;
-}
-
 void EventImpl::setTarget(NodeImpl *_target)
 {
     if (m_target)
@@ -101,36 +86,6 @@ void EventImpl::setTarget(NodeImpl *_target)
         m_target->ref();
 }
 
-NodeImpl *EventImpl::currentTarget() const
-{
-    return m_currentTarget;
-}
-
-void EventImpl::setCurrentTarget(NodeImpl *_currentTarget)
-{
-    m_currentTarget = _currentTarget;
-}
-
-unsigned short EventImpl::eventPhase() const
-{
-    return m_eventPhase;
-}
-
-void EventImpl::setEventPhase(unsigned short _eventPhase)
-{
-    m_eventPhase = _eventPhase;
-}
-
-bool EventImpl::bubbles() const
-{
-    return m_canBubble;
-}
-
-bool EventImpl::cancelable() const
-{
-    return m_cancelable;
-}
-
 DOMTimeStamp EventImpl::timeStamp()
 {
     QDateTime epoch(QDate(1970,1,1),QTime(0,0));
@@ -138,131 +93,21 @@ DOMTimeStamp EventImpl::timeStamp()
     return epoch.secsTo(m_createTime)*1000+m_createTime.time().msec();
 }
 
-void EventImpl::stopPropagation()
-{
-    m_propagationStopped = true;
-}
-
 void EventImpl::preventDefault()
 {
     if (m_cancelable)
        m_defaultPrevented = true;
 }
 
-void EventImpl::initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg)
+void EventImpl::initEvent(const AtomicString &eventTypeArg, bool canBubbleArg, bool cancelableArg)
 {
     // ### ensure this is not called after we have been dispatched (also for subclasses)
 
-    if (m_type)
-       m_type->deref();
-
-    m_type = eventTypeArg.impl();
-    if (m_type)
-       m_type->ref();
-
-    m_id = typeToId(eventTypeArg);
-
+    m_type = eventTypeArg;
     m_canBubble = canBubbleArg;
     m_cancelable = cancelableArg;
 }
 
-static const char * const eventNames[EventImpl::numEventIds] = {
-    0,
-    "DOMFocusIn",
-    "DOMFocusOut",
-    "DOMActivate",
-    "click",
-    "mousedown",
-    "mouseup",
-    "mouseover",
-    "mousemove",
-    "mouseout",
-    "onbeforecut",
-    "oncut",
-    "onbeforecopy",
-    "oncopy",
-    "onbeforepaste",
-    "onpaste",
-    "dragenter",
-    "dragover",
-    "dragleave",
-    "drop",
-    "dragstart",
-    "drag",
-    "dragend",
-    "selectstart",
-    "DOMSubtreeModified",
-    "DOMNodeInserted",
-    "DOMNodeRemoved",
-    "DOMNodeRemovedFromDocument",
-    "DOMNodeInsertedIntoDocument",
-    "DOMAttrModified",
-    "DOMCharacterDataModified",
-    "load",
-    "unload",
-    "abort",
-    "error",
-    "select",
-    "change",
-    "submit",
-    "reset",
-    "focus",
-    "blur",
-    "resize",
-    "scroll",
-    "contextmenu",
-#if APPLE_CHANGES
-    "search",
-#endif
-    "input",
-    "keydown",
-    "keyup",
-    "textInput", // FIXME: is the capital I correct?
-    0, // KHTML_DBLCLICK_EVENT
-    0, // KHTML_CLICK_EVENT
-    0, // KHTML_DRAGDROP_EVENT
-    0, // KHTML_ERROR_EVENT
-    "keypress",
-    0, // KHTML_MOVE_EVENT
-    0, // KHTML_ORIGCLICK_MOUSEUP_EVENT
-    "readystatechange",
-    "mousewheel",
-    0, // horizontal mouse wheel
-};
-
-EventImpl::EventId EventImpl::typeToId(const DOMString &type)
-{
-    for (int i = 0; i < numEventIds; ++i) {
-        const char *n = eventNames[i];
-        if (n && type == n)
-            return static_cast<EventId>(i);
-    }
-    return UNKNOWN_EVENT;
-}
-
-DOMString EventImpl::idToType(EventId id)
-{
-    switch (id) {
-       case KHTML_DBLCLICK_EVENT:
-            return "dblclick";
-       case KHTML_CLICK_EVENT:
-            return "click";
-       case KHTML_DRAGDROP_EVENT:
-            return "khtml_dragdrop";
-       case KHTML_ERROR_EVENT:
-            return "khtml_error";
-       case KHTML_MOVE_EVENT:
-            return "khtml_move";
-        case KHTML_ORIGCLICK_MOUSEUP_EVENT:
-            return "khtml_origclick_mouseup_event";
-        default:
-            break;
-    }
-    if (id >= numEventIds)
-        return DOMString();
-    return eventNames[id];
-}
-
 bool EventImpl::isUIEvent() const
 {
     return false;
@@ -306,9 +151,8 @@ UIEventImpl::UIEventImpl()
     m_detail = 0;
 }
 
-UIEventImpl::UIEventImpl(EventId _id, bool canBubbleArg, bool cancelableArg,
-               AbstractViewImpl *viewArg, long detailArg)
-               : EventImpl(_id,canBubbleArg,cancelableArg)
+UIEventImpl::UIEventImpl(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg, AbstractViewImpl *viewArg, long detailArg)
+    : EventImpl(eventType, canBubbleArg, cancelableArg)
 {
     m_view = viewArg;
     if (m_view)
@@ -322,7 +166,7 @@ UIEventImpl::~UIEventImpl()
         m_view->deref();
 }
 
-void UIEventImpl::initUIEvent(const DOMString &typeArg,
+void UIEventImpl::initUIEvent(const AtomicString &typeArg,
                              bool canBubbleArg,
                              bool cancelableArg,
                              AbstractViewImpl *viewArg,
@@ -386,7 +230,7 @@ MouseRelatedEventImpl::MouseRelatedEventImpl()
 {
 }
 
-MouseRelatedEventImpl::MouseRelatedEventImpl(EventId _id,
+MouseRelatedEventImpl::MouseRelatedEventImpl(const AtomicString &eventType,
                               bool canBubbleArg,
                               bool cancelableArg,
                               AbstractViewImpl *viewArg,
@@ -399,7 +243,7 @@ MouseRelatedEventImpl::MouseRelatedEventImpl(EventId _id,
                               bool altKeyArg,
                               bool shiftKeyArg,
                               bool metaKeyArg)
-    : UIEventWithKeyStateImpl(_id, canBubbleArg, cancelableArg, viewArg, detailArg,
+    : UIEventWithKeyStateImpl(eventType, canBubbleArg, cancelableArg, viewArg, detailArg,
         ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg)
 {
     m_screenX = screenXArg;
@@ -463,7 +307,7 @@ MouseEventImpl::MouseEventImpl()
     m_clipboard = 0;
 }
 
-MouseEventImpl::MouseEventImpl(EventId _id,
+MouseEventImpl::MouseEventImpl(const AtomicString &eventType,
                               bool canBubbleArg,
                               bool cancelableArg,
                               AbstractViewImpl *viewArg,
@@ -479,7 +323,7 @@ MouseEventImpl::MouseEventImpl(EventId _id,
                               unsigned short buttonArg,
                               NodeImpl *relatedTargetArg,
                                ClipboardImpl *clipboardArg)
-    : MouseRelatedEventImpl(_id, canBubbleArg, cancelableArg, viewArg, detailArg,
+    : MouseRelatedEventImpl(eventType, canBubbleArg, cancelableArg, viewArg, detailArg,
         screenXArg, screenYArg, clientXArg, clientYArg,
         ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg)
 {
@@ -500,7 +344,7 @@ MouseEventImpl::~MouseEventImpl()
        m_clipboard->deref();
 }
 
-void MouseEventImpl::initMouseEvent(const DOMString &typeArg,
+void MouseEventImpl::initMouseEvent(const AtomicString &typeArg,
                                     bool canBubbleArg,
                                     bool cancelableArg,
                                     AbstractViewImpl *viewArg,
@@ -543,10 +387,10 @@ bool MouseEventImpl::isMouseEvent() const
 
 bool MouseEventImpl::isDragEvent() const
 {
-    return (m_id == EventImpl::DRAGENTER_EVENT || m_id == EventImpl::DRAGOVER_EVENT
-            || m_id == EventImpl::DRAGLEAVE_EVENT || m_id == EventImpl::DROP_EVENT 
-            || m_id == EventImpl::DRAGSTART_EVENT || m_id == EventImpl::DRAG_EVENT
-            || m_id == EventImpl::DRAGEND_EVENT);
+    return (m_type == dragenterEvent || m_type == dragoverEvent
+            || m_type == dragleaveEvent || m_type == dropEvent 
+            || m_type == dragstartEvent || m_type == dragEvent
+            || m_type == dragendEvent);
 }
 
 long MouseEventImpl::which() const
@@ -568,7 +412,7 @@ KeyboardEventImpl::KeyboardEventImpl()
 }
 
 KeyboardEventImpl::KeyboardEventImpl(QKeyEvent *key, AbstractViewImpl *view)
-  : UIEventWithKeyStateImpl(key->type() == QEvent::KeyRelease ? KEYUP_EVENT : key->isAutoRepeat() ? KEYPRESS_EVENT : KEYDOWN_EVENT,
+  : UIEventWithKeyStateImpl(key->type() == QEvent::KeyRelease ? keyupEvent : key->isAutoRepeat() ? keypressEvent : keydownEvent,
     true, true, view, 0,
     key->state() & Qt::ControlButton,
     key->state() & Qt::AltButton,
@@ -598,7 +442,7 @@ KeyboardEventImpl::KeyboardEventImpl(QKeyEvent *key, AbstractViewImpl *view)
     m_keyLocation = (keyState & Qt::Keypad) ? KeyboardEvent::DOM_KEY_LOCATION_NUMPAD : KeyboardEvent::DOM_KEY_LOCATION_STANDARD;
 }
 
-KeyboardEventImpl::KeyboardEventImpl(EventId _id,
+KeyboardEventImpl::KeyboardEventImpl(const AtomicString &eventType,
                                         bool canBubbleArg,
                                         bool cancelableArg,
                                         AbstractViewImpl *viewArg, 
@@ -609,7 +453,7 @@ KeyboardEventImpl::KeyboardEventImpl(EventId _id,
                                         bool shiftKeyArg, 
                                         bool metaKeyArg, 
                                         bool altGraphKeyArg)
-  : UIEventWithKeyStateImpl(_id, canBubbleArg, cancelableArg, viewArg, 0, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg)
+  : UIEventWithKeyStateImpl(eventType, canBubbleArg, cancelableArg, viewArg, 0, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg)
 {
     m_keyEvent = 0;
     m_keyIdentifier = keyIdentifierArg.impl();
@@ -626,7 +470,7 @@ KeyboardEventImpl::~KeyboardEventImpl()
         m_keyIdentifier->deref();
 }
 
-void KeyboardEventImpl::initKeyboardEvent(const DOMString &typeArg,
+void KeyboardEventImpl::initKeyboardEvent(const AtomicString &typeArg,
                         bool canBubbleArg,
                         bool cancelableArg,
                         AbstractViewImpl *viewArg, 
@@ -655,20 +499,11 @@ void KeyboardEventImpl::initKeyboardEvent(const DOMString &typeArg,
 
 int KeyboardEventImpl::keyCode() const
 {
-    if (!m_keyEvent) {
+    if (!m_keyEvent)
         return 0;
-    }
-    switch (m_id) {
-        case KEYDOWN_EVENT:
-        case KEYUP_EVENT:
-#if APPLE_CHANGES
-            return m_keyEvent->WindowsKeyCode();
-#else
-            // need the equivalent of the above for KDE
-#endif
-        default:
-            return charCode();
-    }
+    if (m_type == keydownEvent || m_type == keyupEvent)
+        return m_keyEvent->WindowsKeyCode();
+    return charCode();
 }
 
 int KeyboardEventImpl::charCode() const
@@ -706,7 +541,7 @@ MutationEventImpl::MutationEventImpl()
     m_attrChange = 0;
 }
 
-MutationEventImpl::MutationEventImpl(EventId _id,
+MutationEventImpl::MutationEventImpl(const AtomicString &eventType,
                                     bool canBubbleArg,
                                     bool cancelableArg,
                                     NodeImpl *relatedNodeArg,
@@ -714,7 +549,7 @@ MutationEventImpl::MutationEventImpl(EventId _id,
                                     const DOMString &newValueArg,
                                     const DOMString &attrNameArg,
                                     unsigned short attrChangeArg)
-                     : EventImpl(_id,canBubbleArg,cancelableArg)
+                     : EventImpl(eventType,canBubbleArg,cancelableArg)
 {
     m_relatedNode = relatedNodeArg;
     if (m_relatedNode)
@@ -743,7 +578,7 @@ MutationEventImpl::~MutationEventImpl()
        m_attrName->deref();
 }
 
-void MutationEventImpl::initMutationEvent(const DOMString &typeArg,
+void MutationEventImpl::initMutationEvent(const AtomicString &typeArg,
                                          bool canBubbleArg,
                                          bool cancelableArg,
                                          NodeImpl *relatedNodeArg,
@@ -790,8 +625,8 @@ ClipboardEventImpl::ClipboardEventImpl()
     m_clipboard = 0;
 }
 
-ClipboardEventImpl::ClipboardEventImpl(EventId _id, bool canBubbleArg, bool cancelableArg, ClipboardImpl *clipboardArg)
-  : EventImpl(_id, canBubbleArg, cancelableArg), m_clipboard(clipboardArg)
+ClipboardEventImpl::ClipboardEventImpl(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg, ClipboardImpl *clipboardArg)
+    : EventImpl(eventType, canBubbleArg, cancelableArg), m_clipboard(clipboardArg)
 {
       if (m_clipboard)
           m_clipboard->ref();
@@ -816,7 +651,7 @@ WheelEventImpl::WheelEventImpl() : m_horizontal(false), m_wheelDelta(0)
 
 WheelEventImpl::WheelEventImpl(bool h, long d, AbstractViewImpl *v,
     long sx, long sy, long cx, long cy, bool ctrl, bool alt, bool shift, bool meta)
-    : MouseRelatedEventImpl(h ? HORIZONTALMOUSEWHEEL_EVENT : MOUSEWHEEL_EVENT,
+    : MouseRelatedEventImpl(h ? khtmlHorizontalmousewheelEvent : mousewheelEvent,
         true, true, v, 0, sx, sy, cx, cy, ctrl, alt, shift, meta)
     , m_horizontal(h), m_wheelDelta(d)
 {
@@ -829,23 +664,21 @@ bool WheelEventImpl::isWheelEvent() const
 
 // -----------------------------------------------------------------------------
 
-RegisteredEventListener::RegisteredEventListener(EventImpl::EventId _id, EventListener *_listener, bool _useCapture)
+RegisteredEventListener::RegisteredEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture)
+    : m_eventType(eventType), m_listener(listener), m_useCapture(useCapture)
 {
-    id = _id;
-    listener = _listener;
-    useCapture = _useCapture;
+    assert(listener);
     listener->ref();
 }
 
-RegisteredEventListener::~RegisteredEventListener() {
-    listener->deref();
+RegisteredEventListener::~RegisteredEventListener()
+{
+    m_listener->deref();
 }
 
-bool RegisteredEventListener::operator==(const RegisteredEventListener &other)
+bool operator==(const RegisteredEventListener &a, const RegisteredEventListener &b)
 {
-    return (id == other.id &&
-           listener == other.listener &&
-           useCapture == other.useCapture);
+    return a.eventType() == b.eventType() && a.listener() == b.listener() && a.useCapture() == b.useCapture();
 }
 
 // -----------------------------------------------------------------------------
@@ -853,3 +686,5 @@ bool RegisteredEventListener::operator==(const RegisteredEventListener &other)
 ClipboardImpl::~ClipboardImpl()
 {
 }
+
+}
index 1bb5cde5423c012839981cad45ea64da61fb5bb5..e958fb50578f0f45c096176dab1700cce93fa55a 100644 (file)
  *
  */
 
-#ifndef _DOM_EventsImpl_h_
-#define _DOM_EventsImpl_h_
+#ifndef DOM_EVENTSIMPL_H
+#define DOM_EVENTSIMPL_H
 
 #include <qdatetime.h>
 #include "dom/dom_node.h"
-#include "dom/dom_string.h"
+#include "xml/dom_atomicstring.h"
 #include "misc/shared.h"
 
 class KHTMLPart;
@@ -44,109 +44,28 @@ class EventListener;
 class NodeImpl;
 class ClipboardImpl;
 
-// ### support user-defined events
-
 class EventImpl : public khtml::Shared<EventImpl>
 {
 public:
-    enum EventId {
-       UNKNOWN_EVENT = 0,
-       // UI events
-        DOMFOCUSIN_EVENT,
-        DOMFOCUSOUT_EVENT,
-        DOMACTIVATE_EVENT,
-        // Mouse events
-        CLICK_EVENT,
-        MOUSEDOWN_EVENT,
-        MOUSEUP_EVENT,
-        MOUSEOVER_EVENT,
-        MOUSEMOVE_EVENT,
-        MOUSEOUT_EVENT,
-        // IE copy/paste events
-        BEFORECUT_EVENT,
-        CUT_EVENT,
-        BEFORECOPY_EVENT,
-        COPY_EVENT,
-        BEFOREPASTE_EVENT,
-        PASTE_EVENT,
-        // IE drag and drop events
-        DRAGENTER_EVENT,
-        DRAGOVER_EVENT,
-        DRAGLEAVE_EVENT,
-        DROP_EVENT,
-        DRAGSTART_EVENT,
-        DRAG_EVENT,
-        DRAGEND_EVENT,
-       // IE selection events
-       SELECTSTART_EVENT,
-        // Mutation events
-        DOMSUBTREEMODIFIED_EVENT,
-        DOMNODEINSERTED_EVENT,
-        DOMNODEREMOVED_EVENT,
-        DOMNODEREMOVEDFROMDOCUMENT_EVENT,
-        DOMNODEINSERTEDINTODOCUMENT_EVENT,
-        DOMATTRMODIFIED_EVENT,
-        DOMCHARACTERDATAMODIFIED_EVENT,
-       // HTML events
-       LOAD_EVENT,
-       UNLOAD_EVENT,
-       ABORT_EVENT,
-       ERROR_EVENT,
-       SELECT_EVENT,
-       CHANGE_EVENT,
-       SUBMIT_EVENT,
-       RESET_EVENT,
-       FOCUS_EVENT,
-       BLUR_EVENT,
-       RESIZE_EVENT,
-       SCROLL_EVENT,
-        CONTEXTMENU_EVENT,
-#if APPLE_CHANGES
-        SEARCH_EVENT,
-#endif
-        INPUT_EVENT,
-        // Keyboard events
-       KEYDOWN_EVENT,
-       KEYUP_EVENT,
-        // Text events
-        TEXTINPUT_EVENT,
-       // khtml events (not part of DOM)
-       KHTML_DBLCLICK_EVENT, // for html ondblclick
-       KHTML_CLICK_EVENT, // for html onclick
-       KHTML_DRAGDROP_EVENT,
-       KHTML_ERROR_EVENT,
-       KEYPRESS_EVENT,
-       KHTML_MOVE_EVENT,
-       KHTML_ORIGCLICK_MOUSEUP_EVENT,
-       // XMLHttpRequest events
-       KHTML_READYSTATECHANGE_EVENT,
-        // extensions
-        MOUSEWHEEL_EVENT,
-        HORIZONTALMOUSEWHEEL_EVENT,
-        numEventIds
-    };
-
     EventImpl();
-    EventImpl(EventId _id, bool canBubbleArg, bool cancelableArg);
+    EventImpl(const AtomicString &type, bool canBubbleArg, bool cancelableArg);
     virtual ~EventImpl();
 
     MAIN_THREAD_ALLOCATED;
 
-    EventId id() const { return m_id; }
-
-    DOMString type() const;
-    NodeImpl *target() const;
-    void setTarget(NodeImpl *_target);
-    NodeImpl *currentTarget() const;
-    void setCurrentTarget(NodeImpl *_currentTarget);
-    unsigned short eventPhase() const;
-    void setEventPhase(unsigned short _eventPhase);
-    bool bubbles() const;
-    bool cancelable() const;
+    const AtomicString &type() const { return m_type; }
+    NodeImpl *target() const { return m_target; }
+    void setTarget(NodeImpl *target);
+    NodeImpl *currentTarget() const { return m_currentTarget; }
+    void setCurrentTarget(NodeImpl *currentTarget) { m_currentTarget = currentTarget; }
+    unsigned short eventPhase() const { return m_eventPhase; }
+    void setEventPhase(unsigned short eventPhase) { m_eventPhase = eventPhase; }
+    bool bubbles() const { return m_canBubble; }
+    bool cancelable() const { return m_cancelable; }
     DOMTimeStamp timeStamp();
-    void stopPropagation();
+    void stopPropagation() { m_propagationStopped = true; }
     void preventDefault();
-    void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg);
+    void initEvent(const AtomicString &eventTypeArg, bool canBubbleArg, bool cancelableArg);
 
     virtual bool isUIEvent() const;
     virtual bool isMouseEvent() const;
@@ -159,9 +78,6 @@ public:
     bool propagationStopped() const { return m_propagationStopped; }
     bool defaultPrevented() const { return m_defaultPrevented; }
 
-    static EventId typeToId(const DOMString &type);
-    static DOMString idToType(EventId id);
-
     void setDefaultHandled() { m_defaultHandled = true; }
     bool defaultHandled() const { return m_defaultHandled; }
 
@@ -170,7 +86,7 @@ public:
     bool getCancelBubble() const { return m_cancelBubble; }
 
 protected:
-    DOMStringImpl *m_type;
+    AtomicString m_type;
     bool m_canBubble;
     bool m_cancelable;
 
@@ -179,7 +95,6 @@ protected:
     bool m_defaultHandled;
     bool m_cancelBubble;
 
-    EventId m_id;
     NodeImpl *m_currentTarget; // ref > 0 maintained externally
     unsigned short m_eventPhase;
     NodeImpl *m_target;
@@ -192,7 +107,7 @@ class UIEventImpl : public EventImpl
 {
 public:
     UIEventImpl();
-    UIEventImpl(EventId _id,
+    UIEventImpl(const AtomicString &type,
                bool canBubbleArg,
                bool cancelableArg,
                AbstractViewImpl *viewArg,
@@ -200,7 +115,7 @@ public:
     virtual ~UIEventImpl();
     AbstractViewImpl *view() const { return m_view; }
     long detail() const { return m_detail; }
-    void initUIEvent(const DOMString &typeArg,
+    void initUIEvent(const AtomicString &typeArg,
                     bool canBubbleArg,
                     bool cancelableArg,
                     AbstractViewImpl *viewArg,
@@ -227,9 +142,9 @@ protected:
 class UIEventWithKeyStateImpl : public UIEventImpl {
 public:
     UIEventWithKeyStateImpl() : m_ctrlKey(false), m_altKey(false), m_shiftKey(false), m_metaKey(false) { }
-    UIEventWithKeyStateImpl(EventId eventID, bool canBubbleArg, bool cancelableArg, AbstractViewImpl *viewArg,
+    UIEventWithKeyStateImpl(const AtomicString &type, bool canBubbleArg, bool cancelableArg, AbstractViewImpl *viewArg,
         long detailArg, bool ctrlKeyArg, bool altKeyArg, bool shiftKeyArg, bool metaKeyArg)
-        : UIEventImpl(eventID, canBubbleArg, cancelableArg, viewArg, detailArg)
+        : UIEventImpl(type, canBubbleArg, cancelableArg, viewArg, detailArg)
         , m_ctrlKey(ctrlKeyArg), m_altKey(altKeyArg), m_shiftKey(shiftKeyArg), m_metaKey(metaKeyArg) { }
 
     bool ctrlKey() const { return m_ctrlKey; }
@@ -248,7 +163,7 @@ protected: // expose these so init functions can set them
 class MouseRelatedEventImpl : public UIEventWithKeyStateImpl {
 public:
     MouseRelatedEventImpl();
-    MouseRelatedEventImpl(EventId _id,
+    MouseRelatedEventImpl(const AtomicString &type,
                           bool canBubbleArg,
                           bool cancelableArg,
                           AbstractViewImpl *viewArg,
@@ -284,7 +199,7 @@ private:
 class MouseEventImpl : public MouseRelatedEventImpl {
 public:
     MouseEventImpl();
-    MouseEventImpl(EventId _id,
+    MouseEventImpl(const AtomicString &type,
                   bool canBubbleArg,
                   bool cancelableArg,
                   AbstractViewImpl *viewArg,
@@ -304,7 +219,7 @@ public:
     unsigned short button() const { return m_button; }
     NodeImpl *relatedTarget() const { return m_relatedTarget; }
     ClipboardImpl *clipboard() const { return m_clipboard; }
-    void initMouseEvent(const DOMString &typeArg,
+    void initMouseEvent(const AtomicString &typeArg,
                        bool canBubbleArg,
                        bool cancelableArg,
                        AbstractViewImpl *viewArg,
@@ -334,7 +249,7 @@ class KeyboardEventImpl : public UIEventWithKeyStateImpl {
 public:
     KeyboardEventImpl();
     KeyboardEventImpl(QKeyEvent *key, AbstractViewImpl *view);
-    KeyboardEventImpl(EventId _id,
+    KeyboardEventImpl(const AtomicString &type,
                 bool canBubbleArg,
                 bool cancelableArg,
                 AbstractViewImpl *viewArg,
@@ -347,7 +262,7 @@ public:
                 bool altGraphKeyArg);
     virtual ~KeyboardEventImpl();
     
-    void initKeyboardEvent(const DOMString &typeArg,
+    void initKeyboardEvent(const AtomicString &typeArg,
                 bool canBubbleArg,
                 bool cancelableArg,
                 AbstractViewImpl *viewArg,
@@ -383,7 +298,7 @@ class MutationEventImpl : public EventImpl {
 // ### fire these during parsing (if necessary)
 public:
     MutationEventImpl();
-    MutationEventImpl(EventId _id,
+    MutationEventImpl(const AtomicString &type,
                      bool canBubbleArg,
                      bool cancelableArg,
                      NodeImpl *relatedNodeArg,
@@ -398,7 +313,7 @@ public:
     DOMString newValue() const { return m_newValue; }
     DOMString attrName() const { return m_attrName; }
     unsigned short attrChange() const { return m_attrChange; }
-    void initMutationEvent(const DOMString &typeArg,
+    void initMutationEvent(const AtomicString &typeArg,
                           bool canBubbleArg,
                           bool cancelableArg,
                           NodeImpl *relatedNodeArg,
@@ -418,7 +333,7 @@ protected:
 class ClipboardEventImpl : public EventImpl {
 public:
     ClipboardEventImpl();
-    ClipboardEventImpl(EventId _id, bool canBubbleArg, bool cancelableArg, ClipboardImpl *clipboardArg);
+    ClipboardEventImpl(const AtomicString &type, bool canBubbleArg, bool cancelableArg, ClipboardImpl *clipboardArg);
     ~ClipboardEventImpl();
 
     ClipboardImpl *clipboard() const { return m_clipboard; }
@@ -448,21 +363,27 @@ private:
 
 class RegisteredEventListener {
 public:
-    RegisteredEventListener(EventImpl::EventId _id, EventListener *_listener, bool _useCapture);
+    RegisteredEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture);
     ~RegisteredEventListener();
 
     MAIN_THREAD_ALLOCATED;
     
-    bool operator==(const RegisteredEventListener &other);
+    const AtomicString &eventType() const { return m_eventType; }
+    EventListener *listener() const { return m_listener; }
+    bool useCapture() const { return m_useCapture; }
 
-    EventImpl::EventId id;
-    EventListener *listener;
-    bool useCapture;
 private:
-    RegisteredEventListener( const RegisteredEventListener & );
-    RegisteredEventListener & operator=( const RegisteredEventListener & );
+    AtomicString m_eventType;
+    EventListener *m_listener;
+    bool m_useCapture;
+
+    RegisteredEventListener(const RegisteredEventListener &);
+    RegisteredEventListener &operator=(const RegisteredEventListener &);
 };
 
+bool operator==(const RegisteredEventListener &, const RegisteredEventListener &);
+inline bool operator!=(const RegisteredEventListener &a, const RegisteredEventListener &b) { return !(a == b); }
+
 // State available during IE's events for drag and drop and copy/paste
 class ClipboardImpl : public khtml::Shared<ClipboardImpl> {
 public:
index 1629181189ec4930d57f5fc443b420ea00b3b5a2..ee6bb6d69a6d4c751c005c40b7b657e2b7a95573 100644 (file)
@@ -66,7 +66,7 @@ public:
     static void remove(DOMStringImpl *);
     
 #ifdef __OBJC__
-    AtomicString(NSString *);
+    AtomicString(NSString *s) : m_string(add(DOMString(s).impl())) { }
     operator NSString *() const { return m_string; }
 #endif
 
index 067006e2c70197c53a59b74b4aff4378b5690d8f..c0017c20c08d50569eb8603da00e51c2f2a68396 100644 (file)
@@ -32,6 +32,7 @@
 #include "xml/dom2_rangeimpl.h"
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom2_viewsimpl.h"
+#include "xml/EventNames.h"
 #include "xml/xml_tokenizer.h"
 
 #include "css/csshelper.h"
@@ -92,6 +93,7 @@ using XBL::XBLBindingManager;
 #endif
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace HTMLNames;
 using namespace khtml;
 
@@ -1344,7 +1346,7 @@ void DocumentImpl::implicitClose()
 
         if (body) {
             dispatchImageLoadEventsNow();
-            body->dispatchWindowEvent(EventImpl::LOAD_EVENT, false, false);
+            body->dispatchWindowEvent(loadEvent, false, false);
 #if APPLE_CHANGES
             KWQ(part())->handledOnloadEvents();
 #endif
@@ -2214,13 +2216,13 @@ bool DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
             oldFocusNode->setActive(false);
 
         oldFocusNode->setFocus(false);
-        oldFocusNode->dispatchHTMLEvent(EventImpl::BLUR_EVENT, false, false);
+        oldFocusNode->dispatchHTMLEvent(blurEvent, false, false);
         if (m_focusNode != 0) {
             // handler shifted focus
             focusChangeBlocked = true;
             newFocusNode = 0;
         }
-        oldFocusNode->dispatchUIEvent(EventImpl::DOMFOCUSOUT_EVENT);
+        oldFocusNode->dispatchUIEvent(DOMFocusOutEvent);
         if (m_focusNode != 0) {
             // handler shifted focus
             focusChangeBlocked = true;
@@ -2254,13 +2256,13 @@ bool DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
         // Set focus on the new node
         m_focusNode = newFocusNode;
         m_focusNode->ref();
-        m_focusNode->dispatchHTMLEvent(EventImpl::FOCUS_EVENT, false, false);
+        m_focusNode->dispatchHTMLEvent(focusEvent, false, false);
         if (m_focusNode != newFocusNode) {
             // handler shifted focus
             focusChangeBlocked = true;
             goto SetFocusNodeDone;
         }
-        m_focusNode->dispatchUIEvent(EventImpl::DOMFOCUSIN_EVENT);
+        m_focusNode->dispatchUIEvent(DOMFocusInEvent);
         if (m_focusNode != newFocusNode) { 
             // handler shifted focus
             focusChangeBlocked = true;
@@ -2360,14 +2362,12 @@ void DocumentImpl::defaultEventHandler(EventImpl *evt)
     // if any html event listeners are registered on the window, then dispatch them here
     QPtrList<RegisteredEventListener> listenersCopy = m_windowEventListeners;
     QPtrListIterator<RegisteredEventListener> it(listenersCopy);
-    for (; it.current(); ++it) {
-        if (it.current()->id == evt->id()) {
-            it.current()->listener->handleEventImpl(evt, true);
-       }
-    }
+    for (; it.current(); ++it)
+        if (it.current()->eventType() == evt->type())
+            it.current()->listener()->handleEventImpl(evt, true);
 
     // handle accesskey
-    if (evt->id()==EventImpl::KEYDOWN_EVENT) {
+    if (evt->type()==keydownEvent) {
         KeyboardEventImpl *kevt = static_cast<KeyboardEventImpl *>(evt);
         if (kevt->ctrlKey()) {
             QKeyEvent *qevt = kevt->qKeyEvent();
@@ -2381,61 +2381,52 @@ void DocumentImpl::defaultEventHandler(EventImpl *evt)
     }
 }
 
-void DocumentImpl::setHTMLWindowEventListener(int id, EventListener *listener)
+void DocumentImpl::setHTMLWindowEventListener(const AtomicString &eventType, EventListener *listener)
 {
     // If we already have it we don't want removeWindowEventListener to delete it
     if (listener)
        listener->ref();
-    removeHTMLWindowEventListener(id);
+    removeHTMLWindowEventListener(eventType);
     if (listener) {
-       addWindowEventListener(id, listener, false);
+       addWindowEventListener(eventType, listener, false);
        listener->deref();
     }
 }
 
-EventListener *DocumentImpl::getHTMLWindowEventListener(int id)
+EventListener *DocumentImpl::getHTMLWindowEventListener(const AtomicString &eventType)
 {
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
-    for (; it.current(); ++it) {
-       if (it.current()->id == id &&
-            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
-           return it.current()->listener;
-       }
-    }
-
+    for (; it.current(); ++it)
+       if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener")
+           return it.current()->listener();
     return 0;
 }
 
-void DocumentImpl::removeHTMLWindowEventListener(int id)
+void DocumentImpl::removeHTMLWindowEventListener(const AtomicString &eventType)
 {
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
-    for (; it.current(); ++it) {
-       if (it.current()->id == id &&
-            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
+    for (; it.current(); ++it)
+       if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener") {
            m_windowEventListeners.removeRef(it.current());
            return;
        }
-    }
 }
 
-void DocumentImpl::addWindowEventListener(int id, EventListener *listener, const bool useCapture)
+void DocumentImpl::addWindowEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture)
 {
     listener->ref();
 
-    // remove existing identical listener set with identical arguments - the DOM2
-    // spec says that "duplicate instances are discarded" in this case.
-    removeWindowEventListener(id,listener,useCapture);
-
-    RegisteredEventListener *rl = new RegisteredEventListener(static_cast<EventImpl::EventId>(id), listener, useCapture);
-    m_windowEventListeners.append(rl);
+    // Remove existing identical listener set with identical arguments.
+    // The DOM 2 spec says that "duplicate instances are discarded" in this case.
+    removeWindowEventListener(eventType, listener, useCapture);
+    m_windowEventListeners.append(new RegisteredEventListener(eventType, listener, useCapture));
 
     listener->deref();
 }
 
-void DocumentImpl::removeWindowEventListener(int id, EventListener *listener, bool useCapture)
+void DocumentImpl::removeWindowEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture)
 {
-    RegisteredEventListener rl(static_cast<EventImpl::EventId>(id),listener,useCapture);
-
+    RegisteredEventListener rl(eventType, listener, useCapture);
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
     for (; it.current(); ++it)
         if (*(it.current()) == rl) {
@@ -2444,11 +2435,11 @@ void DocumentImpl::removeWindowEventListener(int id, EventListener *listener, bo
         }
 }
 
-bool DocumentImpl::hasWindowEventListener(int id)
+bool DocumentImpl::hasWindowEventListener(const AtomicString &eventType)
 {
     QPtrListIterator<RegisteredEventListener> it(m_windowEventListeners);
     for (; it.current(); ++it) {
-       if (it.current()->id == id) {
+       if (it.current()->eventType() == eventType) {
            return true;
        }
     }
index 7cefe11570aff556bd596569efdca900444580b4..0abe4613e4732c7c5f734e57032e65814db63d9d 100644 (file)
@@ -445,13 +445,13 @@ public:
     LocalStyleRefs* localStyleRefs() { return &m_localStyleRefs; }
 
     virtual void defaultEventHandler(EventImpl *evt);
-    void setHTMLWindowEventListener(int id, EventListener *listener);
-    EventListener *getHTMLWindowEventListener(int id);
-    void removeHTMLWindowEventListener(int id);
+    void setHTMLWindowEventListener(const AtomicString &eventType, EventListener *listener);
+    EventListener *getHTMLWindowEventListener(const AtomicString &eventType);
+    void removeHTMLWindowEventListener(const AtomicString &eventType);
 
-    void addWindowEventListener(int id, EventListener *listener, const bool useCapture);
-    void removeWindowEventListener(int id, EventListener *listener, bool useCapture);
-    bool hasWindowEventListener(int id);
+    void addWindowEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture);
+    void removeWindowEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture);
+    bool hasWindowEventListener(const AtomicString &eventType);
 
     EventListener *createHTMLEventListener(QString code, NodeImpl *node);
     
index 49832333ad53fbcb6aaffcd85ee22058a9eea483..f4263b7c5b1fcca7bad19699b8194feb77efe31f 100644 (file)
@@ -588,7 +588,7 @@ void ElementImpl::dispatchAttrRemovalEvent(AttributeImpl *attr)
     if (!getDocument()->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER))
        return;
     //int exceptioncode = 0;
-//     dispatchEvent(new MutationEventImpl(EventImpl::DOMATTRMODIFIED_EVENT,true,false,attr,attr->value(),
+//     dispatchEvent(new MutationEventImpl(DOMAttrModifiedEvent,true,false,attr,attr->value(),
 //               attr->value(), getDocument()->attrName(attr->id()),MutationEvent::REMOVAL),exceptioncode);
 }
 
@@ -597,7 +597,7 @@ void ElementImpl::dispatchAttrAdditionEvent(AttributeImpl *attr)
     if (!getDocument()->hasListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER))
        return;
    // int exceptioncode = 0;
-//     dispatchEvent(new MutationEventImpl(EventImpl::DOMATTRMODIFIED_EVENT,true,false,attr,attr->value(),
+//     dispatchEvent(new MutationEventImpl(DOMAttrModifiedEvent,true,false,attr,attr->value(),
 //                                         attr->value(),getDocument()->attrName(attr->id()),MutationEvent::ADDITION),exceptioncode);
 }
 
index d01fc2b6ce33b80132392bac6f8967b9ce0dc5fc..035485b1325bbe35ec04a1e463c7ec3b16e05cc0 100644 (file)
@@ -32,6 +32,7 @@
 #include "xml/dom_docimpl.h"
 #include "xml/dom_position.h"
 #include "xml/dom2_rangeimpl.h"
+#include "xml/EventNames.h"
 #include "css/csshelper.h"
 #include "css/cssstyleselector.h"
 #include "editing/html_interchange.h"
@@ -68,6 +69,7 @@ using namespace khtml;
 
 namespace DOM {
 
+using namespace EventNames;
 using namespace HTMLNames;
 
 /**
@@ -380,38 +382,29 @@ unsigned long NodeImpl::nodeIndex() const
     return count;
 }
 
-void NodeImpl::addEventListener(int id, EventListener *listener, const bool useCapture)
+void NodeImpl::addEventListener(const AtomicString &eventType, EventListener *listener, const bool useCapture)
 {
     if (getDocument() && !getDocument()->attached())
         return;
 
-    switch (id) {
-       case EventImpl::DOMSUBTREEMODIFIED_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMSUBTREEMODIFIED_LISTENER);
-           break;
-       case EventImpl::DOMNODEINSERTED_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMNODEINSERTED_LISTENER);
-           break;
-       case EventImpl::DOMNODEREMOVED_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMNODEREMOVED_LISTENER);
-           break;
-        case EventImpl::DOMNODEREMOVEDFROMDOCUMENT_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMNODEREMOVEDFROMDOCUMENT_LISTENER);
-           break;
-        case EventImpl::DOMNODEINSERTEDINTODOCUMENT_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMNODEINSERTEDINTODOCUMENT_LISTENER);
-           break;
-        case EventImpl::DOMATTRMODIFIED_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMATTRMODIFIED_LISTENER);
-           break;
-        case EventImpl::DOMCHARACTERDATAMODIFIED_EVENT:
-           getDocument()->addListenerType(DocumentImpl::DOMCHARACTERDATAMODIFIED_LISTENER);
-           break;
-       default:
-           break;
-    }
-
-    RegisteredEventListener *rl = new RegisteredEventListener(static_cast<EventImpl::EventId>(id),listener,useCapture);
+    DocumentImpl::ListenerType type = static_cast<DocumentImpl::ListenerType>(0);
+    if (eventType == DOMSubtreeModifiedEvent)
+        type = DocumentImpl::DOMSUBTREEMODIFIED_LISTENER;
+    else if (eventType == DOMNodeInsertedEvent)
+        type = DocumentImpl::DOMNODEINSERTED_LISTENER;
+    else if (eventType == DOMNodeRemovedEvent)
+        type = DocumentImpl::DOMNODEREMOVED_LISTENER;
+    else if (eventType == DOMNodeRemovedFromDocumentEvent)
+        type = DocumentImpl::DOMNODEREMOVEDFROMDOCUMENT_LISTENER;
+    else if (eventType == DOMNodeInsertedIntoDocumentEvent)
+        type = DocumentImpl::DOMNODEINSERTEDINTODOCUMENT_LISTENER;
+    else if (eventType == DOMAttrModifiedEvent)
+        type = DocumentImpl::DOMATTRMODIFIED_LISTENER;
+    else if (eventType == DOMCharacterDataModifiedEvent)
+        type = DocumentImpl::DOMCHARACTERDATAMODIFIED_LISTENER;
+    if (type)
+        getDocument()->addListenerType(type);
+
     if (!m_regdListeners) {
         m_regdListeners = new QPtrList<RegisteredEventListener>;
        m_regdListeners->setAutoDelete(true);
@@ -419,24 +412,25 @@ void NodeImpl::addEventListener(int id, EventListener *listener, const bool useC
 
     listener->ref();
 
-    // remove existing identical listener set with identical arguments - the DOM2
-    // spec says that "duplicate instances are discarded" in this case.
-    removeEventListener(id,listener,useCapture);
+    // Remove existing identical listener set with identical arguments.
+    // The DOM2 spec says that "duplicate instances are discarded" in this case.
+    removeEventListener(eventType, listener, useCapture);
 
     // adding the first one
     if (m_regdListeners->isEmpty() && getDocument() && !inDocument())
         getDocument()->registerDisconnectedNodeWithEventListeners(this);
         
-    m_regdListeners->append(rl);
+    m_regdListeners->append(new RegisteredEventListener(eventType, listener, useCapture));
+
     listener->deref();
 }
 
-void NodeImpl::removeEventListener(int id, EventListener *listener, bool useCapture)
+void NodeImpl::removeEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture)
 {
     if (!m_regdListeners) // nothing to remove
         return;
 
-    RegisteredEventListener rl(static_cast<EventImpl::EventId>(id),listener,useCapture);
+    RegisteredEventListener rl(eventType, listener, useCapture);
 
     QPtrListIterator<RegisteredEventListener> it(*m_regdListeners);
     for (; it.current(); ++it)
@@ -455,15 +449,14 @@ void NodeImpl::removeAllEventListeners()
     m_regdListeners = 0;
 }
 
-void NodeImpl::removeHTMLEventListener(int id)
+void NodeImpl::removeHTMLEventListener(const AtomicString &eventType)
 {
     if (!m_regdListeners) // nothing to remove
         return;
 
     QPtrListIterator<RegisteredEventListener> it(*m_regdListeners);
     for (; it.current(); ++it)
-        if (it.current()->id == id &&
-            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
+        if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener") {
             m_regdListeners->removeRef(it.current());
             // removed last
             if (m_regdListeners->isEmpty() && getDocument() && !inDocument())
@@ -472,30 +465,27 @@ void NodeImpl::removeHTMLEventListener(int id)
         }
 }
 
-void NodeImpl::setHTMLEventListener(int id, EventListener *listener)
+void NodeImpl::setHTMLEventListener(const AtomicString &eventType, EventListener *listener)
 {
-    // in case we already have it, we don't want removeHTMLEventListener to destroy it
+    // In case we are the only one holding a reference to it, we don't want removeHTMLEventListener to destroy it.
     if (listener)
         listener->ref();
-    removeHTMLEventListener(id);
-    if (listener)
-    {
-        addEventListener(id,listener,false);
+    removeHTMLEventListener(eventType);
+    if (listener) {
+        addEventListener(eventType, listener, false);
         listener->deref();
     }
 }
 
-EventListener *NodeImpl::getHTMLEventListener(int id)
+EventListener *NodeImpl::getHTMLEventListener(const AtomicString &eventType)
 {
     if (!m_regdListeners)
         return 0;
 
     QPtrListIterator<RegisteredEventListener> it(*m_regdListeners);
     for (; it.current(); ++it)
-        if (it.current()->id == id &&
-            it.current()->listener->eventListenerType() == "_khtml_HTMLEventListener") {
-            return it.current()->listener;
-        }
+        if (it.current()->eventType() == eventType && it.current()->listener()->eventListenerType() == "_khtml_HTMLEventListener")
+            return it.current()->listener();
     return 0;
 }
 
@@ -639,18 +629,16 @@ DocumentPtr *DocumentPtr::nullDocumentPtr()
     return &doc;
 }
 
-bool NodeImpl::dispatchHTMLEvent(int _id, bool canBubbleArg, bool cancelableArg)
+bool NodeImpl::dispatchHTMLEvent(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg)
 {
     int exceptioncode = 0;
-    EventImpl *evt = new EventImpl(static_cast<EventImpl::EventId>(_id),canBubbleArg,cancelableArg);
-    return dispatchEvent(evt,exceptioncode,true);
+    return dispatchEvent(new EventImpl(eventType, canBubbleArg, cancelableArg), exceptioncode, true);
 }
 
-bool NodeImpl::dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableArg)
+bool NodeImpl::dispatchWindowEvent(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg)
 {
     int exceptioncode = 0;
-    EventImpl *evt = new EventImpl(static_cast<EventImpl::EventId>(_id),canBubbleArg,cancelableArg);
-    evt->setTarget( 0 );
+    EventImpl *evt = new EventImpl(eventType, canBubbleArg, cancelableArg);
     evt->ref();
     DocumentPtr *doc = document;
     doc->ref();
@@ -658,7 +646,7 @@ bool NodeImpl::dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableAr
     if (!evt->defaultPrevented() && doc->document())
        doc->document()->defaultEventHandler(evt);
     
-    if (_id == EventImpl::LOAD_EVENT && !evt->propagationStopped() && doc->document()) {
+    if (eventType == loadEvent && !evt->propagationStopped() && doc->document()) {
         // For onload events, send them to the enclosing frame only.
         // This is a DOM extension and is independent of bubbling/capturing rules of
         // the DOM.  You send the event only to the enclosing frame.  It does not
@@ -686,24 +674,23 @@ bool NodeImpl::dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableAr
     return r;
 }
 
-bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overrideDetail)
+bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, const AtomicString &overrideType, int overrideDetail)
 {
     bool cancelable = true;
     int detail = overrideDetail; // defaults to 0
-    EventImpl::EventId evtId = EventImpl::UNKNOWN_EVENT;
-    if (overrideId) {
-        evtId = static_cast<EventImpl::EventId>(overrideId);
-    }
-    else {
+    AtomicString eventType;
+    if (!overrideType.isEmpty()) {
+        eventType = overrideType;
+    } else {
         switch (_mouse->type()) {
             case QEvent::MouseButtonPress:
-                evtId = EventImpl::MOUSEDOWN_EVENT;
+                eventType = mousedownEvent;
                 break;
             case QEvent::MouseButtonRelease:
-                evtId = EventImpl::MOUSEUP_EVENT;
+                eventType = mouseupEvent;
                 break;
             case QEvent::MouseButtonDblClick:
-                evtId = EventImpl::CLICK_EVENT;
+                eventType = clickEvent;
 #if APPLE_CHANGES
                 detail = _mouse->clickCount();
 #else
@@ -711,16 +698,16 @@ bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overr
 #endif
                 break;
             case QEvent::MouseMove:
-                evtId = EventImpl::MOUSEMOVE_EVENT;
+                eventType = mousemoveEvent;
                 cancelable = false;
                 break;
             default:
                 break;
         }
     }
-    if (evtId == EventImpl::UNKNOWN_EVENT)
-        return false; // shouldn't happen
 
+    if (eventType.isEmpty())
+        return false; // shouldn't happen
 
     int exceptioncode = 0;
 
@@ -777,7 +764,7 @@ bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overr
 
     bool swallowEvent = false;
 
-    EventImpl *me = new MouseEventImpl(evtId,true,cancelable,getDocument()->defaultView(),
+    EventImpl *me = new MouseEventImpl(eventType,true,cancelable,getDocument()->defaultView(),
                    detail,screenX,screenY,clientX,clientY,ctrlKey,altKey,shiftKey,metaKey,
                    button,0);
     me->ref();
@@ -793,10 +780,10 @@ bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overr
     // of the DOM specs, but is used for compatibility with the traditional onclick="" and ondblclick="" attributes,
     // as there is no way to tell the difference between single & double clicks using DOM (only the click count is
     // stored, which is not necessarily the same)
-    if (evtId == EventImpl::CLICK_EVENT) {
-        evtId = EventImpl::KHTML_CLICK_EVENT;
+    if (eventType == clickEvent) {
+        eventType = khtmlClickEvent;
 
-        me = new MouseEventImpl(EventImpl::KHTML_CLICK_EVENT,
+        me = new MouseEventImpl(khtmlClickEvent,
                                 true,cancelable,getDocument()->defaultView(),
                                 detail,screenX,screenY,clientX,clientY,
                                 ctrlKey,altKey,shiftKey,metaKey,
@@ -814,7 +801,7 @@ bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overr
         me->deref();
 
         if (_mouse->isDoubleClick()) {
-            me = new MouseEventImpl(EventImpl::KHTML_DBLCLICK_EVENT,
+            me = new MouseEventImpl(khtmlDblclickEvent,
                                     true,cancelable,getDocument()->defaultView(),
                                     detail,screenX,screenY,clientX,clientY,
                                     ctrlKey,altKey,shiftKey,metaKey,
@@ -831,29 +818,29 @@ bool NodeImpl::dispatchMouseEvent(QMouseEvent *_mouse, int overrideId, int overr
 #endif
 
     // Also send a DOMActivate event, which causes things like form submissions to occur.
-    if (evtId == EventImpl::KHTML_CLICK_EVENT && !defaultPrevented && !disabled())
-        dispatchUIEvent(EventImpl::DOMACTIVATE_EVENT, detail);
+    if (eventType == khtmlClickEvent && !defaultPrevented && !disabled())
+        dispatchUIEvent(DOMActivateEvent, detail);
 
     return swallowEvent;
 }
 
-bool NodeImpl::dispatchUIEvent(int _id, int detail)
+bool NodeImpl::dispatchUIEvent(const AtomicString &eventType, int detail)
 {
-    assert (!( (_id != EventImpl::DOMFOCUSIN_EVENT &&
-        _id != EventImpl::DOMFOCUSOUT_EVENT &&
-                _id != EventImpl::DOMACTIVATE_EVENT)));
+    assert (!( (eventType != DOMFocusInEvent &&
+                eventType != DOMFocusOutEvent &&
+                eventType != DOMActivateEvent)));
+
+    if (!getDocument())
+        return false;
 
     bool cancelable = false;
-    if (_id == EventImpl::DOMACTIVATE_EVENT)
+    if (eventType == DOMActivateEvent)
         cancelable = true;
 
     int exceptioncode = 0;
-    if (getDocument()) {
-        UIEventImpl *evt = new UIEventImpl(static_cast<EventImpl::EventId>(_id),true,
-                                           cancelable,getDocument()->defaultView(),detail);
-        return dispatchEvent(evt,exceptioncode,true);
-    }
-    return false;
+
+    UIEventImpl *evt = new UIEventImpl(eventType, true, cancelable, getDocument()->defaultView(), detail);
+    return dispatchEvent(evt,exceptioncode,true);
 }
 
 void NodeImpl::registerNodeList(NodeListImpl *list)
@@ -925,7 +912,7 @@ bool NodeImpl::dispatchSubtreeModifiedEvent(bool sendChildrenChanged)
     if (!getDocument()->hasListenerType(DocumentImpl::DOMSUBTREEMODIFIED_LISTENER))
        return false;
     int exceptioncode = 0;
-    return dispatchEvent(new MutationEventImpl(EventImpl::DOMSUBTREEMODIFIED_EVENT,
+    return dispatchEvent(new MutationEventImpl(DOMSubtreeModifiedEvent,
                         true,false,0,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
 }
 
@@ -991,12 +978,9 @@ void NodeImpl::handleLocalEvents(EventImpl *evt, bool useCapture)
 
     QPtrList<RegisteredEventListener> listenersCopy = *m_regdListeners;
     QPtrListIterator<RegisteredEventListener> it(listenersCopy);
-    for (; it.current(); ++it) {
-        if (it.current()->id == evt->id() && it.current()->useCapture == useCapture) {
-            it.current()->listener->handleEventImpl(evt, false);
-        }
-    }
-
+    for (; it.current(); ++it)
+        if (it.current()->eventType() == evt->type() && it.current()->useCapture() == useCapture)
+            it.current()->listener()->handleEventImpl(evt, false);
 }
 
 void NodeImpl::defaultEventHandler(EventImpl *evt)
@@ -1625,16 +1609,6 @@ bool NodeImpl::inSameContainingBlockFlowElement(NodeImpl *n)
 
 // FIXME: End of obviously misplaced HTML editing functions.  Try to move these out of NodeImpl.
 
-void NodeImpl::addEventListener(const DOMString &type, EventListener *listener, bool useCapture)
-{
-    addEventListener(EventImpl::typeToId(type), listener, useCapture);
-}
-
-void NodeImpl::removeEventListener(const DOMString &type, EventListener *listener, bool useCapture)
-{
-    removeEventListener(EventImpl::typeToId(type), listener, useCapture);
-}
-
 SharedPtr<NodeListImpl> NodeImpl::getElementsByTagNameNS(const DOMString &namespaceURI, const DOMString &localName)
 {
     if (namespaceURI.isNull() || localName.isNull())
@@ -1974,7 +1948,7 @@ NodeImpl *ContainerNodeImpl::removeChild ( NodeImpl *oldChild, int &exceptioncod
     // Dispatch pre-removal mutation events
     getDocument()->notifyBeforeNodeRemoval(oldChild); // ### use events instead
     if (getDocument()->hasListenerType(DocumentImpl::DOMNODEREMOVED_LISTENER)) {
-       oldChild->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEREMOVED_EVENT,
+       oldChild->dispatchEvent(new MutationEventImpl(DOMNodeRemovedEvent,
                             true,false,this,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
        if (exceptioncode)
            return 0;
@@ -2460,7 +2434,7 @@ void ContainerNodeImpl::dispatchChildInsertedEvents( NodeImpl *child, int &excep
         child->insertedIntoTree(true);
 
     if (getDocument()->hasListenerType(DocumentImpl::DOMNODEINSERTED_LISTENER)) {
-        child->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEINSERTED_EVENT,
+        child->dispatchEvent(new MutationEventImpl(DOMNodeInsertedEvent,
                                                    true,false,this,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
         if (exceptioncode)
             return;
@@ -2471,7 +2445,7 @@ void ContainerNodeImpl::dispatchChildInsertedEvents( NodeImpl *child, int &excep
 
     if (hasInsertedListeners && inDocument()) {
         for (NodeImpl *c = child; c; c = c->traverseNextNode(child)) {
-            c->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEINSERTEDINTODOCUMENT_EVENT,
+            c->dispatchEvent(new MutationEventImpl(DOMNodeInsertedIntoDocumentEvent,
                                                    false,false,0,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
             if (exceptioncode)
                 return;
@@ -2485,7 +2459,7 @@ void ContainerNodeImpl::dispatchChildRemovalEvents( NodeImpl *child, int &except
     // Dispatch pre-removal mutation events
     getDocument()->notifyBeforeNodeRemoval(child); // ### use events instead
     if (getDocument()->hasListenerType(DocumentImpl::DOMNODEREMOVED_LISTENER)) {
-       child->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEREMOVED_EVENT,
+       child->dispatchEvent(new MutationEventImpl(DOMNodeRemovedEvent,
                             true,false,this,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
        if (exceptioncode)
            return;
@@ -2497,7 +2471,7 @@ void ContainerNodeImpl::dispatchChildRemovalEvents( NodeImpl *child, int &except
     if (inDocument()) {
        for (NodeImpl *c = child; c; c = c->traverseNextNode(child)) {
            if (hasRemovalListeners) {
-               c->dispatchEvent(new MutationEventImpl(EventImpl::DOMNODEREMOVEDFROMDOCUMENT_EVENT,
+               c->dispatchEvent(new MutationEventImpl(DOMNodeRemovedFromDocumentEvent,
                                 false,false,0,DOMString(),DOMString(),DOMString(),0),exceptioncode,true);
                if (exceptioncode)
                    return;
index fa24685c71d9bfdc21271002ec4bb7c47ac4b6c0..0a3c40ce58471ae2d87fc78894ccc04a2f93c938 100644 (file)
@@ -53,6 +53,7 @@ namespace DOM {
 
 using khtml::SharedPtr;
 
+class AtomicString;
 class DocumentImpl;
 class ElementImpl;
 class EventImpl;
@@ -266,22 +267,20 @@ public:
 
     void setDocument(DocumentPtr *doc);
 
-    void addEventListener(const DOMString &, EventListener *listener, bool useCapture);
-    void removeEventListener(const DOMString &, EventListener *listener, bool useCapture);
-
-    void addEventListener(int id, EventListener *listener, bool useCapture);
-    void removeEventListener(int id, EventListener *listener, bool useCapture);
-    void removeHTMLEventListener(int id);
-    void setHTMLEventListener(int id, EventListener *listener);
-    EventListener *getHTMLEventListener(int id);
+    void addEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture);
+    void removeEventListener(const AtomicString &eventType, EventListener *listener, bool useCapture);
+    void removeHTMLEventListener(const AtomicString &eventType);
+    void setHTMLEventListener(const AtomicString &eventType, EventListener *listener);
+    EventListener *getHTMLEventListener(const AtomicString &eventType);
     void removeAllEventListeners();
 
     bool dispatchEvent(EventImpl *evt, int &exceptioncode, bool tempEvent = false);
     bool dispatchGenericEvent( EventImpl *evt, int &exceptioncode);
-    bool dispatchHTMLEvent(int _id, bool canBubbleArg, bool cancelableArg);
-    bool dispatchWindowEvent(int _id, bool canBubbleArg, bool cancelableArg);
-    bool dispatchMouseEvent(QMouseEvent *e, int overrideId = 0, int overrideDetail = 0);
-    bool dispatchUIEvent(int _id, int detail = 0);
+    bool dispatchHTMLEvent(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg);
+    bool dispatchWindowEvent(const AtomicString &eventType, bool canBubbleArg, bool cancelableArg);
+    bool dispatchMouseEvent(QMouseEvent *e);
+    bool dispatchMouseEvent(QMouseEvent *e, const AtomicString &overrideType, int overrideDetail = 0);
+    bool dispatchUIEvent(const AtomicString &eventType, int detail = 0);
     bool dispatchSubtreeModifiedEvent(bool childrenChanged = true);
     bool dispatchKeyEvent(QKeyEvent *key);
     void dispatchWheelEvent(QWheelEvent *);
index ee298ea1f71e878a04bdb7f72e3c1a1bb163436c..5f313e3822079dba69b1d1cd8bc558bb980b2107 100644 (file)
 #include "xml/dom2_eventsimpl.h"
 #include "xml/dom_textimpl.h"
 #include "xml/dom_docimpl.h"
+#include "xml/EventNames.h"
 
 #include "rendering/render_text.h"
 
 #include <kdebug.h>
 
 using namespace DOM;
+using namespace DOM::EventNames;
 using namespace khtml;
 
-
 CharacterDataImpl::CharacterDataImpl(DocumentPtr *doc)
     : NodeImpl(doc)
 {
@@ -224,7 +225,7 @@ void CharacterDataImpl::dispatchModifiedEvent(DOMStringImpl *prevValue)
     DOMStringImpl *newValue = str->copy();
     newValue->ref();
     int exceptioncode = 0;
-    dispatchEvent(new MutationEventImpl(EventImpl::DOMCHARACTERDATAMODIFIED_EVENT,
+    dispatchEvent(new MutationEventImpl(DOMCharacterDataModifiedEvent,
                  true,false,0,prevValue,newValue,DOMString(),0),exceptioncode);
     newValue->deref();
     dispatchSubtreeModifiedEvent();
index 9a26460e4019aca96038da0281214c9098a09b93..10a2c44d2bb1249d68e0b5e9e9a4e1367f54260d 100644 (file)
@@ -65,7 +65,9 @@
 #import "html_miscimpl.h"
 #import "qptrstack.h"
 #import "DOMInternal.h"
+#import "EventNames.h"
 
+using namespace DOM::EventNames;
 using namespace DOM::HTMLNames;
 
 using DOM::DocumentImpl;
@@ -181,18 +183,10 @@ using khtml::VisiblePosition;
 -(ElementImpl *)mouseButtonListener
 {
     // FIXME: Do the continuation search like anchorElement does
-    NodeImpl* elt = m_renderer->element();
-    for ( ; elt; elt = elt->parentNode()) {
-        if (elt->getHTMLEventListener(DOM::EventImpl::KHTML_CLICK_EVENT))
-            return static_cast<HTMLAnchorElementImpl*>(elt);
-            
-        if (elt->getHTMLEventListener(DOM::EventImpl::MOUSEDOWN_EVENT))
-            return static_cast<HTMLAnchorElementImpl*>(elt);
-            
-        if (elt->getHTMLEventListener(DOM::EventImpl::MOUSEUP_EVENT))
-            return static_cast<HTMLAnchorElementImpl*>(elt);
+    for (NodeImpl *elt = m_renderer->element(); elt; elt = elt->parentNode()) {
+        if (elt->getHTMLEventListener(khtmlClickEvent) || elt->getHTMLEventListener(mousedownEvent) || elt->getHTMLEventListener(mouseupEvent))
+            return static_cast<ElementImpl*>(elt);
     }
-    
     return NULL;
 }
 
index fd9879aa0b34f24956e61c13915789969e9bc050..b9cf8626b476403c0746b6f7cca8ec9d4dbff425 100644 (file)
@@ -418,8 +418,8 @@ private:
     static NSView *documentViewForNode(DOM::NodeImpl *);
     
     bool dragHysteresisExceeded(float dragLocationX, float dragLocationY) const;
-    bool dispatchCPPEvent(int eventId, KWQClipboard::AccessPolicy policy);
-    bool dispatchDragSrcEvent(int eventId, const QPoint &loc) const;
+    bool dispatchCPPEvent(const DOM::AtomicString &eventType, KWQClipboard::AccessPolicy policy);
+    bool dispatchDragSrcEvent(const DOM::AtomicString &eventType, const QPoint &loc) const;
 
     NSImage *imageFromRect(NSRect rect) const;
 
index dd8ba2bc42a9679aefc02d98bd414965d52231d5..5b5a8ff177d0395b12a4e6998c3945d2a7854cf1 100644 (file)
@@ -54,6 +54,7 @@
 #import "dom2_rangeimpl.h"
 #import "dom_position.h"
 #import "dom_textimpl.h"
+#import "EventNames.h"
 #import "html_documentimpl.h"
 #import "html_formimpl.h"
 #import "html_tableimpl.h"
@@ -86,6 +87,7 @@
 
 #undef _KWQ_TIMING
 
+using namespace DOM::EventNames;
 using namespace DOM::HTMLNames;
 
 using DOM::AtomicString;
@@ -1485,7 +1487,7 @@ bool KWQKHTMLPart::canCachePage()
         parentPart() ||
         m_url.protocol().startsWith("https") || 
        (d->m_doc && (d->m_doc->applets()->length() != 0 ||
-                      d->m_doc->hasWindowEventListener(EventImpl::UNLOAD_EVENT) ||
+                      d->m_doc->hasWindowEventListener(unloadEvent) ||
                      d->m_doc->hasPasswordField()))) {
         return false;
     }
@@ -1812,7 +1814,7 @@ void KWQKHTMLPart::sendScrollEvent()
         DocumentImpl *doc = xmlDocImpl();
         if (!doc)
             return;
-        doc->dispatchHTMLEvent(EventImpl::SCROLL_EVENT, true, false);
+        doc->dispatchHTMLEvent(scrollEvent, true, false);
     }
 }
 
@@ -2250,9 +2252,9 @@ bool KWQKHTMLPart::dragHysteresisExceeded(float dragLocationX, float dragLocatio
 }
 
 // returns if we should continue "default processing", i.e., whether eventhandler canceled
-bool KWQKHTMLPart::dispatchDragSrcEvent(int eventId, const QPoint &loc) const
+bool KWQKHTMLPart::dispatchDragSrcEvent(const AtomicString &eventType, const QPoint &loc) const
 {
-    bool noDefaultProc = d->m_view->dispatchDragEvent(eventId, _dragSrc.get(), loc, _dragClipboard);
+    bool noDefaultProc = d->m_view->dispatchDragEvent(eventType, _dragSrc.get(), loc, _dragClipboard);
     return !noDefaultProc;
 }
 
@@ -2369,7 +2371,7 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
                         _dragClipboard->setDragImageElement(_dragSrc.get(), QPoint(_mouseDownX - srcX, _mouseDownY - srcY));
                     }
                     
-                    _mouseDownMayStartDrag = dispatchDragSrcEvent(EventImpl::DRAGSTART_EVENT, QPoint(_mouseDownWinX, _mouseDownWinY));
+                    _mouseDownMayStartDrag = dispatchDragSrcEvent(dragstartEvent, QPoint(_mouseDownWinX, _mouseDownWinY));
                     // Invalidate clipboard here against anymore pasteboard writing for security.  The drag
                     // image can still be changed as we drag, but not the pasteboard data.
                     _dragClipboard->setAccessPolicy(KWQClipboard::ImageWritable);
@@ -2396,7 +2398,7 @@ void KWQKHTMLPart::khtmlMouseMoveEvent(MouseMoveEvent *event)
                     BOOL startedDrag = [_bridge startDraggingImage:dragImage at:dragLoc operation:srcOp event:_currentEvent sourceIsDHTML:_dragSrcIsDHTML DHTMLWroteData:wcWrotePasteboard];
                     if (!startedDrag && _dragSrcMayBeDHTML) {
                         // WebKit canned the drag at the last minute - we owe _dragSrc a DRAGEND event
-                        dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, QPoint(dragLocation));
+                        dispatchDragSrcEvent(dragendEvent, QPoint(dragLocation));
                         _mouseDownMayStartDrag = false;
                     }
                 } 
@@ -2438,7 +2440,7 @@ void KWQKHTMLPart::dragSourceMovedTo(const QPoint &loc)
 {
     if (!_dragSrc.isNull() && _dragSrcMayBeDHTML) {
         // for now we don't care if event handler cancels default behavior, since there is none
-        dispatchDragSrcEvent(EventImpl::DRAG_EVENT, loc);
+        dispatchDragSrcEvent(dragEvent, loc);
     }
 }
 
@@ -2447,7 +2449,7 @@ void KWQKHTMLPart::dragSourceEndedAt(const QPoint &loc, NSDragOperation operatio
     if (!_dragSrc.isNull() && _dragSrcMayBeDHTML) {
         _dragClipboard->setDestinationOperation(operation);
         // for now we don't care if event handler cancels default behavior, since there is none
-        dispatchDragSrcEvent(EventImpl::DRAGEND_EVENT, loc);
+        dispatchDragSrcEvent(dragendEvent, loc);
     }
     freeClipboard();
     _dragSrc.reset();
@@ -2455,7 +2457,7 @@ void KWQKHTMLPart::dragSourceEndedAt(const QPoint &loc, NSDragOperation operatio
 
 // Returns whether caller should continue with "the default processing", which is the same as 
 // the event handler NOT setting the return value to false
-bool KWQKHTMLPart::dispatchCPPEvent(int eventId, KWQClipboard::AccessPolicy policy)
+bool KWQKHTMLPart::dispatchCPPEvent(const AtomicString &eventType, KWQClipboard::AccessPolicy policy)
 {
     NodeImpl *target = d->m_selection.start().element();
     if (!target && xmlDocImpl()) {
@@ -2469,7 +2471,7 @@ bool KWQKHTMLPart::dispatchCPPEvent(int eventId, KWQClipboard::AccessPolicy poli
     clipboard->ref();
 
     int exceptioncode = 0;
-    EventImpl *evt = new ClipboardEventImpl(static_cast<EventImpl::EventId>(eventId), true, true, clipboard);
+    EventImpl *evt = new ClipboardEventImpl(eventType, true, true, clipboard);
     evt->ref();
     target->dispatchEvent(evt, exceptioncode, true);
     bool noDefaultProcessing = evt->defaultPrevented();
@@ -2489,17 +2491,17 @@ bool KWQKHTMLPart::dispatchCPPEvent(int eventId, KWQClipboard::AccessPolicy poli
 
 bool KWQKHTMLPart::mayCut()
 {
-    return !dispatchCPPEvent(EventImpl::BEFORECUT_EVENT, KWQClipboard::Numb);
+    return !dispatchCPPEvent(beforecutEvent, KWQClipboard::Numb);
 }
 
 bool KWQKHTMLPart::mayCopy()
 {
-    return !dispatchCPPEvent(EventImpl::BEFORECOPY_EVENT, KWQClipboard::Numb);
+    return !dispatchCPPEvent(beforecopyEvent, KWQClipboard::Numb);
 }
 
 bool KWQKHTMLPart::mayPaste()
 {
-    return !dispatchCPPEvent(EventImpl::BEFOREPASTE_EVENT, KWQClipboard::Numb);
+    return !dispatchCPPEvent(beforepasteEvent, KWQClipboard::Numb);
 }
 
 bool KWQKHTMLPart::tryCut()
@@ -2508,7 +2510,7 @@ bool KWQKHTMLPart::tryCut()
     // also done for security, as it erases data from the last copy/paste.
     [[NSPasteboard generalPasteboard] declareTypes:[NSArray array] owner:nil];
 
-    return !dispatchCPPEvent(EventImpl::CUT_EVENT, KWQClipboard::Writable);
+    return !dispatchCPPEvent(cutEvent, KWQClipboard::Writable);
 }
 
 bool KWQKHTMLPart::tryCopy()
@@ -2517,12 +2519,12 @@ bool KWQKHTMLPart::tryCopy()
     // also done for security, as it erases data from the last copy/paste.
     [[NSPasteboard generalPasteboard] declareTypes:[NSArray array] owner:nil];
 
-    return !dispatchCPPEvent(EventImpl::COPY_EVENT, KWQClipboard::Writable);
+    return !dispatchCPPEvent(copyEvent, KWQClipboard::Writable);
 }
 
 bool KWQKHTMLPart::tryPaste()
 {
-    return !dispatchCPPEvent(EventImpl::PASTE_EVENT, KWQClipboard::Readable);
+    return !dispatchCPPEvent(pasteEvent, KWQClipboard::Readable);
 }
 
 void KWQKHTMLPart::khtmlMouseReleaseEvent(MouseReleaseEvent *event)
@@ -2836,7 +2838,7 @@ bool KWQKHTMLPart::sendContextMenuEvent(NSEvent *event)
     NodeImpl::MouseEvent mev(qev.stateAfter(), NodeImpl::MousePress);
     doc->prepareMouseEvent(false, xm, ym, &mev);
 
-    bool swallowEvent = v->dispatchMouseEvent(EventImpl::CONTEXTMENU_EVENT,
+    bool swallowEvent = v->dispatchMouseEvent(contextmenuEvent,
         mev.innerNode.get(), true, 0, &qev, true, NodeImpl::MousePress);
     if (!swallowEvent && !isPointInsideSelection(xm, ym) &&
         ([_bridge selectWordBeforeMenuEvent] || [_bridge isEditable] || mev.innerNode->isContentEditable())) {
@@ -3765,14 +3767,9 @@ void KWQKHTMLPart::setWindowHasFocus(bool flag)
         return;
     m_windowHasFocus = flag;
 
-    DocumentImpl *doc = xmlDocImpl();
-    if (doc) {
-        NodeImpl *body = doc->body();
-        if (body) {
-            int eventID = flag ? EventImpl::FOCUS_EVENT : EventImpl::BLUR_EVENT;
-            body->dispatchWindowEvent(eventID, false, false);
-        }
-    }
+    if (DocumentImpl *doc = xmlDocImpl())
+        if (NodeImpl *body = doc->body())
+            body->dispatchWindowEvent(flag ? focusEvent : blurEvent, false, false);
 }
 
 QChar KWQKHTMLPart::backslashAsCurrencySymbol() const
index 3056fbdb63f296aea7c3007703a25e8e81f3f8b5..fea7f89a7cddcac29bfe8b1a04081ce464cc0f2b 100644 (file)
@@ -27,6 +27,7 @@
 
 #import "DOMCSS.h"
 #import "DOMHTML.h"
+#import "EventNames.h"
 #import "KWQAssertions.h"
 #import "KWQKHTMLPart.h"
 #import "KWQNSViewExtras.h"
@@ -34,7 +35,9 @@
 #import "render_replaced.h"
 #import "WebCoreBridge.h"
 
+using DOM::AtomicString;
 using DOM::EventImpl;
+using namespace DOM::EventNames;
 using DOM::NodeImpl;
 using khtml::RenderWidget;
 
@@ -1129,56 +1132,51 @@ static NSString *WebContinuousSpellCheckingEnabled = @"WebContinuousSpellCheckin
 
 // FIXME: This does not yet implement the feature of canceling the operation, or the necessary
 // support to implement the clipboard operations entirely in JavaScript.
-- (void)dispatchHTMLEvent:(EventImpl::EventId)eventID
+- (void)dispatchHTMLEvent:(const AtomicString &)eventType
 {
-    if (widget) {
-        const RenderWidget *rw = static_cast<const RenderWidget *>(widget->eventFilterObject());
-        if (rw) {
-            NodeImpl *node = rw->element();
-            if (node) {
-                node->dispatchHTMLEvent(eventID, false, false);
-            }
-        }
-    }
+    if (widget)
+        if (const RenderWidget *rw = static_cast<const RenderWidget *>(widget->eventFilterObject()))
+            if (NodeImpl *node = rw->element())
+                node->dispatchHTMLEvent(eventType, false, false);
 }
 
 - (void)cut:(id)sender
 {
     inCut = YES;
-    [self dispatchHTMLEvent:EventImpl::BEFORECUT_EVENT];
+    [self dispatchHTMLEvent:beforecutEvent];
     [super cut:sender];
-    [self dispatchHTMLEvent:EventImpl::CUT_EVENT];
+    [self dispatchHTMLEvent:cutEvent];
     inCut = NO;
 }
 
 - (void)copy:(id)sender
 {
     if (!inCut)
-        [self dispatchHTMLEvent:EventImpl::BEFORECOPY_EVENT];
+        [self dispatchHTMLEvent:beforecopyEvent];
     [super copy:sender];
     if (!inCut)
-        [self dispatchHTMLEvent:EventImpl::COPY_EVENT];
+        [self dispatchHTMLEvent:copyEvent];
 }
 
 - (void)paste:(id)sender
 {
-    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [self dispatchHTMLEvent:beforepasteEvent];
     [super paste:sender];
-    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+    [self dispatchHTMLEvent:pasteEvent];
 }
 
 - (void)pasteAsPlainText:(id)sender
 {
-    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [self dispatchHTMLEvent:beforepasteEvent];
     [super pasteAsPlainText:sender];
-    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+    [self dispatchHTMLEvent:pasteEvent];
 }
 
 - (void)pasteAsRichText:(id)sender
 {
-    [self dispatchHTMLEvent:EventImpl::BEFOREPASTE_EVENT];
+    [self dispatchHTMLEvent:beforepasteEvent];
     [super pasteAsRichText:sender];
-    [self dispatchHTMLEvent:EventImpl::PASTE_EVENT];
+    [self dispatchHTMLEvent:pasteEvent];
 }
 
 - (BOOL)inResponderChange