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

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

Powered by Google App Engine
This is Rietveld 408576698