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

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

Issue 1857143002: Oilpan: Remove RefCountedGarbageCollectedEventTargetWithInlineData (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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // This is the base class for all DOM event targets. To make your class an 82 // This is the base class for all DOM event targets. To make your class an
83 // EventTarget, follow these steps: 83 // EventTarget, follow these steps:
84 // - Make your IDL interface inherit from EventTarget. 84 // - Make your IDL interface inherit from EventTarget.
85 // Optionally add "attribute EventHandler onfoo;" attributes. 85 // Optionally add "attribute EventHandler onfoo;" attributes.
86 // - Inherit from EventTargetWithInlineData (only in rare cases should you use 86 // - Inherit from EventTargetWithInlineData (only in rare cases
87 // EventTarget directly); or, if you want YourClass to be inherited from 87 // should you use EventTarget directly).
88 // RefCountedGarbageCollected<YourClass> in addition to EventTargetWithInlineD ata,
89 // inherit from RefCountedGarbageCollectedEventTargetWithInlineData<YourClass> .
90 // - In your class declaration, EventTargetWithInlineData (or 88 // - In your class declaration, EventTargetWithInlineData (or
91 // RefCountedGarbageCollectedEventTargetWithInlineData<>) must come first in 89 // EventTargetWithInlineData) must come first in
sof 2016/04/11 10:43:46 remove "(or EventTargetWithInlineData)"
92 // the base class list. If your class is non-final, classes inheriting from 90 // the base class list. If your class is non-final, classes inheriting from
93 // your class need to come first, too. 91 // your class need to come first, too.
94 // - Figure out if you now need to inherit from ActiveDOMObject as well. 92 // - Figure out if you now need to inherit from ActiveDOMObject as well.
95 // - In your class declaration, you will typically use 93 // - In your class declaration, you will typically use
96 // REFCOUNTED_EVENT_TARGET(YourClass) if YourClass is a RefCounted<>, 94 // REFCOUNTED_EVENT_TARGET(YourClass) if YourClass is a RefCounted<>,
97 // or REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(OtherRefCounted<YourClass>) 95 // or REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(OtherRefCounted<YourClass>)
98 // if YourClass uses a different kind of reference counting template such as 96 // if YourClass uses a different kind of reference counting template such as
99 // RefCountedGarbageCollected<YourClass>. 97 // RefCountedGarbageCollected<YourClass>.
100 // - Make sure to include this header file in your .h file, or you will get 98 // - Make sure to include this header file in your .h file, or you will get
101 // very strange compiler errors. 99 // very strange compiler errors.
102 // - If you added an onfoo attribute, use DEFINE_ATTRIBUTE_EVENT_LISTENER(foo) 100 // - If you added an onfoo attribute, use DEFINE_ATTRIBUTE_EVENT_LISTENER(foo)
103 // in your class declaration. 101 // in your class declaration.
104 // - Override EventTarget::interfaceName() and getExecutionContext(). The former 102 // - Override EventTarget::interfaceName() and getExecutionContext(). The former
105 // will typically return EventTargetNames::YourClassName. The latter will 103 // will typically return EventTargetNames::YourClassName. The latter will
106 // return ActiveDOMObject::executionContext (if you are an ActiveDOMObject) 104 // return ActiveDOMObject::executionContext (if you are an ActiveDOMObject)
107 // or the document you're in. 105 // or the document you're in.
108 // - Your trace() method will need to call EventTargetWithInlineData::trace 106 // - Your trace() method will need to call EventTargetWithInlineData::trace
109 // or RefCountedGarbageCollectedEventTargetWithInlineData<YourClass>::trace, 107 // or EventTargetWithInlineData::trace,
sof 2016/04/11 10:43:46 remove line.
110 // depending on the base class of your class. 108 // depending on the base class of your class.
109 // - EventTargets do not support EAGERLY_FINALIZE. You need to use
110 // a pre-finalizer instead.
haraken 2016/04/11 08:32:20 Note: This fact is checked by a runtime verificati
111 // 111 //
112 // 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
113 // comment (and much more straightforward). 113 // comment (and much more straightforward).
114 class CORE_EXPORT EventTarget : public GarbageCollectedFinalized<EventTarget>, p ublic ScriptWrappable { 114 class CORE_EXPORT EventTarget : public GarbageCollectedFinalized<EventTarget>, p ublic ScriptWrappable {
115 DEFINE_WRAPPERTYPEINFO(); 115 DEFINE_WRAPPERTYPEINFO();
116 public: 116 public:
117 virtual ~EventTarget(); 117 virtual ~EventTarget();
118 118
119 #if !ENABLE(OILPAN) 119 #if !ENABLE(OILPAN)
120 void ref() { refEventTarget(); } 120 void ref() { refEventTarget(); }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 204 }
205 205
206 protected: 206 protected:
207 EventTargetData* eventTargetData() final { return &m_eventTargetData; } 207 EventTargetData* eventTargetData() final { return &m_eventTargetData; }
208 EventTargetData& ensureEventTargetData() final { return m_eventTargetData; } 208 EventTargetData& ensureEventTargetData() final { return m_eventTargetData; }
209 209
210 private: 210 private:
211 EventTargetData m_eventTargetData; 211 EventTargetData m_eventTargetData;
212 }; 212 };
213 213
214 // Base class for classes that wish to inherit from RefCountedGarbageCollected ( in non-Oilpan world) and
215 // EventTargetWithInlineData (in both worlds). For details about how to use this class template, see the comments for
216 // EventTargetWithInlineData above.
217 //
218 // This class template exists to circumvent Oilpan's "leftmost class rule", wher e the Oilpan classes must come first in
219 // the base class list to avoid memory offset adjustment. In non-Oilpan world, R efCountedGarbageCollected<T> must come
220 // first, but in Oilpan world EventTargetWithInlineData needs to come first. Thi s class templates does the required
221 // #if-switch here, in order to avoid a lot of "#if ENABLE(OILPAN)"-s sprinkled in the derived classes.
222 #if ENABLE(OILPAN)
223 template <typename T>
224 class RefCountedGarbageCollectedEventTargetWithInlineData : public EventTargetWi thInlineData {
225 public:
226 DEFINE_INLINE_VIRTUAL_TRACE()
227 {
228 static_assert(!IsEagerlyFinalizedType<T>::value, "EventTargets do not su pport eager finalization.");
229 EventTargetWithInlineData::trace(visitor);
230 }
231 };
232 #else
233 template <typename T>
234 class RefCountedGarbageCollectedEventTargetWithInlineData : public RefCountedGar bageCollected<T>, public EventTargetWithInlineData {
235 public:
236 DEFINE_INLINE_VIRTUAL_TRACE() { EventTargetWithInlineData::trace(visitor); }
237 };
238 #endif
239
240 // FIXME: These macros should be split into separate DEFINE and DECLARE 214 // FIXME: These macros should be split into separate DEFINE and DECLARE
241 // macros to avoid causing so many header includes. 215 // macros to avoid causing so many header includes.
242 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \ 216 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
243 EventListener* on##attribute() { return this->getAttributeEventListener(Even tTypeNames::attribute); } \ 217 EventListener* on##attribute() { return this->getAttributeEventListener(Even tTypeNames::attribute); } \
244 void setOn##attribute(EventListener* listener) { this->setAttributeEventList ener(EventTypeNames::attribute, listener); } \ 218 void setOn##attribute(EventListener* listener) { this->setAttributeEventList ener(EventTypeNames::attribute, listener); } \
245 219
246 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \ 220 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \
247 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \ 221 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \
248 static void setOn##attribute(EventTarget& eventTarget, EventListener* listen er) { eventTarget.setAttributeEventListener(EventTypeNames::attribute, listener) ; } \ 222 static void setOn##attribute(EventTarget& eventTarget, EventListener* listen er) { eventTarget.setAttributeEventListener(EventTypeNames::attribute, listener) ; } \
249 223
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 using baseClass::deref; \ 286 using baseClass::deref; \
313 private: \ 287 private: \
314 void refEventTarget() final { ref(); } \ 288 void refEventTarget() final { ref(); } \
315 void derefEventTarget() final { deref(); } \ 289 void derefEventTarget() final { deref(); } \
316 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro 290 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro
317 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>) 291 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>)
318 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>) 292 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>)
319 #endif // ENABLE(OILPAN) 293 #endif // ENABLE(OILPAN)
320 294
321 #endif // EventTarget_h 295 #endif // EventTarget_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/MessagePort.cpp ('k') | third_party/WebKit/Source/core/fileapi/FileReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698