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

Unified 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: Fix up couple of nits 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/events/EventTarget.h
diff --git a/third_party/WebKit/Source/core/events/EventTarget.h b/third_party/WebKit/Source/core/events/EventTarget.h
index 5f56ecb04adcf376f578f59ca61a2f76aede39e3..2d22c16a80e4706f20cf6987a17ec1bc385f16ca 100644
--- a/third_party/WebKit/Source/core/events/EventTarget.h
+++ b/third_party/WebKit/Source/core/events/EventTarget.h
@@ -79,6 +79,23 @@ public:
OwnPtr<FiringEventIteratorVector> firingEventIterators;
};
+enum class DispatchEventResult {
+ // Event was not canceled by event handler or default event handler.
+ NotCanceled,
+ // Event was canceled by event handler; ie. a script handler calling preventDefault.
philipj_slow 2016/02/25 04:21:27 i.e. is a much more common spelling, in Source/cor
dtapuska 2016/02/25 14:20:24 Done.
+ CanceledByEventHandler,
+ // Event was canceled by the default event handler; ie. executing the default action.
+ // This result should be used sparingly as it deviates from the DOM Event Dispatch
+ // model. Default event handlers really shouldn't be invoked inside of dispatch.
+ CanceledByDefaultEventHandler,
+ // Event was canceled but suppressed before dispatched to event handler.
+ // This result should be used sparingly; and likely its usage likely indicates
philipj_slow 2016/02/25 04:21:27 two likely
dtapuska 2016/02/25 14:20:24 Done.
+ // there is potential for a bug. Trusted events may return this code; but untrusted
+ // events likely should always execute the event handler the developer intends to
+ // execute.
+ CanceledBeforeDispatch,
+};
+
// This is the base class for all DOM event targets. To make your class an
// EventTarget, follow these steps:
// - Make your IDL interface inherit from EventTarget.
@@ -138,7 +155,7 @@ public:
bool removeEventListener(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener>, EventListenerOptions&);
virtual void removeAllEventListeners();
- bool dispatchEvent(PassRefPtrWillBeRawPtr<Event>);
+ DispatchEventResult dispatchEvent(PassRefPtrWillBeRawPtr<Event>);
// dispatchEventForBindings is intended to only be called from
// javascript originated calls. This method will validate and may adjust
@@ -156,7 +173,7 @@ public:
EventListenerVector* getEventListeners(const AtomicString& eventType);
Vector<AtomicString> eventTypes();
- bool fireEventListeners(Event*);
+ DispatchEventResult fireEventListeners(Event*);
DEFINE_INLINE_VIRTUAL_TRACE() { }
@@ -167,7 +184,7 @@ protected:
virtual bool addEventListenerInternal(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&);
virtual bool removeEventListenerInternal(const AtomicString& eventType, PassRefPtrWillBeRawPtr<EventListener>, const EventListenerOptions&);
- virtual bool dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>);
+ virtual DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Event>);
// Subclasses should likely not override these themselves; instead, they should subclass EventTargetWithInlineData.
virtual EventTargetData* eventTargetData() = 0;
« no previous file with comments | « third_party/WebKit/Source/core/events/EventDispatcher.cpp ('k') | third_party/WebKit/Source/core/events/EventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698