00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef _KJS_EVENTS_H_
00023
#define _KJS_EVENTS_H_
00024
00025
#include "ecma/kjs_dom.h"
00026
#include "dom/dom2_events.h"
00027
#include "dom/dom_misc.h"
00028
00029
namespace KJS {
00030
00031
class Window;
00032
00033
class JSEventListener :
public DOM::
EventListener {
00034
public:
00040 JSEventListener(Object _listener,
const Object &_win,
bool _html =
false);
00041
virtual ~JSEventListener();
00042
void hackSetThisObj( Object& thisObj ) { m_hackThisObj = thisObj; }
00043
void hackUnsetThisObj() { m_hackThisObj = Object(0L); }
00044
virtual void handleEvent(
DOM::Event &evt);
00045
virtual DOM::DOMString eventListenerType();
00046
00047 Value listenerObj()
const {
return listener; }
00048
00049
00050
00051
void clear() { listener = Null(); }
00052
00053
protected:
00054 Value listener;
00055
bool html;
00056 Object win, m_hackThisObj;
00057 };
00058
00059
00060
class EventConstructor :
public DOMObject {
00061
public:
00062 EventConstructor(ExecState *);
00063
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00064 Value getValueProperty(ExecState *,
int token)
const;
00065
00066
virtual const ClassInfo* classInfo()
const {
return &info; }
00067
static const ClassInfo info;
00068 };
00069
00070 Value getEventConstructor(ExecState *exec);
00071
00072
class DOMEvent :
public DOMObject {
00073
public:
00074
00075 DOMEvent(ExecState *exec,
DOM::Event e);
00076
00077 DOMEvent(
const Object &proto,
DOM::Event e);
00078 ~DOMEvent();
00079
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00080 Value getValueProperty(ExecState *,
int token)
const;
00081
virtual void tryPut(ExecState *exec,
const Identifier &propertyName,
00082
const Value& value,
int attr = None);
00083
virtual Value defaultValue(ExecState *exec, KJS::Type hint)
const;
00084
void putValueProperty(ExecState *exec,
int token,
const Value& value,
int);
00085
virtual const ClassInfo* classInfo()
const {
return &info; }
00086
static const ClassInfo info;
00087
enum { Type, Target, CurrentTarget, EventPhase, Bubbles,
00088 Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
00089
00090 SrcElement, ReturnValue, CancelBubble };
00091
DOM::Event toEvent()
const {
return event; }
00092
protected:
00093
DOM::Event event;
00094 };
00095
00096 Value getDOMEvent(ExecState *exec,
DOM::Event e);
00097
00101
DOM::Event toEvent(
const Value&);
00102
00103
00104
class EventExceptionConstructor :
public DOMObject {
00105
public:
00106 EventExceptionConstructor(ExecState *);
00107
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00108 Value getValueProperty(ExecState *,
int token)
const;
00109
00110
virtual const ClassInfo* classInfo()
const {
return &info; }
00111
static const ClassInfo info;
00112 };
00113
00114 Value getEventExceptionConstructor(ExecState *exec);
00115
00116
class DOMUIEvent :
public DOMEvent {
00117
public:
00118
00119 DOMUIEvent(ExecState *exec,
DOM::UIEvent ue);
00120
00121 DOMUIEvent(
const Object &proto,
DOM::UIEvent ue);
00122 ~DOMUIEvent();
00123
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00124 Value getValueProperty(ExecState *,
int token)
const;
00125
00126
virtual const ClassInfo* classInfo()
const {
return &info; }
00127
static const ClassInfo info;
00128
enum { View, Detail, KeyCode, LayerX, LayerY, PageX, PageY, Which, InitUIEvent };
00129
DOM::UIEvent toUIEvent()
const {
return static_cast<DOM::UIEvent>(
event); }
00130 };
00131
00132
class DOMMouseEvent :
public DOMUIEvent {
00133
public:
00134 DOMMouseEvent(ExecState *exec,
DOM::MouseEvent me);
00135 ~DOMMouseEvent();
00136
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00137 Value getValueProperty(ExecState *,
int token)
const;
00138
00139
virtual const ClassInfo* classInfo()
const {
return &info; }
00140
static const ClassInfo info;
00141
enum { ScreenX, ScreenY, ClientX, X, ClientY, Y, OffsetX, OffsetY,
00142 CtrlKey, ShiftKey, AltKey,
00143 MetaKey, Button, RelatedTarget, FromElement, ToElement,
00144 InitMouseEvent
00145 };
00146
DOM::MouseEvent toMouseEvent()
const {
return static_cast<DOM::MouseEvent>(
event); }
00147 };
00148
00149
class DOMTextEvent :
public DOMUIEvent {
00150
public:
00151 DOMTextEvent(ExecState *exec,
DOM::TextEvent ke);
00152 ~DOMTextEvent();
00153
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00154 Value getValueProperty(ExecState *,
int token)
const;
00155
00156
virtual const ClassInfo* classInfo()
const {
return &info; }
00157
static const ClassInfo info;
00158
enum { Key, VirtKey, OutputString, InitTextEvent, InputGenerated, NumPad };
00159
DOM::TextEvent toTextEvent()
const {
return static_cast<DOM::TextEvent>(
event); }
00160 };
00161
00162
00163
class MutationEventConstructor :
public DOMObject {
00164
public:
00165 MutationEventConstructor(ExecState *);
00166
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00167 Value getValueProperty(ExecState *,
int token)
const;
00168
00169
virtual const ClassInfo* classInfo()
const {
return &info; }
00170
static const ClassInfo info;
00171 };
00172
00173 Value getMutationEventConstructor(ExecState *exec);
00174
00175
class DOMMutationEvent :
public DOMEvent {
00176
public:
00177 DOMMutationEvent(ExecState *exec,
DOM::MutationEvent me);
00178 ~DOMMutationEvent();
00179
virtual Value tryGet(ExecState *exec,
const Identifier &p)
const;
00180 Value getValueProperty(ExecState *,
int token)
const;
00181
00182
virtual const ClassInfo* classInfo()
const {
return &info; }
00183
static const ClassInfo info;
00184
enum { AttrChange, RelatedNode, AttrName, PrevValue, NewValue,
00185 InitMutationEvent };
00186
DOM::MutationEvent toMutationEvent()
const {
return static_cast<DOM::MutationEvent>(
event); }
00187 };
00188
00189 }
00190
00191
#endif