KHTML
khtmlpart_p.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 * 00003 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> 00004 * 1999-2001 Lars Knoll <knoll@kde.org> 00005 * 1999-2001 Antti Koivisto <koivisto@kde.org> 00006 * 2000-2001 Simon Hausmann <hausmann@kde.org> 00007 * 2000-2001 Dirk Mueller <mueller@kde.org> 00008 * 2000 Stefan Schimanski <1Stein@gmx.de> 00009 * 2001-2005 George Staikos <staikos@kde.org> 00010 * 00011 * This library is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU Library General Public 00013 * License as published by the Free Software Foundation; either 00014 * version 2 of the License, or (at your option) any later version. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public License 00022 * along with this library; see the file COPYING.LIB. If not, write to 00023 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00024 * Boston, MA 02110-1301, USA. 00025 */ 00026 #ifndef khtmlpart_p_h 00027 #define khtmlpart_p_h 00028 00029 #include <kcursor.h> 00030 #include <kxmlguifactory.h> 00031 #include <kaction.h> 00032 #include <kparts/partmanager.h> 00033 #include <kparts/statusbarextension.h> 00034 #include <kparts/browserextension.h> 00035 #include <kparts/scriptableextension.h> 00036 00037 #include <QtCore/QDate> 00038 #include <QtCore/QPointer> 00039 #include <QtCore/QMap> 00040 #include <QtCore/QTimer> 00041 #include <QtCore/QList> 00042 #include <QtCore/QQueue> 00043 00044 #include "html/html_formimpl.h" 00045 #include "html/html_objectimpl.h" 00046 #include "khtml_run.h" 00047 #include "khtml_global.h" 00048 #include "khtml_events.h" 00049 #include "khtml_ext.h" 00050 #include "khtml_settings.h" 00051 #include "khtml_childframe_p.h" 00052 00053 #include <kencodingdetector.h> 00054 #include "ecma/kjs_proxy.h" 00055 #include "xml/dom_nodeimpl.h" 00056 #include "editing/editing_p.h" 00057 #include "ui/findbar/khtmlfind_p.h" 00058 #include "ui/passwordbar/storepassbar.h" 00059 #include "ecma/kjs_scriptable.h" 00060 00061 class KFind; 00062 class KFindDialog; 00063 class KCodecAction; 00064 class KUrlLabel; 00065 class KJavaAppletContext; 00066 class KJSErrorDlg; 00067 class KToggleAction; 00068 class KHTMLViewBar; 00069 00070 namespace KIO 00071 { 00072 class Job; 00073 class TransferJob; 00074 } 00075 namespace KParts 00076 { 00077 class StatusBarExtension; 00078 } 00079 00080 #include "khtml_wallet_p.h" 00081 00082 enum MimeType { 00083 MimeHTML, 00084 MimeSVG, 00085 MimeXHTML, 00086 MimeXML, // XML but not SVG or XHTML 00087 MimeImage, 00088 MimeText, 00089 MimeOther 00090 }; 00091 00092 00093 class KHTMLPartPrivate 00094 { 00095 KHTMLPartPrivate(const KHTMLPartPrivate & other); 00096 KHTMLPartPrivate& operator=(const KHTMLPartPrivate&); 00097 public: 00098 KHTMLPartPrivate(KHTMLPart* part, QObject* parent) : 00099 m_find( part, (part->parentPart() ? &part->parentPart()->d->m_find : 0) ), m_storePass( part ) 00100 { 00101 q = part; 00102 m_doc = 0L; 00103 m_decoder = 0L; 00104 #ifndef KHTML_NO_WALLET 00105 m_wallet = 0L; 00106 #endif 00107 m_bWalletOpened = false; 00108 m_runningScripts = 0; 00109 m_job = 0L; 00110 m_bComplete = true; 00111 m_bLoadEventEmitted = true; 00112 m_cachePolicy = KIO::CC_Verify; 00113 m_manager = 0L; 00114 m_settings = new KHTMLSettings(*KHTMLGlobal::defaultHTMLSettings()); 00115 m_bClearing = false; 00116 m_bCleared = false; 00117 m_zoomFactor = 100; 00118 m_fontScaleFactor = 100; 00119 m_bDnd = true; 00120 m_linkCursor = QCursor(Qt::PointingHandCursor); 00121 m_loadedObjects = 0; 00122 m_totalObjectCount = 0; 00123 m_jobPercent = 0; 00124 m_haveEncoding = false; 00125 m_activeFrame = 0L; 00126 m_ssl_in_use = false; 00127 m_jsedlg = 0; 00128 m_formNotification = KHTMLPart::NoNotification; 00129 00130 m_cacheId = 0; 00131 m_frameNameId = 1; 00132 00133 m_restored = false; 00134 m_restoreScrollPosition = false; 00135 00136 m_focusNodeNumber = -1; 00137 m_focusNodeRestored = false; 00138 00139 m_bJScriptForce = false; 00140 m_bJScriptOverride = false; 00141 m_bJavaForce = false; 00142 m_bJavaOverride = false; 00143 m_bPluginsForce = false; 00144 m_bPluginsOverride = false; 00145 m_onlyLocalReferences = false; 00146 m_forcePermitLocalImages = false; 00147 m_bDNSPrefetch = KHTMLPart::DNSPrefetchDisabled; 00148 m_bDNSPrefetchIsDefault = true; 00149 m_DNSPrefetchTimer = -1; 00150 m_DNSTTLTimer = -1; 00151 m_numDNSPrefetchedNames = 0; 00152 00153 m_caretMode = false; 00154 m_designMode = false; 00155 00156 m_metaRefreshEnabled = true; 00157 m_statusMessagesEnabled = true; 00158 00159 m_bFirstData = true; 00160 m_bStrictModeQuirk = true; 00161 m_submitForm = 0; 00162 m_delayRedirect = 0; 00163 m_autoDetectLanguage = KEncodingDetector::SemiautomaticDetection; 00164 00165 // inherit settings from parent 00166 if(parent && parent->inherits("KHTMLPart")) 00167 { 00168 KHTMLPart* part = static_cast<KHTMLPart*>(parent); 00169 if(part->d) 00170 { 00171 m_bJScriptForce = part->d->m_bJScriptForce; 00172 m_bJScriptOverride = part->d->m_bJScriptOverride; 00173 m_bJavaForce = part->d->m_bJavaForce; 00174 m_bJavaOverride = part->d->m_bJavaOverride; 00175 m_bPluginsForce = part->d->m_bPluginsForce; 00176 m_bPluginsOverride = part->d->m_bPluginsOverride; 00177 m_bDNSPrefetch = part->d->m_bDNSPrefetch; 00178 m_bDNSPrefetchIsDefault = part->d->m_bDNSPrefetchIsDefault; 00179 m_onlyLocalReferences = part->d->m_onlyLocalReferences; 00180 m_forcePermitLocalImages = part->d->m_forcePermitLocalImages; 00181 // Same for SSL settings 00182 m_ssl_in_use = part->d->m_ssl_in_use; 00183 m_caretMode = part->d->m_caretMode; 00184 m_designMode = part->d->m_designMode; 00185 m_zoomFactor = part->d->m_zoomFactor; 00186 m_fontScaleFactor = part->d->m_fontScaleFactor; 00187 m_autoDetectLanguage = part->d->m_autoDetectLanguage; 00188 m_encoding = part->d->m_encoding; 00189 m_haveEncoding = part->d->m_haveEncoding; 00190 } 00191 } 00192 00193 m_focusNodeNumber = -1; 00194 m_focusNodeRestored = false; 00195 m_opener = 0; 00196 m_openedByJS = false; 00197 m_newJSInterpreterExists = false; 00198 m_jobspeed = 0; 00199 m_statusBarWalletLabel = 0L; 00200 m_statusBarUALabel = 0L; 00201 m_statusBarJSErrorLabel = 0L; 00202 m_userStyleSheetLastModified = 0; 00203 #ifndef KHTML_NO_WALLET 00204 m_wq = 0; 00205 #endif 00206 } 00207 ~KHTMLPartPrivate() 00208 { 00209 delete m_statusBarExtension; 00210 delete m_scriptableExtension; 00211 delete m_extension; 00212 delete m_settings; 00213 #ifndef KHTML_NO_WALLET 00214 delete m_wallet; 00215 #endif 00216 #ifndef Q_WS_QWS 00217 //delete m_javaContext; 00218 #endif 00219 } 00220 00221 KHTMLPart* q; 00222 00223 QPointer<khtml::ChildFrame> m_frame; 00224 KHTMLFrameList m_frames; 00225 KHTMLFrameList m_objects; 00226 00227 QPointer<KHTMLView> m_view; 00228 QPointer<KHTMLViewBar> m_topViewBar; 00229 QPointer<KHTMLViewBar> m_bottomViewBar; 00230 KHTMLPartBrowserExtension *m_extension; 00231 KParts::StatusBarExtension *m_statusBarExtension; 00232 KHTMLPartBrowserHostExtension *m_hostExtension; 00233 KJS::KHTMLPartScriptable *m_scriptableExtension; 00234 KUrlLabel* m_statusBarIconLabel; 00235 KUrlLabel* m_statusBarWalletLabel; 00236 KUrlLabel* m_statusBarUALabel; 00237 KUrlLabel* m_statusBarJSErrorLabel; 00238 KUrlLabel* m_statusBarPopupLabel; 00239 QList<QPointer<KHTMLPart> > m_suppressedPopupOriginParts; // We need to guard these in case the origin 00240 // is a child part. 00241 int m_openableSuppressedPopups; 00242 DOM::DocumentImpl *m_doc; 00243 KEncodingDetector::AutoDetectScript m_autoDetectLanguage; 00244 KEncodingDetector *m_decoder; 00245 QString m_encoding; 00246 QString m_sheetUsed; 00247 qlonglong m_cacheId; 00248 00249 #ifndef KHTML_NO_WALLET 00250 KWallet::Wallet* m_wallet; 00251 QStringList m_walletForms; 00252 #endif 00253 int m_runningScripts; 00254 bool m_bOpenMiddleClick; 00255 bool m_bJScriptEnabled; 00256 bool m_bJScriptDebugEnabled; 00257 bool m_bJavaEnabled; 00258 bool m_bPluginsEnabled; 00259 bool m_bJScriptForce; 00260 bool m_bJScriptOverride; 00261 bool m_bJavaForce; 00262 bool m_bJavaOverride; 00263 bool m_bPluginsForce; 00264 bool m_metaRefreshEnabled; 00265 bool m_bPluginsOverride; 00266 bool m_restored; 00267 bool m_restoreScrollPosition; 00268 bool m_statusMessagesEnabled; 00269 bool m_bWalletOpened; 00270 bool m_urlSelectedOpenedURL; // KDE4: remove 00271 bool m_bDNSPrefetchIsDefault; 00272 int m_DNSPrefetchTimer; 00273 int m_DNSTTLTimer; 00274 int m_numDNSPrefetchedNames; 00275 QQueue<QString> m_DNSPrefetchQueue; 00276 KHTMLPart::DNSPrefetch m_bDNSPrefetch; 00277 int m_frameNameId; 00278 00279 KHTMLSettings *m_settings; 00280 00281 KIO::TransferJob * m_job; 00282 00283 QString m_statusBarText[3]; 00284 unsigned long m_jobspeed; 00285 QString m_lastModified; 00286 QString m_httpHeaders; 00287 QString m_pageServices; 00288 00289 // QStrings for SSL metadata 00290 // Note: When adding new variables don't forget to update ::saveState()/::restoreState()! 00291 QString m_ssl_peer_chain, 00292 m_ssl_peer_ip, 00293 m_ssl_cipher, 00294 m_ssl_protocol_version, 00295 m_ssl_cipher_used_bits, 00296 m_ssl_cipher_bits, 00297 m_ssl_cert_errors, 00298 m_ssl_parent_ip, 00299 m_ssl_parent_cert; 00300 bool m_ssl_in_use; 00301 00302 bool m_bComplete; 00303 bool m_bLoadEventEmitted; 00304 bool m_haveEncoding; 00305 bool m_onlyLocalReferences; 00306 bool m_forcePermitLocalImages; 00307 bool m_redirectLockHistory; 00308 00309 KUrl m_workingURL; 00310 00311 KIO::CacheControl m_cachePolicy; 00312 QTimer m_redirectionTimer; 00313 QTime m_parsetime; 00314 int m_delayRedirect; 00315 QString m_redirectURL; 00316 00317 KAction *m_paViewDocument; 00318 KAction *m_paViewFrame; 00319 KAction *m_paViewInfo; 00320 KAction *m_paSaveBackground; 00321 KAction *m_paSaveDocument; 00322 KAction *m_paSaveFrame; 00323 KAction *m_paSecurity; 00324 KCodecAction *m_paSetEncoding; 00325 KSelectAction *m_paUseStylesheet; 00326 KSelectAction *m_paIncZoomFactor; 00327 KSelectAction *m_paDecZoomFactor; 00328 KAction *m_paLoadImages; 00329 KAction *m_paFind; 00330 KAction *m_paFindNext; 00331 KAction *m_paFindPrev; 00332 KAction *m_paFindAheadText; 00333 KAction *m_paFindAheadLinks; 00334 KAction *m_paPrintFrame; 00335 KAction *m_paSelectAll; 00336 KAction *m_paDebugScript; 00337 KAction *m_paDebugDOMTree; 00338 KAction *m_paDebugRenderTree; 00339 KAction *m_paStopAnimations; 00340 KToggleAction *m_paToggleCaretMode; 00341 QMap<QAction*, int> m_paLanguageMap; 00342 00343 KParts::PartManager *m_manager; 00344 00345 KHTMLPart::GUIProfile m_guiProfile; 00346 00347 int m_zoomFactor; 00348 int m_fontScaleFactor; 00349 00350 QString m_strSelectedURL; 00351 QString m_strSelectedURLTarget; 00352 QString m_referrer; 00353 QString m_pageReferrer; 00354 00355 struct SubmitForm 00356 { 00357 const char *submitAction; 00358 QString submitUrl; 00359 QByteArray submitFormData; 00360 QString target; 00361 QString submitContentType; 00362 QString submitBoundary; 00363 }; 00364 00365 SubmitForm *m_submitForm; 00366 00367 bool m_bMousePressed; 00368 bool m_bRightMousePressed; 00369 DOM::Node m_mousePressNode; //node under the mouse when the mouse was pressed (set in the mouse handler) 00370 00371 khtml::EditorContext editor_context; 00372 00373 QString m_overURL; 00374 QString m_overURLTarget; 00375 00376 bool m_bDnd; 00377 bool m_bFirstData; 00378 bool m_bStrictModeQuirk; 00379 bool m_bClearing; 00380 bool m_bCleared; 00381 bool m_focusNodeRestored; 00382 00383 int m_focusNodeNumber; 00384 00385 QPoint m_dragStartPos; 00386 #ifdef KHTML_NO_SELECTION 00387 QPoint m_dragLastPos; 00388 #endif 00389 00390 bool m_designMode; 00391 bool m_caretMode; 00392 00393 QCursor m_linkCursor; 00394 QTimer m_scrollTimer; 00395 00396 unsigned long m_loadedObjects; 00397 unsigned long m_totalObjectCount; 00398 unsigned int m_jobPercent; 00399 00400 KHTMLPart::FormNotification m_formNotification; 00401 QTimer m_progressUpdateTimer; 00402 00403 QStringList m_pluginPageQuestionAsked; 00404 00405 KHTMLFind m_find; 00406 StorePass m_storePass; 00407 00408 KJSErrorDlg *m_jsedlg; 00409 00410 //QGuardedPtr<KParts::Part> m_activeFrame; 00411 KParts::Part * m_activeFrame; 00412 QPointer<KHTMLPart> m_opener; 00413 bool m_openedByJS; 00414 bool m_newJSInterpreterExists; // set to 1 by setOpenedByJS, for window.open 00415 00416 void setFlagRecursively(bool KHTMLPartPrivate::*flag, bool value); 00417 00418 time_t m_userStyleSheetLastModified; 00419 00420 QSet<QString> m_lookedupHosts; 00421 static bool s_dnsInitialised; 00422 00423 #ifndef KHTML_NO_WALLET 00424 KHTMLWalletQueue *m_wq; 00425 #endif 00426 00427 // Does determination of how we should handle the given type, as per HTML5 rules 00428 MimeType classifyMimeType(const QString& mime); 00429 00430 void clearRedirection(); 00431 00432 bool isLocalAnchorJump(const KUrl& url); 00433 void executeAnchorJump(const KUrl& url, bool lockHistory); 00434 00435 static bool isJavaScriptURL(const QString& url); 00436 static QString codeForJavaScriptURL(const QString& url); 00437 void executeJavascriptURL(const QString &u); 00438 00439 bool isInPageURL(const QString& url) { 00440 return isLocalAnchorJump(KUrl(url)) || isJavaScriptURL(url); 00441 } 00442 00443 void executeInPageURL(const QString& url, bool lockHistory) { 00444 KUrl kurl(url); 00445 if (isLocalAnchorJump(kurl)) 00446 executeAnchorJump(kurl, lockHistory); 00447 else 00448 executeJavascriptURL(url); 00449 } 00450 00451 void propagateInitialDomainAndBaseTo(KHTMLPart* kid); 00452 00453 void renameFrameForContainer(DOM::HTMLPartContainerElementImpl* cont, 00454 const QString& newName); 00455 00456 KHTMLPart* findFrameParent(KParts::ReadOnlyPart* callingPart, const QString& f, 00457 khtml::ChildFrame **childFrame, bool checkForNavigation); 00458 00459 bool canNavigate(KParts::ReadOnlyPart* b); 00460 KHTMLPart* top(); 00461 00462 // Check whether the frame is fully loaded. 00463 // The return value doesn't consider any pending redirections. 00464 // If the return value is true, however, pendingRedirections will 00465 // report if there are any 00466 bool isFullyLoaded(bool* pendingRedirections) const; 00467 }; 00468 00469 #endif
KDE 4.6 API Reference