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 struct KHTMLFrameList : public QValueList<khtml::ChildFrame>
00099 {
00100     Iterator find( const QString &name ) KDE_NO_EXPORT;
00101 };
00102 
00103 typedef KHTMLFrameList::ConstIterator ConstFrameIt;
00104 typedef KHTMLFrameList::Iterator FrameIt;
00105 
00106 static int khtml_part_dcop_counter = 0;
00107 
00108 class KHTMLPartPrivate
00109 {
00110 public:
00111   KHTMLPartPrivate(QObject* parent)
00112   {
00113     m_doc = 0L;
00114     m_decoder = 0L;
00115     m_jscript = 0L;
00116     m_wallet = 0L;
00117     m_bWalletOpened = false;
00118     m_runningScripts = 0;
00119     m_kjs_lib = 0;
00120     m_job = 0L;
00121     m_bComplete = true;
00122     m_bLoadEventEmitted = true;
00123     m_cachePolicy = KIO::CC_Verify;
00124     m_manager = 0L;
00125     m_settings = new KHTMLSettings(*KHTMLFactory::defaultHTMLSettings());
00126     m_bClearing = false;
00127     m_bCleared = false;
00128     m_zoomFactor = 100;
00129     m_bDnd = true;
00130     m_startOffset = m_endOffset = 0;
00131     m_startBeforeEnd = true;
00132     m_extendAtEnd = true;
00133     m_linkCursor = KCursor::handCursor();
00134     m_loadedObjects = 0;
00135     m_totalObjectCount = 0;
00136     m_jobPercent = 0;
00137     m_haveEncoding = false;
00138     m_activeFrame = 0L;
00139     m_find = 0;
00140     m_findDialog = 0;
00141     m_ssl_in_use = false;
00142     m_jsedlg = 0;
00143     m_formNotification = KHTMLPart::NoNotification;
00144 
00145 #ifndef Q_WS_QWS
00146     m_javaContext = 0;
00147 #endif
00148     m_cacheId = 0;
00149     m_frameNameId = 1;
00150 
00151     m_restored = false;
00152 
00153     m_focusNodeNumber = -1;
00154     m_focusNodeRestored = false;
00155 
00156     m_bJScriptForce = false;
00157     m_bJScriptOverride = false;
00158     m_bJavaForce = false;
00159     m_bJavaOverride = false;
00160     m_bPluginsForce = false;
00161     m_bPluginsOverride = false;
00162     m_onlyLocalReferences = false;
00163 
00164     m_caretMode = false;
00165     m_designMode = false;
00166 
00167     m_metaRefreshEnabled = true;
00168     m_statusMessagesEnabled = true;
00169 
00170     m_bFirstData = true;
00171     m_submitForm = 0;
00172     m_delayRedirect = 0;
00173     m_autoDetectLanguage = khtml::Decoder::SemiautomaticDetection;
00174 
00175     // inherit settings from parent
00176     if(parent && parent->inherits("KHTMLPart"))
00177     {
00178         KHTMLPart* part = static_cast<KHTMLPart*>(parent);
00179         if(part->d)
00180         {
00181             m_bJScriptForce = part->d->m_bJScriptForce;
00182             m_bJScriptOverride = part->d->m_bJScriptOverride;
00183             m_bJavaForce = part->d->m_bJavaForce;
00184             m_bJavaOverride = part->d->m_bJavaOverride;
00185             m_bPluginsForce = part->d->m_bPluginsForce;
00186             m_bPluginsOverride = part->d->m_bPluginsOverride;
00187             // Same for SSL settings
00188             m_ssl_in_use = part->d->m_ssl_in_use;
00189             m_onlyLocalReferences = part->d->m_onlyLocalReferences;
00190             m_caretMode = part->d->m_caretMode;
00191             m_designMode = part->d->m_designMode;
00192             m_zoomFactor = part->d->m_zoomFactor;
00193             m_autoDetectLanguage = part->d->m_autoDetectLanguage;
00194             m_encoding = part->d->m_encoding;
00195             m_haveEncoding = part->d->m_haveEncoding;
00196         }
00197     }
00198 
00199     m_focusNodeNumber = -1;
00200     m_focusNodeRestored = false;
00201     m_opener = 0;
00202     m_openedByJS = false;
00203     m_newJSInterpreterExists = false;
00204     m_dcopobject = 0;
00205     m_jobspeed = 0;
00206     m_dcop_counter = ++khtml_part_dcop_counter;
00207     m_statusBarWalletLabel = 0L;
00208     m_statusBarJSErrorLabel = 0L;
00209     m_userStyleSheetLastModified = 0;
00210   }
00211   ~KHTMLPartPrivate()
00212   {
00213     delete m_dcopobject;
00214     delete m_statusBarExtension;
00215     delete m_extension;
00216     delete m_settings;
00217     delete m_jscript;
00218     delete m_wallet;
00219     if ( m_kjs_lib)
00220        m_kjs_lib->unload();
00221 #ifndef Q_WS_QWS
00222     //delete m_javaContext;
00223 #endif
00224   }
00225 
00226   KHTMLFrameList m_frames;
00227   QValueList<khtml::ChildFrame> m_objects;
00228 
00229   QGuardedPtr<KHTMLView> m_view;
00230   KHTMLPartBrowserExtension *m_extension;
00231   KParts::StatusBarExtension *m_statusBarExtension;
00232   KHTMLPartBrowserHostExtension *m_hostExtension;
00233   KURLLabel* m_statusBarIconLabel;
00234   KURLLabel* m_statusBarWalletLabel;
00235   KURLLabel* m_statusBarJSErrorLabel;
00236   DOM::DocumentImpl *m_doc;
00237   khtml::Decoder *m_decoder;
00238   QString m_encoding;
00239   QString m_sheetUsed;
00240   long m_cacheId;
00241   QString scheduledScript;
00242   DOM::Node scheduledScriptNode;
00243 
00244   KJSProxy *m_jscript;
00245   KWallet::Wallet* m_wallet;
00246   KLibrary *m_kjs_lib;
00247   int m_runningScripts;
00248   bool m_bBackRightClick :1;
00249   bool m_bJScriptEnabled :1;
00250   bool m_bJScriptDebugEnabled :1;
00251   bool m_bJavaEnabled :1;
00252   bool m_bPluginsEnabled :1;
00253   bool m_bJScriptForce :1;
00254   bool m_bJScriptOverride :1;
00255   bool m_bJavaForce :1;
00256   bool m_bJavaOverride :1;
00257   bool m_bPluginsForce :1;
00258   bool m_metaRefreshEnabled :1;
00259   bool m_bPluginsOverride :1;
00260   bool m_restored :1;
00261   bool m_statusMessagesEnabled :1;
00262   bool m_bWalletOpened :1;
00263   int m_frameNameId;
00264   int m_dcop_counter;
00265   DCOPObject *m_dcopobject;
00266 
00267 #ifndef Q_WS_QWS
00268   KJavaAppletContext *m_javaContext;
00269 #endif
00270 
00271   KHTMLSettings *m_settings;
00272 
00273   KIO::TransferJob * m_job;
00274 
00275   QString m_statusBarText[3];
00276   unsigned long m_jobspeed;
00277   QString m_lastModified;
00278   QString m_httpHeaders;
00279   QString m_pageServices;
00280 
00281   // QStrings for SSL metadata
00282   // Note: When adding new variables don't forget to update ::saveState()/::restoreState()!
00283   bool m_ssl_in_use;
00284   QString m_ssl_peer_certificate,
00285           m_ssl_peer_chain,
00286           m_ssl_peer_ip,
00287           m_ssl_cipher,
00288           m_ssl_cipher_desc,
00289           m_ssl_cipher_version,
00290           m_ssl_cipher_used_bits,
00291           m_ssl_cipher_bits,
00292           m_ssl_cert_state,
00293           m_ssl_parent_ip,
00294           m_ssl_parent_cert;
00295 
00296   bool m_bComplete:1;
00297   bool m_bLoadEventEmitted:1;
00298   bool m_haveEncoding:1;
00299   bool m_onlyLocalReferences :1;
00300   bool m_redirectLockHistory:1;
00301 
00302   KURL m_workingURL;
00303 
00304   KIO::CacheControl m_cachePolicy;
00305   QTimer m_redirectionTimer;
00306   QTime m_parsetime;
00307   int m_delayRedirect;
00308   QString m_redirectURL;
00309 
00310   KAction *m_paViewDocument;
00311   KAction *m_paViewFrame;
00312   KAction *m_paViewInfo;
00313   KAction *m_paSaveBackground;
00314   KAction *m_paSaveDocument;
00315   KAction *m_paSaveFrame;
00316   KAction *m_paSecurity;
00317   KActionMenu *m_paSetEncoding;
00318   KSelectAction *m_paUseStylesheet;
00319   KHTMLZoomFactorAction *m_paIncZoomFactor;
00320   KHTMLZoomFactorAction *m_paDecZoomFactor;
00321   KAction *m_paLoadImages;
00322   KAction *m_paFind;
00323   KAction *m_paFindNext;
00324   KAction *m_paPrintFrame;
00325   KAction *m_paSelectAll;
00326   KAction *m_paDebugScript;
00327   KAction *m_paDebugDOMTree;
00328   KAction *m_paDebugRenderTree;
00329   KAction *m_paStopAnimations;
00330   KToggleAction *m_paToggleCaretMode;
00331 
00332   KParts::PartManager *m_manager;
00333 
00334   QString m_popupMenuXML;
00335   KHTMLPart::GUIProfile m_guiProfile;
00336 
00337   int m_zoomFactor;
00338 
00339   QString m_strSelectedURL;
00340   QString m_strSelectedURLTarget;
00341   QString m_referrer;
00342   QString m_pageReferrer;
00343 
00344   struct SubmitForm
00345   {
00346     const char *submitAction;
00347     QString submitUrl;
00348     QByteArray submitFormData;
00349     QString target;
00350     QString submitContentType;
00351     QString submitBoundary;
00352   };
00353 
00354   SubmitForm *m_submitForm;
00355 
00356   bool m_bMousePressed;
00357   bool m_bRightMousePressed;
00358   DOM::Node m_mousePressNode; //node under the mouse when the mouse was pressed (set in the mouse handler)
00359 
00360   // simply using the selection limits for the caret position does not suffice
00361   // as we need to know on which side to extend the selection
00362 //  DOM::Node m_caretNode;  // node containing the caret
00363 //  long m_caretOffset;     // offset within this node (0-based)
00364 
00365   // the caret uses the selection variables for its position. If m_extendAtEnd
00366   // is true, m_selectionEnd and m_endOffset contain the mandatory caret
00367   // position, otherwise it's m_selectionStart and m_startOffset.
00368   DOM::Node m_selectionStart;
00369   long m_startOffset;
00370   DOM::Node m_selectionEnd;
00371   long m_endOffset;
00372   QString m_overURL;
00373   QString m_overURLTarget;
00374 
00375   bool m_startBeforeEnd:1;
00376   bool m_extendAtEnd:1;     // true if selection is to be extended at its end
00377   bool m_bDnd:1;
00378   bool m_bFirstData:1;
00379   bool m_bClearing:1;
00380   bool m_bCleared:1;
00381   bool m_bSecurityInQuestion:1;
00382   bool m_focusNodeRestored:1;
00383 
00384   int m_focusNodeNumber;
00385 
00386   QPoint m_dragStartPos;
00387 #ifdef KHTML_NO_SELECTION
00388   QPoint m_dragLastPos;
00389 #endif
00390 
00391   bool m_designMode;
00392   bool m_caretMode;
00393 
00394   QCursor m_linkCursor;
00395   QTimer m_scrollTimer;
00396 
00397   unsigned long m_loadedObjects;
00398   unsigned long m_totalObjectCount;
00399   unsigned int m_jobPercent;
00400 
00401   KHTMLPart::FormNotification m_formNotification;
00402   QTimer m_progressUpdateTimer;
00403 
00404   QStringList m_pluginPageQuestionAsked;
00405 
00407   struct StringPortion
00408   {
00409       // Just basic ref/deref on our node to make sure it doesn't get deleted
00410       StringPortion( int i, DOM::NodeImpl* n ) : index(i), node(n) { if (node) node->ref(); }
00411       StringPortion() : index(0), node(0) {} // for QValueList
00412       StringPortion( const StringPortion& other ) : node(0) { operator=(other); }
00413       StringPortion& operator=( const StringPortion& other ) {
00414           index=other.index;
00415           if (other.node) other.node->ref();
00416           if (node) node->deref();
00417           node=other.node;
00418           return *this;
00419       }
00420       ~StringPortion() { if (node) node->deref(); }
00421 
00422       int index;
00423       DOM::NodeImpl *node;
00424   };
00425   QValueList<StringPortion> m_stringPortions;
00426 
00427   KFind *m_find;
00428   KFindDialog *m_findDialog;
00429 
00430   struct findState
00431   {
00432     findState()
00433     { options = 0; }
00434     QStringList history;
00435     QString text;
00436     int options;
00437   };
00438 
00439   findState m_lastFindState;
00440 
00441   KJSErrorDlg *m_jsedlg;
00442 
00443   DOM::NodeImpl *m_findNode; // current node
00444   DOM::NodeImpl *m_findNodeEnd; // end node
00445   int m_findPos; // current pos in current node
00446   int m_findPosEnd; // pos in end node
00448 
00449   //QGuardedPtr<KParts::Part> m_activeFrame;
00450   KParts::Part * m_activeFrame;
00451   QGuardedPtr<KHTMLPart> m_opener;
00452   bool m_openedByJS;
00453   bool m_newJSInterpreterExists; // set to 1 by setOpenedByJS, for window.open
00454 
00455   khtml::Decoder::AutoDetectLanguage m_autoDetectLanguage;
00456   KPopupMenu *m_automaticDetection;
00457   KSelectAction *m_manualDetection;
00458 
00459   void setFlagRecursively(bool KHTMLPartPrivate::*flag, bool value);
00461   DOM::Node &caretNode() {
00462     return m_extendAtEnd ? m_selectionEnd : m_selectionStart;
00463   }
00465   long &caretOffset() {
00466     return m_extendAtEnd ? m_endOffset : m_startOffset;
00467   }
00468 
00469   time_t m_userStyleSheetLastModified;
00470 };
00471 
00472 #endif
KDE Logo
This file is part of the documentation for khtml Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed May 12 09:09:50 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2003