OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. |
6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 6 * Copyright (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 7 * (C) 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 #ifndef EventTarget_h | 32 #ifndef EventTarget_h |
33 #define EventTarget_h | 33 #define EventTarget_h |
34 | 34 |
35 #include "bindings/core/v8/ScriptWrappable.h" | 35 #include "bindings/core/v8/ScriptWrappable.h" |
36 #include "bindings/core/v8/UnionTypesCore.h" | 36 #include "bindings/core/v8/UnionTypesCore.h" |
37 #include "core/CoreExport.h" | 37 #include "core/CoreExport.h" |
38 #include "core/EventNames.h" | 38 #include "core/EventNames.h" |
39 #include "core/EventTargetNames.h" | 39 #include "core/EventTargetNames.h" |
40 #include "core/EventTypeNames.h" | 40 #include "core/EventTypeNames.h" |
| 41 #include "core/events/EventDispatchResult.h" |
41 #include "core/events/EventListenerMap.h" | 42 #include "core/events/EventListenerMap.h" |
42 #include "platform/heap/Handle.h" | 43 #include "platform/heap/Handle.h" |
43 #include "wtf/Allocator.h" | 44 #include "wtf/Allocator.h" |
44 #include "wtf/text/AtomicString.h" | 45 #include "wtf/text/AtomicString.h" |
45 | 46 |
46 namespace blink { | 47 namespace blink { |
47 | 48 |
| 49 class Event; |
48 class LocalDOMWindow; | 50 class LocalDOMWindow; |
49 class Event; | |
50 class ExceptionState; | 51 class ExceptionState; |
51 class MessagePort; | 52 class MessagePort; |
52 class Node; | 53 class Node; |
53 | 54 |
54 struct FiringEventIterator { | 55 struct FiringEventIterator { |
55 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 56 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
56 FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t&
end) | 57 FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t&
end) |
57 : eventType(eventType) | 58 : eventType(eventType) |
58 , iterator(iterator) | 59 , iterator(iterator) |
59 , end(end) | 60 , end(end) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 | 132 |
132 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, bool useCapture = false); | 133 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, bool useCapture = false); |
133 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, const EventListenerOptionsOrBoolean&); | 134 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, const EventListenerOptionsOrBoolean&); |
134 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, EventListenerOptions&); | 135 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<
EventListener>, EventListenerOptions&); |
135 | 136 |
136 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, bool useCapture = false); | 137 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, bool useCapture = false); |
137 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, const EventListenerOptionsOrBoolean&); | 138 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, const EventListenerOptionsOrBoolean&); |
138 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, EventListenerOptions&); | 139 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP
tr<EventListener>, EventListenerOptions&); |
139 virtual void removeAllEventListeners(); | 140 virtual void removeAllEventListeners(); |
140 | 141 |
141 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>); | 142 DispatchEventResult dispatchEvent(PassRefPtrWillBeRawPtr<Event>); |
142 | 143 |
143 // dispatchEventForBindings is intended to only be called from | 144 // dispatchEventForBindings is intended to only be called from |
144 // javascript originated calls. This method will validate and may adjust | 145 // javascript originated calls. This method will validate and may adjust |
145 // the Event object before dispatching. | 146 // the Event object before dispatching. |
146 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState&
); | 147 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState&
); |
147 virtual void uncaughtExceptionInEventHandler(); | 148 virtual void uncaughtExceptionInEventHandler(); |
148 | 149 |
149 // Used for legacy "onEvent" attribute APIs. | 150 // Used for legacy "onEvent" attribute APIs. |
150 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill
BeRawPtr<EventListener>); | 151 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill
BeRawPtr<EventListener>); |
151 EventListener* getAttributeEventListener(const AtomicString& eventType); | 152 EventListener* getAttributeEventListener(const AtomicString& eventType); |
152 | 153 |
153 bool hasEventListeners() const; | 154 bool hasEventListeners() const; |
154 bool hasEventListeners(const AtomicString& eventType) const; | 155 bool hasEventListeners(const AtomicString& eventType) const; |
155 bool hasCapturingEventListeners(const AtomicString& eventType); | 156 bool hasCapturingEventListeners(const AtomicString& eventType); |
156 EventListenerVector* getEventListeners(const AtomicString& eventType); | 157 EventListenerVector* getEventListeners(const AtomicString& eventType); |
157 Vector<AtomicString> eventTypes(); | 158 Vector<AtomicString> eventTypes(); |
158 | 159 |
159 bool fireEventListeners(Event*); | 160 DispatchEventResult fireEventListeners(Event*); |
| 161 |
| 162 static DispatchEventResult dispatchEventResult(const Event&); |
160 | 163 |
161 DEFINE_INLINE_VIRTUAL_TRACE() { } | 164 DEFINE_INLINE_VIRTUAL_TRACE() { } |
162 | 165 |
163 virtual bool keepEventInNode(Event*) { return false; } | 166 virtual bool keepEventInNode(Event*) { return false; } |
164 | 167 |
165 protected: | 168 protected: |
166 EventTarget(); | 169 EventTarget(); |
167 | 170 |
168 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef
PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); | 171 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef
PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); |
169 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass
RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); | 172 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass
RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); |
170 virtual bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>); | 173 virtual DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve
nt>); |
171 | 174 |
172 // Subclasses should likely not override these themselves; instead, they sho
uld subclass EventTargetWithInlineData. | 175 // Subclasses should likely not override these themselves; instead, they sho
uld subclass EventTargetWithInlineData. |
173 virtual EventTargetData* eventTargetData() = 0; | 176 virtual EventTargetData* eventTargetData() = 0; |
174 virtual EventTargetData& ensureEventTargetData() = 0; | 177 virtual EventTargetData& ensureEventTargetData() = 0; |
175 | 178 |
176 private: | 179 private: |
177 #if !ENABLE(OILPAN) | 180 #if !ENABLE(OILPAN) |
178 // Subclasses should likely not override these themselves; instead, they sho
uld use the REFCOUNTED_EVENT_TARGET() macro. | 181 // Subclasses should likely not override these themselves; instead, they sho
uld use the REFCOUNTED_EVENT_TARGET() macro. |
179 virtual void refEventTarget() = 0; | 182 virtual void refEventTarget() = 0; |
180 virtual void derefEventTarget() = 0; | 183 virtual void derefEventTarget() = 0; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 using baseClass::deref; \ | 322 using baseClass::deref; \ |
320 private: \ | 323 private: \ |
321 void refEventTarget() final { ref(); } \ | 324 void refEventTarget() final { ref(); } \ |
322 void derefEventTarget() final { deref(); } \ | 325 void derefEventTarget() final { deref(); } \ |
323 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro | 326 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro |
324 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo
unted<baseClass>) | 327 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo
unted<baseClass>) |
325 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET
_REFCOUNTING(RefCountedGarbageCollected<baseClass>) | 328 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET
_REFCOUNTING(RefCountedGarbageCollected<baseClass>) |
326 #endif // ENABLE(OILPAN) | 329 #endif // ENABLE(OILPAN) |
327 | 330 |
328 #endif // EventTarget_h | 331 #endif // EventTarget_h |
OLD | NEW |