#ifndef KJS_DOM_H
#define KJS_DOM_H
#include "JSNode.h"
#include "NodeList.h"
#include "kjs_binding.h"
#include "DeprecatedValueList.h"
namespace WebCore {
class AtomicString;
class Attr;
class CharacterData;
class DocumentType;
class DOMImplementation;
class Element;
class Entity;
class EventTargetNode;
class NamedNodeMap;
class Notation;
class ProcessingInstruction;
class Text;
}
namespace KJS {
KJS_DEFINE_PROTOTYPE_WITH_PROTOTYPE(DOMEventTargetNodeProto, WebCore::JSNodeProto)
class DOMEventTargetNode : public WebCore::JSNode {
public:
DOMEventTargetNode(ExecState *exec, WebCore::Node *n);
void setListener(ExecState* exec, const WebCore::AtomicString &eventType, JSValue* func) const;
JSValue* getListener(const WebCore::AtomicString &eventType) const;
virtual void pushEventHandlerScope(ExecState* exec, ScopeChain &scope) const;
bool getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot);
JSValue* getValueProperty(ExecState* exec, int token) const;
virtual void put(ExecState* exec, const Identifier& propertyName, JSValue* value, int attr);
void putValueProperty(ExecState* exec, int token, JSValue* value, int);
enum {
AddEventListener, RemoveEventListener, DispatchEvent,
OnAbort, OnBlur, OnChange, OnClick, OnContextMenu, OnDblClick, OnDragDrop, OnError,
OnDragEnter, OnDragOver, OnDragLeave, OnDrop, OnDragStart, OnDrag, OnDragEnd,
OnBeforeCut, OnCut, OnBeforeCopy, OnCopy, OnBeforePaste, OnPaste, OnSelectStart,
OnFocus, OnInput, OnKeyDown, OnKeyPress, OnKeyUp, OnLoad, OnMouseDown,
OnMouseMove, OnMouseOut, OnMouseOver, OnMouseUp, OnMouseWheel, OnMove, OnReset,
OnResize, OnScroll, OnSearch, OnSelect, OnSubmit, OnUnload
};
};
WebCore::EventTargetNode* toEventTargetNode(JSValue*); WebCore::Node* toNode(JSValue*);
class DOMNodeList : public DOMObject {
public:
DOMNodeList(ExecState *, WebCore::NodeList *l);
~DOMNodeList();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
JSValue *getValueProperty(ExecState *exec, int token) const;
virtual JSValue *callAsFunction(ExecState *exec, JSObject *thisObj, const List&args);
virtual bool implementsCall() const { return true; }
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
enum { Length, Item };
WebCore::NodeList *impl() const { return m_impl.get(); }
virtual JSValue *toPrimitive(ExecState *exec, JSType preferred = UndefinedType) const;
private:
static JSValue *indexGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot& slot);
static JSValue *nameGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot& slot);
RefPtr<WebCore::NodeList> m_impl;
};
WebCore::Attr* toAttr(JSValue*, bool& ok);
WebCore::Element *toElement(JSValue *);
WebCore::DocumentType *toDocumentType(JSValue *);
class DOMNamedNodeMap : public DOMObject {
public:
DOMNamedNodeMap(ExecState *, WebCore::NamedNodeMap *m);
~DOMNamedNodeMap();
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual const ClassInfo* classInfo() const { return &info; }
virtual bool toBoolean(ExecState *) const { return true; }
static const ClassInfo info;
enum { GetNamedItem, SetNamedItem, RemoveNamedItem, Item,
GetNamedItemNS, SetNamedItemNS, RemoveNamedItemNS };
WebCore::NamedNodeMap *impl() const { return m_impl.get(); }
private:
static JSValue *lengthGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
static JSValue *indexGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
static JSValue *nameGetter(ExecState *exec, JSObject *, const Identifier&, const PropertySlot& slot);
RefPtr<WebCore::NamedNodeMap> m_impl;
};
class DOMExceptionConstructor : public DOMObject {
public:
DOMExceptionConstructor(ExecState*);
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
JSValue *getValueProperty(ExecState *exec, int token) const;
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
};
JSValue* toJS(ExecState*, WebCore::Document*);
bool checkNodeSecurity(ExecState *exec, WebCore::Node *n);
JSValue *getRuntimeObject(ExecState *exec, WebCore::Node *n);
JSValue* toJS(ExecState*, PassRefPtr<WebCore::Node>);
JSValue* toJS(ExecState*, WebCore::NamedNodeMap *);
JSValue* toJS(ExecState*, PassRefPtr<WebCore::NodeList>);
JSObject *getNodeConstructor(ExecState *exec);
JSObject *getDOMExceptionConstructor(ExecState *exec);
class DOMNamedNodesCollection : public DOMObject {
public:
DOMNamedNodesCollection(ExecState *exec, const WebCore::DeprecatedValueList< RefPtr<WebCore::Node> >& nodes );
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
private:
static JSValue *lengthGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
static JSValue *indexGetter(ExecState* exec, JSObject *, const Identifier&, const PropertySlot& slot);
WebCore::DeprecatedValueList< RefPtr<WebCore::Node> > m_nodes;
};
}
#endif