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

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

Issue 1479923002: Enumerate the return value of dispatchEvent so it is clear. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_passive_uma_add
Patch Set: Add back the EventDispatchResult enum 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // or the document you're in. 107 // or the document you're in.
108 // - Your trace() method will need to call EventTargetWithInlineData::trace 108 // - Your trace() method will need to call EventTargetWithInlineData::trace
109 // or RefCountedGarbageCollectedEventTargetWithInlineData<YourClass>::trace, 109 // or RefCountedGarbageCollectedEventTargetWithInlineData<YourClass>::trace,
110 // depending on the base class of your class. 110 // depending on the base class of your class.
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 NoBaseWillBeGarbageCollectedFinalized<Eve ntTarget>, public ScriptWrappable { 114 class CORE_EXPORT EventTarget : public NoBaseWillBeGarbageCollectedFinalized<Eve ntTarget>, public ScriptWrappable {
115 DEFINE_WRAPPERTYPEINFO(); 115 DEFINE_WRAPPERTYPEINFO();
116 public: 116 public:
117 enum class DispatchEventResult {
tkent 2016/02/22 01:40:22 nit: You may move this out from EventTarget for co
dtapuska 2016/02/23 19:14:40 Done.
118 // Event was not consumed by application or system.
119 NotHandled,
philipj_slow 2016/02/22 07:30:18 In order to bring this closer to the https://dom.s
Rick Byers 2016/02/22 15:16:14 +1. This is the place to describe how we want the
dtapuska 2016/02/23 19:14:40 Done.
dtapuska 2016/02/23 19:14:40 Done.
120 // Event was consumed but suppressed before dispatched to application.
121 HandledSuppressed,
122 // Event was consumed by application itself; ie. a script handler callin g preventDefault.
123 HandledApplication,
124 // Event was consumed by the system; ie. executing the default action.
125 HandledSystem,
126 };
127
117 virtual ~EventTarget(); 128 virtual ~EventTarget();
118 129
119 #if !ENABLE(OILPAN) 130 #if !ENABLE(OILPAN)
120 void ref() { refEventTarget(); } 131 void ref() { refEventTarget(); }
121 void deref() { derefEventTarget(); } 132 void deref() { derefEventTarget(); }
122 #endif 133 #endif
123 134
124 virtual const AtomicString& interfaceName() const = 0; 135 virtual const AtomicString& interfaceName() const = 0;
125 virtual ExecutionContext* executionContext() const = 0; 136 virtual ExecutionContext* executionContext() const = 0;
126 137
127 virtual Node* toNode(); 138 virtual Node* toNode();
128 virtual const LocalDOMWindow* toDOMWindow() const; 139 virtual const LocalDOMWindow* toDOMWindow() const;
129 virtual LocalDOMWindow* toDOMWindow(); 140 virtual LocalDOMWindow* toDOMWindow();
130 virtual MessagePort* toMessagePort(); 141 virtual MessagePort* toMessagePort();
131 142
132 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false); 143 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, bool useCapture = false);
133 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, const EventListenerOptionsOrBoolean&); 144 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, const EventListenerOptionsOrBoolean&);
134 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, EventListenerOptions&); 145 bool addEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr< EventListener>, EventListenerOptions&);
135 146
136 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false); 147 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, bool useCapture = false);
137 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, const EventListenerOptionsOrBoolean&); 148 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, const EventListenerOptionsOrBoolean&);
138 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, EventListenerOptions&); 149 bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawP tr<EventListener>, EventListenerOptions&);
139 virtual void removeAllEventListeners(); 150 virtual void removeAllEventListeners();
140 151
141 bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>); 152 EventTarget::DispatchEventResult dispatchEvent(PassRefPtrWillBeRawPtr<Event> );
142 153
143 // dispatchEventForBindings is intended to only be called from 154 // dispatchEventForBindings is intended to only be called from
144 // javascript originated calls. This method will validate and may adjust 155 // javascript originated calls. This method will validate and may adjust
145 // the Event object before dispatching. 156 // the Event object before dispatching.
146 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& ); 157 bool dispatchEventForBindings(PassRefPtrWillBeRawPtr<Event>, ExceptionState& );
147 virtual void uncaughtExceptionInEventHandler(); 158 virtual void uncaughtExceptionInEventHandler();
148 159
149 // Used for legacy "onEvent" attribute APIs. 160 // Used for legacy "onEvent" attribute APIs.
150 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>); 161 bool setAttributeEventListener(const AtomicString& eventType, PassRefPtrWill BeRawPtr<EventListener>);
151 EventListener* getAttributeEventListener(const AtomicString& eventType); 162 EventListener* getAttributeEventListener(const AtomicString& eventType);
152 163
153 bool hasEventListeners() const; 164 bool hasEventListeners() const;
154 bool hasEventListeners(const AtomicString& eventType) const; 165 bool hasEventListeners(const AtomicString& eventType) const;
155 bool hasCapturingEventListeners(const AtomicString& eventType); 166 bool hasCapturingEventListeners(const AtomicString& eventType);
156 EventListenerVector* getEventListeners(const AtomicString& eventType); 167 EventListenerVector* getEventListeners(const AtomicString& eventType);
157 Vector<AtomicString> eventTypes(); 168 Vector<AtomicString> eventTypes();
158 169
159 bool fireEventListeners(Event*); 170 EventTarget::DispatchEventResult fireEventListeners(Event*);
160 171
161 DEFINE_INLINE_VIRTUAL_TRACE() { } 172 DEFINE_INLINE_VIRTUAL_TRACE() { }
162 173
163 virtual bool keepEventInNode(Event*) { return false; } 174 virtual bool keepEventInNode(Event*) { return false; }
164 175
165 protected: 176 protected:
166 EventTarget(); 177 EventTarget();
167 178
168 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener>, const EventListenerOptions&); 179 virtual bool addEventListenerInternal(const AtomicString& eventType, PassRef PtrWillBeRawPtr<EventListener>, const EventListenerOptions&);
169 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&); 180 virtual bool removeEventListenerInternal(const AtomicString& eventType, Pass RefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&);
170 virtual bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>); 181 virtual EventTarget::DispatchEventResult dispatchEventInternal(PassRefPtrWil lBeRawPtr<Event>);
171 182
172 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData. 183 // Subclasses should likely not override these themselves; instead, they sho uld subclass EventTargetWithInlineData.
173 virtual EventTargetData* eventTargetData() = 0; 184 virtual EventTargetData* eventTargetData() = 0;
174 virtual EventTargetData& ensureEventTargetData() = 0; 185 virtual EventTargetData& ensureEventTargetData() = 0;
175 186
176 private: 187 private:
177 #if !ENABLE(OILPAN) 188 #if !ENABLE(OILPAN)
178 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro. 189 // Subclasses should likely not override these themselves; instead, they sho uld use the REFCOUNTED_EVENT_TARGET() macro.
179 virtual void refEventTarget() = 0; 190 virtual void refEventTarget() = 0;
180 virtual void derefEventTarget() = 0; 191 virtual void derefEventTarget() = 0;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 using baseClass::deref; \ 330 using baseClass::deref; \
320 private: \ 331 private: \
321 void refEventTarget() final { ref(); } \ 332 void refEventTarget() final { ref(); } \
322 void derefEventTarget() final { deref(); } \ 333 void derefEventTarget() final { deref(); } \
323 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro 334 typedef int thisIsHereToForceASemiColonAfterThisEventTargetMacro
324 #define REFCOUNTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET_REFCOUNTING(RefCo unted<baseClass>) 335 #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>) 336 #define REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(baseClass) DEFINE_EVENT_TARGET _REFCOUNTING(RefCountedGarbageCollected<baseClass>)
326 #endif // ENABLE(OILPAN) 337 #endif // ENABLE(OILPAN)
327 338
328 #endif // EventTarget_h 339 #endif // EventTarget_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698