Changeset 181216 in webkit


Ignore:
Timestamp:
Mar 7, 2015 5:37:26 PM (9 years ago)
Author:
Darin Adler
Message:

Unindent EventTarget, EventListener, JSEventLister.h files
https://bugs.webkit.org/show_bug.cgi?id=142440

Reviewed by Alexey Proskuryakov.

  • bindings/js/JSEventListener.h:
  • dom/EventListener.h:
  • dom/EventTarget.h:

Change indentation to match coding style rules.

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r181215 r181216  
     12015-03-07  Darin Adler  <darin@apple.com>
     2
     3        Unindent EventTarget, EventListener, JSEventLister.h files
     4        https://bugs.webkit.org/show_bug.cgi?id=142440
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * bindings/js/JSEventListener.h:
     9        * dom/EventListener.h:
     10        * dom/EventTarget.h:
     11        Change indentation to match coding style rules.
     12
    1132015-03-07  Geoffrey Garen  <ggaren@apple.com>
    214
  • trunk/Source/WebCore/bindings/js/JSEventListener.h

    r181156 r181216  
    3030namespace WebCore {
    3131
    32     class EventTarget;
    33     class HTMLElement;
    34     class JSDOMGlobalObject;
     32class EventTarget;
     33class HTMLElement;
     34class JSDOMGlobalObject;
    3535
    36     class JSEventListener : public EventListener {
    37     public:
    38         static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld& world)
    39         {
    40             return adoptRef(*new JSEventListener(listener, wrapper, isAttribute, world));
    41         }
    42 
    43         static const JSEventListener* cast(const EventListener* listener)
    44         {
    45             return listener->type() == JSEventListenerType
    46                 ? static_cast<const JSEventListener*>(listener)
    47                 : 0;
    48         }
    49 
    50         virtual ~JSEventListener();
    51 
    52         virtual bool operator==(const EventListener& other) override;
    53 
    54         // Returns true if this event listener was created for an event handler attribute, like "onload" or "onclick".
    55         bool isAttribute() const { return m_isAttribute; }
    56 
    57         JSC::JSObject* jsFunction(ScriptExecutionContext*) const;
    58         DOMWrapperWorld& isolatedWorld() const { return *m_isolatedWorld; }
    59 
    60         JSC::JSObject* wrapper() const { return m_wrapper.get(); }
    61         void setWrapper(JSC::VM&, JSC::JSObject* wrapper) const { m_wrapper = JSC::Weak<JSC::JSObject>(wrapper); }
    62 
    63     private:
    64         virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const;
    65         virtual void visitJSFunction(JSC::SlotVisitor&) override;
    66         virtual bool virtualisAttribute() const override;
    67 
    68     protected:
    69         JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
    70         virtual void handleEvent(ScriptExecutionContext*, Event*) override;
    71 
    72     private:
    73         mutable JSC::Weak<JSC::JSObject> m_jsFunction;
    74         mutable JSC::Weak<JSC::JSObject> m_wrapper;
    75 
    76         bool m_isAttribute;
    77         RefPtr<DOMWrapperWorld> m_isolatedWorld;
    78     };
    79 
    80     // For "onxxx" attributes that automatically set up JavaScript event listeners.
    81     JSC::JSValue eventHandlerAttribute(EventTarget&, const AtomicString& eventType);
    82     void setEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, EventTarget&, const AtomicString& eventType, JSC::JSValue);
    83 
    84     // Like the functions above, but for attributes that forward event handlers to the window object rather than setting them on the target.
    85     JSC::JSValue windowForwardedEventHandlerAttribute(HTMLElement&, const AtomicString& eventType);
    86     void setWindowForwardedEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, HTMLElement&, const AtomicString& eventType, JSC::JSValue);
    87 
    88     Ref<JSEventListener> createJSEventListenerForAdd(JSC::ExecState&, JSC::JSObject& listener, JSC::JSObject& wrapper);
    89     Ref<JSEventListener> createJSEventListenerForRemove(JSC::ExecState&, JSC::JSObject& listener, JSC::JSObject& wrapper);
    90 
    91     inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* scriptExecutionContext) const
     36class JSEventListener : public EventListener {
     37public:
     38    static Ref<JSEventListener> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld& world)
    9239    {
    93         // initializeJSFunction can trigger code that deletes this event listener
    94         // before we're done. It should always return 0 in this case.
    95         Ref<JSEventListener> protect(const_cast<JSEventListener&>(*this));
    96         JSC::Strong<JSC::JSObject> wrapper(m_isolatedWorld->vm(), m_wrapper.get());
    97 
    98         if (!m_jsFunction) {
    99             JSC::JSObject* function = initializeJSFunction(scriptExecutionContext);
    100             JSC::JSObject* wrapper = m_wrapper.get();
    101             if (wrapper)
    102                 JSC::Heap::heap(wrapper)->writeBarrier(wrapper, function);
    103             m_jsFunction = JSC::Weak<JSC::JSObject>(function);
    104         }
    105 
    106         // Verify that we have a valid wrapper protecting our function from
    107         // garbage collection. That is except for when we're not in the normal
    108         // world and can have zombie m_jsFunctions.
    109         ASSERT(!m_isolatedWorld->isNormal() || m_wrapper || !m_jsFunction);
    110 
    111         // If m_wrapper is 0, then m_jsFunction is zombied, and should never be accessed.
    112         if (!m_wrapper)
    113             return 0;
    114 
    115         // Try to verify that m_jsFunction wasn't recycled. (Not exact, since an
    116         // event listener can be almost anything, but this makes test-writing easier).
    117         ASSERT(!m_jsFunction || static_cast<JSC::JSCell*>(m_jsFunction.get())->isObject());
    118 
    119         return m_jsFunction.get();
     40        return adoptRef(*new JSEventListener(listener, wrapper, isAttribute, world));
    12041    }
    12142
    122     inline Ref<JSEventListener> createJSEventListenerForRemove(JSC::ExecState& state, JSC::JSObject& listener, JSC::JSObject& wrapper)
     43    static const JSEventListener* cast(const EventListener* listener)
    12344    {
    124         return createJSEventListenerForAdd(state, listener, wrapper);
     45        return listener->type() == JSEventListenerType
     46            ? static_cast<const JSEventListener*>(listener)
     47            : 0;
    12548    }
     49
     50    virtual ~JSEventListener();
     51
     52    virtual bool operator==(const EventListener& other) override;
     53
     54    // Returns true if this event listener was created for an event handler attribute, like "onload" or "onclick".
     55    bool isAttribute() const { return m_isAttribute; }
     56
     57    JSC::JSObject* jsFunction(ScriptExecutionContext*) const;
     58    DOMWrapperWorld& isolatedWorld() const { return *m_isolatedWorld; }
     59
     60    JSC::JSObject* wrapper() const { return m_wrapper.get(); }
     61    void setWrapper(JSC::VM&, JSC::JSObject* wrapper) const { m_wrapper = JSC::Weak<JSC::JSObject>(wrapper); }
     62
     63private:
     64    virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const;
     65    virtual void visitJSFunction(JSC::SlotVisitor&) override;
     66    virtual bool virtualisAttribute() const override;
     67
     68protected:
     69    JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld&);
     70    virtual void handleEvent(ScriptExecutionContext*, Event*) override;
     71
     72private:
     73    mutable JSC::Weak<JSC::JSObject> m_jsFunction;
     74    mutable JSC::Weak<JSC::JSObject> m_wrapper;
     75
     76    bool m_isAttribute;
     77    RefPtr<DOMWrapperWorld> m_isolatedWorld;
     78};
     79
     80// For "onxxx" attributes that automatically set up JavaScript event listeners.
     81JSC::JSValue eventHandlerAttribute(EventTarget&, const AtomicString& eventType);
     82void setEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, EventTarget&, const AtomicString& eventType, JSC::JSValue);
     83
     84// Like the functions above, but for attributes that forward event handlers to the window object rather than setting them on the target.
     85JSC::JSValue windowForwardedEventHandlerAttribute(HTMLElement&, const AtomicString& eventType);
     86void setWindowForwardedEventHandlerAttribute(JSC::ExecState&, JSC::JSObject&, HTMLElement&, const AtomicString& eventType, JSC::JSValue);
     87
     88Ref<JSEventListener> createJSEventListenerForAdd(JSC::ExecState&, JSC::JSObject& listener, JSC::JSObject& wrapper);
     89Ref<JSEventListener> createJSEventListenerForRemove(JSC::ExecState&, JSC::JSObject& listener, JSC::JSObject& wrapper);
     90
     91inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* scriptExecutionContext) const
     92{
     93    // initializeJSFunction can trigger code that deletes this event listener
     94    // before we're done. It should always return 0 in this case.
     95    Ref<JSEventListener> protect(const_cast<JSEventListener&>(*this));
     96    JSC::Strong<JSC::JSObject> wrapper(m_isolatedWorld->vm(), m_wrapper.get());
     97
     98    if (!m_jsFunction) {
     99        JSC::JSObject* function = initializeJSFunction(scriptExecutionContext);
     100        JSC::JSObject* wrapper = m_wrapper.get();
     101        if (wrapper)
     102            JSC::Heap::heap(wrapper)->writeBarrier(wrapper, function);
     103        m_jsFunction = JSC::Weak<JSC::JSObject>(function);
     104    }
     105
     106    // Verify that we have a valid wrapper protecting our function from
     107    // garbage collection. That is except for when we're not in the normal
     108    // world and can have zombie m_jsFunctions.
     109    ASSERT(!m_isolatedWorld->isNormal() || m_wrapper || !m_jsFunction);
     110
     111    // If m_wrapper is 0, then m_jsFunction is zombied, and should never be accessed.
     112    if (!m_wrapper)
     113        return 0;
     114
     115    // Try to verify that m_jsFunction wasn't recycled. (Not exact, since an
     116    // event listener can be almost anything, but this makes test-writing easier).
     117    ASSERT(!m_jsFunction || static_cast<JSC::JSCell*>(m_jsFunction.get())->isObject());
     118
     119    return m_jsFunction.get();
     120}
     121
     122inline Ref<JSEventListener> createJSEventListenerForRemove(JSC::ExecState& state, JSC::JSObject& listener, JSC::JSObject& wrapper)
     123{
     124    return createJSEventListenerForAdd(state, listener, wrapper);
     125}
    126126
    127127} // namespace WebCore
  • trunk/Source/WebCore/dom/EventListener.h

    r152814 r181216  
    2525
    2626namespace JSC {
    27     class JSObject;
    28     class SlotVisitor;
     27class JSObject;
     28class SlotVisitor;
    2929}
    3030
    3131namespace WebCore {
    3232
    33     class ScriptExecutionContext;
    34     class Event;
     33class ScriptExecutionContext;
     34class Event;
    3535
    36     class EventListener : public RefCounted<EventListener> {
    37     public:
    38         enum Type {
    39             JSEventListenerType,
    40             ImageEventListenerType,
    41             ObjCEventListenerType,
    42             CPPEventListenerType,
    43             ConditionEventListenerType,
    44             GObjectEventListenerType,
    45             NativeEventListenerType,
    46             SVGTRefTargetEventListenerType,
    47             MediaControlsAppleEventListenerType
    48         };
     36class EventListener : public RefCounted<EventListener> {
     37public:
     38    enum Type {
     39        JSEventListenerType,
     40        ImageEventListenerType,
     41        ObjCEventListenerType,
     42        CPPEventListenerType,
     43        ConditionEventListenerType,
     44        GObjectEventListenerType,
     45        NativeEventListenerType,
     46        SVGTRefTargetEventListenerType,
     47        MediaControlsAppleEventListenerType
     48    };
    4949
    50         virtual ~EventListener() { }
    51         virtual bool operator==(const EventListener&) = 0;
    52         virtual void handleEvent(ScriptExecutionContext*, Event*) = 0;
    53         virtual bool wasCreatedFromMarkup() const { return false; }
     50    virtual ~EventListener() { }
     51    virtual bool operator==(const EventListener&) = 0;
     52    virtual void handleEvent(ScriptExecutionContext*, Event*) = 0;
     53    virtual bool wasCreatedFromMarkup() const { return false; }
    5454
    55         virtual void visitJSFunction(JSC::SlotVisitor&) { }
     55    virtual void visitJSFunction(JSC::SlotVisitor&) { }
    5656
    57         bool isAttribute() const { return virtualisAttribute(); }
    58         Type type() const { return m_type; }
     57    bool isAttribute() const { return virtualisAttribute(); }
     58    Type type() const { return m_type; }
    5959
    60     protected:
    61         explicit EventListener(Type type)
    62             : m_type(type)
    63         {
    64         }
     60protected:
     61    explicit EventListener(Type type)
     62        : m_type(type)
     63    {
     64    }
    6565
    66     private:
    67         virtual bool virtualisAttribute() const { return false; }
    68        
    69         Type m_type;
    70     };
     66private:
     67    virtual bool virtualisAttribute() const { return false; }
     68   
     69    Type m_type;
     70};
    7171
    7272}
  • trunk/Source/WebCore/dom/EventTarget.h

    r181169 r181216  
    2626 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2727 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    29  *
     28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    3029 */
    3130
     
    4544
    4645namespace WebCore {
     46
     47class AudioNode;
     48class AudioContext;
     49class AudioTrackList;
     50class DedicatedWorkerGlobalScope;
     51class DOMApplicationCache;
     52class DOMWindow;
     53class Event;
     54class EventListener;
     55class EventSource;
     56class FileReader;
     57class FileWriter;
     58class IDBDatabase;
     59class IDBRequest;
     60class IDBTransaction;
     61class ScriptProcessorNode;
     62class MediaController;
     63class MediaStream;
     64class MessagePort;
     65class Node;
     66class Notification;
     67class ScriptExecutionContext;
     68class TextTrack;
     69class TextTrackCue;
     70class VideoTrackList;
     71class WebSocket;
     72class WebKitNamedFlow;
     73class Worker;
     74class XMLHttpRequest;
     75class XMLHttpRequestUpload;
     76
     77typedef int ExceptionCode;
     78
     79struct FiringEventIterator {
     80    FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& size)
     81        : eventType(eventType)
     82        , iterator(iterator)
     83        , size(size)
     84    {
     85    }
     86
     87    const AtomicString& eventType;
     88    size_t& iterator;
     89    size_t& size;
     90};
     91typedef Vector<FiringEventIterator, 1> FiringEventIteratorVector;
     92
     93struct EventTargetData {
     94    WTF_MAKE_NONCOPYABLE(EventTargetData); WTF_MAKE_FAST_ALLOCATED;
     95public:
     96    EventTargetData();
     97    ~EventTargetData();
     98
     99    EventListenerMap eventListenerMap;
     100    std::unique_ptr<FiringEventIteratorVector> firingEventIterators;
     101};
     102
     103enum EventTargetInterface {
     104
     105#define DOM_EVENT_INTERFACE_DECLARE(name) name##EventTargetInterfaceType,
     106DOM_EVENT_TARGET_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
     107#undef DOM_EVENT_INTERFACE_DECLARE
     108
     109};
     110
     111class EventTarget {
     112public:
     113    void ref() { refEventTarget(); }
     114    void deref() { derefEventTarget(); }
     115
     116    virtual EventTargetInterface eventTargetInterface() const = 0;
     117    virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
     118
     119    virtual Node* toNode();
     120    virtual DOMWindow* toDOMWindow();
     121    virtual bool isMessagePort() const;
     122
     123    virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
     124    virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
     125    virtual void removeAllEventListeners();
     126    virtual bool dispatchEvent(PassRefPtr<Event>);
     127    bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); // DOM API
     128    virtual void uncaughtExceptionInEventHandler();
     129
     130    // Used for legacy "onEvent" attribute APIs.
     131    bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
     132    bool clearAttributeEventListener(const AtomicString& eventType);
     133    EventListener* getAttributeEventListener(const AtomicString& eventType);
     134
     135    bool hasEventListeners() const;
     136    bool hasEventListeners(const AtomicString& eventType);
     137    bool hasCapturingEventListeners(const AtomicString& eventType);
     138    const EventListenerVector& getEventListeners(const AtomicString& eventType);
     139
     140    bool fireEventListeners(Event*);
     141    bool isFiringEventListeners();
     142
     143    void visitJSEventListeners(JSC::SlotVisitor&);
     144    void invalidateJSEventListeners(JSC::JSObject*);
     145
     146protected:
     147    virtual ~EventTarget();
    47148   
    48     class AudioNode;
    49     class AudioContext;
    50     class AudioTrackList;
    51     class DedicatedWorkerGlobalScope;
    52     class DOMApplicationCache;
    53     class DOMWindow;
    54     class Event;
    55     class EventListener;
    56     class EventSource;
    57     class FileReader;
    58     class FileWriter;
    59     class IDBDatabase;
    60     class IDBRequest;
    61     class IDBTransaction;
    62     class ScriptProcessorNode;
    63     class MediaController;
    64     class MediaStream;
    65     class MessagePort;
    66     class Node;
    67     class Notification;
    68     class ScriptExecutionContext;
    69     class TextTrack;
    70     class TextTrackCue;
    71     class VideoTrackList;
    72     class WebSocket;
    73     class WebKitNamedFlow;
    74     class Worker;
    75     class XMLHttpRequest;
    76     class XMLHttpRequestUpload;
    77 
    78     typedef int ExceptionCode;
    79 
    80     struct FiringEventIterator {
    81         FiringEventIterator(const AtomicString& eventType, size_t& iterator, size_t& size)
    82             : eventType(eventType)
    83             , iterator(iterator)
    84             , size(size)
    85         {
    86         }
    87 
    88         const AtomicString& eventType;
    89         size_t& iterator;
    90         size_t& size;
    91     };
    92     typedef Vector<FiringEventIterator, 1> FiringEventIteratorVector;
    93 
    94     struct EventTargetData {
    95         WTF_MAKE_NONCOPYABLE(EventTargetData); WTF_MAKE_FAST_ALLOCATED;
    96     public:
    97         EventTargetData();
    98         ~EventTargetData();
    99 
    100         EventListenerMap eventListenerMap;
    101         std::unique_ptr<FiringEventIteratorVector> firingEventIterators;
    102     };
    103 
    104     enum EventTargetInterface {
    105 
    106     #define DOM_EVENT_INTERFACE_DECLARE(name) name##EventTargetInterfaceType,
    107     DOM_EVENT_TARGET_INTERFACES_FOR_EACH(DOM_EVENT_INTERFACE_DECLARE)
    108     #undef DOM_EVENT_INTERFACE_DECLARE
    109 
    110     };
    111 
    112     class EventTarget {
    113     public:
    114         void ref() { refEventTarget(); }
    115         void deref() { derefEventTarget(); }
    116 
    117         virtual EventTargetInterface eventTargetInterface() const = 0;
    118         virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
    119 
    120         virtual Node* toNode();
    121         virtual DOMWindow* toDOMWindow();
    122         virtual bool isMessagePort() const;
    123 
    124         virtual bool addEventListener(const AtomicString& eventType, PassRefPtr<EventListener>, bool useCapture);
    125         virtual bool removeEventListener(const AtomicString& eventType, EventListener*, bool useCapture);
    126         virtual void removeAllEventListeners();
    127         virtual bool dispatchEvent(PassRefPtr<Event>);
    128         bool dispatchEvent(PassRefPtr<Event>, ExceptionCode&); // DOM API
    129         virtual void uncaughtExceptionInEventHandler();
    130 
    131         // Used for legacy "onEvent" attribute APIs.
    132         bool setAttributeEventListener(const AtomicString& eventType, PassRefPtr<EventListener>);
    133         bool clearAttributeEventListener(const AtomicString& eventType);
    134         EventListener* getAttributeEventListener(const AtomicString& eventType);
    135 
    136         bool hasEventListeners() const;
    137         bool hasEventListeners(const AtomicString& eventType);
    138         bool hasCapturingEventListeners(const AtomicString& eventType);
    139         const EventListenerVector& getEventListeners(const AtomicString& eventType);
    140 
    141         bool fireEventListeners(Event*);
    142         bool isFiringEventListeners();
    143 
    144         void visitJSEventListeners(JSC::SlotVisitor&);
    145         void invalidateJSEventListeners(JSC::JSObject*);
    146 
    147     protected:
    148         virtual ~EventTarget();
    149        
    150         virtual EventTargetData* eventTargetData() = 0;
    151         virtual EventTargetData& ensureEventTargetData() = 0;
    152 
    153     private:
    154         virtual void refEventTarget() = 0;
    155         virtual void derefEventTarget() = 0;
    156        
    157         void fireEventListeners(Event*, EventTargetData*, EventListenerVector&);
    158 
    159         friend class EventListenerIterator;
    160     };
    161 
    162     class EventTargetWithInlineData : public EventTarget {
    163     protected:
    164         virtual EventTargetData* eventTargetData() override final { return &m_eventTargetData; }
    165         virtual EventTargetData& ensureEventTargetData() override final { return m_eventTargetData; }
    166     private:
    167         EventTargetData m_eventTargetData;
    168     };
    169 
    170     inline void EventTarget::visitJSEventListeners(JSC::SlotVisitor& visitor)
    171     {
    172         EventListenerIterator iterator(this);
    173         while (EventListener* listener = iterator.nextListener())
    174             listener->visitJSFunction(visitor);
    175     }
    176 
    177     inline bool EventTarget::isFiringEventListeners()
    178     {
    179         EventTargetData* d = eventTargetData();
    180         if (!d)
    181             return false;
    182         return d->firingEventIterators && !d->firingEventIterators->isEmpty();
    183     }
    184 
    185     inline bool EventTarget::hasEventListeners() const
    186     {
    187         EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetData();
    188         if (!d)
    189             return false;
    190         return !d->eventListenerMap.isEmpty();
    191     }
    192 
    193     inline bool EventTarget::hasEventListeners(const AtomicString& eventType)
    194     {
    195         EventTargetData* d = eventTargetData();
    196         if (!d)
    197             return false;
    198         return d->eventListenerMap.contains(eventType);
    199     }
    200 
    201     inline bool EventTarget::hasCapturingEventListeners(const AtomicString& eventType)
    202     {
    203         EventTargetData* d = eventTargetData();
    204         if (!d)
    205             return false;
    206         return d->eventListenerMap.containsCapturing(eventType);
    207     }
     149    virtual EventTargetData* eventTargetData() = 0;
     150    virtual EventTargetData& ensureEventTargetData() = 0;
     151
     152private:
     153    virtual void refEventTarget() = 0;
     154    virtual void derefEventTarget() = 0;
     155   
     156    void fireEventListeners(Event*, EventTargetData*, EventListenerVector&);
     157
     158    friend class EventListenerIterator;
     159};
     160
     161class EventTargetWithInlineData : public EventTarget {
     162protected:
     163    virtual EventTargetData* eventTargetData() override final { return &m_eventTargetData; }
     164    virtual EventTargetData& ensureEventTargetData() override final { return m_eventTargetData; }
     165private:
     166    EventTargetData m_eventTargetData;
     167};
     168
     169inline void EventTarget::visitJSEventListeners(JSC::SlotVisitor& visitor)
     170{
     171    EventListenerIterator iterator(this);
     172    while (EventListener* listener = iterator.nextListener())
     173        listener->visitJSFunction(visitor);
     174}
     175
     176inline bool EventTarget::isFiringEventListeners()
     177{
     178    EventTargetData* d = eventTargetData();
     179    if (!d)
     180        return false;
     181    return d->firingEventIterators && !d->firingEventIterators->isEmpty();
     182}
     183
     184inline bool EventTarget::hasEventListeners() const
     185{
     186    EventTargetData* d = const_cast<EventTarget*>(this)->eventTargetData();
     187    if (!d)
     188        return false;
     189    return !d->eventListenerMap.isEmpty();
     190}
     191
     192inline bool EventTarget::hasEventListeners(const AtomicString& eventType)
     193{
     194    EventTargetData* d = eventTargetData();
     195    if (!d)
     196        return false;
     197    return d->eventListenerMap.contains(eventType);
     198}
     199
     200inline bool EventTarget::hasCapturingEventListeners(const AtomicString& eventType)
     201{
     202    EventTargetData* d = eventTargetData();
     203    if (!d)
     204        return false;
     205    return d->eventListenerMap.containsCapturing(eventType);
     206}
    208207
    209208} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.