Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 public: | 72 public: |
| 73 EventTargetData(); | 73 EventTargetData(); |
| 74 ~EventTargetData(); | 74 ~EventTargetData(); |
| 75 | 75 |
| 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 enum class DispatchEventResult { | |
| 83 // Event was not consumed by application or system. | |
|
philipj_slow
2016/02/24 10:19:51
s/consumed/canceled/, s/application/event handler/
dtapuska
2016/02/24 22:14:16
Done.
| |
| 84 NotCanceled, | |
| 85 // Event was consumed by application itself; ie. a script handler calling pr eventDefault. | |
| 86 CanceledByEventHandler, | |
| 87 // Event was consumed by the system; ie. executing the default action. | |
| 88 CanceledByDefaultEventHandler, | |
|
philipj_slow
2016/02/24 10:19:51
Add stern warnings that these two should not be us
dtapuska
2016/02/24 22:14:16
Done.
| |
| 89 // Event was consumed but suppressed before dispatched to application. | |
| 90 CanceledBeforeDispatch, | |
| 91 }; | |
| 92 | |
| 82 // This is the base class for all DOM event targets. To make your class an | 93 // This is the base class for all DOM event targets. To make your class an |
| 83 // EventTarget, follow these steps: | 94 // EventTarget, follow these steps: |
| 84 // - Make your IDL interface inherit from EventTarget. | 95 // - Make your IDL interface inherit from EventTarget. |
| 85 // Optionally add "attribute EventHandler onfoo;" attributes. | 96 // Optionally add "attribute EventHandler onfoo;" attributes. |
| 86 // - Inherit from EventTargetWithInlineData (only in rare cases should you use | 97 // - Inherit from EventTargetWithInlineData (only in rare cases should you use |
| 87 // EventTarget directly); or, if you want YourClass to be inherited from | 98 // EventTarget directly); or, if you want YourClass to be inherited from |
| 88 // RefCountedGarbageCollected<YourClass> in addition to EventTargetWithInlineD ata, | 99 // RefCountedGarbageCollected<YourClass> in addition to EventTargetWithInlineD ata, |
| 89 // inherit from RefCountedGarbageCollectedEventTargetWithInlineData<YourClass> . | 100 // inherit from RefCountedGarbageCollectedEventTargetWithInlineData<YourClass> . |
| 90 // - In your class declaration, EventTargetWithInlineData (or | 101 // - In your class declaration, EventTargetWithInlineData (or |
| 91 // RefCountedGarbageCollectedEventTargetWithInlineData<>) must come first in | 102 // RefCountedGarbageCollectedEventTargetWithInlineData<>) must come first in |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 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 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 DispatchEventResult dispatchEventInternal(PassRefPtrWillBeRawPtr<Eve nt>); |
| 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 Loading... | |
| 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 |
| OLD | NEW |