~ubuntu-branches/ubuntu/maverick/webkit/maverick

« back to all changes in this revision

Viewing changes to WebCore/bindings/js/kjs_events.h

  • Committer: Bazaar Package Importer
  • Author(s): Mike Hommey
  • Date: 2007-08-19 15:54:12 UTC
  • Revision ID: james.westby@ubuntu.com-20070819155412-uxxg1h9plpghmtbi
Tags: upstream-0~svn25144
ImportĀ upstreamĀ versionĀ 0~svn25144

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  This file is part of the KDE libraries
 
3
 *  Copyright (C) 2001 Peter Kelly (pmk@post.com)
 
4
 *  Copyright (C) 2003 Apple Computer, Inc.
 
5
 *
 
6
 *  This library is free software; you can redistribute it and/or
 
7
 *  modify it under the terms of the GNU Lesser General Public
 
8
 *  License as published by the Free Software Foundation; either
 
9
 *  version 2 of the License, or (at your option) any later version.
 
10
 *
 
11
 *  This library is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 *  Lesser General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU Lesser General Public
 
17
 *  License along with this library; if not, write to the Free Software
 
18
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 */
 
20
 
 
21
#ifndef kjs_events_h
 
22
#define kjs_events_h
 
23
 
 
24
#include "EventListener.h"
 
25
#include "PlatformString.h"
 
26
#include "kjs_dom.h"
 
27
#include "kjs_html.h"
 
28
 
 
29
 
 
30
namespace KJS {
 
31
    class Window;
 
32
}
 
33
 
 
34
namespace WebCore {
 
35
 
 
36
    class Clipboard;
 
37
    class Event;
 
38
 
 
39
    class JSAbstractEventListener : public EventListener {
 
40
    public:
 
41
        JSAbstractEventListener(bool html = false);
 
42
 
 
43
        virtual void handleEvent(Event*, bool isWindowEvent);
 
44
        virtual bool isHTMLEventListener() const;
 
45
        virtual KJS::JSObject* listenerObj() const = 0;
 
46
        virtual KJS::Window* windowObj() const = 0;
 
47
 
 
48
    private:
 
49
        bool m_html;
 
50
    };
 
51
 
 
52
    class JSUnprotectedEventListener : public JSAbstractEventListener {
 
53
    public:
 
54
        JSUnprotectedEventListener(KJS::JSObject* listener, KJS::Window*, bool html = false);
 
55
        virtual ~JSUnprotectedEventListener();
 
56
 
 
57
        virtual KJS::JSObject* listenerObj() const;
 
58
        virtual KJS::Window* windowObj() const;
 
59
        void clearWindowObj();
 
60
        virtual void mark();
 
61
    private:
 
62
        KJS::JSObject* m_listener;
 
63
        KJS::Window* m_win;
 
64
    };
 
65
 
 
66
    class JSEventListener : public JSAbstractEventListener {
 
67
    public:
 
68
        JSEventListener(KJS::JSObject* listener, KJS::Window*, bool html = false);
 
69
        virtual ~JSEventListener();
 
70
 
 
71
        virtual KJS::JSObject* listenerObj() const;
 
72
        virtual KJS::Window* windowObj() const;
 
73
        void clearWindowObj();
 
74
 
 
75
    protected:
 
76
        mutable KJS::ProtectedPtr<KJS::JSObject> m_listener;
 
77
 
 
78
    private:
 
79
        KJS::ProtectedPtr<KJS::Window> m_win;
 
80
    };
 
81
 
 
82
    class JSLazyEventListener : public JSEventListener {
 
83
    public:
 
84
        JSLazyEventListener(const String& functionName, const String& code, KJS::Window*, Node*, int lineNumber = 0);
 
85
        virtual KJS::JSObject* listenerObj() const;
 
86
 
 
87
    private:
 
88
        virtual KJS::JSValue* eventParameterName() const;
 
89
        void parseCode() const;
 
90
 
 
91
        mutable String m_functionName;
 
92
        mutable String m_code;
 
93
        mutable bool m_parsed;
 
94
        int m_lineNumber;
 
95
        Node* m_originalNode;
 
96
    };
 
97
 
 
98
    KJS::JSValue* getNodeEventListener(Node*, const AtomicString& eventType);
 
99
 
 
100
    class JSClipboard : public KJS::DOMObject {
 
101
    public:
 
102
        JSClipboard(KJS::ExecState*, Clipboard*);
 
103
        virtual ~JSClipboard();
 
104
 
 
105
        virtual bool getOwnPropertySlot(KJS::ExecState*, const KJS::Identifier&, KJS::PropertySlot&);
 
106
        KJS::JSValue* getValueProperty(KJS::ExecState*, int token) const;
 
107
        virtual void put(KJS::ExecState*, const KJS::Identifier&, KJS::JSValue*, int attr = KJS::None);
 
108
        void putValueProperty(KJS::ExecState*, int token, KJS::JSValue*, int attr);
 
109
 
 
110
        virtual const KJS::ClassInfo* classInfo() const { return &info; }
 
111
        static const KJS::ClassInfo info;
 
112
 
 
113
        enum { ClearData, GetData, SetData, Types, SetDragImage, DropEffect, EffectAllowed };
 
114
 
 
115
        Clipboard* impl() const { return m_impl.get(); }
 
116
 
 
117
    private:
 
118
        RefPtr<Clipboard> m_impl;
 
119
    };
 
120
 
 
121
    KJS::JSValue* toJS(KJS::ExecState*, Clipboard*);
 
122
    Clipboard* toClipboard(KJS::JSValue*);
 
123
 
 
124
} // namespace WebCore
 
125
 
 
126
#endif // kjs_events_h