#ifndef kjs_window_h
#define kjs_window_h
#include "PlatformString.h"
#include "kjs_binding.h"
#include <kjs/protect.h>
#include "SecurityOrigin.h"
#include <wtf/HashMap.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/Platform.h>
#include <wtf/Vector.h>
namespace WebCore {
class AtomicString;
class DOMWindow;
class Frame;
class JSEventListener;
class JSLocation;
class JSUnprotectedEventListener;
class PausedTimeouts;
class ScheduledAction;
}
namespace KJS {
class DOMWindowTimer;
class WindowPrivate;
class Window : public JSGlobalObject {
typedef JSGlobalObject Base;
friend class WebCore::ScheduledAction;
protected:
Window(JSObject* prototype, WebCore::DOMWindow*);
public:
virtual ~Window();
WebCore::DOMWindow* impl() const { return m_impl.get(); }
void disconnectFrame();
static JSValue* retrieve(WebCore::Frame*);
static Window* retrieveWindow(WebCore::Frame*);
static Window* retrieveActive(ExecState*);
virtual void mark();
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
JSValue* getValueProperty(ExecState*, int token) const;
virtual void put(ExecState*, const Identifier& propertyName, JSValue*, int attr = None);
int installTimeout(const UString& handler, int t, bool singleShot);
int installTimeout(JSValue* function, const List& args, int t, bool singleShot);
void clearTimeout(int timerId, bool delAction = true);
WebCore::PausedTimeouts* pauseTimeouts();
void resumeTimeouts(WebCore::PausedTimeouts*);
void timerFired(DOMWindowTimer*);
WebCore::JSLocation* location() const;
WebCore::JSEventListener* findJSEventListener(JSValue*, bool html = false);
WebCore::JSEventListener *findOrCreateJSEventListener(JSValue*, bool html = false);
WebCore::JSUnprotectedEventListener* findJSUnprotectedEventListener(JSValue*, bool html = false);
WebCore::JSUnprotectedEventListener *findOrCreateJSUnprotectedEventListener(JSValue*, bool html = false);
void clear();
void setCurrentEvent(WebCore::Event*);
WebCore::Event* currentEvent();
void setReturnValueSlot(JSValue** slot);
typedef HashMap<JSObject*, WebCore::JSEventListener*> ListenersMap;
typedef HashMap<JSObject*, WebCore::JSUnprotectedEventListener*> UnprotectedListenersMap;
ListenersMap& jsEventListeners();
ListenersMap& jsHTMLEventListeners();
UnprotectedListenersMap& jsUnprotectedEventListeners();
UnprotectedListenersMap& jsUnprotectedHTMLEventListeners();
virtual const ClassInfo* classInfo() const { return &info; }
static const ClassInfo info;
virtual ExecState* globalExec();
virtual bool shouldInterruptScript() const;
virtual bool shouldInterruptScriptBeforeTimeout() const;
bool allowsAccessFrom(ExecState*) const;
bool allowsAccessFromNoErrorMessage(ExecState*) const;
bool allowsAccessFrom(ExecState*, WebCore::String& message) const;
void printErrorMessage(const WebCore::String&) const;
virtual bool allowsAccessFrom(const JSGlobalObject*) const;
enum {
Crypto, Event_, Location_, Navigator_,
ClientInformation,
Orientation,
Onabort, Onblur, Onchange, Onclick,
Ondblclick, Onerror, Onfocus, Onkeydown,
Onkeypress, Onkeyup, Onload, Onmousedown,
Onmousemove, Onmouseout, Onmouseover, Onmouseup,
OnWindowMouseWheel, Onreset, Onresize, Onscroll,
Onsearch, Onselect, Onsubmit, Onunload,
Onbeforeunload,
OnWebKitAnimationStart, OnWebKitAnimationIteration, OnWebKitAnimationEnd,
OnWebKitTransitionEnd,
OnOrientationChange,
#if ENABLE(TOUCH_EVENTS)
OnTouchStart, OnTouchMove, OnTouchEnd, OnTouchCancel,
OnGestureStart, OnGestureChange, OnGestureEnd,
#endif
#if ENABLE(TOUCH_EVENTS)
Touch, TouchList,
#endif
DOMException, Audio, Image, Option, XMLHttpRequest, WebKitCSSMatrix, WebKitPoint,
XSLTProcessor_
};
private:
JSValue* getListener(ExecState*, const WebCore::AtomicString& eventType) const;
void setListener(ExecState*, const WebCore::AtomicString& eventType, JSValue* func);
static JSValue* childFrameGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
static JSValue* indexGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
static JSValue* namedItemGetter(ExecState*, JSObject*, const Identifier&, const PropertySlot&);
void clearHelperObjectProperties();
void clearAllTimeouts();
int installTimeout(WebCore::ScheduledAction*, int interval, bool singleShot);
bool allowsAccessFromPrivate(const JSGlobalObject*, WebCore::SecurityOrigin::Reason&) const;
bool allowsAccessFromPrivate(const ExecState*, WebCore::SecurityOrigin::Reason&) const;
WebCore::String crossDomainAccessErrorMessage(const JSGlobalObject*, WebCore::SecurityOrigin::Reason) const;
RefPtr<WebCore::DOMWindow> m_impl;
OwnPtr<WindowPrivate> d;
};
JSValue* windowProtoFuncAToB(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncBToA(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncOpen(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncSetTimeout(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncClearTimeout(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncSetInterval(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncAddEventListener(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncRemoveEventListener(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncShowModalDialog(ExecState*, JSObject*, const List&);
JSValue* windowProtoFuncNotImplemented(ExecState*, JSObject*, const List&);
}
namespace WebCore {
KJS::JSValue* toJS(KJS::ExecState*, DOMWindow*);
}
#endif // kjs_window_h