Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: Source/core/events/EventTarget.h

Issue 1238083002: Oilpan: Move the EventListener hierarchy to Oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void deref() { derefEventTarget(); } 115 void deref() { derefEventTarget(); }
116 #endif 116 #endif
117 117
118 virtual const AtomicString& interfaceName() const = 0; 118 virtual const AtomicString& interfaceName() const = 0;
119 virtual ExecutionContext* executionContext() const = 0; 119 virtual ExecutionContext* executionContext() const = 0;
120 120
121 virtual Node* toNode(); 121 virtual Node* toNode();
122 virtual LocalDOMWindow* toDOMWindow(); 122 virtual LocalDOMWindow* toDOMWindow();
123 virtual MessagePort* toMessagePort(); 123 virtual MessagePort* toMessagePort();
124 124
125 virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<Even tListener>, bool useCapture); 125 virtual bool addEventListener(const AtomicString& eventType, PassRefPtrWillB eRawPtr<EventListener>, bool useCapture);
126 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtr<E ventListener>, bool useCapture); 126 virtual bool removeEventListener(const AtomicString& eventType, PassRefPtrWi llBeRawPtr<EventListener>, bool useCapture);
127 virtual void removeAllEventListeners(); 127 virtual void removeAllEventListeners();
128 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>); 128 virtual bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>);
129 129
130 // dispatchEventForBindings is intended to only be called from 130 // dispatchEventForBindings is intended to only be called from
131 // javascript originated calls. This method will validate and may adjust 131 // javascript originated calls. This method will validate and may adjust
132 // the Event object before dispatching. 132 // the Event object before dispatching.
133 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& ); 133 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& );
134 virtual void uncaughtExceptionInEventHandler(); 134 virtual void uncaughtExceptionInEventHandler();
135 135
136 // Used for legacy "onEvent" attribute APIs. 136 // Used for legacy "onEvent" attribute APIs.
137 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<Eve ntListener>); 137 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>);
138 EventListener* getAttributeEventListener(const AtomicString& eventType); 138 EventListener* getAttributeEventListener(const AtomicString& eventType);
139 139
140 bool hasEventListeners() const; 140 bool hasEventListeners() const;
141 bool hasEventListeners(const AtomicString& eventType) const; 141 bool hasEventListeners(const AtomicString& eventType) const;
142 bool hasCapturingEventListeners(const AtomicString& eventType); 142 bool hasCapturingEventListeners(const AtomicString& eventType);
143 const EventListenerVector& getEventListeners(const AtomicString& eventType); 143 const EventListenerVector& getEventListeners(const AtomicString& eventType);
144 Vector<AtomicString> eventTypes(); 144 Vector<AtomicString> eventTypes();
145 145
146 bool fireEventListeners(Event*); 146 bool fireEventListeners(Event*);
147 147
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 class RefCountedGarbageCollectedEventTargetWithInlineData : public RefCountedGar bageCollected<T>, public EventTargetWithInlineData { 207 class RefCountedGarbageCollectedEventTargetWithInlineData : public RefCountedGar bageCollected<T>, public EventTargetWithInlineData {
208 public: 208 public:
209 DEFINE_INLINE_VIRTUAL_TRACE() { EventTargetWithInlineData::trace(visitor); } 209 DEFINE_INLINE_VIRTUAL_TRACE() { EventTargetWithInlineData::trace(visitor); }
210 }; 210 };
211 #endif 211 #endif
212 212
213 // FIXME: These macros should be split into separate DEFINE and DECLARE 213 // FIXME: These macros should be split into separate DEFINE and DECLARE
214 // macros to avoid causing so many header includes. 214 // macros to avoid causing so many header includes.
215 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \ 215 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
216 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::attribute); } \ 216 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::attribute); } \
217 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::attribute, listener); } \ 217 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { setA ttributeEventListener(EventTypeNames::attribute, listener); } \
218 218
219 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \ 219 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \
220 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \ 220 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \
221 static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListe ner> listener) { eventTarget.setAttributeEventListener(EventTypeNames::attribute , listener); } \ 221 static void setOn##attribute(EventTarget& eventTarget, PassRefPtrWillBeRawPt r<EventListener> listener) { eventTarget.setAttributeEventListener(EventTypeName s::attribute, listener); } \
222 222
223 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 223 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
224 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \ 224 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \
225 void setOn##attribute(PassRefPtr<EventListener> listener) { document().setWi ndowAttributeEventListener(EventTypeNames::attribute, listener); } \ 225 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { docu ment().setWindowAttributeEventListener(EventTypeNames::attribute, listener); } \
226 226
227 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 227 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
228 static EventListener* on##attribute(EventTarget& eventTarget) { \ 228 static EventListener* on##attribute(EventTarget& eventTarget) { \
229 if (Node* node = eventTarget.toNode()) \ 229 if (Node* node = eventTarget.toNode()) \
230 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \ 230 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \
231 ASSERT(eventTarget.toDOMWindow()); \ 231 ASSERT(eventTarget.toDOMWindow()); \
232 return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \ 232 return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \
233 } \ 233 } \
234 static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListe ner> listener) { \ 234 static void setOn##attribute(EventTarget& eventTarget, PassRefPtrWillBeRawPt r<EventListener> listener) { \
235 if (Node* node = eventTarget.toNode()) \ 235 if (Node* node = eventTarget.toNode()) \
236 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \ 236 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \
237 else { \ 237 else { \
238 ASSERT(eventTarget.toDOMWindow()); \ 238 ASSERT(eventTarget.toDOMWindow()); \
239 eventTarget.setAttributeEventListener(EventTypeNames::attribute, lis tener); \ 239 eventTarget.setAttributeEventListener(EventTypeNames::attribute, lis tener); \
240 } \ 240 } \
241 } 241 }
242 242
243 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \ 243 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \
244 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \ 244 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \
245 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::eventName, listener); } \ 245 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { setA ttributeEventListener(EventTypeNames::eventName, listener); } \
246 246
247 #define DECLARE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(recipient, attribute) \ 247 #define DECLARE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(recipient, attribute) \
248 EventListener* on##attribute(); \ 248 EventListener* on##attribute(); \
249 void setOn##attribute(PassRefPtr<EventListener> listener); 249 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener);
250 250
251 #define DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(type, recipient, attribute) \ 251 #define DEFINE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(type, recipient, attribute) \
252 EventListener* type::on##attribute() { return recipient ? recipient->getAttr ibuteEventListener(EventTypeNames::attribute) : 0; } \ 252 EventListener* type::on##attribute() { return recipient ? recipient->getAttr ibuteEventListener(EventTypeNames::attribute) : 0; } \
253 void type::setOn##attribute(PassRefPtr<EventListener> listener) \ 253 void type::setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) \
254 { \ 254 { \
255 if (recipient) \ 255 if (recipient) \
256 recipient->setAttributeEventListener(EventTypeNames::attribute, list ener); \ 256 recipient->setAttributeEventListener(EventTypeNames::attribute, list ener); \
257 } 257 }
258 258
259 inline bool EventTarget::hasEventListeners() const 259 inline bool EventTarget::hasEventListeners() const
260 { 260 {
261 // FIXME: We should have a const version of eventTargetData. 261 // FIXME: We should have a const version of eventTargetData.
262 if (const EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetDa ta()) 262 if (const EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetDa ta())
263 return !d->eventListenerMap.isEmpty(); 263 return !d->eventListenerMap.isEmpty();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 using baseClass::deref; \ 297 using baseClass::deref; \
298 private: \ 298 private: \
299 void refEventTarget() final { ref(); } \ 299 void refEventTarget() final { ref(); } \
300 void derefEventTarget() final { deref(); } \ 300 void derefEventTarget() final { deref(); } \
301 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro 301 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro
302 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>) 302 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>)
303 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>) 303 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>)
304 #endif // ENABLE(OILPAN) 304 #endif // ENABLE(OILPAN)
305 305
306 #endif // EventTarget_h 306 #endif // EventTarget_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698