File indexing completed on 2024-04-28 15:22:55
0001 /* 0002 * This file is part of the DOM implementation for KDE. 0003 * 0004 * Copyright 2001 Peter Kelly (pmk@post.com) 0005 * Copyright 2003 Apple Computer, Inc. 0006 * 0007 * This library is free software; you can redistribute it and/or 0008 * modify it under the terms of the GNU Library General Public 0009 * License as published by the Free Software Foundation; either 0010 * version 2 of the License, or (at your option) any later version. 0011 * 0012 * This library is distributed in the hope that it will be useful, 0013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0015 * Library General Public License for more details. 0016 * 0017 * You should have received a copy of the GNU Library General Public License 0018 * along with this library; see the file COPYING.LIB. If not, write to 0019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0020 * Boston, MA 02110-1301, USA. 0021 * 0022 * This file includes excerpts from the Document Object Model (DOM) 0023 * Level 3 Events Specification (Working Group Note 07 November 2003) 0024 * https://www.w3.org/TR/DOM-Level-3-Events/ 0025 * Copyright © 2003 World Wide Web Consortium , (Massachusetts Institute of 0026 * Technology, European Research Consortium for Informatics and Mathematics, 0027 * Keio University ). All Rights Reserved. 0028 * 0029 */ 0030 0031 #ifndef _DOM_Events_h_ 0032 #define _DOM_Events_h_ 0033 0034 #include <dom/dom_node.h> 0035 #include <dom/dom_misc.h> 0036 0037 namespace DOM 0038 { 0039 0040 class Event; 0041 class EventException; 0042 class UIEvent; 0043 class MouseEvent; 0044 class TextEvent; 0045 class MutationEvent; 0046 class AbstractView; 0047 0048 class EventListenerImpl; 0049 class EventImpl; 0050 class UIEventImpl; 0051 class MouseEventImpl; 0052 class MutationEventImpl; 0053 0054 /** 0055 * Introduced in DOM Level 2 0056 * 0057 * The EventListener interface is the primary method for handling events. 0058 * Users implement the EventListener interface and register their listener on 0059 * an EventTarget using the AddEventListener method. The users should also 0060 * remove their EventListener from its EventTarget after they have completed 0061 * using the listener. 0062 * 0063 * When a Node is copied using the cloneNode method the EventListeners attached 0064 * to the source Node are not attached to the copied Node. If the user wishes 0065 * the same EventListeners to be added to the newly created copy the user must 0066 * add them manually. 0067 * 0068 */ 0069 class KHTML_EXPORT EventListener : public DomShared 0070 { 0071 public: 0072 EventListener(); 0073 virtual ~EventListener(); 0074 0075 /** 0076 * This method is called whenever an event occurs of the type for which the 0077 * EventListener interface was registered. Parameters 0078 * 0079 * @param evt The Event contains contextual information about the event. It 0080 * also contains the stopPropagation and preventDefault methods which are 0081 * used in determining the event's flow and default action. 0082 * 0083 */ 0084 virtual void handleEvent(Event &evt); 0085 0086 /** 0087 * @internal 0088 * not part of the DOM 0089 * 0090 * Returns a name specifying the type of listener. Useful for checking 0091 * if an event is of a particular sublass. 0092 * 0093 */ 0094 virtual DOMString eventListenerType(); 0095 0096 protected: 0097 /** 0098 * @internal 0099 * Reserved. Do not use in your subclasses. 0100 */ 0101 EventListenerImpl *impl; 0102 }; 0103 0104 /** 0105 * Introduced in DOM Level 2 0106 * 0107 * The Event interface is used to provide contextual information about an event 0108 * to the handler processing the event. An object which implements the Event 0109 * interface is generally passed as the first parameter to an event handler. 0110 * More specific context information is passed to event handlers by deriving 0111 * additional interfaces from Event which contain information directly relating 0112 * to the type of event they accompany. These derived interfaces are also 0113 * implemented by the object passed to the event listener. 0114 * 0115 */ 0116 class KHTML_EXPORT Event 0117 { 0118 friend class Document; 0119 friend class NodeImpl; 0120 friend class DocumentImpl; 0121 public: 0122 Event(); 0123 Event(const Event &other); 0124 virtual ~Event(); 0125 0126 Event &operator = (const Event &other); 0127 0128 /** 0129 * An integer indicating which phase of event flow is being processed. 0130 * 0131 * AT_TARGET: The event is currently being evaluated at the target 0132 * EventTarget. 0133 * 0134 * BUBBLING_PHASE: The current event phase is the bubbling phase. 0135 * 0136 * CAPTURING_PHASE: The current event phase is the capturing phase. 0137 * 0138 */ 0139 enum PhaseType { 0140 CAPTURING_PHASE = 1, 0141 AT_TARGET = 2, 0142 BUBBLING_PHASE = 3 0143 }; 0144 0145 /** 0146 * The name of the event (case-insensitive). The name must be an XML name. 0147 * 0148 */ 0149 DOMString type() const; 0150 0151 /** 0152 * Used to indicate the EventTarget to which the event was originally 0153 * dispatched. 0154 * 0155 */ 0156 Node target() const; 0157 0158 /** 0159 * Used to indicate the EventTarget whose EventListeners are currently 0160 * being processed. This is particularly useful during capturing and 0161 * bubbling. 0162 * 0163 */ 0164 Node currentTarget() const; 0165 0166 /** 0167 * Used to indicate which phase of event flow is currently being evaluated. 0168 * 0169 */ 0170 unsigned short eventPhase() const; 0171 0172 /** 0173 * Used to indicate whether or not an event is a bubbling event. If the 0174 * event can bubble the value is true, else the value is false. 0175 * 0176 */ 0177 bool bubbles() const; 0178 0179 /** 0180 * Used to indicate whether or not an event can have its default action 0181 * prevented. If the default action can be prevented the value is true, 0182 * else the value is false. 0183 * 0184 */ 0185 bool cancelable() const; 0186 0187 /** 0188 * Used to specify the time (in milliseconds relative to the epoch) at 0189 * which the event was created. Due to the fact that some systems may not 0190 * provide this information the value of timeStamp may be not available for 0191 * all events. When not available, a value of 0 will be returned. Examples 0192 * of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970. 0193 * 0194 */ 0195 DOMTimeStamp timeStamp() const; 0196 0197 /** 0198 * The stopPropagation method is used prevent further propagation of an 0199 * event during event flow. If this method is called by any EventListener 0200 * the event will cease propagating through the tree. The event will 0201 * complete dispatch to all listeners on the current EventTarget before 0202 * event flow stops. This method may be used during any stage of event flow. 0203 * 0204 */ 0205 void stopPropagation(); 0206 0207 /** 0208 * If an event is cancelable, the preventDefault method is used to signify 0209 * that the event is to be canceled, meaning any default action normally 0210 * taken by the implementation as a result of the event will not occur. If, 0211 * during any stage of event flow, the preventDefault method is called the 0212 * event is canceled. Any default action associated with the event will not 0213 * occur. Calling this method for a non-cancelable event has no effect. 0214 * Once preventDefault has been called it will remain in effect throughout 0215 * the remainder of the event's propagation. This method may be used during 0216 * any stage of event flow. 0217 * 0218 */ 0219 void preventDefault(); 0220 0221 /** 0222 * The initEvent method is used to initialize the value of an Event created 0223 * through the DocumentEvent interface. This method may only be called 0224 * before the Event has been dispatched via the dispatchEvent method, 0225 * though it may be called multiple times during that phase if necessary. 0226 * If called multiple times the final invocation takes precedence. If 0227 * called from a subclass of Event interface only the values specified in 0228 * the initEvent method are modified, all other attributes are left 0229 * unchanged. 0230 * 0231 * @param eventTypeArg Specifies the event type. This type may be any event 0232 * type currently defined in this specification or a new event type.. The 0233 * string must be an XML name. 0234 * 0235 * Any new event type must not begin with any upper, lower, or mixed case 0236 * version of the string "DOM". This prefix is reserved for future DOM 0237 * event sets. It is also strongly recommended that third parties adding 0238 * their own events use their own prefix to avoid confusion and lessen the 0239 * probability of conflicts with other new events. 0240 * 0241 * @param canBubbleArg Specifies whether or not the event can bubble. 0242 * 0243 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 0244 * 0245 */ 0246 void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg); 0247 0248 /** 0249 * @internal 0250 * not part of the DOM 0251 */ 0252 EventImpl *handle() const; 0253 bool isNull() const; 0254 0255 Event(EventImpl *i); 0256 protected: 0257 EventImpl *impl; 0258 }; 0259 0260 /** 0261 * Introduced in DOM Level 2: 0262 * 0263 * Event operations may throw an EventException as specified in their method 0264 * descriptions. 0265 * 0266 */ 0267 class KHTML_EXPORT EventException 0268 { 0269 public: 0270 EventException(unsigned short _code); 0271 EventException(const EventException &other); 0272 EventException &operator = (const EventException &other); 0273 virtual ~EventException() {} 0274 0275 /** 0276 * An integer indicating the type of error generated. 0277 * 0278 * UNSPECIFIED_EVENT_TYPE_ERR: If the Event's type was not specified by 0279 * initializing the event before the method was called. Specification of 0280 * the Event's type as null or an empty string will also trigger this 0281 * exception. 0282 * 0283 */ 0284 enum EventExceptionCode { 0285 UNSPECIFIED_EVENT_TYPE_ERR = 0, 0286 _EXCEPTION_OFFSET = 3000, 0287 _EXCEPTION_MAX = 3999 0288 }; 0289 0290 unsigned short code; 0291 0292 /// Returns the name of this error 0293 DOMString codeAsString() const; 0294 0295 /// Returns the name of given error code 0296 static DOMString codeAsString(int cssCode); 0297 0298 /** @internal - checks to see whether internal code is an event one */ 0299 static bool isEventExceptionCode(int exceptioncode); 0300 0301 }; 0302 0303 /** 0304 * Introduced in DOM Level 2 0305 * 0306 * The UIEvent interface provides specific contextual information associated 0307 * with User Interface events. 0308 * 0309 */ 0310 class KHTML_EXPORT UIEvent : public Event 0311 { 0312 public: 0313 UIEvent(); 0314 UIEvent(const UIEvent &other); 0315 UIEvent(const Event &other); 0316 UIEvent &operator = (const UIEvent &other); 0317 UIEvent &operator = (const Event &other); 0318 virtual ~UIEvent(); 0319 0320 /** 0321 * The view attribute identifies the AbstractView from which the event was 0322 * generated. 0323 * 0324 */ 0325 AbstractView view() const; 0326 0327 /** 0328 * Specifies some detail information about the Event, depending on the type 0329 * of event. 0330 * 0331 */ 0332 long detail() const; 0333 0334 /** 0335 * Non-standard extension to support IE-style keyCode event property. 0336 * 0337 */ 0338 int keyCode() const; 0339 0340 /** 0341 * Non-standard extension to support IE-style charCode event property. 0342 * 0343 */ 0344 int charCode() const; 0345 0346 /** 0347 * Non-standard extensions to support Netscape-style pageX and pageY event properties. 0348 * 0349 */ 0350 int pageX() const; 0351 int pageY() const; 0352 0353 /** 0354 * Non-standard extensions to support Netscape-style layerX and layerY event properties. 0355 * 0356 */ 0357 int layerX() const; 0358 int layerY() const; 0359 0360 /** 0361 * Non-standard extension to support Netscape-style "which" event property. 0362 * 0363 */ 0364 int which() const; 0365 0366 /** 0367 * The initUIEvent method is used to initialize the value of a UIEvent 0368 * created through the DocumentEvent interface. This method may only be 0369 * called before the UIEvent has been dispatched via the dispatchEvent 0370 * method, though it may be called multiple times during that phase if 0371 * necessary. If called multiple times, the final invocation takes 0372 * precedence. 0373 * 0374 * @param typeArg Specifies the event type. 0375 * 0376 * @param canBubbleArg Specifies whether or not the event can bubble. 0377 * 0378 * @param cancelableArg Specifies whether or not the event's default action 0379 * can be prevented. 0380 * 0381 * @param viewArg Specifies the Event's AbstractView. 0382 * 0383 * @param detailArg Specifies the Event's detail. 0384 * 0385 */ 0386 void initUIEvent(const DOMString &typeArg, 0387 bool canBubbleArg, 0388 bool cancelableArg, 0389 const AbstractView &viewArg, 0390 long detailArg); 0391 protected: 0392 UIEvent(UIEventImpl *impl); 0393 }; 0394 0395 /** 0396 * Introduced in DOM Level 2 0397 * 0398 * The MouseEvent interface provides specific contextual information associated 0399 * with Mouse events. 0400 * 0401 * The detail attribute inherited from UIEvent indicates the number of times a 0402 * mouse button has been pressed and released over the same screen location 0403 * during a user action. The attribute value is 1 when the user begins this 0404 * action and increments by 1 for each full sequence of pressing and releasing. 0405 * If the user moves the mouse between the mousedown and mouseup the value will 0406 * be set to 0, indicating that no click is occurring. 0407 * 0408 * In the case of nested elements mouse events are always targeted at the most 0409 * deeply nested element. Ancestors of the targeted element may use bubbling to 0410 * obtain notification of mouse events which occur within its descendent elements. 0411 * 0412 */ 0413 class KHTML_EXPORT MouseEvent : public UIEvent 0414 { 0415 public: 0416 MouseEvent(); 0417 MouseEvent(const MouseEvent &other); 0418 MouseEvent(const Event &other); 0419 MouseEvent &operator = (const MouseEvent &other); 0420 MouseEvent &operator = (const Event &other); 0421 virtual ~MouseEvent(); 0422 0423 /** 0424 * The horizontal coordinate at which the event occurred relative to the 0425 * origin of the screen coordinate system. 0426 * 0427 */ 0428 long screenX() const; 0429 0430 /** 0431 * The vertical coordinate at which the event occurred relative to the 0432 * origin of the screen coordinate system. 0433 * 0434 */ 0435 long screenY() const; 0436 0437 /** 0438 * The horizontal coordinate at which the event occurred relative to the 0439 * DOM implementation's client area. 0440 * 0441 */ 0442 long clientX() const; 0443 0444 /** 0445 * The vertical coordinate at which the event occurred relative to the DOM 0446 * implementation's client area. 0447 * 0448 */ 0449 long clientY() const; 0450 0451 /** 0452 * Used to indicate whether the 'ctrl' key was depressed during the firing 0453 * of the event. 0454 */ 0455 bool ctrlKey() const; 0456 0457 /** 0458 * Used to indicate whether the 'shift' key was depressed during the firing 0459 * of the event. 0460 * 0461 */ 0462 bool shiftKey() const; 0463 0464 /** 0465 * Used to indicate whether the 'alt' key was depressed during the firing 0466 * of the event. On some platforms this key may map to an alternative key 0467 * name. 0468 * 0469 */ 0470 bool altKey() const; 0471 0472 /** 0473 * Used to indicate whether the 'meta' key was depressed during the firing 0474 * of the event. On some platforms this key may map to an alternative key 0475 * name. 0476 * 0477 */ 0478 bool metaKey() const; 0479 0480 /** 0481 * During mouse events caused by the depression or release of a mouse 0482 * button, button is used to indicate which mouse button changed state. The 0483 * values for button range from zero to indicate the left button of the 0484 * mouse, one to indicate the middle button if present, and two to indicate 0485 * the right button. For mice configured for left handed use in which the 0486 * button actions are reversed the values are instead read from right to 0487 * left. 0488 * 0489 */ 0490 unsigned short button() const; 0491 0492 /** 0493 * Used to identify a secondary EventTarget related to a UI event. 0494 * Currently this attribute is used with the mouseover event to indicate 0495 * the EventTarget which the pointing device exited and with the mouseout 0496 * event to indicate the EventTarget which the pointing device entered. 0497 * 0498 */ 0499 Node relatedTarget() const; 0500 0501 /** 0502 * The initMouseEvent method is used to initialize the value of a 0503 * MouseEvent created through the DocumentEvent interface. This method may 0504 * only be called before the MouseEvent has been dispatched via the 0505 * dispatchEvent method, though it may be called multiple times during that 0506 * phase if necessary. If called multiple times, the final invocation takes 0507 * precedence. Parameters 0508 * 0509 * @param typeArg Specifies the event type. 0510 * 0511 * @param canBubbleArg Specifies whether or not the event can bubble. 0512 * 0513 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 0514 * 0515 * @param viewArg Specifies the Event's AbstractView. 0516 * 0517 * @param detailArg Specifies the Event's mouse click count. 0518 * 0519 * @param screenXArg Specifies the Event's screen x coordinate 0520 * 0521 * @param screenYArg Specifies the Event's screen y coordinate 0522 * 0523 * @param clientXArg Specifies the Event's client x coordinate 0524 * 0525 * @param clientYArg Specifies the Event's client y coordinate 0526 * 0527 * @param ctrlKeyArg Specifies whether or not control key was depressed during the Event. 0528 * 0529 * @param altKeyArg Specifies whether or not alt key was depressed during the Event. 0530 * 0531 * @param shiftKeyArg Specifies whether or not shift key was depressed during the Event. 0532 * 0533 * @param metaKeyArg Specifies whether or not meta key was depressed during the Event. 0534 * 0535 * @param buttonArg Specifies the Event's mouse button. 0536 * 0537 * @param relatedTargetArg Specifies the Event's related EventTarget. 0538 * 0539 */ 0540 void initMouseEvent(const DOMString &typeArg, 0541 bool canBubbleArg, 0542 bool cancelableArg, 0543 const AbstractView &viewArg, 0544 long detailArg, 0545 long screenXArg, 0546 long screenYArg, 0547 long clientXArg, 0548 long clientYArg, 0549 bool ctrlKeyArg, 0550 bool altKeyArg, 0551 bool shiftKeyArg, 0552 bool metaKeyArg, 0553 unsigned short buttonArg, 0554 const Node &relatedTargetArg); 0555 protected: 0556 MouseEvent(MouseEventImpl *impl); 0557 }; 0558 0559 /** 0560 * Introduced in DOM Level 3 0561 * 0562 * DOM::TextEvent is used to indicate actual text entry 0563 * during text input. It corresponds to the HTML keypress events 0564 */ 0565 class KHTML_EXPORT TextEvent : public UIEvent 0566 { 0567 public: 0568 TextEvent(); 0569 TextEvent(const TextEvent &other); 0570 TextEvent(const Event &other); 0571 TextEvent &operator = (const TextEvent &other); 0572 TextEvent &operator = (const Event &other); 0573 virtual ~TextEvent(); 0574 0575 /** 0576 * initTextEvent 0577 * The initTextEvent method is used to initialize the value of a TextEvent 0578 * object and has the same behavior as UIEvent.initUIEvent(). 0579 * The value of UIEvent.detail remains undefined. 0580 * 0581 * Parameters: 0582 * 0583 * Specifies the event type. 0584 * canBubbleArg of type boolean 0585 * Specifies whether or not the event can bubble. 0586 * cancelableArg of type boolean 0587 * Specifies whether or not the event's default action can be prevent. 0588 * viewArg of type views::AbstractView 0589 * Specifies the TextEvent's AbstractView. 0590 * dataArg of type DOMString 0591 * Specifies TextEvent.data. 0592 */ 0593 void initTextEvent(const DOMString &typeArg, 0594 bool canBubbleArg, 0595 bool cancelableArg, 0596 const AbstractView &viewArg, 0597 const DOMString &dataArg); 0598 0599 /** 0600 * data of type DOMString, readonly 0601 * 0602 * data holds the value of the characters generated by the character device. This may be a single Unicode character or a non-empty sequence of Unicode characters [Unicode]. Characters should be normalized as defined by the Unicode normalization form NFC, defined in [UTR #15]. 0603 * Note: while the DOM spec specifies that the string never be empty, 0604 * KHTML can not guarantee that 0605 */ 0606 DOMString data() const; 0607 }; 0608 0609 /** 0610 * Introduced in DOM Level 3 0611 * 0612 * DOM::KeyboardEvent 0613 * The KeyboardEvent interface provides specific contextual information 0614 * associated with keyboard devices. Each keyboard event references a 0615 * key using an identifier. Keyboard events are commonly directed at 0616 * the element that has the focus. 0617 * 0618 * The KeyboardEvent interface provides convenient attributes for some 0619 * common modifiers keys: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey, 0620 * KeyboardEvent.altKey, KeyboardEvent.metaKey. These attributes are 0621 * equivalent to use the method KeyboardEvent.getModifierState(keyIdentifierArg) 0622 * with "Control", "Shift", "Alt", or "Meta" respectively. 0623 * 0624 * To create an instance of the KeyboardEvent interface, use the 0625 * DocumentEvent.createEvent("KeyboardEvent") method call. 0626 */ 0627 class KHTML_EXPORT KeyboardEvent : public UIEvent 0628 { 0629 public: 0630 KeyboardEvent(); 0631 KeyboardEvent(const KeyboardEvent &other); 0632 KeyboardEvent(const Event &other); 0633 KeyboardEvent &operator = (const KeyboardEvent &other); 0634 KeyboardEvent &operator = (const Event &other); 0635 virtual ~KeyboardEvent(); 0636 0637 enum KeyLocation { 0638 /** 0639 The key activation is not distinguished as the left 0640 or right version of the key, and did not originate 0641 from the numeric keypad (or did not originate with a 0642 virtual key corresponding to the numeric keypad). 0643 Example: the 'Q' key on a PC 101 Key US keyboard. 0644 */ 0645 DOM_KEY_LOCATION_STANDARD = 0x00, 0646 0647 /** 0648 The key activated is in the left key location 0649 (there is more than one possible location for this key). 0650 Example: the left Shift key on a PC 101 Key US keyboard. 0651 0652 Note: KHTML currently always considers modifier keys to be on the left 0653 */ 0654 DOM_KEY_LOCATION_LEFT = 0x01, 0655 0656 /** 0657 The key activated is in the right key location 0658 (there is more than one possible location for this key). 0659 Example: the right Shift key on a PC 101 Key US keyboard. 0660 0661 Note: KHTML currently always considers modifier keys to be on the left 0662 */ 0663 DOM_KEY_LOCATION_RIGHT = 0x02, 0664 0665 /** 0666 The key activation originated on the numeric keypad or 0667 with a virtual key corresponding to the numeric keypad. 0668 Example: the '1' key on a PC 101 Key US keyboard located on the numeric pad. 0669 */ 0670 DOM_KEY_LOCATION_NUMPAD = 0x03 0671 }; 0672 0673 /** 0674 * keyIdentifier of type DOMString, readonly 0675 * 0676 * keyIdentifier holds the identifier of the key. The key identifiers 0677 * are defined in Appendix A.2 "Key identifiers set" 0678 * (https://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set) 0679 */ 0680 DOMString keyIdentifier() const; 0681 0682 /** 0683 * keyLocation of type unsigned long, readonly 0684 * 0685 * The keyLocation attribute contains an indication of the location 0686 * of they key on the device. 0687 * See the KeyLocation enum for possible values 0688 */ 0689 unsigned long keyLocation() const; 0690 0691 /** 0692 * ctrlKey of type boolean, readonly 0693 * 0694 * true if the control (Ctrl) key modifier is activated. 0695 */ 0696 bool ctrlKey() const; 0697 0698 /** 0699 * shiftKey of type boolean, readonly 0700 * 0701 * true if the shift (Shift) key modifier is activated. 0702 */ 0703 bool shiftKey() const; 0704 0705 /** 0706 * altKey of type boolean, readonly 0707 * 0708 * true if the alt (Alt) key modifier is activated. 0709 */ 0710 bool altKey() const; 0711 0712 /** 0713 * metaKey of type boolean, readonly 0714 * 0715 * true if the meta (Meta) key modifier is activated. 0716 */ 0717 bool metaKey() const; 0718 0719 /** 0720 * getModifierState 0721 * 0722 * 0723 * This methods queries the state of a modifier using a key identifier 0724 * 0725 * Parameters: 0726 * 0727 * keyIdentifierArg of type DOMString 0728 * A modifier key identifier. Supported modifier keys are "Alt", "Control", "Meta", "Shift". 0729 * 0730 * Return Value 0731 * boolean true if it is modifier key and the modifier is activated, false otherwise. 0732 */ 0733 bool getModifierState(DOMString keyIdentifierArg) const; 0734 0735 /** 0736 * initKeyboardEvent 0737 * 0738 * The initKeyboardEvent method is used to initialize the value of a 0739 * KeyboardEvent object and has the same behavior as UIEvent.initUIEvent(). 0740 * The value of UIEvent.detail remains undefined. 0741 * 0742 * Parameters: 0743 * typeArg of type DOMString 0744 * Specifies the event type. 0745 * canBubbleArg of type boolean 0746 * Specifies whether or not the event can bubble. 0747 * cancelableArg of type boolean 0748 * Specifies whether or not the event's default action can be prevent. 0749 * viewArg of type views::AbstractView 0750 * Specifies the TextEvent's AbstractView. 0751 * keyIdentifierArg of type DOMString 0752 * Specifies KeyboardEvent.keyIdentifier. 0753 * keyLocationArg of type unsigned long 0754 * Specifies KeyboardEvent.keyLocation. 0755 * modifiersList of type DOMString 0756 * A white space separated list of modifier key identifiers to be activated on this object. 0757 */ 0758 void initKeyboardEvent(DOMString typeArg, 0759 bool canBubbleArg, 0760 bool cancelableArg, 0761 AbstractView viewArg, 0762 DOMString keyIdentifierArg, 0763 unsigned long keyLocationArg, 0764 DOMString modifiersList); 0765 }; 0766 0767 /** 0768 * Introduced in DOM Level 2 0769 * 0770 * The MutationEvent interface provides specific contextual information 0771 * associated with Mutation events. 0772 * 0773 */ 0774 class KHTML_EXPORT MutationEvent : public Event 0775 { 0776 public: 0777 MutationEvent(); 0778 MutationEvent(const MutationEvent &other); 0779 MutationEvent(const Event &other); 0780 MutationEvent &operator = (const MutationEvent &other); 0781 MutationEvent &operator = (const Event &other); 0782 virtual ~MutationEvent(); 0783 0784 /** 0785 * An integer indicating in which way the Attr was changed. 0786 * 0787 * ADDITION: The Attr was just added. 0788 * 0789 * MODIFICATION: The Attr was modified in place. 0790 * 0791 * REMOVAL: The Attr was just removed. 0792 * 0793 */ 0794 enum attrChangeType { 0795 MODIFICATION = 1, 0796 ADDITION = 2, 0797 REMOVAL = 3 0798 }; 0799 0800 /** 0801 * relatedNode is used to identify a secondary node related to a mutation 0802 * event. For example, if a mutation event is dispatched to a node 0803 * indicating that its parent has changed, the relatedNode is the changed 0804 * parent. If an event is instead dispatched to a subtree indicating a node 0805 * was changed within it, the relatedNode is the changed node. In the case 0806 * of the DOMAttrModified event it indicates the Attr node which was 0807 * modified, added, or removed. 0808 * 0809 */ 0810 Node relatedNode() const; 0811 0812 /** 0813 * prevValue indicates the previous value of the Attr node in 0814 * DOMAttrModified events, and of the CharacterData node in 0815 * DOMCharDataModified events. 0816 * 0817 */ 0818 DOMString prevValue() const; 0819 0820 /** 0821 * newValue indicates the new value of the Attr node in DOMAttrModified 0822 * events, and of the CharacterData node in DOMCharDataModified events. 0823 * 0824 */ 0825 DOMString newValue() const; 0826 0827 /** 0828 * attrName indicates the name of the changed Attr node in a 0829 * DOMAttrModified event. 0830 * 0831 */ 0832 DOMString attrName() const; 0833 0834 /** 0835 * attrChange indicates the type of change which triggered the 0836 * DOMAttrModified event. The values can be MODIFICATION, ADDITION, or 0837 * REMOVAL. 0838 * 0839 */ 0840 unsigned short attrChange() const; 0841 0842 /** 0843 * The initMutationEvent method is used to initialize the value of a 0844 * MutationEvent created through the DocumentEvent interface. This method 0845 * may only be called before the MutationEvent has been dispatched via the 0846 * dispatchEvent method, though it may be called multiple times during that 0847 * phase if necessary. If called multiple times, the final invocation takes 0848 * precedence. 0849 * 0850 * @param typeArg Specifies the event type. 0851 * 0852 * @param canBubbleArg Specifies whether or not the event can bubble. 0853 * 0854 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 0855 * 0856 * @param relatedNodeArg Specifies the Event's related Node. 0857 * 0858 * @param prevValueArg Specifies the Event's prevValue attribute. This value may be null. 0859 * 0860 * @param newValueArg Specifies the Event's newValue attribute. This value may be null. 0861 * 0862 * @param attrNameArg Specifies the Event's attrName attribute. This value may be null. 0863 * 0864 * @param attrChangeArg Specifies the Event's attrChange attribute 0865 * 0866 */ 0867 void initMutationEvent(const DOMString &typeArg, 0868 bool canBubbleArg, 0869 bool cancelableArg, 0870 const Node &relatedNodeArg, 0871 const DOMString &prevValueArg, 0872 const DOMString &newValueArg, 0873 const DOMString &attrNameArg, 0874 unsigned short attrChangeArg); 0875 protected: 0876 MutationEvent(MutationEventImpl *impl); 0877 }; 0878 0879 } //namespace 0880 #endif