1 /* 2 * This file is part of the DOM implementation for KDE. 3 * 4 * Copyright 2001 Peter Kelly (pmk@post.com) 5 * Copyright 2003 Apple Computer, Inc. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Library General Public 9 * License as published by the Free Software Foundation; either 10 * version 2 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Library General Public License for more details. 16 * 17 * You should have received a copy of the GNU Library General Public License 18 * along with this library; see the file COPYING.LIB. If not, write to 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 * Boston, MA 02110-1301, USA. 21 * 22 * This file includes excerpts from the Document Object Model (DOM) 23 * Level 3 Events Specification (Working Group Note 07 November 2003) 24 * https://www.w3.org/TR/DOM-Level-3-Events/ 25 * Copyright © 2003 World Wide Web Consortium , (Massachusetts Institute of 26 * Technology, European Research Consortium for Informatics and Mathematics, 27 * Keio University ). All Rights Reserved. 28 * 29 */ 30 31 #ifndef _DOM_Events_h_ 32 #define _DOM_Events_h_ 33 34 #include <dom/dom_node.h> 35 #include <dom/dom_misc.h> 36 37 namespace DOM 38 { 39 40 class Event; 41 class EventException; 42 class UIEvent; 43 class MouseEvent; 44 class TextEvent; 45 class MutationEvent; 46 class AbstractView; 47 48 class EventListenerImpl; 49 class EventImpl; 50 class UIEventImpl; 51 class MouseEventImpl; 52 class MutationEventImpl; 53 54 /** 55 * Introduced in DOM Level 2 56 * 57 * The EventListener interface is the primary method for handling events. 58 * Users implement the EventListener interface and register their listener on 59 * an EventTarget using the AddEventListener method. The users should also 60 * remove their EventListener from its EventTarget after they have completed 61 * using the listener. 62 * 63 * When a Node is copied using the cloneNode method the EventListeners attached 64 * to the source Node are not attached to the copied Node. If the user wishes 65 * the same EventListeners to be added to the newly created copy the user must 66 * add them manually. 67 * 68 */ 69 class KHTML_EXPORT EventListener : public DomShared 70 { 71 public: 72 EventListener(); 73 virtual ~EventListener(); 74 75 /** 76 * This method is called whenever an event occurs of the type for which the 77 * EventListener interface was registered. Parameters 78 * 79 * @param evt The Event contains contextual information about the event. It 80 * also contains the stopPropagation and preventDefault methods which are 81 * used in determining the event's flow and default action. 82 * 83 */ 84 virtual void handleEvent(Event &evt); 85 86 /** 87 * @internal 88 * not part of the DOM 89 * 90 * Returns a name specifying the type of listener. Useful for checking 91 * if an event is of a particular sublass. 92 * 93 */ 94 virtual DOMString eventListenerType(); 95 96 protected: 97 /** 98 * @internal 99 * Reserved. Do not use in your subclasses. 100 */ 101 EventListenerImpl *impl; 102 }; 103 104 /** 105 * Introduced in DOM Level 2 106 * 107 * The Event interface is used to provide contextual information about an event 108 * to the handler processing the event. An object which implements the Event 109 * interface is generally passed as the first parameter to an event handler. 110 * More specific context information is passed to event handlers by deriving 111 * additional interfaces from Event which contain information directly relating 112 * to the type of event they accompany. These derived interfaces are also 113 * implemented by the object passed to the event listener. 114 * 115 */ 116 class KHTML_EXPORT Event 117 { 118 friend class Document; 119 friend class NodeImpl; 120 friend class DocumentImpl; 121 public: 122 Event(); 123 Event(const Event &other); 124 virtual ~Event(); 125 126 Event &operator = (const Event &other); 127 128 /** 129 * An integer indicating which phase of event flow is being processed. 130 * 131 * AT_TARGET: The event is currently being evaluated at the target 132 * EventTarget. 133 * 134 * BUBBLING_PHASE: The current event phase is the bubbling phase. 135 * 136 * CAPTURING_PHASE: The current event phase is the capturing phase. 137 * 138 */ 139 enum PhaseType { 140 CAPTURING_PHASE = 1, 141 AT_TARGET = 2, 142 BUBBLING_PHASE = 3 143 }; 144 145 /** 146 * The name of the event (case-insensitive). The name must be an XML name. 147 * 148 */ 149 DOMString type() const; 150 151 /** 152 * Used to indicate the EventTarget to which the event was originally 153 * dispatched. 154 * 155 */ 156 Node target() const; 157 158 /** 159 * Used to indicate the EventTarget whose EventListeners are currently 160 * being processed. This is particularly useful during capturing and 161 * bubbling. 162 * 163 */ 164 Node currentTarget() const; 165 166 /** 167 * Used to indicate which phase of event flow is currently being evaluated. 168 * 169 */ 170 unsigned short eventPhase() const; 171 172 /** 173 * Used to indicate whether or not an event is a bubbling event. If the 174 * event can bubble the value is true, else the value is false. 175 * 176 */ 177 bool bubbles() const; 178 179 /** 180 * Used to indicate whether or not an event can have its default action 181 * prevented. If the default action can be prevented the value is true, 182 * else the value is false. 183 * 184 */ 185 bool cancelable() const; 186 187 /** 188 * Used to specify the time (in milliseconds relative to the epoch) at 189 * which the event was created. Due to the fact that some systems may not 190 * provide this information the value of timeStamp may be not available for 191 * all events. When not available, a value of 0 will be returned. Examples 192 * of epoch time are the time of the system start or 0:0:0 UTC 1st January 1970. 193 * 194 */ 195 DOMTimeStamp timeStamp() const; 196 197 /** 198 * The stopPropagation method is used prevent further propagation of an 199 * event during event flow. If this method is called by any EventListener 200 * the event will cease propagating through the tree. The event will 201 * complete dispatch to all listeners on the current EventTarget before 202 * event flow stops. This method may be used during any stage of event flow. 203 * 204 */ 205 void stopPropagation(); 206 207 /** 208 * If an event is cancelable, the preventDefault method is used to signify 209 * that the event is to be canceled, meaning any default action normally 210 * taken by the implementation as a result of the event will not occur. If, 211 * during any stage of event flow, the preventDefault method is called the 212 * event is canceled. Any default action associated with the event will not 213 * occur. Calling this method for a non-cancelable event has no effect. 214 * Once preventDefault has been called it will remain in effect throughout 215 * the remainder of the event's propagation. This method may be used during 216 * any stage of event flow. 217 * 218 */ 219 void preventDefault(); 220 221 /** 222 * The initEvent method is used to initialize the value of an Event created 223 * through the DocumentEvent interface. This method may only be called 224 * before the Event has been dispatched via the dispatchEvent method, 225 * though it may be called multiple times during that phase if necessary. 226 * If called multiple times the final invocation takes precedence. If 227 * called from a subclass of Event interface only the values specified in 228 * the initEvent method are modified, all other attributes are left 229 * unchanged. 230 * 231 * @param eventTypeArg Specifies the event type. This type may be any event 232 * type currently defined in this specification or a new event type.. The 233 * string must be an XML name. 234 * 235 * Any new event type must not begin with any upper, lower, or mixed case 236 * version of the string "DOM". This prefix is reserved for future DOM 237 * event sets. It is also strongly recommended that third parties adding 238 * their own events use their own prefix to avoid confusion and lessen the 239 * probability of conflicts with other new events. 240 * 241 * @param canBubbleArg Specifies whether or not the event can bubble. 242 * 243 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 244 * 245 */ 246 void initEvent(const DOMString &eventTypeArg, bool canBubbleArg, bool cancelableArg); 247 248 /** 249 * @internal 250 * not part of the DOM 251 */ 252 EventImpl *handle() const; 253 bool isNull() const; 254 255 Event(EventImpl *i); 256 protected: 257 EventImpl *impl; 258 }; 259 260 /** 261 * Introduced in DOM Level 2: 262 * 263 * Event operations may throw an EventException as specified in their method 264 * descriptions. 265 * 266 */ 267 class KHTML_EXPORT EventException 268 { 269 public: 270 EventException(unsigned short _code); 271 EventException(const EventException &other); 272 EventException &operator = (const EventException &other); ~EventException()273 virtual ~EventException() {} 274 275 /** 276 * An integer indicating the type of error generated. 277 * 278 * UNSPECIFIED_EVENT_TYPE_ERR: If the Event's type was not specified by 279 * initializing the event before the method was called. Specification of 280 * the Event's type as null or an empty string will also trigger this 281 * exception. 282 * 283 */ 284 enum EventExceptionCode { 285 UNSPECIFIED_EVENT_TYPE_ERR = 0, 286 _EXCEPTION_OFFSET = 3000, 287 _EXCEPTION_MAX = 3999 288 }; 289 290 unsigned short code; 291 292 /// Returns the name of this error 293 DOMString codeAsString() const; 294 295 /// Returns the name of given error code 296 static DOMString codeAsString(int cssCode); 297 298 /** @internal - checks to see whether internal code is an event one */ 299 static bool isEventExceptionCode(int exceptioncode); 300 301 }; 302 303 /** 304 * Introduced in DOM Level 2 305 * 306 * The UIEvent interface provides specific contextual information associated 307 * with User Interface events. 308 * 309 */ 310 class KHTML_EXPORT UIEvent : public Event 311 { 312 public: 313 UIEvent(); 314 UIEvent(const UIEvent &other); 315 UIEvent(const Event &other); 316 UIEvent &operator = (const UIEvent &other); 317 UIEvent &operator = (const Event &other); 318 virtual ~UIEvent(); 319 320 /** 321 * The view attribute identifies the AbstractView from which the event was 322 * generated. 323 * 324 */ 325 AbstractView view() const; 326 327 /** 328 * Specifies some detail information about the Event, depending on the type 329 * of event. 330 * 331 */ 332 long detail() const; 333 334 /** 335 * Non-standard extension to support IE-style keyCode event property. 336 * 337 */ 338 int keyCode() const; 339 340 /** 341 * Non-standard extension to support IE-style charCode event property. 342 * 343 */ 344 int charCode() const; 345 346 /** 347 * Non-standard extensions to support Netscape-style pageX and pageY event properties. 348 * 349 */ 350 int pageX() const; 351 int pageY() const; 352 353 /** 354 * Non-standard extensions to support Netscape-style layerX and layerY event properties. 355 * 356 */ 357 int layerX() const; 358 int layerY() const; 359 360 /** 361 * Non-standard extension to support Netscape-style "which" event property. 362 * 363 */ 364 int which() const; 365 366 /** 367 * The initUIEvent method is used to initialize the value of a UIEvent 368 * created through the DocumentEvent interface. This method may only be 369 * called before the UIEvent has been dispatched via the dispatchEvent 370 * method, though it may be called multiple times during that phase if 371 * necessary. If called multiple times, the final invocation takes 372 * precedence. 373 * 374 * @param typeArg Specifies the event type. 375 * 376 * @param canBubbleArg Specifies whether or not the event can bubble. 377 * 378 * @param cancelableArg Specifies whether or not the event's default action 379 * can be prevented. 380 * 381 * @param viewArg Specifies the Event's AbstractView. 382 * 383 * @param detailArg Specifies the Event's detail. 384 * 385 */ 386 void initUIEvent(const DOMString &typeArg, 387 bool canBubbleArg, 388 bool cancelableArg, 389 const AbstractView &viewArg, 390 long detailArg); 391 protected: 392 UIEvent(UIEventImpl *impl); 393 }; 394 395 /** 396 * Introduced in DOM Level 2 397 * 398 * The MouseEvent interface provides specific contextual information associated 399 * with Mouse events. 400 * 401 * The detail attribute inherited from UIEvent indicates the number of times a 402 * mouse button has been pressed and released over the same screen location 403 * during a user action. The attribute value is 1 when the user begins this 404 * action and increments by 1 for each full sequence of pressing and releasing. 405 * If the user moves the mouse between the mousedown and mouseup the value will 406 * be set to 0, indicating that no click is occurring. 407 * 408 * In the case of nested elements mouse events are always targeted at the most 409 * deeply nested element. Ancestors of the targeted element may use bubbling to 410 * obtain notification of mouse events which occur within its descendent elements. 411 * 412 */ 413 class KHTML_EXPORT MouseEvent : public UIEvent 414 { 415 public: 416 MouseEvent(); 417 MouseEvent(const MouseEvent &other); 418 MouseEvent(const Event &other); 419 MouseEvent &operator = (const MouseEvent &other); 420 MouseEvent &operator = (const Event &other); 421 virtual ~MouseEvent(); 422 423 /** 424 * The horizontal coordinate at which the event occurred relative to the 425 * origin of the screen coordinate system. 426 * 427 */ 428 long screenX() const; 429 430 /** 431 * The vertical coordinate at which the event occurred relative to the 432 * origin of the screen coordinate system. 433 * 434 */ 435 long screenY() const; 436 437 /** 438 * The horizontal coordinate at which the event occurred relative to the 439 * DOM implementation's client area. 440 * 441 */ 442 long clientX() const; 443 444 /** 445 * The vertical coordinate at which the event occurred relative to the DOM 446 * implementation's client area. 447 * 448 */ 449 long clientY() const; 450 451 /** 452 * Used to indicate whether the 'ctrl' key was depressed during the firing 453 * of the event. 454 */ 455 bool ctrlKey() const; 456 457 /** 458 * Used to indicate whether the 'shift' key was depressed during the firing 459 * of the event. 460 * 461 */ 462 bool shiftKey() const; 463 464 /** 465 * Used to indicate whether the 'alt' key was depressed during the firing 466 * of the event. On some platforms this key may map to an alternative key 467 * name. 468 * 469 */ 470 bool altKey() const; 471 472 /** 473 * Used to indicate whether the 'meta' key was depressed during the firing 474 * of the event. On some platforms this key may map to an alternative key 475 * name. 476 * 477 */ 478 bool metaKey() const; 479 480 /** 481 * During mouse events caused by the depression or release of a mouse 482 * button, button is used to indicate which mouse button changed state. The 483 * values for button range from zero to indicate the left button of the 484 * mouse, one to indicate the middle button if present, and two to indicate 485 * the right button. For mice configured for left handed use in which the 486 * button actions are reversed the values are instead read from right to 487 * left. 488 * 489 */ 490 unsigned short button() const; 491 492 /** 493 * Used to identify a secondary EventTarget related to a UI event. 494 * Currently this attribute is used with the mouseover event to indicate 495 * the EventTarget which the pointing device exited and with the mouseout 496 * event to indicate the EventTarget which the pointing device entered. 497 * 498 */ 499 Node relatedTarget() const; 500 501 /** 502 * The initMouseEvent method is used to initialize the value of a 503 * MouseEvent created through the DocumentEvent interface. This method may 504 * only be called before the MouseEvent has been dispatched via the 505 * dispatchEvent method, though it may be called multiple times during that 506 * phase if necessary. If called multiple times, the final invocation takes 507 * precedence. Parameters 508 * 509 * @param typeArg Specifies the event type. 510 * 511 * @param canBubbleArg Specifies whether or not the event can bubble. 512 * 513 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 514 * 515 * @param viewArg Specifies the Event's AbstractView. 516 * 517 * @param detailArg Specifies the Event's mouse click count. 518 * 519 * @param screenXArg Specifies the Event's screen x coordinate 520 * 521 * @param screenYArg Specifies the Event's screen y coordinate 522 * 523 * @param clientXArg Specifies the Event's client x coordinate 524 * 525 * @param clientYArg Specifies the Event's client y coordinate 526 * 527 * @param ctrlKeyArg Specifies whether or not control key was depressed during the Event. 528 * 529 * @param altKeyArg Specifies whether or not alt key was depressed during the Event. 530 * 531 * @param shiftKeyArg Specifies whether or not shift key was depressed during the Event. 532 * 533 * @param metaKeyArg Specifies whether or not meta key was depressed during the Event. 534 * 535 * @param buttonArg Specifies the Event's mouse button. 536 * 537 * @param relatedTargetArg Specifies the Event's related EventTarget. 538 * 539 */ 540 void initMouseEvent(const DOMString &typeArg, 541 bool canBubbleArg, 542 bool cancelableArg, 543 const AbstractView &viewArg, 544 long detailArg, 545 long screenXArg, 546 long screenYArg, 547 long clientXArg, 548 long clientYArg, 549 bool ctrlKeyArg, 550 bool altKeyArg, 551 bool shiftKeyArg, 552 bool metaKeyArg, 553 unsigned short buttonArg, 554 const Node &relatedTargetArg); 555 protected: 556 MouseEvent(MouseEventImpl *impl); 557 }; 558 559 /** 560 * Introduced in DOM Level 3 561 * 562 * DOM::TextEvent is used to indicate actual text entry 563 * during text input. It corresponds to the HTML keypress events 564 */ 565 class KHTML_EXPORT TextEvent : public UIEvent 566 { 567 public: 568 TextEvent(); 569 TextEvent(const TextEvent &other); 570 TextEvent(const Event &other); 571 TextEvent &operator = (const TextEvent &other); 572 TextEvent &operator = (const Event &other); 573 virtual ~TextEvent(); 574 575 /** 576 * initTextEvent 577 * The initTextEvent method is used to initialize the value of a TextEvent 578 * object and has the same behavior as UIEvent.initUIEvent(). 579 * The value of UIEvent.detail remains undefined. 580 * 581 * Parameters: 582 * 583 * Specifies the event type. 584 * canBubbleArg of type boolean 585 * Specifies whether or not the event can bubble. 586 * cancelableArg of type boolean 587 * Specifies whether or not the event's default action can be prevent. 588 * viewArg of type views::AbstractView 589 * Specifies the TextEvent's AbstractView. 590 * dataArg of type DOMString 591 * Specifies TextEvent.data. 592 */ 593 void initTextEvent(const DOMString &typeArg, 594 bool canBubbleArg, 595 bool cancelableArg, 596 const AbstractView &viewArg, 597 const DOMString &dataArg); 598 599 /** 600 * data of type DOMString, readonly 601 * 602 * 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]. 603 * Note: while the DOM spec specifies that the string never be empty, 604 * KHTML can not guarantee that 605 */ 606 DOMString data() const; 607 }; 608 609 /** 610 * Introduced in DOM Level 3 611 * 612 * DOM::KeyboardEvent 613 * The KeyboardEvent interface provides specific contextual information 614 * associated with keyboard devices. Each keyboard event references a 615 * key using an identifier. Keyboard events are commonly directed at 616 * the element that has the focus. 617 * 618 * The KeyboardEvent interface provides convenient attributes for some 619 * common modifiers keys: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey, 620 * KeyboardEvent.altKey, KeyboardEvent.metaKey. These attributes are 621 * equivalent to use the method KeyboardEvent.getModifierState(keyIdentifierArg) 622 * with "Control", "Shift", "Alt", or "Meta" respectively. 623 * 624 * To create an instance of the KeyboardEvent interface, use the 625 * DocumentEvent.createEvent("KeyboardEvent") method call. 626 */ 627 class KHTML_EXPORT KeyboardEvent : public UIEvent 628 { 629 public: 630 KeyboardEvent(); 631 KeyboardEvent(const KeyboardEvent &other); 632 KeyboardEvent(const Event &other); 633 KeyboardEvent &operator = (const KeyboardEvent &other); 634 KeyboardEvent &operator = (const Event &other); 635 virtual ~KeyboardEvent(); 636 637 enum KeyLocation { 638 /** 639 The key activation is not distinguished as the left 640 or right version of the key, and did not originate 641 from the numeric keypad (or did not originate with a 642 virtual key corresponding to the numeric keypad). 643 Example: the 'Q' key on a PC 101 Key US keyboard. 644 */ 645 DOM_KEY_LOCATION_STANDARD = 0x00, 646 647 /** 648 The key activated is in the left key location 649 (there is more than one possible location for this key). 650 Example: the left Shift key on a PC 101 Key US keyboard. 651 652 Note: KHTML currently always considers modifier keys to be on the left 653 */ 654 DOM_KEY_LOCATION_LEFT = 0x01, 655 656 /** 657 The key activated is in the right key location 658 (there is more than one possible location for this key). 659 Example: the right Shift key on a PC 101 Key US keyboard. 660 661 Note: KHTML currently always considers modifier keys to be on the left 662 */ 663 DOM_KEY_LOCATION_RIGHT = 0x02, 664 665 /** 666 The key activation originated on the numeric keypad or 667 with a virtual key corresponding to the numeric keypad. 668 Example: the '1' key on a PC 101 Key US keyboard located on the numeric pad. 669 */ 670 DOM_KEY_LOCATION_NUMPAD = 0x03 671 }; 672 673 /** 674 * keyIdentifier of type DOMString, readonly 675 * 676 * keyIdentifier holds the identifier of the key. The key identifiers 677 * are defined in Appendix A.2 "Key identifiers set" 678 * (https://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set) 679 */ 680 DOMString keyIdentifier() const; 681 682 /** 683 * keyLocation of type unsigned long, readonly 684 * 685 * The keyLocation attribute contains an indication of the location 686 * of they key on the device. 687 * See the KeyLocation enum for possible values 688 */ 689 unsigned long keyLocation() const; 690 691 /** 692 * ctrlKey of type boolean, readonly 693 * 694 * true if the control (Ctrl) key modifier is activated. 695 */ 696 bool ctrlKey() const; 697 698 /** 699 * shiftKey of type boolean, readonly 700 * 701 * true if the shift (Shift) key modifier is activated. 702 */ 703 bool shiftKey() const; 704 705 /** 706 * altKey of type boolean, readonly 707 * 708 * true if the alt (Alt) key modifier is activated. 709 */ 710 bool altKey() const; 711 712 /** 713 * metaKey of type boolean, readonly 714 * 715 * true if the meta (Meta) key modifier is activated. 716 */ 717 bool metaKey() const; 718 719 /** 720 * getModifierState 721 * 722 * 723 * This methods queries the state of a modifier using a key identifier 724 * 725 * Parameters: 726 * 727 * keyIdentifierArg of type DOMString 728 * A modifier key identifier. Supported modifier keys are "Alt", "Control", "Meta", "Shift". 729 * 730 * Return Value 731 * boolean true if it is modifier key and the modifier is activated, false otherwise. 732 */ 733 bool getModifierState(DOMString keyIdentifierArg) const; 734 735 /** 736 * initKeyboardEvent 737 * 738 * The initKeyboardEvent method is used to initialize the value of a 739 * KeyboardEvent object and has the same behavior as UIEvent.initUIEvent(). 740 * The value of UIEvent.detail remains undefined. 741 * 742 * Parameters: 743 * typeArg of type DOMString 744 * Specifies the event type. 745 * canBubbleArg of type boolean 746 * Specifies whether or not the event can bubble. 747 * cancelableArg of type boolean 748 * Specifies whether or not the event's default action can be prevent. 749 * viewArg of type views::AbstractView 750 * Specifies the TextEvent's AbstractView. 751 * keyIdentifierArg of type DOMString 752 * Specifies KeyboardEvent.keyIdentifier. 753 * keyLocationArg of type unsigned long 754 * Specifies KeyboardEvent.keyLocation. 755 * modifiersList of type DOMString 756 * A white space separated list of modifier key identifiers to be activated on this object. 757 */ 758 void initKeyboardEvent(DOMString typeArg, 759 bool canBubbleArg, 760 bool cancelableArg, 761 AbstractView viewArg, 762 DOMString keyIdentifierArg, 763 unsigned long keyLocationArg, 764 DOMString modifiersList); 765 }; 766 767 /** 768 * Introduced in DOM Level 2 769 * 770 * The MutationEvent interface provides specific contextual information 771 * associated with Mutation events. 772 * 773 */ 774 class KHTML_EXPORT MutationEvent : public Event 775 { 776 public: 777 MutationEvent(); 778 MutationEvent(const MutationEvent &other); 779 MutationEvent(const Event &other); 780 MutationEvent &operator = (const MutationEvent &other); 781 MutationEvent &operator = (const Event &other); 782 virtual ~MutationEvent(); 783 784 /** 785 * An integer indicating in which way the Attr was changed. 786 * 787 * ADDITION: The Attr was just added. 788 * 789 * MODIFICATION: The Attr was modified in place. 790 * 791 * REMOVAL: The Attr was just removed. 792 * 793 */ 794 enum attrChangeType { 795 MODIFICATION = 1, 796 ADDITION = 2, 797 REMOVAL = 3 798 }; 799 800 /** 801 * relatedNode is used to identify a secondary node related to a mutation 802 * event. For example, if a mutation event is dispatched to a node 803 * indicating that its parent has changed, the relatedNode is the changed 804 * parent. If an event is instead dispatched to a subtree indicating a node 805 * was changed within it, the relatedNode is the changed node. In the case 806 * of the DOMAttrModified event it indicates the Attr node which was 807 * modified, added, or removed. 808 * 809 */ 810 Node relatedNode() const; 811 812 /** 813 * prevValue indicates the previous value of the Attr node in 814 * DOMAttrModified events, and of the CharacterData node in 815 * DOMCharDataModified events. 816 * 817 */ 818 DOMString prevValue() const; 819 820 /** 821 * newValue indicates the new value of the Attr node in DOMAttrModified 822 * events, and of the CharacterData node in DOMCharDataModified events. 823 * 824 */ 825 DOMString newValue() const; 826 827 /** 828 * attrName indicates the name of the changed Attr node in a 829 * DOMAttrModified event. 830 * 831 */ 832 DOMString attrName() const; 833 834 /** 835 * attrChange indicates the type of change which triggered the 836 * DOMAttrModified event. The values can be MODIFICATION, ADDITION, or 837 * REMOVAL. 838 * 839 */ 840 unsigned short attrChange() const; 841 842 /** 843 * The initMutationEvent method is used to initialize the value of a 844 * MutationEvent created through the DocumentEvent interface. This method 845 * may only be called before the MutationEvent has been dispatched via the 846 * dispatchEvent method, though it may be called multiple times during that 847 * phase if necessary. If called multiple times, the final invocation takes 848 * precedence. 849 * 850 * @param typeArg Specifies the event type. 851 * 852 * @param canBubbleArg Specifies whether or not the event can bubble. 853 * 854 * @param cancelableArg Specifies whether or not the event's default action can be prevented. 855 * 856 * @param relatedNodeArg Specifies the Event's related Node. 857 * 858 * @param prevValueArg Specifies the Event's prevValue attribute. This value may be null. 859 * 860 * @param newValueArg Specifies the Event's newValue attribute. This value may be null. 861 * 862 * @param attrNameArg Specifies the Event's attrName attribute. This value may be null. 863 * 864 * @param attrChangeArg Specifies the Event's attrChange attribute 865 * 866 */ 867 void initMutationEvent(const DOMString &typeArg, 868 bool canBubbleArg, 869 bool cancelableArg, 870 const Node &relatedNodeArg, 871 const DOMString &prevValueArg, 872 const DOMString &newValueArg, 873 const DOMString &attrNameArg, 874 unsigned short attrChangeArg); 875 protected: 876 MutationEvent(MutationEventImpl *impl); 877 }; 878 879 } //namespace 880 #endif 881