]>
Commit | Line | Data |
---|---|---|
a90939db JF |
1 | /* |
2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
4 | * (C) 2001 Dirk Mueller (mueller@kde.org) | |
5 | * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | |
6 | * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | |
7 | * | |
8 | * This library is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU Library General Public | |
10 | * License as published by the Free Software Foundation; either | |
11 | * version 2 of the License, or (at your option) any later version. | |
12 | * | |
13 | * This library is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * Library General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU Library General Public License | |
19 | * along with this library; see the file COPYING.LIB. If not, write to | |
20 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
21 | * Boston, MA 02110-1301, USA. | |
22 | * | |
23 | */ | |
24 | ||
25 | #ifndef EventTargetNode_h | |
26 | #define EventTargetNode_h | |
27 | ||
28 | #include "EventTarget.h" | |
29 | #include "Node.h" | |
30 | ||
31 | namespace WebCore { | |
32 | ||
33 | class Attribute; | |
34 | class Frame; | |
35 | class RegisteredEventListener; | |
36 | ||
37 | typedef Vector<RefPtr<RegisteredEventListener> > RegisteredEventListenerVector; | |
38 | ||
39 | class EventTargetNode : public Node, public EventTarget { | |
40 | public: | |
41 | EventTargetNode(Document*, bool isElement = false, bool isContainer = false, bool isText = false); | |
42 | virtual ~EventTargetNode(); | |
43 | ||
44 | virtual bool isEventTargetNode() const { return true; } | |
45 | virtual EventTargetNode* toNode() { return this; } | |
46 | ||
47 | virtual ScriptExecutionContext* scriptExecutionContext() const; | |
48 | ||
49 | virtual void addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture); | |
50 | virtual void removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture); | |
51 | virtual bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); | |
52 | void removeAllEventListeners(); | |
53 | ||
54 | void setInlineEventListenerForType(const AtomicString& eventType, PassRefPtr<EventListener>); | |
55 | void setInlineEventListenerForTypeAndAttribute(const AtomicString& eventType, Attribute*); | |
56 | void removeInlineEventListenerForType(const AtomicString& eventType); | |
57 | bool dispatchEventForType(const AtomicString& eventType, bool canBubble, bool cancelable); | |
58 | EventListener* inlineEventListenerForType(const AtomicString& eventType) const; | |
59 | ||
60 | bool dispatchSubtreeModifiedEvent(); | |
61 | void dispatchWindowEvent(PassRefPtr<Event>); | |
62 | void dispatchWindowEvent(const AtomicString& eventType, bool canBubble, bool cancelable); | |
63 | bool dispatchUIEvent(const AtomicString& eventType, int detail = 0, PassRefPtr<Event> underlyingEvent = 0); | |
64 | bool dispatchKeyEvent(const PlatformKeyboardEvent&); | |
65 | void dispatchWheelEvent(PlatformWheelEvent&); | |
66 | bool dispatchMouseEvent(const PlatformMouseEvent&, const AtomicString& eventType, | |
67 | int clickCount = 0, Node* relatedTarget = 0); | |
68 | bool dispatchMouseEvent(const AtomicString& eventType, int button, int clickCount, | |
69 | int pageX, int pageY, int screenX, int screenY, | |
70 | bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, | |
71 | bool isSimulated = false, Node* relatedTarget = 0, PassRefPtr<Event> underlyingEvent = 0); | |
72 | void dispatchSimulatedMouseEvent(const AtomicString& eventType, PassRefPtr<Event> underlyingEvent = 0); | |
73 | void dispatchSimulatedClick(PassRefPtr<Event> underlyingEvent, bool sendMouseEvents = false, bool showPressedLook = true); | |
74 | bool dispatchProgressEvent(const AtomicString &eventType, bool lengthComputableArg, unsigned loadedArg, unsigned totalArg); | |
75 | void dispatchStorageEvent(const AtomicString &eventType, const String& key, const String& oldValue, const String& newValue, Frame* source); | |
76 | bool dispatchWebKitAnimationEvent(const AtomicString& eventType, const String& animationName, double elapsedTime); | |
77 | bool dispatchWebKitTransitionEvent(const AtomicString& eventType, const String& propertyName, double elapsedTime); | |
78 | bool dispatchGenericEvent(PassRefPtr<Event>); | |
79 | ||
80 | virtual void handleLocalEvents(Event*, bool useCapture); | |
81 | ||
82 | virtual void dispatchFocusEvent(); | |
83 | virtual void dispatchBlurEvent(); | |
84 | ||
85 | virtual void insertedIntoDocument(); | |
86 | virtual void removedFromDocument(); | |
87 | virtual void willMoveToNewOwnerDocument(); | |
88 | virtual void didMoveToNewOwnerDocument(); | |
89 | ||
90 | /** | |
91 | * Perform the default action for an event e.g. submitting a form | |
92 | */ | |
93 | virtual void defaultEventHandler(Event*); | |
94 | ||
95 | /** | |
96 | * Used for disabled form elements; if true, prevents mouse events from being dispatched | |
97 | * to event listeners, and prevents DOMActivate events from being sent at all. | |
98 | */ | |
99 | virtual bool disabled() const; | |
100 | ||
101 | virtual bool willRespondToMouseMoveEvents(); | |
102 | virtual bool willRespondToMouseWheelEvents(); | |
103 | virtual bool willRespondToMouseClickEvents(); | |
104 | ||
105 | const RegisteredEventListenerVector& eventListeners() const; | |
106 | ||
107 | EventListener* onabort() const; | |
108 | void setOnabort(PassRefPtr<EventListener>); | |
109 | EventListener* onblur() const; | |
110 | void setOnblur(PassRefPtr<EventListener>); | |
111 | EventListener* onchange() const; | |
112 | void setOnchange(PassRefPtr<EventListener>); | |
113 | EventListener* onclick() const; | |
114 | void setOnclick(PassRefPtr<EventListener>); | |
115 | EventListener* oncontextmenu() const; | |
116 | void setOncontextmenu(PassRefPtr<EventListener>); | |
117 | EventListener* ondblclick() const; | |
118 | void setOndblclick(PassRefPtr<EventListener>); | |
119 | EventListener* onerror() const; | |
120 | void setOnerror(PassRefPtr<EventListener>); | |
121 | EventListener* onfocus() const; | |
122 | void setOnfocus(PassRefPtr<EventListener>); | |
123 | EventListener* oninput() const; | |
124 | void setOninput(PassRefPtr<EventListener>); | |
125 | EventListener* onkeydown() const; | |
126 | void setOnkeydown(PassRefPtr<EventListener>); | |
127 | EventListener* onkeypress() const; | |
128 | void setOnkeypress(PassRefPtr<EventListener>); | |
129 | EventListener* onkeyup() const; | |
130 | void setOnkeyup(PassRefPtr<EventListener>); | |
131 | EventListener* onload() const; | |
132 | void setOnload(PassRefPtr<EventListener>); | |
133 | EventListener* onmousedown() const; | |
134 | void setOnmousedown(PassRefPtr<EventListener>); | |
135 | EventListener* onmousemove() const; | |
136 | void setOnmousemove(PassRefPtr<EventListener>); | |
137 | EventListener* onmouseout() const; | |
138 | void setOnmouseout(PassRefPtr<EventListener>); | |
139 | EventListener* onmouseover() const; | |
140 | void setOnmouseover(PassRefPtr<EventListener>); | |
141 | EventListener* onmouseup() const; | |
142 | void setOnmouseup(PassRefPtr<EventListener>); | |
143 | EventListener* onmousewheel() const; | |
144 | void setOnmousewheel(PassRefPtr<EventListener>); | |
145 | EventListener* onbeforecut() const; | |
146 | void setOnbeforecut(PassRefPtr<EventListener>); | |
147 | EventListener* oncut() const; | |
148 | void setOncut(PassRefPtr<EventListener>); | |
149 | EventListener* onbeforecopy() const; | |
150 | void setOnbeforecopy(PassRefPtr<EventListener>); | |
151 | EventListener* oncopy() const; | |
152 | void setOncopy(PassRefPtr<EventListener>); | |
153 | EventListener* onbeforepaste() const; | |
154 | void setOnbeforepaste(PassRefPtr<EventListener>); | |
155 | EventListener* onpaste() const; | |
156 | void setOnpaste(PassRefPtr<EventListener>); | |
157 | EventListener* ondragenter() const; | |
158 | void setOndragenter(PassRefPtr<EventListener>); | |
159 | EventListener* ondragover() const; | |
160 | void setOndragover(PassRefPtr<EventListener>); | |
161 | EventListener* ondragleave() const; | |
162 | void setOndragleave(PassRefPtr<EventListener>); | |
163 | EventListener* ondrop() const; | |
164 | void setOndrop(PassRefPtr<EventListener>); | |
165 | EventListener* ondragstart() const; | |
166 | void setOndragstart(PassRefPtr<EventListener>); | |
167 | EventListener* ondrag() const; | |
168 | void setOndrag(PassRefPtr<EventListener>); | |
169 | EventListener* ondragend() const; | |
170 | void setOndragend(PassRefPtr<EventListener>); | |
171 | EventListener* onreset() const; | |
172 | void setOnreset(PassRefPtr<EventListener>); | |
173 | EventListener* onresize() const; | |
174 | void setOnresize(PassRefPtr<EventListener>); | |
175 | EventListener* onscroll() const; | |
176 | void setOnscroll(PassRefPtr<EventListener>); | |
177 | EventListener* onsearch() const; | |
178 | void setOnsearch(PassRefPtr<EventListener>); | |
179 | EventListener* onselect() const; | |
180 | void setOnselect(PassRefPtr<EventListener>); | |
181 | EventListener* onselectstart() const; | |
182 | void setOnselectstart(PassRefPtr<EventListener>); | |
183 | EventListener* onsubmit() const; | |
184 | void setOnsubmit(PassRefPtr<EventListener>); | |
185 | EventListener* onunload() const; | |
186 | void setOnunload(PassRefPtr<EventListener>); | |
187 | EventListener* onorientationchange() const; | |
188 | void setOnorientationchange(PassRefPtr<EventListener>); | |
189 | #if ENABLE(TOUCH_EVENTS) | |
190 | EventListener* ontouchstart() const; | |
191 | void setOntouchstart(PassRefPtr<EventListener>); | |
192 | EventListener* ontouchmove() const; | |
193 | void setOntouchmove(PassRefPtr<EventListener>); | |
194 | EventListener* ontouchend() const; | |
195 | void setOntouchend(PassRefPtr<EventListener>); | |
196 | EventListener* ontouchcancel() const; | |
197 | void setOntouchcancel(PassRefPtr<EventListener>); | |
198 | EventListener* ongesturestart() const; | |
199 | void setOngesturestart(PassRefPtr<EventListener>); | |
200 | EventListener* ongesturechange() const; | |
201 | void setOngesturechange(PassRefPtr<EventListener>); | |
202 | EventListener* ongestureend() const; | |
203 | void setOngestureend(PassRefPtr<EventListener>); | |
204 | #endif | |
205 | ||
206 | using Node::ref; | |
207 | using Node::deref; | |
208 | ||
209 | private: | |
210 | virtual void refEventTarget() { ref(); } | |
211 | virtual void derefEventTarget() { deref(); } | |
212 | }; | |
213 | ||
214 | inline EventTargetNode* EventTargetNodeCast(Node* n) | |
215 | { | |
216 | ASSERT(n->isEventTargetNode()); | |
217 | return static_cast<EventTargetNode*>(n); | |
218 | } | |
219 | ||
220 | inline const EventTargetNode* EventTargetNodeCast(const Node* n) | |
221 | { | |
222 | ASSERT(n->isEventTargetNode()); | |
223 | return static_cast<const EventTargetNode*>(n); | |
224 | } | |
225 | ||
226 | } // namespace WebCore | |
227 | ||
228 | #endif // EventTargetNode_h |