File indexing completed on 2024-04-21 14:58:36

0001 /*
0002  * This file is part of the DOM implementation for KDE.
0003  *
0004  * Copyright (C) 2001 Peter Kelly (pmk@post.com)
0005  *           (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de)
0006  *           (C) 2002 Apple Computer, Inc.
0007  *           (C) 2010 Maksim Orlovich (maksim@kde.org)
0008  *
0009  * This library is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Library General Public
0011  * License as published by the Free Software Foundation; either
0012  * version 2 of the License, or (at your option) any later version.
0013  *
0014  * This library is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * Library General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Library General Public License
0020  * along with this library; see the file COPYING.LIB.  If not, write to
0021  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0022  * Boston, MA 02110-1301, USA.
0023  *
0024  */
0025 
0026 #ifndef _DOM_EventsImpl_h_
0027 #define _DOM_EventsImpl_h_
0028 
0029 #include "dom/dom2_events.h"
0030 #include "xml/dom2_viewsimpl.h"
0031 #include "misc/idstring.h"
0032 #include "misc/enum.h"
0033 #include <QDateTime>
0034 #include <QWeakPointer>
0035 
0036 #undef FOCUS_EVENT //for win32
0037 
0038 class QMouseEvent;
0039 class QKeyEvent;
0040 class KHTMLPart;
0041 
0042 namespace DOM
0043 {
0044 
0045 class AbstractViewImpl;
0046 class DOMStringImpl;
0047 class NodeImpl;
0048 class DocumentImpl;
0049 
0050 class RegisteredEventListener
0051 {
0052 public:
0053     RegisteredEventListener() : useCapture(false), listener(nullptr) {}
0054 
0055     RegisteredEventListener(EventName _id, EventListener *_listener, bool _useCapture)
0056         : eventName(_id), useCapture(_useCapture), listener(_listener)
0057     {
0058         if (listener) {
0059             listener->ref();
0060         }
0061     }
0062 
0063     ~RegisteredEventListener()
0064     {
0065         if (listener) {
0066             listener->deref();
0067         } listener = nullptr;
0068     }
0069 
0070     bool operator==(const RegisteredEventListener &other) const
0071     {
0072         return eventName == other.eventName && listener == other.listener
0073                && useCapture == other.useCapture;
0074     }
0075 
0076     EventName eventName;
0077     bool useCapture;
0078     EventListener *listener;
0079 
0080     RegisteredEventListener(const RegisteredEventListener &other) :
0081         eventName(other.eventName), useCapture(other.useCapture), listener(other.listener)
0082     {
0083         if (listener) {
0084             listener->ref();
0085         }
0086     }
0087 
0088     RegisteredEventListener &operator=(const RegisteredEventListener &other)
0089     {
0090         eventName  = other.eventName;
0091         useCapture = other.useCapture;
0092         if (other.listener) {
0093             other.listener->ref();
0094         }
0095         if (listener) {
0096             listener->deref();
0097         }
0098         listener = other.listener;
0099         return *this;
0100     }
0101 };
0102 
0103 struct RegisteredListenerList {
0104     RegisteredListenerList() : listeners(nullptr)
0105     {}
0106 
0107     ~RegisteredListenerList();
0108 
0109     void addEventListener(EventName id, EventListener *listener, const bool useCapture);
0110     void removeEventListener(EventName id, EventListener *listener, bool useCapture);
0111 
0112     void setHTMLEventListener(EventName id, EventListener *listener);
0113     EventListener *getHTMLEventListener(EventName id);
0114 
0115     bool hasEventListener(EventName id);
0116     void clear();
0117 
0118     // TODO: remove/deprecate?
0119     bool stillContainsListener(const RegisteredEventListener &listener);
0120 
0121     QList<RegisteredEventListener> *listeners;//The actual listener list - may be 0
0122 private:
0123     bool isHTMLEventListener(EventListener *listener);
0124 };
0125 
0126 class EventTargetImpl : public khtml::TreeShared<EventTargetImpl>
0127 {
0128 public:
0129     enum Type {
0130         DOM_NODE,
0131         WINDOW,
0132         XML_HTTP_REQUEST
0133     };
0134 
0135     virtual Type eventTargetType() const = 0;
0136 
0137     /* Override this to provide access to associated document in order to
0138      * set appropriate 'has listerner' flags
0139      */
0140     virtual DocumentImpl *eventTargetDocument();
0141 
0142     /**
0143      * Perform the default action for an event e.g. submitting a form
0144      */
0145     virtual void defaultEventHandler(EventImpl *evt);
0146 
0147     /*
0148      * This method fires all the registered handlers for this event
0149      * (checking the capture flag as well(
0150      */
0151     void handleLocalEvents(EventImpl *evt, bool useCapture);
0152 
0153     void addEventListener(EventName id, EventListener *listener, const bool useCapture);
0154     void removeEventListener(EventName id, EventListener *listener, bool useCapture);
0155     void setHTMLEventListener(EventName id, EventListener *listener);
0156     void setHTMLEventListener(unsigned id, EventListener *listener);
0157     EventListener *getHTMLEventListener(EventName id);
0158     EventListener *getHTMLEventListener(unsigned id);
0159 
0160     RegisteredListenerList &listenerList()
0161     {
0162         return m_regdListeners;
0163     }
0164 private:
0165     void setDocListenerFlag(unsigned flag);
0166     RegisteredListenerList m_regdListeners;
0167 };
0168 
0169 class EventImpl : public khtml::Shared<EventImpl>
0170 {
0171 public:
0172     enum EventId {
0173         // UI events
0174         DOMFOCUSIN_EVENT,
0175         DOMFOCUSOUT_EVENT,
0176         DOMACTIVATE_EVENT,
0177         // Mouse events
0178         CLICK_EVENT,
0179         MOUSEDOWN_EVENT,
0180         MOUSEUP_EVENT,
0181         MOUSEOVER_EVENT,
0182         MOUSEMOVE_EVENT,
0183         MOUSEOUT_EVENT,
0184         // Mutation events
0185         DOMSUBTREEMODIFIED_EVENT,
0186         DOMNODEINSERTED_EVENT,
0187         DOMNODEREMOVED_EVENT,
0188         DOMNODEREMOVEDFROMDOCUMENT_EVENT,
0189         DOMNODEINSERTEDINTODOCUMENT_EVENT,
0190         DOMATTRMODIFIED_EVENT,
0191         DOMCHARACTERDATAMODIFIED_EVENT,
0192         // HTML events
0193         LOAD_EVENT,
0194         UNLOAD_EVENT,
0195         ABORT_EVENT,
0196         ERROR_EVENT,
0197         SELECT_EVENT,
0198         CHANGE_EVENT,
0199         SUBMIT_EVENT,
0200         RESET_EVENT,
0201         FOCUS_EVENT,
0202         BLUR_EVENT,
0203         RESIZE_EVENT,
0204         SCROLL_EVENT,
0205         HASHCHANGE_EVENT,
0206         // keyboard events
0207         KEYDOWN_EVENT,
0208         KEYUP_EVENT,
0209         KEYPRESS_EVENT, //Mostly corresponds to DOM3 textInput event.
0210         // khtml events (not part of DOM)
0211         KHTML_ECMA_DBLCLICK_EVENT, // for html ondblclick
0212         KHTML_ECMA_CLICK_EVENT, // for html onclick
0213         KHTML_DRAGDROP_EVENT,
0214         KHTML_MOVE_EVENT,
0215         KHTML_MOUSEWHEEL_EVENT,
0216         KHTML_CONTENTLOADED_EVENT,
0217         // XMLHttpRequest events
0218         KHTML_READYSTATECHANGE_EVENT,
0219         // HTML5 events
0220         MESSAGE_EVENT
0221     };
0222 
0223     EventImpl();
0224     EventImpl(EventId id, bool canBubbleArg, bool cancelableArg);
0225     virtual ~EventImpl();
0226 
0227     EventId id() const
0228     {
0229         return EventId(m_eventName.id());
0230     }
0231     DOMString type() const
0232     {
0233         return m_eventName.toString();
0234     }
0235     EventName name() const
0236     {
0237         return m_eventName;
0238     }
0239 
0240     EventTargetImpl *target() const
0241     {
0242         return m_target;
0243     }
0244     void setTarget(EventTargetImpl *_target);
0245     EventTargetImpl *currentTarget() const
0246     {
0247         return m_currentTarget;
0248     }
0249     void setCurrentTarget(EventTargetImpl *_currentTarget)
0250     {
0251         m_currentTarget = _currentTarget;
0252     }
0253     unsigned short eventPhase() const
0254     {
0255         return m_eventPhase;
0256     }
0257     void setEventPhase(unsigned short _eventPhase)
0258     {
0259         m_eventPhase = _eventPhase;
0260     }
0261     bool bubbles() const
0262     {
0263         return m_canBubble;
0264     }
0265     bool cancelable() const
0266     {
0267         return m_cancelable;
0268     }
0269     DOMTimeStamp timeStamp();
0270     void stopPropagation(bool stop)
0271     {
0272         m_propagationStopped = stop;
0273     }
0274     void preventDefault(bool prevent)
0275     {
0276         if (m_cancelable) {
0277             m_defaultPrevented = prevent;
0278         }
0279     }
0280 
0281     void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg);
0282 
0283     virtual bool isUIEvent() const;
0284     virtual bool isMouseEvent() const;
0285     virtual bool isMutationEvent() const;
0286     virtual bool isTextInputEvent() const;
0287     virtual bool isKeyboardEvent() const;
0288     virtual bool isMessageEvent() const;
0289     virtual bool isHashChangeEvent() const;
0290     bool isKeyRelatedEvent() const
0291     {
0292         return isTextInputEvent() || isKeyboardEvent();
0293     }
0294 
0295     bool propagationStopped() const
0296     {
0297         return m_propagationStopped;
0298     }
0299     bool defaultPrevented() const
0300     {
0301         return m_defaultPrevented;
0302     }
0303 
0304     void setDefaultHandled()
0305     {
0306         m_defaultHandled = true;
0307     }
0308     bool defaultHandled() const
0309     {
0310         return m_defaultHandled;
0311     }
0312 
0313     DOMString message() const
0314     {
0315         return m_message;
0316     }
0317     void setMessage(const DOMString &_message)
0318     {
0319         m_message = _message;
0320     }
0321 
0322     static khtml::IDTable<EventImpl> *idTable()
0323     {
0324         if (s_idTable) {
0325             return s_idTable;
0326         } else {
0327             return initIdTable();
0328         }
0329     }
0330 protected:
0331     static khtml::IDTable<EventImpl> *s_idTable;
0332     static khtml::IDTable<EventImpl> *initIdTable();
0333     EventName m_eventName;
0334     bool m_canBubble  : 1;
0335     bool m_cancelable : 1;
0336 
0337     bool m_propagationStopped : 1;
0338     bool m_defaultPrevented   : 1;
0339     bool m_defaultHandled     : 1;
0340     unsigned short m_eventPhase : 2;
0341     EventTargetImpl *m_currentTarget; // ref > 0 maintained externally
0342     EventTargetImpl *m_target;
0343     QDateTime m_createTime;
0344     DOMString m_message;
0345 };
0346 
0347 class UIEventImpl : public EventImpl
0348 {
0349 public:
0350     UIEventImpl() : m_view(nullptr), m_detail(0) {}
0351     UIEventImpl(EventId _id,
0352                 bool canBubbleArg,
0353                 bool cancelableArg,
0354                 AbstractViewImpl *viewArg,
0355                 long detailArg);
0356     virtual ~UIEventImpl();
0357     AbstractViewImpl *view() const
0358     {
0359         return m_view;
0360     }
0361     long detail() const
0362     {
0363         return m_detail;
0364     }
0365     void initUIEvent(const DOMString &typeArg,
0366                      bool canBubbleArg,
0367                      bool cancelableArg,
0368                      AbstractViewImpl *viewArg,
0369                      long detailArg);
0370     bool isUIEvent() const override;
0371 
0372     //Compat stuff
0373     virtual int keyCode() const
0374     {
0375         return 0;
0376     }
0377     virtual int charCode() const
0378     {
0379         return 0;
0380     }
0381 
0382     virtual long pageX() const
0383     {
0384         return 0;
0385     }
0386     virtual long pageY() const
0387     {
0388         return 0;
0389     }
0390     virtual long layerX() const
0391     {
0392         return 0;
0393     }
0394     virtual long layerY() const
0395     {
0396         return 0;
0397     }
0398     virtual int which() const
0399     {
0400         return 0;
0401     }
0402 protected:
0403     AbstractViewImpl *m_view;
0404     long m_detail;
0405 
0406 };
0407 
0408 // Introduced in DOM Level 2: - internal
0409 class MouseEventImpl : public UIEventImpl
0410 {
0411 public:
0412     enum Orientation {
0413         ONone = 0,
0414         OHorizontal,
0415         OVertical
0416     };
0417 
0418     MouseEventImpl();
0419     MouseEventImpl(EventId _id,
0420                    bool canBubbleArg,
0421                    bool cancelableArg,
0422                    AbstractViewImpl *viewArg,
0423                    long detailArg,
0424                    long screenXArg,
0425                    long screenYArg,
0426                    long clientXArg,
0427                    long clientYArg,
0428                    long pageXArg,
0429                    long pageYArg,
0430                    bool ctrlKeyArg,
0431                    bool altKeyArg,
0432                    bool shiftKeyArg,
0433                    bool metaKeyArg,
0434                    unsigned short buttonArg,
0435                    NodeImpl *relatedTargetArg,
0436                    QMouseEvent *qe = nullptr,
0437                    bool isDoubleClick = false,
0438                    Orientation orient = ONone);
0439     virtual ~MouseEventImpl();
0440     long screenX() const
0441     {
0442         return m_screenX;
0443     }
0444     long screenY() const
0445     {
0446         return m_screenY;
0447     }
0448     long clientX() const
0449     {
0450         return m_clientX;
0451     }
0452     long clientY() const
0453     {
0454         return m_clientY;
0455     }
0456     long layerX() const override
0457     {
0458         return m_layerX;    // non-DOM extension
0459     }
0460     long layerY() const override
0461     {
0462         return m_layerY;    // non-DOM extension
0463     }
0464     long pageX() const override
0465     {
0466         return m_pageX;    // non-DOM extension
0467     }
0468     long pageY() const override
0469     {
0470         return m_pageY;    // non-DOM extension
0471     }
0472     int which() const override
0473     {
0474         return button() + 1;    // non-DOM extension
0475     }
0476     bool isDoubleClick() const
0477     {
0478         return m_isDoubleClick;    // non-DOM extension
0479     }
0480     Orientation orientation() const
0481     {
0482         return KDE_CAST_BF_ENUM(Orientation, m_orientation);    // non-DOM extension
0483     }
0484     bool ctrlKey() const
0485     {
0486         return m_ctrlKey;
0487     }
0488     bool shiftKey() const
0489     {
0490         return m_shiftKey;
0491     }
0492     bool altKey() const
0493     {
0494         return m_altKey;
0495     }
0496     bool metaKey() const
0497     {
0498         return m_metaKey;
0499     }
0500     unsigned short button() const
0501     {
0502         return m_button;
0503     }
0504     NodeImpl *relatedTarget() const
0505     {
0506         return m_relatedTarget;
0507     }
0508 
0509     void computeLayerPos();
0510 
0511     void initMouseEvent(const DOMString &typeArg,
0512                         bool canBubbleArg,
0513                         bool cancelableArg,
0514                         AbstractViewImpl *viewArg,
0515                         long detailArg,
0516                         long screenXArg,
0517                         long screenYArg,
0518                         long clientXArg,
0519                         long clientYArg,
0520                         bool ctrlKeyArg,
0521                         bool altKeyArg,
0522                         bool shiftKeyArg,
0523                         bool metaKeyArg,
0524                         unsigned short buttonArg,
0525                         const Node &relatedTargetArg,
0526                         Orientation orient = ONone);
0527     bool isMouseEvent() const override;
0528 
0529     QMouseEvent *qEvent() const
0530     {
0531         return m_qevent;
0532     }
0533 protected:
0534     long m_screenX;
0535     long m_screenY;
0536     long m_clientX;
0537     long m_clientY;
0538     long m_layerX;
0539     long m_layerY;
0540     long m_pageX;
0541     long m_pageY;
0542     bool m_ctrlKey : 1;
0543     bool m_altKey  : 1;
0544     bool m_shiftKey : 1;
0545     bool m_metaKey : 1;
0546     bool m_isDoubleClick : 1;
0547     KDE_BF_ENUM(Orientation) m_orientation : 2;
0548     unsigned short m_button;
0549     NodeImpl *m_relatedTarget;
0550     QMouseEvent *m_qevent;
0551 };
0552 
0553 class KeyEventBaseImpl : public UIEventImpl
0554 {
0555 public:
0556     // VirtualKeyCode
0557     enum KeyCodes  {
0558         DOM_VK_UNDEFINED           = 0x0,
0559         DOM_VK_RIGHT_ALT           = 0x12,
0560         DOM_VK_LEFT_ALT            = 0x12,
0561         DOM_VK_LEFT_CONTROL        = 0x11,
0562         DOM_VK_RIGHT_CONTROL       = 0x11,
0563         DOM_VK_LEFT_SHIFT          = 0x10,
0564         DOM_VK_RIGHT_SHIFT         = 0x10,
0565         DOM_VK_META            = 0x9D,
0566         DOM_VK_BACK_SPACE          = 0x08,
0567         DOM_VK_CAPS_LOCK           = 0x14,
0568         DOM_VK_INSERT          = 0x2D,
0569         DOM_VK_DELETE          = 0x7F,
0570         DOM_VK_END             = 0x23,
0571         DOM_VK_ENTER           = 0x0D,
0572         DOM_VK_ESCAPE          = 0x1B,
0573         DOM_VK_HOME            = 0x24,
0574         DOM_VK_NUM_LOCK            = 0x90,
0575         DOM_VK_PAUSE           = 0x13,
0576         DOM_VK_PRINTSCREEN         = 0x9A,
0577         DOM_VK_SCROLL_LOCK         = 0x91,
0578         DOM_VK_SPACE           = 0x20,
0579         DOM_VK_TAB             = 0x09,
0580         DOM_VK_LEFT            = 0x25,
0581         DOM_VK_RIGHT           = 0x27,
0582         DOM_VK_UP              = 0x26,
0583         DOM_VK_DOWN            = 0x28,
0584         DOM_VK_PAGE_DOWN           = 0x22,
0585         DOM_VK_PAGE_UP             = 0x21,
0586         DOM_VK_F1              = 0x70,
0587         DOM_VK_F2              = 0x71,
0588         DOM_VK_F3              = 0x72,
0589         DOM_VK_F4              = 0x73,
0590         DOM_VK_F5              = 0x74,
0591         DOM_VK_F6              = 0x75,
0592         DOM_VK_F7              = 0x76,
0593         DOM_VK_F8              = 0x77,
0594         DOM_VK_F9              = 0x78,
0595         DOM_VK_F10             = 0x79,
0596         DOM_VK_F11             = 0x7A,
0597         DOM_VK_F12             = 0x7B,
0598         DOM_VK_F13             = 0xF000,
0599         DOM_VK_F14             = 0xF001,
0600         DOM_VK_F15             = 0xF002,
0601         DOM_VK_F16             = 0xF003,
0602         DOM_VK_F17             = 0xF004,
0603         DOM_VK_F18             = 0xF005,
0604         DOM_VK_F19             = 0xF006,
0605         DOM_VK_F20             = 0xF007,
0606         DOM_VK_F21             = 0xF008,
0607         DOM_VK_F22             = 0xF009,
0608         DOM_VK_F23             = 0xF00A,
0609         DOM_VK_F24             = 0xF00B
0610     };
0611 
0612     void initKeyBaseEvent(const DOMString &typeArg,
0613                           bool canBubbleArg,
0614                           bool cancelableArg,
0615                           AbstractViewImpl *viewArg,
0616                           unsigned long keyVal,
0617                           unsigned long virtKeyVal,
0618                           unsigned long modifiers);
0619 
0620     bool ctrlKey()  const
0621     {
0622         return m_modifier & Qt::ControlModifier;
0623     }
0624     bool shiftKey() const
0625     {
0626         return m_modifier & Qt::ShiftModifier;
0627     }
0628     bool altKey()   const
0629     {
0630         return m_modifier & Qt::AltModifier;
0631     }
0632     bool metaKey()  const
0633     {
0634         return m_modifier & Qt::MetaModifier;
0635     }
0636 
0637     bool             inputGenerated() const
0638     {
0639         return m_virtKeyVal == 0;
0640     }
0641     unsigned long    keyVal() const
0642     {
0643         return m_keyVal;
0644     }
0645     unsigned long    virtKeyVal() const
0646     {
0647         return m_virtKeyVal;
0648     }
0649 
0650     QKeyEvent *qKeyEvent() const
0651     {
0652         if (!m_keyEvent) {
0653             buildQKeyEvent();
0654         } return m_keyEvent;
0655     }
0656 
0657     ~KeyEventBaseImpl();
0658 
0659     bool checkModifier(unsigned long modifierArg);
0660 
0661     int which() const override
0662     {
0663         return keyCode();    // non-DOM extension
0664     }
0665 
0666     //Returns true if the event was synthesized by client use of DOM
0667     bool isSynthetic() const
0668     {
0669         return m_synthetic;
0670     }
0671 protected:
0672     KeyEventBaseImpl(): m_keyEvent(nullptr), m_keyVal(0), m_virtKeyVal(0), m_modifier(0), m_synthetic(false)
0673     {
0674         m_detail = 0;
0675     }
0676 
0677     KeyEventBaseImpl(EventId id,
0678                      bool canBubbleArg,
0679                      bool cancelableArg,
0680                      AbstractViewImpl *viewArg,
0681                      QKeyEvent *key);
0682 
0683     mutable QKeyEvent *m_keyEvent;
0684     unsigned long m_keyVal;     //Unicode key value
0685     unsigned long m_virtKeyVal; //Virtual key value for keys like arrows, Fn, etc.
0686 
0687     // bitfield containing state of modifiers. not part of the dom.
0688     unsigned long    m_modifier;
0689 
0690     bool             m_synthetic;
0691 
0692     void buildQKeyEvent() const; //Construct a Qt key event from m_keyVal/m_virtKeyVal
0693 };
0694 
0695 class TextEventImpl : public KeyEventBaseImpl
0696 {
0697 public:
0698     TextEventImpl();
0699 
0700     TextEventImpl(QKeyEvent *key, DOM::AbstractViewImpl *view);
0701 
0702     void initTextEvent(const DOMString &typeArg,
0703                        bool canBubbleArg,
0704                        bool cancelableArg,
0705                        AbstractViewImpl *viewArg,
0706                        const DOMString &text);
0707 
0708     bool isTextInputEvent() const override;
0709 
0710     //Legacy key stuff...
0711     int keyCode() const override;
0712     int charCode() const override;
0713 
0714     DOMString data() const
0715     {
0716         return m_outputString;
0717     }
0718 private:
0719     DOMString m_outputString;
0720 };
0721 
0722 class KeyboardEventImpl : public KeyEventBaseImpl
0723 {
0724 public:
0725     KeyboardEventImpl();
0726     KeyboardEventImpl(QKeyEvent *key, DOM::AbstractViewImpl *view);
0727 
0728     bool isKeyboardEvent() const override;
0729 
0730     //Legacy key stuff...
0731     int keyCode() const override;
0732     int charCode() const override;
0733 
0734     DOMString     keyIdentifier() const;
0735     unsigned long keyLocation() const
0736     {
0737         return m_keyLocation;
0738     }
0739 
0740     bool getModifierState(const DOMString &keyIdentifierArg) const;
0741 
0742     void initKeyboardEvent(const DOMString &typeArg,
0743                            bool canBubbleArg,
0744                            bool cancelableArg,
0745                            AbstractViewImpl *viewArg,
0746                            const DOMString &keyIdentifierArg,
0747                            unsigned long keyLocationArg,
0748                            const DOMString &modifiersList);
0749 
0750 private:
0751     unsigned long m_keyLocation;
0752 };
0753 
0754 class MutationEventImpl : public EventImpl
0755 {
0756 // ### fire these during parsing (if necessary)
0757 public:
0758     MutationEventImpl();
0759     MutationEventImpl(EventId _id, /* for convenience */
0760                       bool canBubbleArg,
0761                       bool cancelableArg,
0762                       const Node &relatedNodeArg,
0763                       const DOMString &prevValueArg,
0764                       const DOMString &newValueArg,
0765                       const DOMString &attrNameArg,
0766                       unsigned short attrChangeArg);
0767     ~MutationEventImpl();
0768 
0769     Node relatedNode() const
0770     {
0771         return m_relatedNode;
0772     }
0773     DOMString prevValue() const
0774     {
0775         return m_prevValue;
0776     }
0777     DOMString newValue() const
0778     {
0779         return m_newValue;
0780     }
0781     DOMString attrName() const
0782     {
0783         return m_attrName;
0784     }
0785     unsigned short attrChange() const
0786     {
0787         return m_attrChange;
0788     }
0789     void initMutationEvent(const DOMString &typeArg,
0790                            bool canBubbleArg,
0791                            bool cancelableArg,
0792                            const Node &relatedNodeArg,
0793                            const DOMString &prevValueArg,
0794                            const DOMString &newValueArg,
0795                            const DOMString &attrNameArg,
0796                            unsigned short attrChangeArg);
0797     bool isMutationEvent() const override;
0798 protected:
0799     NodeImpl *m_relatedNode;
0800     DOMStringImpl *m_prevValue;
0801     DOMStringImpl *m_newValue;
0802     DOMStringImpl *m_attrName;
0803     unsigned short m_attrChange;
0804 };
0805 
0806 class MessageEventImpl : public EventImpl
0807 {
0808 public:
0809     enum DataType {
0810         JS_VALUE
0811     };
0812 
0813     class Data : public khtml::Shared<Data>
0814     {
0815     public:
0816         virtual DataType messageDataType() const = 0;
0817         virtual ~Data() {}
0818     };
0819 
0820     RefPtr<Data> data() const
0821     {
0822         return m_data;
0823     }
0824     DOMString  origin() const
0825     {
0826         return m_origin;
0827     }
0828     KHTMLPart *source() const
0829     {
0830         return m_source.toStrongRef().data();
0831     }
0832     DOMString  lastEventId() const
0833     {
0834         return m_lastEventId;
0835     }
0836 
0837     MessageEventImpl();
0838 
0839     void initMessageEvent(const DOMString &eventTypeArg,
0840                           bool  canBubbleArg,
0841                           bool  cancelableArg,
0842                           const RefPtr<Data> &dataArg,
0843                           const DOMString &originArg,
0844                           const DOMString &lastEventIdArg,
0845                           KHTMLPart *sourceArg); // no message ports yet.
0846     bool isMessageEvent() const override;
0847 private:
0848     RefPtr<Data> m_data;
0849     DOMString    m_origin;
0850     DOMString    m_lastEventId;
0851     QWeakPointer<KHTMLPart>  m_source;
0852 };
0853 
0854 class HashChangeEventImpl : public EventImpl
0855 {
0856 public:
0857     const DOMString &oldUrl() const
0858     {
0859         return m_oldUrl;
0860     }
0861     const DOMString &newUrl() const
0862     {
0863         return m_newUrl;
0864     }
0865 
0866     HashChangeEventImpl();
0867 
0868     void initHashChangeEvent(const DOMString &eventTypeArg,
0869                              bool  canBubbleArg,
0870                              bool  cancelableArg,
0871                              const DOMString &oldUrl,
0872                              const DOMString &newUrl
0873                             );
0874     bool isHashChangeEvent() const override;
0875 private:
0876     DOMString    m_oldUrl;
0877     DOMString    m_newUrl;
0878 };
0879 
0880 } //namespace
0881 #endif