khtml Library API Documentation

khtmlpart_p.h

00001 #ifndef khtmlpart_p_h
00002 #define khtmlpart_p_h
00003 
00004 /* This file is part of the KDE project
00005  *
00006  * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
00007  *                     1999-2001 Lars Knoll <knoll@kde.org>
00008  *                     1999-2001 Antti Koivisto <koivisto@kde.org>
00009  *                     2000-2001 Simon Hausmann <hausmann@kde.org>
00010  *                     2000-2001 Dirk Mueller <mueller@kde.org>
00011  *                     2000 Stefan Schimanski <1Stein@gmx.de>
00012  *                     2001-2003 George Stiakos <staikos@kde.org>
00013  *
00014  * This library is free software; you can redistribute it and/or
00015  * modify it under the terms of the GNU Library General Public
00016  * License as published by the Free Software Foundation; either
00017  * version 2 of the License, or (at your option) any later version.
00018  *
00019  * This library is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * Library General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU Library General Public License
00025  * along with this library; see the file COPYING.LIB.  If not, write to
00026  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00027  * Boston, MA 02111-1307, USA.
00028  */
00029 #include <kcursor.h>
00030 #include <klibloader.h>
00031 #include <kxmlguifactory.h>
00032 #include <kaction.h>
00033 #include <kparts/partmanager.h>
00034 #include <kparts/statusbarextension.h>
00035 #include <kwallet.h>
00036 #include <qtimer.h>
00037 
00038 #include "khtml_run.h"
00039 #include "khtml_factory.h"
00040 #include "khtml_events.h"
00041 #include "khtml_ext.h"
00042 #include "khtml_iface.h"
00043 #include "khtml_settings.h"
00044 #include "misc/decoder.h"
00045 #include "ecma/kjs_proxy.h"
00046 
00047 class KFind;
00048 class KFindDialog;
00049 class KPopupMenu;
00050 class KSelectAction;
00051 class KURLLabel;
00052 class KJavaAppletContext;
00053 class KJSErrorDlg;
00054 
00055 namespace KIO
00056 {
00057   class Job;
00058   class TransferJob;
00059 }
00060 namespace KParts
00061 {
00062   class StatusBarExtension;
00063 }
00064 
00065 namespace khtml
00066 {
00067   struct ChildFrame
00068   {
00069       enum Type { Frame, IFrame, Object };
00070 
00071       ChildFrame() {
00072           m_bCompleted = false; m_bPreloaded = false; m_type = Frame; m_bNotify = false;
00073           m_bPendingRedirection = false;
00074       }
00075 
00076       ~ChildFrame() { if (m_run) m_run->abort(); }
00077 
00078     QGuardedPtr<khtml::RenderPart> m_frame;
00079     QGuardedPtr<KParts::ReadOnlyPart> m_part;
00080     QGuardedPtr<KParts::BrowserExtension> m_extension;
00081     QGuardedPtr<KParts::LiveConnectExtension> m_liveconnect;
00082     QString m_serviceName;
00083     QString m_serviceType;
00084     bool m_bCompleted;
00085     QString m_name;
00086     KParts::URLArgs m_args;
00087     QGuardedPtr<KHTMLRun> m_run;
00088     bool m_bPreloaded;
00089     KURL m_workingURL;
00090     Type m_type;
00091     QStringList m_params;
00092     bool m_bNotify;
00093     bool m_bPendingRedirection;
00094   };
00095 
00096 }
00097 
00098 class FrameList : public QValueList<khtml::ChildFrame>
00099 {
00100 public:
00101     Iterator find( const QString &name );
00102 };
00103 
00104 typedef FrameList::ConstIterator ConstFrameIt;
00105 typedef FrameList::Iterator FrameIt;
00106 
00107 static int khtml_part_dcop_counter = 0;
00108 
00109 class KHTMLPartPrivate
00110 {
00111 public:
00112   KHTMLPartPrivate(QObject* parent)
00113   {
00114     m_doc = 0L;
00115     m_decoder = 0L;
00116     m_jscript = 0L;
00117     m_wallet = 0L;
00118     m_bWalletOpened = false;
00119     m_runningScripts = 0;
00120     m_kjs_lib = 0;
00121     m_job = 0L;
00122     m_bComplete = true;
00123     m_bLoadEventEmitted = true;
00124     m_cachePolicy = KIO::CC_Verify;
00125     m_manager = 0L;
00126     m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
00127     m_bClearing = false;
00128     m_bCleared = false;
00129     m_zoomFactor = 100;
00130     m_bDnd = true;
00131     m_startOffset = m_endOffset = 0;
00132     m_startBeforeEnd = true;
00133     m_extendAtEnd = true;
00134     m_linkCursor = KCursor::handCursor();
00135     m_loadedObjects = 0;
00136     m_totalObjectCount = 0;
00137     m_jobPercent = 0;
00138     m_haveEncoding = false;
00139     m_activeFrame = 0L;
00140     m_find = 0;
00141     m_findDialog = 0;
00142     m_ssl_in_use = false;
00143     m_jsedlg = 0;
00144     m_formNotification = KHTMLPart::NoNotification;
00145 
00146 #ifndef Q_WS_QWS
00147     m_javaContext = 0;
00148 #endif
00149     m_cacheId = 0;
00150     m_frameNameId = 1;
00151 
00152     m_restored = false;
00153 
00154     m_focusNodeNumber = -1;
00155     m_focusNodeRestored = false;
00156 
00157     m_bJScriptForce = false;
00158     m_bJScriptOverride = false;
00159     m_bJavaForce = false;
00160     m_bJavaOverride = false;
00161     m_bPluginsForce = false;
00162     m_bPluginsOverride = false;
00163     m_onlyLocalReferences = false;
00164 
00165     m_caretMode = false;
00166     m_designMode = false;
00167 
00168     m_metaRefreshEnabled = true;
00169     m_statusMessagesEnabled = true;
00170 
00171     m_bFirstData = true;
00172     m_submitForm = 0;
00173     m_delayRedirect = 0;
00174     m_autoDetectLanguage = khtml::Decoder::SemiautomaticDetection;
00175 
00176     // inherit settings from parent
00177     if(parent && parent->inherits("KHTMLPart"))
00178     {
00179         KHTMLPart* part = static_cast<KHTMLPart*>(parent);
00180         if(part->d)
00181         {
00182             m_bJScriptForce = part->d->m_bJScriptForce;
00183             m_bJScriptOverride = part->d->m_bJScriptOverride;
00184             m_bJavaForce = part->d->m_bJavaForce;
00185             m_bJavaOverride = part->d->m_bJavaOverride;
00186             m_bPluginsForce = part->d->m_bPluginsForce;
00187             m_bPluginsOverride = part->d->m_bPluginsOverride;
00188             // Same for SSL settings
00189             m_ssl_in_use = part->d->m_ssl_in_use;
00190             m_onlyLocalReferences = part->d->m_onlyLocalReferences;
00191             m_caretMode = part->d->m_caretMode;
00192             m_designMode = part->d->m_designMode;
00193             m_zoomFactor = part->d->m_zoomFactor;
00194             m_autoDetectLanguage = part->d->m_autoDetectLanguage;
00195         }
00196     }
00197 
00198     m_focusNodeNumber = -1;
00199     m_focusNodeRestored = false;
00200     m_opener = 0;
00201     m_openedByJS = false;
00202     m_newJSInterpreterExists = false;
00203     m_dcopobject = 0;
00204     m_jobspeed = 0;
00205     m_dcop_counter = ++khtml_part_dcop_counter;
00206     m_statusBarWalletLabel = 0L;
00207     m_statusBarJSErrorLabel = 0L;
00208   }
00209   ~KHTMLPartPrivate()
00210   {
00211     delete m_dcopobject;
00212     delete m_statusBarExtension;
00213     delete m_extension;
00214     delete m_settings;
00215     delete m_jscript;
00216     delete m_wallet;
00217     if ( m_kjs_lib)
00218        m_kjs_lib->unload();
00219 #ifndef Q_WS_QWS
00220     //delete m_javaContext;
00221 #endif
00222   }
00223 
00224   FrameList m_frames;
00225   QValueList<khtml::ChildFrame> m_objects;
00226 
00227   QGuardedPtr<KHTMLView> m_view;
00228   KHTMLPartBrowserExtension *m_extension;
00229   KParts::StatusBarExtension *m_statusBarExtension;
00230   KHTMLPartBrowserHostExtension *m_hostExtension;
00231   KURLLabel* m_statusBarIconLabel;
00232   KURLLabel* m_statusBarWalletLabel;
00233   KURLLabel* m_statusBarJSErrorLabel;
00234   DOM::DocumentImpl *m_doc;
00235   khtml::Decoder *m_decoder;
00236   QString m_encoding;
00237   QString m_sheetUsed;
00238   long m_cacheId;
00239   QString scheduledScript;
00240   DOM::Node scheduledScriptNode;
00241 
00242   KJSProxy *m_jscript;
00243   KWallet::Wallet* m_wallet;
00244   KLibrary *m_kjs_lib;
00245   int m_runningScripts;
00246   bool m_bBackRightClick :1;
00247   bool m_bJScriptEnabled :1;
00248   bool m_bJScriptDebugEnabled :1;
00249   bool m_bJavaEnabled :1;
00250   bool m_bPluginsEnabled :1;
00251   bool m_bJScriptForce :1;
00252   bool m_bJScriptOverride :1;
00253   bool m_bJavaForce :1;
00254   bool m_bJavaOverride :1;
00255   bool m_bPluginsForce :1;
00256   bool m_metaRefreshEnabled :1;
00257   bool m_bPluginsOverride :1;
00258   bool m_restored :1;
00259   bool m_statusMessagesEnabled :1;
00260   bool m_bWalletOpened :1;
00261   int m_frameNameId;
00262   int m_dcop_counter;
00263   DCOPObject *m_dcopobject;
00264 
00265 #ifndef Q_WS_QWS
00266   KJavaAppletContext *m_javaContext;
00267 #endif
00268 
00269   KHTMLSettings *m_settings;
00270 
00271   KIO::TransferJob * m_job;
00272 
00273   QString m_statusBarText[3];
00274   unsigned long m_jobspeed;
00275   QString m_lastModified;
00276   QString m_httpHeaders;
00277   QString m_pageServices;
00278 
00279   // QStrings for SSL metadata
00280   // Note: When adding new variables don't forget to update ::saveState()/::restoreState()!
00281   bool m_ssl_in_use;
00282   QString m_ssl_peer_certificate,
00283           m_ssl_peer_chain,
00284           m_ssl_peer_ip,
00285           m_ssl_cipher,
00286           m_ssl_cipher_desc,
00287           m_ssl_cipher_version,
00288           m_ssl_cipher_used_bits,
00289           m_ssl_cipher_bits,
00290           m_ssl_cert_state,
00291           m_ssl_parent_ip,
00292           m_ssl_parent_cert;
00293 
00294   bool m_bComplete:1;
00295   bool m_bLoadEventEmitted:1;
00296   bool m_haveEncoding:1;
00297   bool m_onlyLocalReferences :1;
00298   bool m_redirectLockHistory:1;
00299 
00300   KURL m_workingURL;
00301 
00302   KIO::CacheControl m_cachePolicy;
00303   QTimer m_redirectionTimer;
00304   QTime m_parsetime;
00305   int m_delayRedirect;
00306   QString m_redirectURL;
00307 
00308   KAction *m_paViewDocument;
00309   KAction *m_paViewFrame;
00310   KAction *m_paViewInfo;
00311   KAction *m_paSaveBackground;
00312   KAction *m_paSaveDocument;
00313   KAction *m_paSaveFrame;
00314   KAction *m_paSecurity;
00315   KActionMenu *m_paSetEncoding;
00316   KSelectAction *m_paUseStylesheet;
00317   KHTMLZoomFactorAction *m_paIncZoomFactor;
00318   KHTMLZoomFactorAction *m_paDecZoomFactor;
00319   KAction *m_paLoadImages;
00320   KAction *m_paFind;
00321   KAction *m_paFindNext;
00322   KAction *m_paPrintFrame;
00323   KAction *m_paSelectAll;
00324   KAction *m_paDebugScript;
00325   KAction *m_paDebugDOMTree;
00326   KAction *m_paDebugRenderTree;
00327   KAction *m_paStopAnimations;
00328   KToggleAction *m_paToggleCaretMode;
00329 
00330   KParts::PartManager *m_manager;
00331 
00332   QString m_popupMenuXML;
00333   KHTMLPart::GUIProfile m_guiProfile;
00334 
00335   int m_zoomFactor;
00336 
00337   QString m_strSelectedURL;
00338   QString m_strSelectedURLTarget;
00339   QString m_referrer;
00340   QString m_pageReferrer;
00341 
00342   struct SubmitForm
00343   {
00344     const char *submitAction;
00345     QString submitUrl;
00346     QByteArray submitFormData;
00347     QString target;
00348     QString submitContentType;
00349     QString submitBoundary;
00350   };
00351 
00352   SubmitForm *m_submitForm;
00353 
00354   bool m_bMousePressed;
00355   bool m_bRightMousePressed;
00356   DOM::Node m_mousePressNode; //node under the mouse when the mouse was pressed (set in the mouse handler)
00357 
00358   // simply using the selection limits for the caret position does not suffice
00359   // as we need to know on which side to extend the selection
00360 //  DOM::Node m_caretNode;  // node containing the caret
00361 //  long m_caretOffset;     // offset within this node (0-based)
00362 
00363   // the caret uses the selection variables for its position. If m_extendAtEnd
00364   // is true, m_selectionEnd and m_endOffset contain the mandatory caret
00365   // position, otherwise it's m_selectionStart and m_startOffset.
00366   DOM::Node m_selectionStart;
00367   long m_startOffset;
00368   DOM::Node m_selectionEnd;
00369   long m_endOffset;
00370   QString m_overURL;
00371   QString m_overURLTarget;
00372 
00373   bool m_startBeforeEnd:1;
00374   bool m_extendAtEnd:1;     // true if selection is to be extended at its end
00375   bool m_bDnd:1;
00376   bool m_bFirstData:1;
00377   bool m_bClearing:1;
00378   bool m_bCleared:1;
00379   bool m_bSecurityInQuestion:1;
00380   bool m_focusNodeRestored:1;
00381 
00382   int m_focusNodeNumber;
00383 
00384   QPoint m_dragStartPos;
00385 #ifdef KHTML_NO_SELECTION
00386   QPoint m_dragLastPos;
00387 #endif
00388 
00389   bool m_designMode;
00390   bool m_caretMode;
00391 
00392   QCursor m_linkCursor;
00393   QTimer m_scrollTimer;
00394 
00395   unsigned long m_loadedObjects;
00396   unsigned long m_totalObjectCount;
00397   unsigned int m_jobPercent;
00398 
00399   KHTMLPart::FormNotification m_formNotification;
00400   QTimer m_progressUpdateTimer;
00401 
00402   QStringList m_pluginPageQuestionAsked;
00403 
00405   struct StringPortion
00406   {
00407       // Just basic ref/deref on our node to make sure it doesn't get deleted
00408       StringPortion( int i, DOM::NodeImpl* n ) : index(i), node(n) { if (node) node->ref(); }
00409       StringPortion() : index(0), node(0) {} // for QValueList
00410       StringPortion( const StringPortion& other ) : node(0) { operator=(other); }
00411       StringPortion& operator=( const StringPortion& other ) {
00412           index=other.index;
00413           if (other.node) other.node->ref();
00414           if (node) node->deref();
00415           node=other.node;
00416           return *this;
00417       }
00418       ~StringPortion() { if (node) node->deref(); }
00419 
00420       int index;
00421       DOM::NodeImpl *node;
00422   };
00423   QValueList<StringPortion> m_stringPortions;
00424 
00425   KFind *m_find;
00426   KFindDialog *m_findDialog;
00427 
00428   struct findState
00429   {
00430     findState()
00431     { options = 0; }
00432     QStringList history;
00433     QString text;
00434     int options;
00435   };
00436 
00437   findState m_lastFindState;
00438 
00439   KJSErrorDlg *m_jsedlg;
00440 
00441   DOM::NodeImpl *m_findNode; // current node
00442   DOM::NodeImpl *m_findNodeEnd; // end node
00443   int m_findPos; // current pos in current node
00444   int m_findPosEnd; // pos in end node
00446 
00447   //QGuardedPtr<KParts::Part> m_activeFrame;
00448   KParts::Part * m_activeFrame;
00449   QGuardedPtr<KHTMLPart> m_opener;
00450   bool m_openedByJS;
00451   bool m_newJSInterpreterExists; // set to 1 by setOpenedByJS, for window.open
00452 
00453   khtml::Decoder::AutoDetectLanguage m_autoDetectLanguage;
00454   KPopupMenu *m_automaticDetection;
00455   KSelectAction *m_manualDetection;
00456 
00457   void setFlagRecursively(bool KHTMLPartPrivate::*flag, bool value);
00459   DOM::Node &caretNode() {
00460     return m_extendAtEnd ? m_selectionEnd : m_selectionStart;
00461   }
00463   long &caretOffset() {
00464     return m_extendAtEnd ? m_endOffset : m_startOffset;
00465   }
00466 
00467 };
00468 
00469 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 4 12:37:20 2004 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2003