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

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

Issue 171333003: Pass implementation object to supplemental classes by reference (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 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 | 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 EventTargetData m_eventTargetData; 155 EventTargetData m_eventTargetData;
156 }; 156 };
157 157
158 // FIXME: These macros should be split into separate DEFINE and DECLARE 158 // FIXME: These macros should be split into separate DEFINE and DECLARE
159 // macros to avoid causing so many header includes. 159 // macros to avoid causing so many header includes.
160 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \ 160 #define DEFINE_ATTRIBUTE_EVENT_LISTENER(attribute) \
161 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::attribute); } \ 161 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::attribute); } \
162 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::attribute, listener); } \ 162 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::attribute, listener); } \
163 163
164 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \ 164 #define DEFINE_STATIC_ATTRIBUTE_EVENT_LISTENER(attribute) \
165 static EventListener* on##attribute(EventTarget* eventTarget) { return event Target->getAttributeEventListener(EventTypeNames::attribute); } \ 165 static EventListener* on##attribute(EventTarget& eventTarget) { return event Target.getAttributeEventListener(EventTypeNames::attribute); } \
166 static void setOn##attribute(EventTarget* eventTarget, PassRefPtr<EventListe ner> listener) { eventTarget->setAttributeEventListener(EventTypeNames::attribut e, listener); } \ 166 static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListe ner> listener) { eventTarget.setAttributeEventListener(EventTypeNames::attribute , listener); } \
167 167
168 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 168 #define DEFINE_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
169 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \ 169 EventListener* on##attribute() { return document().getWindowAttributeEventLi stener(EventTypeNames::attribute); } \
170 void setOn##attribute(PassRefPtr<EventListener> listener) { document().setWi ndowAttributeEventListener(EventTypeNames::attribute, listener); } \ 170 void setOn##attribute(PassRefPtr<EventListener> listener) { document().setWi ndowAttributeEventListener(EventTypeNames::attribute, listener); } \
171 171
172 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \ 172 #define DEFINE_STATIC_WINDOW_ATTRIBUTE_EVENT_LISTENER(attribute) \
173 static EventListener* on##attribute(EventTarget* eventTarget) { \ 173 static EventListener* on##attribute(EventTarget& eventTarget) { \
174 if (Node* node = eventTarget->toNode()) \ 174 if (Node* node = eventTarget.toNode()) \
175 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \ 175 return node->document().getWindowAttributeEventListener(EventTypeNam es::attribute); \
176 ASSERT(eventTarget->toDOMWindow()); \ 176 ASSERT(eventTarget.toDOMWindow()); \
177 return eventTarget->getAttributeEventListener(EventTypeNames::attribute) ; \ 177 return eventTarget.getAttributeEventListener(EventTypeNames::attribute); \
178 } \ 178 } \
179 static void setOn##attribute(EventTarget* eventTarget, PassRefPtr<EventListe ner> listener) { \ 179 static void setOn##attribute(EventTarget& eventTarget, PassRefPtr<EventListe ner> listener) { \
180 if (Node* node = eventTarget->toNode()) \ 180 if (Node* node = eventTarget.toNode()) \
181 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \ 181 node->document().setWindowAttributeEventListener(EventTypeNames::att ribute, listener); \
182 else { \ 182 else { \
183 ASSERT(eventTarget->toDOMWindow()); \ 183 ASSERT(eventTarget.toDOMWindow()); \
184 eventTarget->setAttributeEventListener(EventTypeNames::attribute, li stener); \ 184 eventTarget.setAttributeEventListener(EventTypeNames::attribute, lis tener); \
185 } \ 185 } \
186 } 186 }
187 187
188 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \ 188 #define DEFINE_MAPPED_ATTRIBUTE_EVENT_LISTENER(attribute, eventName) \
189 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \ 189 EventListener* on##attribute() { return getAttributeEventListener(EventTypeN ames::eventName); } \
190 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::eventName, listener); } \ 190 void setOn##attribute(PassRefPtr<EventListener> listener) { setAttributeEven tListener(EventTypeNames::eventName, listener); } \
191 191
192 #define DECLARE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(recipient, attribute) \ 192 #define DECLARE_FORWARDING_ATTRIBUTE_EVENT_LISTENER(recipient, attribute) \
193 EventListener* on##attribute(); \ 193 EventListener* on##attribute(); \
194 void setOn##attribute(PassRefPtr<EventListener> listener); 194 void setOn##attribute(PassRefPtr<EventListener> listener);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 virtual void refEventTarget() OVERRIDE FINAL { ref(); } \ 235 virtual void refEventTarget() OVERRIDE FINAL { ref(); } \
236 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } \ 236 virtual void derefEventTarget() OVERRIDE FINAL { deref(); } \
237 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro 237 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro
238 238
239 // Use this macro if your EventTarget subclass is also a subclass of WTF::RefCou nted. 239 // Use this macro if your EventTarget subclass is also a subclass of WTF::RefCou nted.
240 // A ref-counted class that uses a different method of refcounting should use DE FINE_EVENT_TARGET_REFCOUNTING directly. 240 // A ref-counted class that uses a different method of refcounting should use DE FINE_EVENT_TARGET_REFCOUNTING directly.
241 // Both of these macros are meant to be placed just before the "public:" section of the class declaration. 241 // Both of these macros are meant to be placed just before the "public:" section of the class declaration.
242 #define REFCOUNTED_EVENT_TARGET(className) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<className>) 242 #define REFCOUNTED_EVENT_TARGET(className) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<className>)
243 243
244 #endif // EventTarget_h 244 #endif // EventTarget_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698