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 Object listenerObj() const { return listener; }
00048
00049 ObjectImp *listenerObjImp() const { return static_cast<ObjectImp *>(listener.imp()); }
00050
00051 void clear() { listener = Object(); }
00052
00053 protected:
00054 Object listener;
00055 bool html;
00056 Object win, m_hackThisObj;
00057 };
00058
00059 Value getNodeEventListener(DOM::Node n, int eventId);
00060
00061
00062 class EventConstructor : public DOMObject {
00063 public:
00064 EventConstructor(ExecState *);
00065 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00066 Value getValueProperty(ExecState *, int token) const;
00067
00068 virtual const ClassInfo* classInfo() const { return &info; }
00069 static const ClassInfo info;
00070 };
00071
00072 Value getEventConstructor(ExecState *exec);
00073
00074 class DOMEvent : public DOMObject {
00075 public:
00076
00077 DOMEvent(ExecState *exec, DOM::Event e);
00078
00079 DOMEvent(const Object &proto, DOM::Event e);
00080 ~DOMEvent();
00081 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00082 Value getValueProperty(ExecState *, int token) const;
00083 virtual void tryPut(ExecState *exec, const Identifier &propertyName,
00084 const Value& value, int attr = None);
00085 virtual Value defaultValue(ExecState *exec, KJS::Type hint) const;
00086 void putValueProperty(ExecState *exec, int token, const Value& value, int);
00087 virtual const ClassInfo* classInfo() const { return &info; }
00088 static const ClassInfo info;
00089 enum { Type, Target, CurrentTarget, EventPhase, Bubbles,
00090 Cancelable, TimeStamp, StopPropagation, PreventDefault, InitEvent,
00091
00092 SrcElement, ReturnValue, CancelBubble };
00093 DOM::Event toEvent() const { return event; }
00094 protected:
00095 DOM::Event event;
00096 };
00097
00098 Value getDOMEvent(ExecState *exec, DOM::Event e);
00099
00103 DOM::Event toEvent(const Value&);
00104
00105
00106 class EventExceptionConstructor : public DOMObject {
00107 public:
00108 EventExceptionConstructor(ExecState *);
00109 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00110 Value getValueProperty(ExecState *, int token) const;
00111
00112 virtual const ClassInfo* classInfo() const { return &info; }
00113 static const ClassInfo info;
00114 };
00115
00116 Value getEventExceptionConstructor(ExecState *exec);
00117
00118 class DOMUIEvent : public DOMEvent {
00119 public:
00120
00121 DOMUIEvent(ExecState *exec, DOM::UIEvent ue);
00122
00123 DOMUIEvent(const Object &proto, DOM::UIEvent ue);
00124 ~DOMUIEvent();
00125 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00126 Value getValueProperty(ExecState *, int token) const;
00127
00128 virtual const ClassInfo* classInfo() const { return &info; }
00129 static const ClassInfo info;
00130 enum { View, Detail, KeyCode, LayerX, LayerY, PageX, PageY, Which, InitUIEvent };
00131 DOM::UIEvent toUIEvent() const { return static_cast<DOM::UIEvent>(event); }
00132 };
00133
00134 class DOMMouseEvent : public DOMUIEvent {
00135 public:
00136 DOMMouseEvent(ExecState *exec, DOM::MouseEvent me);
00137 ~DOMMouseEvent();
00138 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00139 Value getValueProperty(ExecState *, int token) const;
00140
00141 virtual const ClassInfo* classInfo() const { return &info; }
00142 static const ClassInfo info;
00143 enum { ScreenX, ScreenY, ClientX, X, ClientY, Y, OffsetX, OffsetY,
00144 CtrlKey, ShiftKey, AltKey,
00145 MetaKey, Button, RelatedTarget, FromElement, ToElement,
00146 InitMouseEvent
00147 };
00148 DOM::MouseEvent toMouseEvent() const { return static_cast<DOM::MouseEvent>(event); }
00149 };
00150
00151 class DOMTextEvent : public DOMUIEvent {
00152 public:
00153 DOMTextEvent(ExecState *exec, DOM::TextEvent ke);
00154 ~DOMTextEvent();
00155 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00156 Value getValueProperty(ExecState *, int token) const;
00157
00158 virtual const ClassInfo* classInfo() const { return &info; }
00159 static const ClassInfo info;
00160 enum { Key, VirtKey, OutputString, InitTextEvent, InputGenerated, NumPad };
00161 DOM::TextEvent toTextEvent() const { return static_cast<DOM::TextEvent>(event); }
00162 };
00163
00164
00165 class MutationEventConstructor : public DOMObject {
00166 public:
00167 MutationEventConstructor(ExecState *);
00168 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00169 Value getValueProperty(ExecState *, int token) const;
00170
00171 virtual const ClassInfo* classInfo() const { return &info; }
00172 static const ClassInfo info;
00173 };
00174
00175 Value getMutationEventConstructor(ExecState *exec);
00176
00177 class DOMMutationEvent : public DOMEvent {
00178 public:
00179 DOMMutationEvent(ExecState *exec, DOM::MutationEvent me);
00180 ~DOMMutationEvent();
00181 virtual Value tryGet(ExecState *exec,const Identifier &p) const;
00182 Value getValueProperty(ExecState *, int token) const;
00183
00184 virtual const ClassInfo* classInfo() const { return &info; }
00185 static const ClassInfo info;
00186 enum { AttrChange, RelatedNode, AttrName, PrevValue, NewValue,
00187 InitMutationEvent };
00188 DOM::MutationEvent toMutationEvent() const { return static_cast<DOM::MutationEvent>(event); }
00189 };
00190
00191 }
00192
00193 #endif