khtml Library API Documentation

kjs_window.h

00001 // -*- c-basic-offset: 2 -*- 00002 /* 00003 * This file is part of the KDE libraries 00004 * Copyright (C) 2000 Harri Porten (porten@kde.org) 00005 * Copyright (C) 2003 Apple Computer, Inc. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Library General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Library General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Library General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef _KJS_WINDOW_H_ 00023 #define _KJS_WINDOW_H_ 00024 00025 #include <qobject.h> 00026 #include <qguardedptr.h> 00027 #include <qmap.h> 00028 #include <qptrlist.h> 00029 #include <qdatetime.h> 00030 00031 #include "kjs_binding.h" 00032 00033 class QTimer; 00034 class KHTMLView; 00035 class KHTMLPart; 00036 00037 namespace KJS { 00038 00039 class WindowFunc; 00040 class WindowQObject; 00041 class Location; 00042 class History; 00043 class External; 00044 class FrameArray; 00045 class JSEventListener; 00046 class JSLazyEventListener; 00047 00048 class Screen : public ObjectImp { 00049 public: 00050 Screen(ExecState *exec); 00051 enum { 00052 Height, Width, ColorDepth, PixelDepth, AvailLeft, AvailTop, AvailHeight, 00053 AvailWidth 00054 }; 00055 virtual Value get(ExecState *exec, const Identifier &propertyName) const; 00056 Value getValueProperty(ExecState *exec, int token) const; 00057 private: 00058 KHTMLView *view; 00059 virtual const ClassInfo* classInfo() const { return &info; } 00060 static const ClassInfo info; 00061 }; 00062 00063 class Window : public ObjectImp { 00064 friend QGuardedPtr<KHTMLPart> getInstance(); 00065 friend class Location; 00066 friend class WindowFunc; 00067 friend class WindowQObject; 00068 friend class ScheduledAction; 00069 public: 00070 Window(KHTMLPart *p); 00071 public: 00072 ~Window(); 00078 static Value retrieve(KHTMLPart *p); 00082 static Window *retrieveWindow(KHTMLPart *p); 00087 static Window *retrieveActive(ExecState *exec); 00088 QGuardedPtr<KHTMLPart> part() const { return m_part; } 00089 virtual void mark(); 00090 virtual bool hasProperty(ExecState *exec, const Identifier &p) const; 00091 virtual Value get(ExecState *exec, const Identifier &propertyName) const; 00092 virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None); 00093 virtual bool toBoolean(ExecState *exec) const; 00094 void scheduleClose(); 00095 void closeNow(); 00096 void delayedGoHistory(int steps); 00097 void goHistory(int steps); 00098 void goURL(ExecState* exec, const QString& url, bool lockHistory); 00099 Value openWindow(ExecState *exec, const List &args); 00100 void resizeTo(QWidget* tl, int width, int height); 00101 void afterScriptExecution(); 00102 bool isSafeScript(ExecState *exec) const { 00103 KHTMLPart *activePart = static_cast<KJS::ScriptInterpreter *>( exec->interpreter() )->part(); 00104 if ( activePart == m_part ) return true; 00105 return checkIsSafeScript( activePart ); 00106 } 00107 Location *location() const; 00108 ObjectImp* frames( ExecState* exec ) const; 00109 JSEventListener *getJSEventListener(const Value &val, bool html = false); 00110 JSLazyEventListener *getJSLazyEventListener(const QString &code, const QString &name, bool html = false); 00111 void clear( ExecState *exec ); 00112 virtual UString toString(ExecState *exec) const; 00113 00114 // Set the current "event" object 00115 void setCurrentEvent( DOM::Event *evt ); 00116 00117 QPtrDict<JSEventListener> jsEventListeners; 00118 virtual const ClassInfo* classInfo() const { return &info; } 00119 static const ClassInfo info; 00120 enum { Closed, Crypto, DefaultStatus, Status, Document, Node, EventCtor, Range, 00121 NodeFilter, DOMException, CSSRule, Frames, _History, _External, Event, InnerHeight, 00122 InnerWidth, Length, _Location, Navigate, Name, _Navigator, _Konqueror, ClientInformation, 00123 OffscreenBuffering, Opener, OuterHeight, OuterWidth, PageXOffset, PageYOffset, 00124 Parent, Personalbar, ScreenX, ScreenY, Scrollbars, Scroll, ScrollBy, 00125 ScreenTop, ScreenLeft, 00126 ScrollTo, ScrollX, ScrollY, MoveBy, MoveTo, ResizeBy, ResizeTo, Self, _Window, Top, _Screen, 00127 Image, Option, Alert, Confirm, Prompt, Open, SetTimeout, ClearTimeout, XMLHttpRequest, XMLSerializer, 00128 Focus, Blur, Close, SetInterval, ClearInterval, CaptureEvents, ReleaseEvents, 00129 Print, AddEventListener, RemoveEventListener, SideBar, 00130 Onabort, Onblur, 00131 Onchange, Onclick, Ondblclick, Ondragdrop, Onerror, Onfocus, 00132 Onkeydown, Onkeypress, Onkeyup, Onload, Onmousedown, Onmousemove, 00133 Onmouseout, Onmouseover, Onmouseup, Onmove, Onreset, Onresize, 00134 Onselect, Onsubmit, Onunload }; 00135 WindowQObject *winq; 00136 protected: 00137 enum DelayedActionId { NullAction, DelayedClose, DelayedGoHistory }; 00138 00139 Value getListener(ExecState *exec, int eventId) const; 00140 void setListener(ExecState *exec, int eventId, Value func); 00141 private: 00142 struct DelayedAction; 00143 friend struct DelayedAction; 00144 00145 bool checkIsSafeScript( KHTMLPart* activePart ) const; 00146 00147 QGuardedPtr<KHTMLPart> m_part; 00148 Screen *screen; 00149 History *history; 00150 External *external; 00151 FrameArray *m_frames; 00152 Location *loc; 00153 DOM::Event *m_evt; 00154 00155 struct DelayedAction { 00156 DelayedAction() : actionId(NullAction) {} // for QValueList 00157 DelayedAction( DelayedActionId id, QVariant p = QVariant() ) : actionId(id), param(p) {} 00158 DelayedActionId actionId; 00159 QVariant param; // just in case 00160 }; 00161 QValueList<DelayedAction> m_delayed; 00162 }; 00163 00169 class ScheduledAction { 00170 public: 00171 ScheduledAction(Object _func, List _args, QTime _nextTime, int _interval, bool _singleShot, int _timerId); 00172 ScheduledAction(QString _code, QTime _nextTime, int _interval, bool _singleShot, int _timerId); 00173 ~ScheduledAction(); 00174 void execute(Window *window); 00175 void mark(); 00176 00177 ObjectImp *func; 00178 List args; 00179 QString code; 00180 bool isFunction; 00181 bool singleShot; 00182 00183 QTime nextTime; 00184 int interval; 00185 bool executing; 00186 int timerId; 00187 }; 00188 00189 class WindowQObject : public QObject { 00190 Q_OBJECT 00191 public: 00192 WindowQObject(Window *w); 00193 ~WindowQObject(); 00194 int installTimeout(const Identifier &handler, int t, bool singleShot); 00195 int installTimeout(const Value &func, List args, int t, bool singleShot); 00196 void clearTimeout(int timerId); 00197 void mark(); 00198 public slots: 00199 void timeoutClose(); 00200 protected slots: 00201 void parentDestroyed(); 00202 protected: 00203 void timerEvent(QTimerEvent *e); 00204 void setNextTimer(); 00205 private: 00206 Window *parent; 00207 KHTMLPart *part; // not guarded, may be dangling 00208 QPtrList<ScheduledAction> scheduledActions; 00209 int pausedTime; 00210 int lastTimerId; 00211 }; 00212 00213 class Location : public ObjectImp { 00214 public: 00215 ~Location(); 00216 virtual Value get(ExecState *exec, const Identifier &propertyName) const; 00217 virtual void put(ExecState *exec, const Identifier &propertyName, const Value &value, int attr = None); 00218 virtual Value toPrimitive(ExecState *exec, Type preferred) const; 00219 virtual UString toString(ExecState *exec) const; 00220 enum { Hash, Href, Hostname, Host, Pathname, Port, Protocol, Search, EqualEqual, 00221 Assign, Replace, Reload, ToString }; 00222 KHTMLPart *part() const { return m_part; } 00223 virtual const ClassInfo* classInfo() const { return &info; } 00224 static const ClassInfo info; 00225 private: 00226 friend class Window; 00227 Location(KHTMLPart *p); 00228 QGuardedPtr<KHTMLPart> m_part; 00229 }; 00230 00231 #ifdef Q_WS_QWS 00232 class Konqueror : public ObjectImp { 00233 friend class KonquerorFunc; 00234 public: 00235 Konqueror(KHTMLPart *p) : part(p) { } 00236 virtual Value get(ExecState *exec, const Identifier &propertyName) const; 00237 virtual bool hasProperty(ExecState *exec, const Identifier &p) const; 00238 virtual UString toString(ExecState *exec) const; 00239 virtual const ClassInfo* classInfo() const { return &info; } 00240 static const ClassInfo info; 00241 private: 00242 KHTMLPart *part; 00243 }; 00244 #endif 00245 00246 } // namespace 00247 00248 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Sep 29 09:42:29 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003