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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 , end(end) 60 , end(end)
61 { 61 {
62 } 62 }
63 63
64 const AtomicString& eventType; 64 const AtomicString& eventType;
65 size_t& iterator; 65 size_t& iterator;
66 size_t& end; 66 size_t& end;
67 }; 67 };
68 using FiringEventIteratorVector = Vector<FiringEventIterator, 1>; 68 using FiringEventIteratorVector = Vector<FiringEventIterator, 1>;
69 69
70 class CORE_EXPORT EventTargetData final : public NoBaseWillBeGarbageCollectedFin alized<EventTargetData> { 70 class CORE_EXPORT EventTargetData final : public GarbageCollectedFinalized<Event TargetData> {
71 WTF_MAKE_NONCOPYABLE(EventTargetData); 71 WTF_MAKE_NONCOPYABLE(EventTargetData);
72 USING_FAST_MALLOC_WILL_BE_REMOVED(EventTargetData);
73 public: 72 public:
74 EventTargetData(); 73 EventTargetData();
75 ~EventTargetData(); 74 ~EventTargetData();
76 75
77 DECLARE_TRACE(); 76 DECLARE_TRACE();
78 77
79 EventListenerMap eventListenerMap; 78 EventListenerMap eventListenerMap;
80 OwnPtr<FiringEventIteratorVector> firingEventIterators; 79 OwnPtr<FiringEventIteratorVector> firingEventIterators;
81 }; 80 };
82 81
(...skipping 22 matching lines...) Expand all
105 // - Override EventTarget::interfaceName() and getExecutionContext(). The former 104 // - Override EventTarget::interfaceName() and getExecutionContext(). The former
106 // will typically return EventTargetNames::YourClassName. The latter will 105 // will typically return EventTargetNames::YourClassName. The latter will
107 // return ActiveDOMObject::executionContext (if you are an ActiveDOMObject) 106 // return ActiveDOMObject::executionContext (if you are an ActiveDOMObject)
108 // or the document you're in. 107 // or the document you're in.
109 // - Your trace() method will need to call EventTargetWithInlineData::trace 108 // - Your trace() method will need to call EventTargetWithInlineData::trace
110 // or RefCountedGarbageCollectedEventTargetWithInlineData<YourClass>::trace, 109 // or RefCountedGarbageCollectedEventTargetWithInlineData<YourClass>::trace,
111 // depending on the base class of your class. 110 // depending on the base class of your class.
112 // 111 //
113 // Optionally, add a FooEvent.idl class, but that's outside the scope of this 112 // Optionally, add a FooEvent.idl class, but that's outside the scope of this
114 // comment (and much more straightforward). 113 // comment (and much more straightforward).
115 class CORE_EXPORT EventTarget : public NoBaseWillBeGarbageCollectedFinalized<Eve ntTarget>, public ScriptWrappable { 114 class CORE_EXPORT EventTarget : public GarbageCollectedFinalized<EventTarget>, p ublic ScriptWrappable {
116 DEFINE_WRAPPERTYPEINFO(); 115 DEFINE_WRAPPERTYPEINFO();
117 public: 116 public:
118 virtual ~EventTarget(); 117 virtual ~EventTarget();
119 118
120 #if !ENABLE(OILPAN) 119 #if !ENABLE(OILPAN)
121 void ref() { refEventTarget(); } 120 void ref() { refEventTarget(); }
122 void deref() { derefEventTarget(); } 121 void deref() { derefEventTarget(); }
123 #endif 122 #endif
124 123
125 virtual const AtomicString& interfaceName() const = 0; 124 virtual const AtomicString& interfaceName() const = 0;
126 virtual ExecutionContext* getExecutionContext() const = 0; 125 virtual ExecutionContext* getExecutionContext() const = 0;
127 126
128 virtual Node* toNode(); 127 virtual Node* toNode();
129 virtual const LocalDOMWindow* toDOMWindow() const; 128 virtual const LocalDOMWindow* toDOMWindow() const;
130 virtual LocalDOMWindow* toDOMWindow(); 129 virtual LocalDOMWindow* toDOMWindow();
131 virtual MessagePort* toMessagePort(); 130 virtual MessagePort* toMessagePort();
132 131
133 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false); 132 bool addEventListener(const AtomicString& eventType, RawPtr<EventListener>, bool useCapture = false);
134 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, const EventListenerOptionsOrBoolean&); 133 bool addEventListener(const AtomicString& eventType, RawPtr<EventListener>, const EventListenerOptionsOrBoolean&);
135 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, EventListenerOptions&); 134 bool addEventListener(const AtomicString& eventType, RawPtr<EventListener>, EventListenerOptions&);
136 135
137 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false); 136 bool removeEventListener(const AtomicString& eventType, RawPtr<EventListener >, bool useCapture = false);
138 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, const EventListenerOptionsOrBoolean&); 137 bool removeEventListener(const AtomicString& eventType, RawPtr<EventListener >, const EventListenerOptionsOrBoolean&);
139 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, EventListenerOptions&); 138 bool removeEventListener(const AtomicString& eventType, RawPtr<EventListener >, EventListenerOptions&);
140 virtual void removeAllEventListeners(); 139 virtual void removeAllEventListeners();
141 140
142 DispatchEventResult dispatchEvent(PassRefPtrWillBeRawPtr<Event>); 141 DispatchEventResult dispatchEvent(RawPtr<Event>);
143 142
144 // dispatchEventForBindings is intended to only be called from 143 // dispatchEventForBindings is intended to only be called from
145 // javascript originated calls. This method will validate and may adjust 144 // javascript originated calls. This method will validate and may adjust
146 // the Event object before dispatching. 145 // the Event object before dispatching.
147 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& ); 146 bool dispatchEventForBindings(RawPtr<Event>, ExceptionState&);
148 virtual void uncaughtExceptionInEventHandler(); 147 virtual void uncaughtExceptionInEventHandler();
149 148
150 // Used for legacy "onEvent" attribute APIs. 149 // Used for legacy "onEvent" attribute APIs.
151 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>); 150 bool setAttributeEventListener(const AtomicString& eventType, RawPtr<EventLi stener>);
152 EventListener* getAttributeEventListener(const AtomicString& eventType); 151 EventListener* getAttributeEventListener(const AtomicString& eventType);
153 152
154 bool hasEventListeners() const; 153 bool hasEventListeners() const;
155 bool hasEventListeners(const AtomicString& eventType) const; 154 bool hasEventListeners(const AtomicString& eventType) const;
156 bool hasCapturingEventListeners(const AtomicString& eventType); 155 bool hasCapturingEventListeners(const AtomicString& eventType);
157 EventListenerVector* getEventListeners(const AtomicString& eventType); 156 EventListenerVector* getEventListeners(const AtomicString& eventType);
158 Vector<AtomicString> eventTypes(); 157 Vector<AtomicString> eventTypes();
159 158
160 DispatchEventResult fireEventListeners(Event*); 159 DispatchEventResult fireEventListeners(Event*);
161 160
162 static DispatchEventResult dispatchEventResult(const Event&); 161 static DispatchEventResult dispatchEventResult(const Event&);
163 162
164 DEFINE_INLINE_VIRTUAL_TRACE() { } 163 DEFINE_INLINE_VIRTUAL_TRACE() { }
165 164
166 virtual bool keepEventInNode(Event*) { return false; } 165 virtual bool keepEventInNode(Event*) { return false; }
167 166
168 protected: 167 protected:
169 EventTarget(); 168 EventTarget();
170 169
171 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); 170 virtual bool addEventListenerInternal(const AtomicString& eventType, RawPtr< EventListener>, const EventListenerOptions&);
172 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); 171 virtual bool removeEventListenerInternal(const AtomicString& eventType, RawP tr<EventListener>, const EventListenerOptions&);
173 virtual DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve nt>); 172 virtual DispatchEventResult dispatchEventInternal(RawPtr<Event>);
174 173
175 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData. 174 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData.
176 virtual EventTargetData* eventTargetData() = 0; 175 virtual EventTargetData* eventTargetData() = 0;
177 virtual EventTargetData& ensureEventTargetData() = 0; 176 virtual EventTargetData& ensureEventTargetData() = 0;
178 177
179 private: 178 private:
180 #if !ENABLE(OILPAN) 179 #if !ENABLE(OILPAN)
181 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro. 180 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro.
182 virtual void refEventTarget() = 0; 181 virtual void refEventTarget() = 0;
183 virtual void derefEventTarget() = 0; 182 virtual void derefEventTarget() = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 class RefCountedGarbageCollectedEventTargetWithInlineData : public RefCountedGar bageCollected<T>, public EventTargetWithInlineData { 243 class RefCountedGarbageCollectedEventTargetWithInlineData : public RefCountedGar bageCollected<T>, public EventTargetWithInlineData {
245 public: 244 public:
246 DEFINE_INLINE_VIRTUAL_TRACE() { EventTargetWithInlineData::trace(visitor); } 245 DEFINE_INLINE_VIRTUAL_TRACE() { EventTargetWithInlineData::trace(visitor); }
247 }; 246 };
248 #endif 247 #endif
249 248
250 // FIXME: These macros should be split into separate DEFINE and DECLARE 249 // FIXME: These macros should be split into separate DEFINE and DECLARE
251 // macros to avoid causing so many header includes. 250 // macros to avoid causing so many header includes.
252 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \ 251 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
253 EventListener* on##attribute() { return this->getAttributeEventListener(Even tTypeNames::attribute); } \ 252 EventListener* on##attribute() { return this->getAttributeEventListener(Even tTypeNames::attribute); } \
254 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { this ->setAttributeEventListener(EventTypeNames::attribute, listener); } \ 253 void setOn##attribute(RawPtr<EventListener> listener) { this->setAttributeEv entListener(EventTypeNames::attribute, listener); } \
255 254
256 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \ 255 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \
257 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \ 256 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \
258 static void setOn##attribute(EventTarget& eventTarget, PassRefPtrWillBeRawPt r<EventListener> listener) { eventTarget.setAttributeEventListener(EventTypeName s::attribute, listener); } \ 257 static void setOn##attribute(EventTarget& eventTarget, RawPtr<EventListener> listener) { eventTarget.setAttributeEventListener(EventTypeNames::attribute, li stener); } \
259 258
260 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 259 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
261 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \ 260 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \
262 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { docu ment().setWindowAttributeEventListener(EventTypeNames::attribute, listener); } \ 261 void setOn##attribute(RawPtr<EventListener> listener) { document().setWindow AttributeEventListener(EventTypeNames::attribute, listener); } \
263 262
264 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 263 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
265 static EventListener* on##attribute(EventTarget& eventTarget) { \ 264 static EventListener* on##attribute(EventTarget& eventTarget) { \
266 if (Node* node = eventTarget.toNode()) \ 265 if (Node* node = eventTarget.toNode()) \
267 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \ 266 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \
268 ASSERT(eventTarget.toDOMWindow()); \ 267 ASSERT(eventTarget.toDOMWindow()); \
269 return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \ 268 return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \
270 } \ 269 } \
271 static void setOn##attribute(EventTarget& eventTarget, PassRefPtrWillBeRawPt r<EventListener> listener) { \ 270 static void setOn##attribute(EventTarget& eventTarget, RawPtr<EventListener> listener) { \
272 if (Node* node = eventTarget.toNode()) \ 271 if (Node* node = eventTarget.toNode()) \
273 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \ 272 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \
274 else { \ 273 else { \
275 ASSERT(eventTarget.toDOMWindow()); \ 274 ASSERT(eventTarget.toDOMWindow()); \
276 eventTarget.setAttributeEventListener(EventTypeNames::attribute, lis tener); \ 275 eventTarget.setAttributeEventListener(EventTypeNames::attribute, lis tener); \
277 } \ 276 } \
278 } 277 }
279 278
280 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \ 279 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \
281 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \ 280 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \
282 void setOn##attribute(PassRefPtrWillBeRawPtr<EventListener> listener) { setA ttributeEventListener(EventTypeNames::eventName, listener); } \ 281 void setOn##attribute(RawPtr<EventListener> listener) { setAttributeEventLis tener(EventTypeNames::eventName, listener); } \
283 282
284 inline bool EventTarget::hasEventListeners() const 283 inline bool EventTarget::hasEventListeners() const
285 { 284 {
286 // FIXME: We should have a const version of eventTargetData. 285 // FIXME: We should have a const version of eventTargetData.
287 if (const EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetDa ta()) 286 if (const EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetDa ta())
288 return !d->eventListenerMap.isEmpty(); 287 return !d->eventListenerMap.isEmpty();
289 return false; 288 return false;
290 } 289 }
291 290
292 inline bool EventTarget::hasEventListeners(const AtomicString& eventType) const 291 inline bool EventTarget::hasEventListeners(const AtomicString& eventType) const
(...skipping 29 matching lines...) Expand all
322 using baseClass::deref; \ 321 using baseClass::deref; \
323 private: \ 322 private: \
324 void refEventTarget() final { ref(); } \ 323 void refEventTarget() final { ref(); } \
325 void derefEventTarget() final { deref(); } \ 324 void derefEventTarget() final { deref(); } \
326 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro 325 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro
327 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>) 326 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>)
328 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>) 327 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>)
329 #endif // ENABLE(OILPAN) 328 #endif // ENABLE(OILPAN)
330 329
331 #endif // EventTarget_h 330 #endif // EventTarget_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/events/EventSender.h ('k') | third_party/WebKit/Source/core/events/EventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698