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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 public: | 72 public: |
73 EventTargetData(); | 73 EventTargetData(); |
74 ~EventTargetData(); | 74 ~EventTargetData(); |
75 | 75 |
76 DECLARE_TRACE(); | 76 DECLARE_TRACE(); |
77 | 77 |
78 EventListenerMap eventListenerMap; | 78 EventListenerMap eventListenerMap; |
79 OwnPtr<FiringEventIteratorVector> firingEventIterators; | 79 OwnPtr<FiringEventIteratorVector> firingEventIterators; |
80 }; | 80 }; |
81 | 81 |
82 enum class DispatchEventResult { | |
83 // Event was not canceled by event handler or default event handler. | |
84 NotCanceled, | |
85 // Event was canceled by event handler; ie. a script handler calling prevent Default. | |
philipj_slow
2016/02/25 04:21:27
i.e. is a much more common spelling, in Source/cor
dtapuska
2016/02/25 14:20:24
Done.
| |
86 CanceledByEventHandler, | |
87 // Event was canceled by the default event handler; ie. executing the defaul t action. | |
88 // This result should be used sparingly as it deviates from the DOM Event Di spatch | |
89 // model. Default event handlers really shouldn't be invoked inside of dispa tch. | |
90 CanceledByDefaultEventHandler, | |
91 // Event was canceled but suppressed before dispatched to event handler. | |
92 // This result should be used sparingly; and likely its usage likely indicat es | |
philipj_slow
2016/02/25 04:21:27
two likely
dtapuska
2016/02/25 14:20:24
Done.
| |
93 // there is potential for a bug. Trusted events may return this code; but un trusted | |
94 // events likely should always execute the event handler the developer inten ds to | |
95 // execute. | |
96 CanceledBeforeDispatch, | |
97 }; | |
98 | |
82 // This is the base class for all DOM event targets. To make your class an | 99 // This is the base class for all DOM event targets. To make your class an |
83 // EventTarget, follow these steps: | 100 // EventTarget, follow these steps: |
84 // - Make your IDL interface inherit from EventTarget. | 101 // - Make your IDL interface inherit from EventTarget. |
85 // Optionally add "attribute EventHandler onfoo;" attributes. | 102 // Optionally add "attribute EventHandler onfoo;" attributes. |
86 // - Inherit from EventTargetWithInlineData (only in rare cases should you use | 103 // - Inherit from EventTargetWithInlineData (only in rare cases should you use |
87 // EventTarget directly); or, if you want YourClass to be inherited from | 104 // EventTarget directly); or, if you want YourClass to be inherited from |
88 // RefCountedGarbageCollected<YourClass> in addition to EventTargetWithInlineD ata, | 105 // RefCountedGarbageCollected<YourClass> in addition to EventTargetWithInlineD ata, |
89 // inherit from RefCountedGarbageCollectedEventTargetWithInlineData<YourClass> . | 106 // inherit from RefCountedGarbageCollectedEventTargetWithInlineData<YourClass> . |
90 // - In your class declaration, EventTargetWithInlineData (or | 107 // - In your class declaration, EventTargetWithInlineData (or |
91 // RefCountedGarbageCollectedEventTargetWithInlineData<>) must come first in | 108 // RefCountedGarbageCollectedEventTargetWithInlineData<>) must come first in |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 | 148 |
132 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false); | 149 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false); |
133 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, const EventListenerOptionsOrBoolean&); | 150 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, const EventListenerOptionsOrBoolean&); |
134 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, EventListenerOptions&); | 151 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, EventListenerOptions&); |
135 | 152 |
136 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false); | 153 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false); |
137 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, const EventListenerOptionsOrBoolean&); | 154 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, const EventListenerOptionsOrBoolean&); |
138 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, EventListenerOptions&); | 155 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, EventListenerOptions&); |
139 virtual void removeAllEventListeners(); | 156 virtual void removeAllEventListeners(); |
140 | 157 |
141 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>); | 158 DispatchEventResult dispatchEvent(PassRefPtrWillBeRawPtr<Event>); |
142 | 159 |
143 // dispatchEventForBindings is intended to only be called from | 160 // dispatchEventForBindings is intended to only be called from |
144 // javascript originated calls. This method will validate and may adjust | 161 // javascript originated calls. This method will validate and may adjust |
145 // the Event object before dispatching. | 162 // the Event object before dispatching. |
146 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& ); | 163 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& ); |
147 virtual void uncaughtExceptionInEventHandler(); | 164 virtual void uncaughtExceptionInEventHandler(); |
148 | 165 |
149 // Used for legacy "onEvent" attribute APIs. | 166 // Used for legacy "onEvent" attribute APIs. |
150 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>); | 167 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>); |
151 EventListener* getAttributeEventListener(const AtomicString& eventType); | 168 EventListener* getAttributeEventListener(const AtomicString& eventType); |
152 | 169 |
153 bool hasEventListeners() const; | 170 bool hasEventListeners() const; |
154 bool hasEventListeners(const AtomicString& eventType) const; | 171 bool hasEventListeners(const AtomicString& eventType) const; |
155 bool hasCapturingEventListeners(const AtomicString& eventType); | 172 bool hasCapturingEventListeners(const AtomicString& eventType); |
156 EventListenerVector* getEventListeners(const AtomicString& eventType); | 173 EventListenerVector* getEventListeners(const AtomicString& eventType); |
157 Vector<AtomicString> eventTypes(); | 174 Vector<AtomicString> eventTypes(); |
158 | 175 |
159 bool fireEventListeners(Event*); | 176 DispatchEventResult fireEventListeners(Event*); |
160 | 177 |
161 DEFINE_INLINE_VIRTUAL_TRACE() { } | 178 DEFINE_INLINE_VIRTUAL_TRACE() { } |
162 | 179 |
163 virtual bool keepEventInNode(Event*) { return false; } | 180 virtual bool keepEventInNode(Event*) { return false; } |
164 | 181 |
165 protected: | 182 protected: |
166 EventTarget(); | 183 EventTarget(); |
167 | 184 |
168 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); | 185 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); |
169 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); | 186 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); |
170 virtual bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>); | 187 virtual DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve nt>); |
171 | 188 |
172 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData. | 189 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData. |
173 virtual EventTargetData* eventTargetData() = 0; | 190 virtual EventTargetData* eventTargetData() = 0; |
174 virtual EventTargetData& ensureEventTargetData() = 0; | 191 virtual EventTargetData& ensureEventTargetData() = 0; |
175 | 192 |
176 private: | 193 private: |
177 #if !ENABLE(OILPAN) | 194 #if !ENABLE(OILPAN) |
178 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro. | 195 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro. |
179 virtual void refEventTarget() = 0; | 196 virtual void refEventTarget() = 0; |
180 virtual void derefEventTarget() = 0; | 197 virtual void derefEventTarget() = 0; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 using baseClass::deref; \ | 336 using baseClass::deref; \ |
320 private: \ | 337 private: \ |
321 void refEventTarget() final { ref(); } \ | 338 void refEventTarget() final { ref(); } \ |
322 void derefEventTarget() final { deref(); } \ | 339 void derefEventTarget() final { deref(); } \ |
323 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro | 340 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro |
324 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>) | 341 #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>) | 342 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>) |
326 #endif // ENABLE(OILPAN) | 343 #endif // ENABLE(OILPAN) |
327 | 344 |
328 #endif // EventTarget_h | 345 #endif // EventTarget_h |
OLD | NEW |