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 * http://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
37namespace DOM {
38
39class Event;
40class EventException;
41class UIEvent;
42class MouseEvent;
43class TextEvent;
44class MutationEvent;
45class AbstractView;
46
47class EventListenerImpl;
48class EventImpl;
49class UIEventImpl;
50class MouseEventImpl;
51class MutationEventImpl;
52
53
54
55/**
56 * Introduced in DOM Level 2
57 *
58 * The EventListener interface is the primary method for handling events.
59 * Users implement the EventListener interface and register their listener on
60 * an EventTarget using the AddEventListener method. The users should also
61 * remove their EventListener from its EventTarget after they have completed
62 * using the listener.
63 *
64 * When a Node is copied using the cloneNode method the EventListeners attached
65 * to the source Node are not attached to the copied Node. If the user wishes
66 * the same EventListeners to be added to the newly created copy the user must
67 * add them manually.
68 *
69 */
70class KHTML_EXPORT EventListener : public DomShared {
71public:
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
96protected:
97 /**
98 * @internal
99 * Reserved. Do not use in your subclasses.
100 */
101 EventListenerImpl *impl;
102};
103
104
105/**
106 * Introduced in DOM Level 2
107 *
108 * The Event interface is used to provide contextual information about an event
109 * to the handler processing the event. An object which implements the Event
110 * interface is generally passed as the first parameter to an event handler.
111 * More specific context information is passed to event handlers by deriving
112 * additional interfaces from Event which contain information directly relating
113 * to the type of event they accompany. These derived interfaces are also
114 * implemented by the object passed to the event listener.
115 *
116 */
117class KHTML_EXPORT Event {
118 friend class Document;
119 friend class NodeImpl;
120 friend class DocumentImpl;
121public:
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);
256protected:
257 EventImpl *impl;
258};
259
260
261/**
262 * Introduced in DOM Level 2:
263 *
264 * Event operations may throw an EventException as specified in their method
265 * descriptions.
266 *
267 */
268class KHTML_EXPORT EventException
269{
270public:
271 EventException(unsigned short _code);
272 EventException(const EventException &other);
273 EventException & operator = (const EventException &other);
274 virtual ~EventException() {}
275
276 /**
277 * An integer indicating the type of error generated.
278 *
279 * UNSPECIFIED_EVENT_TYPE_ERR: If the Event's type was not specified by
280 * initializing the event before the method was called. Specification of
281 * the Event's type as null or an empty string will also trigger this
282 * exception.
283 *
284 */
285 enum EventExceptionCode {
286 UNSPECIFIED_EVENT_TYPE_ERR = 0,
287 _EXCEPTION_OFFSET = 3000,
288 _EXCEPTION_MAX = 3999
289 };
290
291 unsigned short code;
292
293 /// Returns the name of this error
294 DOMString codeAsString() const;
295
296 /// Returns the name of given error code
297 static DOMString codeAsString(int cssCode);
298
299 /** @internal - checks to see whether internal code is an event one */
300 static bool isEventExceptionCode(int exceptioncode);
301
302};
303
304
305/**
306 * Introduced in DOM Level 2
307 *
308 * The UIEvent interface provides specific contextual information associated
309 * with User Interface events.
310 *
311 */
312class KHTML_EXPORT UIEvent : public Event {
313public:
314 UIEvent();
315 UIEvent(const UIEvent &other);
316 UIEvent(const Event &other);
317 UIEvent & operator = (const UIEvent &other);
318 UIEvent & operator = (const Event &other);
319 virtual ~UIEvent();
320
321 /**
322 * The view attribute identifies the AbstractView from which the event was
323 * generated.
324 *
325 */
326 AbstractView view() const;
327
328 /**
329 * Specifies some detail information about the Event, depending on the type
330 * of event.
331 *
332 */
333 long detail() const;
334
335 /**
336 * Non-standard extension to support IE-style keyCode event property.
337 *
338 */
339 int keyCode() const;
340
341 /**
342 * Non-standard extension to support IE-style charCode event property.
343 *
344 */
345 int charCode() const;
346
347 /**
348 * Non-standard extensions to support Netscape-style pageX and pageY event properties.
349 *
350 */
351 int pageX() const;
352 int pageY() const;
353
354 /**
355 * Non-standard extensions to support Netscape-style layerX and layerY event properties.
356 *
357 */
358 int layerX() const;
359 int layerY() const;
360
361 /**
362 * Non-standard extension to support Netscape-style "which" event property.
363 *
364 */
365 int which() const;
366
367 /**
368 * The initUIEvent method is used to initialize the value of a UIEvent
369 * created through the DocumentEvent interface. This method may only be
370 * called before the UIEvent has been dispatched via the dispatchEvent
371 * method, though it may be called multiple times during that phase if
372 * necessary. If called multiple times, the final invocation takes
373 * precedence.
374 *
375 * @param typeArg Specifies the event type.
376 *
377 * @param canBubbleArg Specifies whether or not the event can bubble.
378 *
379 * @param cancelableArg Specifies whether or not the event's default action
380 * can be prevented.
381 *
382 * @param viewArg Specifies the Event's AbstractView.
383 *
384 * @param detailArg Specifies the Event's detail.
385 *
386 */
387 void initUIEvent(const DOMString &typeArg,
388 bool canBubbleArg,
389 bool cancelableArg,
390 const AbstractView &viewArg,
391 long detailArg);
392protected:
393 UIEvent(UIEventImpl *impl);
394};
395
396
397
398
399/**
400 * Introduced in DOM Level 2
401 *
402 * The MouseEvent interface provides specific contextual information associated
403 * with Mouse events.
404 *
405 * The detail attribute inherited from UIEvent indicates the number of times a
406 * mouse button has been pressed and released over the same screen location
407 * during a user action. The attribute value is 1 when the user begins this
408 * action and increments by 1 for each full sequence of pressing and releasing.
409 * If the user moves the mouse between the mousedown and mouseup the value will
410 * be set to 0, indicating that no click is occurring.
411 *
412 * In the case of nested elements mouse events are always targeted at the most
413 * deeply nested element. Ancestors of the targeted element may use bubbling to
414 * obtain notification of mouse events which occur within its descendent elements.
415 *
416 */
417class KHTML_EXPORT MouseEvent : public UIEvent {
418public:
419 MouseEvent();
420 MouseEvent(const MouseEvent &other);
421 MouseEvent(const Event &other);
422 MouseEvent & operator = (const MouseEvent &other);
423 MouseEvent & operator = (const Event &other);
424 virtual ~MouseEvent();
425
426 /**
427 * The horizontal coordinate at which the event occurred relative to the
428 * origin of the screen coordinate system.
429 *
430 */
431 long screenX() const;
432
433 /**
434 * The vertical coordinate at which the event occurred relative to the
435 * origin of the screen coordinate system.
436 *
437 */
438 long screenY() const;
439
440 /**
441 * The horizontal coordinate at which the event occurred relative to the
442 * DOM implementation's client area.
443 *
444 */
445 long clientX() const;
446
447 /**
448 * The vertical coordinate at which the event occurred relative to the DOM
449 * implementation's client area.
450 *
451 */
452 long clientY() const;
453
454 /**
455 * Used to indicate whether the 'ctrl' key was depressed during the firing
456 * of the event.
457 */
458 bool ctrlKey() const;
459
460 /**
461 * Used to indicate whether the 'shift' key was depressed during the firing
462 * of the event.
463 *
464 */
465 bool shiftKey() const;
466
467 /**
468 * Used to indicate whether the 'alt' key was depressed during the firing
469 * of the event. On some platforms this key may map to an alternative key
470 * name.
471 *
472 */
473 bool altKey() const;
474
475 /**
476 * Used to indicate whether the 'meta' key was depressed during the firing
477 * of the event. On some platforms this key may map to an alternative key
478 * name.
479 *
480 */
481 bool metaKey() const;
482
483 /**
484 * During mouse events caused by the depression or release of a mouse
485 * button, button is used to indicate which mouse button changed state. The
486 * values for button range from zero to indicate the left button of the
487 * mouse, one to indicate the middle button if present, and two to indicate
488 * the right button. For mice configured for left handed use in which the
489 * button actions are reversed the values are instead read from right to
490 * left.
491 *
492 */
493 unsigned short button() const;
494
495 /**
496 * Used to identify a secondary EventTarget related to a UI event.
497 * Currently this attribute is used with the mouseover event to indicate
498 * the EventTarget which the pointing device exited and with the mouseout
499 * event to indicate the EventTarget which the pointing device entered.
500 *
501 */
502 Node relatedTarget() const;
503
504 /**
505 * The initMouseEvent method is used to initialize the value of a
506 * MouseEvent created through the DocumentEvent interface. This method may
507 * only be called before the MouseEvent has been dispatched via the
508 * dispatchEvent method, though it may be called multiple times during that
509 * phase if necessary. If called multiple times, the final invocation takes
510 * precedence. Parameters
511 *
512 * @param typeArg Specifies the event type.
513 *
514 * @param canBubbleArg Specifies whether or not the event can bubble.
515 *
516 * @param cancelableArg Specifies whether or not the event's default action can be prevented.
517 *
518 * @param viewArg Specifies the Event's AbstractView.
519 *
520 * @param detailArg Specifies the Event's mouse click count.
521 *
522 * @param screenXArg Specifies the Event's screen x coordinate
523 *
524 * @param screenYArg Specifies the Event's screen y coordinate
525 *
526 * @param clientXArg Specifies the Event's client x coordinate
527 *
528 * @param clientYArg Specifies the Event's client y coordinate
529 *
530 * @param ctrlKeyArg Specifies whether or not control key was depressed during the Event.
531 *
532 * @param altKeyArg Specifies whether or not alt key was depressed during the Event.
533 *
534 * @param shiftKeyArg Specifies whether or not shift key was depressed during the Event.
535 *
536 * @param metaKeyArg Specifies whether or not meta key was depressed during the Event.
537 *
538 * @param buttonArg Specifies the Event's mouse button.
539 *
540 * @param relatedTargetArg Specifies the Event's related EventTarget.
541 *
542 */
543 void initMouseEvent(const DOMString &typeArg,
544 bool canBubbleArg,
545 bool cancelableArg,
546 const AbstractView &viewArg,
547 long detailArg,
548 long screenXArg,
549 long screenYArg,
550 long clientXArg,
551 long clientYArg,
552 bool ctrlKeyArg,
553 bool altKeyArg,
554 bool shiftKeyArg,
555 bool metaKeyArg,
556 unsigned short buttonArg,
557 const Node &relatedTargetArg);
558protected:
559 MouseEvent(MouseEventImpl *impl);
560};
561
562/**
563 * Introduced in DOM Level 3
564 *
565 * DOM::TextEvent is used to indicate actual text entry
566 * during text input. It corresponds to the HTML keypress events
567 */
568class KHTML_EXPORT TextEvent : public UIEvent {
569public:
570 TextEvent();
571 TextEvent(const TextEvent &other);
572 TextEvent(const Event &other);
573 TextEvent & operator = (const TextEvent &other);
574 TextEvent & operator = (const Event &other);
575 virtual ~TextEvent();
576
577 /**
578 * initTextEvent
579 * The initTextEvent method is used to initialize the value of a TextEvent
580 * object and has the same behavior as UIEvent.initUIEvent().
581 * The value of UIEvent.detail remains undefined.
582 *
583 * Parameters:
584 *
585 * Specifies the event type.
586 * canBubbleArg of type boolean
587 * Specifies whether or not the event can bubble.
588 * cancelableArg of type boolean
589 * Specifies whether or not the event's default action can be prevent.
590 * viewArg of type views::AbstractView
591 * Specifies the TextEvent's AbstractView.
592 * dataArg of type DOMString
593 * Specifies TextEvent.data.
594 */
595 void initTextEvent(const DOMString &typeArg,
596 bool canBubbleArg,
597 bool cancelableArg,
598 const AbstractView &viewArg,
599 const DOMString &dataArg);
600
601 /**
602 * data of type DOMString, readonly
603 *
604 * 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].
605 * Note: while the DOM spec specifies that the string never be empty,
606 * KHTML can not guarantee that
607 */
608 DOMString data() const;
609};
610
611
612/**
613 * Introduced in DOM Level 3
614 *
615 * DOM::KeyboardEvent
616 * The KeyboardEvent interface provides specific contextual information
617 * associated with keyboard devices. Each keyboard event references a
618 * key using an identifier. Keyboard events are commonly directed at
619 * the element that has the focus.
620 *
621 * The KeyboardEvent interface provides convenient attributes for some
622 * common modifiers keys: KeyboardEvent.ctrlKey, KeyboardEvent.shiftKey,
623 * KeyboardEvent.altKey, KeyboardEvent.metaKey. These attributes are
624 * equivalent to use the method KeyboardEvent.getModifierState(keyIdentifierArg)
625 * with "Control", "Shift", "Alt", or "Meta" respectively.
626 *
627 * To create an instance of the KeyboardEvent interface, use the
628 * DocumentEvent.createEvent("KeyboardEvent") method call.
629 */
630class KHTML_EXPORT KeyboardEvent : public UIEvent {
631public:
632 KeyboardEvent();
633 KeyboardEvent(const KeyboardEvent &other);
634 KeyboardEvent(const Event &other);
635 KeyboardEvent & operator = (const KeyboardEvent &other);
636 KeyboardEvent & operator = (const Event &other);
637 virtual ~KeyboardEvent();
638
639 enum KeyLocation {
640 /**
641 The key activation is not distinguished as the left
642 or right version of the key, and did not originate
643 from the numeric keypad (or did not originate with a
644 virtual key corresponding to the numeric keypad).
645 Example: the 'Q' key on a PC 101 Key US keyboard.
646 */
647 DOM_KEY_LOCATION_STANDARD = 0x00,
648
649 /**
650 The key activated is in the left key location
651 (there is more than one possible location for this key).
652 Example: the left Shift key on a PC 101 Key US keyboard.
653
654 Note: KHTML currently always considers modifier keys to be on the left
655 */
656 DOM_KEY_LOCATION_LEFT = 0x01,
657
658 /**
659 The key activated is in the right key location
660 (there is more than one possible location for this key).
661 Example: the right Shift key on a PC 101 Key US keyboard.
662
663 Note: KHTML currently always considers modifier keys to be on the left
664 */
665 DOM_KEY_LOCATION_RIGHT = 0x02,
666
667 /**
668 The key activation originated on the numeric keypad or
669 with a virtual key corresponding to the numeric keypad.
670 Example: the '1' key on a PC 101 Key US keyboard located on the numeric pad.
671 */
672 DOM_KEY_LOCATION_NUMPAD = 0x03
673 };
674
675 /**
676 * keyIdentifier of type DOMString, readonly
677 *
678 * keyIdentifier holds the identifier of the key. The key identifiers
679 * are defined in Appendix A.2 "Key identifiers set"
680 * (http://www.w3.org/TR/DOM-Level-3-Events/keyset.html#KeySet-Set)
681 */
682 DOMString keyIdentifier() const;
683
684 /**
685 * keyLocation of type unsigned long, readonly
686 *
687 * The keyLocation attribute contains an indication of the location
688 * of they key on the device.
689 * See the KeyLocation enum for possible values
690 */
691 unsigned long keyLocation() const;
692
693 /**
694 * ctrlKey of type boolean, readonly
695 *
696 * true if the control (Ctrl) key modifier is activated.
697 */
698 bool ctrlKey() const;
699
700 /**
701 * shiftKey of type boolean, readonly
702 *
703 * true if the shift (Shift) key modifier is activated.
704 */
705 bool shiftKey() const;
706
707 /**
708 * altKey of type boolean, readonly
709 *
710 * true if the alt (Alt) key modifier is activated.
711 */
712 bool altKey() const;
713
714 /**
715 * metaKey of type boolean, readonly
716 *
717 * true if the meta (Meta) key modifier is activated.
718 */
719 bool metaKey() const;
720
721 /**
722 * getModifierState
723 *
724 *
725 * This methods queries the state of a modifier using a key identifier
726 *
727 * Parameters:
728 *
729 * keyIdentifierArg of type DOMString
730 * A modifier key identifier. Supported modifier keys are "Alt", "Control", "Meta", "Shift".
731 *
732 * Return Value
733 * boolean true if it is modifier key and the modifier is activated, false otherwise.
734 */
735 bool getModifierState(DOMString keyIdentifierArg) const;
736
737
738 /**
739 * initKeyboardEvent
740 *
741 * The initKeyboardEvent method is used to initialize the value of a
742 * KeyboardEvent object and has the same behavior as UIEvent.initUIEvent().
743 * The value of UIEvent.detail remains undefined.
744 *
745 * Parameters:
746 * typeArg of type DOMString
747 * Specifies the event type.
748 * canBubbleArg of type boolean
749 * Specifies whether or not the event can bubble.
750 * cancelableArg of type boolean
751 * Specifies whether or not the event's default action can be prevent.
752 * viewArg of type views::AbstractView
753 * Specifies the TextEvent's AbstractView.
754 * keyIdentifierArg of type DOMString
755 * Specifies KeyboardEvent.keyIdentifier.
756 * keyLocationArg of type unsigned long
757 * Specifies KeyboardEvent.keyLocation.
758 * modifiersList of type DOMString
759 * A white space separated list of modifier key identifiers to be activated on this object.
760 */
761 void initKeyboardEvent(DOMString typeArg,
762 bool canBubbleArg,
763 bool cancelableArg,
764 AbstractView viewArg,
765 DOMString keyIdentifierArg,
766 unsigned long keyLocationArg,
767 DOMString modifiersList);
768};
769
770
771/**
772 * Introduced in DOM Level 2
773 *
774 * The MutationEvent interface provides specific contextual information
775 * associated with Mutation events.
776 *
777 */
778class KHTML_EXPORT MutationEvent : public Event {
779public:
780 MutationEvent();
781 MutationEvent(const MutationEvent &other);
782 MutationEvent(const Event &other);
783 MutationEvent & operator = (const MutationEvent &other);
784 MutationEvent & operator = (const Event &other);
785 virtual ~MutationEvent();
786
787 /**
788 * An integer indicating in which way the Attr was changed.
789 *
790 * ADDITION: The Attr was just added.
791 *
792 * MODIFICATION: The Attr was modified in place.
793 *
794 * REMOVAL: The Attr was just removed.
795 *
796 */
797 enum attrChangeType {
798 MODIFICATION = 1,
799 ADDITION = 2,
800 REMOVAL = 3
801 };
802
803
804 /**
805 * relatedNode is used to identify a secondary node related to a mutation
806 * event. For example, if a mutation event is dispatched to a node
807 * indicating that its parent has changed, the relatedNode is the changed
808 * parent. If an event is instead dispatched to a subtree indicating a node
809 * was changed within it, the relatedNode is the changed node. In the case
810 * of the DOMAttrModified event it indicates the Attr node which was
811 * modified, added, or removed.
812 *
813 */
814 Node relatedNode() const;
815
816 /**
817 * prevValue indicates the previous value of the Attr node in
818 * DOMAttrModified events, and of the CharacterData node in
819 * DOMCharDataModified events.
820 *
821 */
822 DOMString prevValue() const;
823
824 /**
825 * newValue indicates the new value of the Attr node in DOMAttrModified
826 * events, and of the CharacterData node in DOMCharDataModified events.
827 *
828 */
829 DOMString newValue() const;
830
831 /**
832 * attrName indicates the name of the changed Attr node in a
833 * DOMAttrModified event.
834 *
835 */
836 DOMString attrName() const;
837
838 /**
839 * attrChange indicates the type of change which triggered the
840 * DOMAttrModified event. The values can be MODIFICATION, ADDITION, or
841 * REMOVAL.
842 *
843 */
844 unsigned short attrChange() const;
845
846 /**
847 * The initMutationEvent method is used to initialize the value of a
848 * MutationEvent created through the DocumentEvent interface. This method
849 * may only be called before the MutationEvent has been dispatched via the
850 * dispatchEvent method, though it may be called multiple times during that
851 * phase if necessary. If called multiple times, the final invocation takes
852 * precedence.
853 *
854 * @param typeArg Specifies the event type.
855 *
856 * @param canBubbleArg Specifies whether or not the event can bubble.
857 *
858 * @param cancelableArg Specifies whether or not the event's default action can be prevented.
859 *
860 * @param relatedNodeArg Specifies the Event's related Node.
861 *
862 * @param prevValueArg Specifies the Event's prevValue attribute. This value may be null.
863 *
864 * @param newValueArg Specifies the Event's newValue attribute. This value may be null.
865 *
866 * @param attrNameArg Specifies the Event's attrName attribute. This value may be null.
867 *
868 * @param attrChangeArg Specifies the Event's attrChange attribute
869 *
870 */
871 void initMutationEvent(const DOMString &typeArg,
872 bool canBubbleArg,
873 bool cancelableArg,
874 const Node &relatedNodeArg,
875 const DOMString &prevValueArg,
876 const DOMString &newValueArg,
877 const DOMString &attrNameArg,
878 unsigned short attrChangeArg);
879protected:
880 MutationEvent(MutationEventImpl *impl);
881};
882
883
884
885} //namespace
886#endif
887