2 * Copyright (C) 2001 Peter Kelly (pmk@post.com)
3 * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 #ifndef JSEventListener_h
21 #define JSEventListener_h
23 #include "EventListener.h"
24 #include <runtime/Protect.h>
28 class JSDOMGlobalObject;
30 class JSAbstractEventListener : public EventListener {
32 bool isInline() const { return m_isInline; }
35 JSAbstractEventListener(bool isInline)
36 : m_isInline(isInline)
41 virtual void handleEvent(Event*, bool isWindowEvent);
42 virtual JSDOMGlobalObject* globalObject() const = 0;
43 virtual bool virtualIsInline() const;
48 class JSEventListener : public JSAbstractEventListener {
50 static PassRefPtr<JSEventListener> create(JSC::JSObject* listener, JSDOMGlobalObject* globalObject, bool isInline)
52 return adoptRef(new JSEventListener(listener, globalObject, isInline));
54 virtual ~JSEventListener();
56 void clearGlobalObject();
59 JSEventListener(JSC::JSObject* listener, JSDOMGlobalObject*, bool isInline);
61 virtual JSC::JSObject* function() const;
63 virtual JSDOMGlobalObject* globalObject() const;
65 JSC::JSObject* m_listener;
66 JSDOMGlobalObject* m_globalObject;
69 class JSProtectedEventListener : public JSAbstractEventListener {
71 static PassRefPtr<JSProtectedEventListener> create(JSC::JSObject* listener, JSDOMGlobalObject* globalObject, bool isInline)
73 return adoptRef(new JSProtectedEventListener(listener, globalObject, isInline));
75 virtual ~JSProtectedEventListener();
77 void clearGlobalObject();
80 JSProtectedEventListener(JSC::JSObject* listener, JSDOMGlobalObject*, bool isInline);
82 mutable JSC::ProtectedPtr<JSC::JSObject> m_listener;
83 JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject;
86 virtual JSC::JSObject* function() const;
87 virtual JSDOMGlobalObject* globalObject() const;
90 } // namespace WebCore
92 #endif // JSEventListener_h