fix logic
[personal-kdelibs.git] / khtml / khtmlpart_p.h
blob6a4b884ff1872fcf642da9ba44d29456b0f9343f
1 /* This file is part of the KDE project
3 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
4 * 1999-2001 Lars Knoll <knoll@kde.org>
5 * 1999-2001 Antti Koivisto <koivisto@kde.org>
6 * 2000-2001 Simon Hausmann <hausmann@kde.org>
7 * 2000-2001 Dirk Mueller <mueller@kde.org>
8 * 2000 Stefan Schimanski <1Stein@gmx.de>
9 * 2001-2005 George Staikos <staikos@kde.org>
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details.
21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
26 #ifndef khtmlpart_p_h
27 #define khtmlpart_p_h
29 #include <kcursor.h>
30 #include <klibloader.h>
31 #include <kxmlguifactory.h>
32 #include <kaction.h>
33 #include <kparts/partmanager.h>
34 #include <kparts/statusbarextension.h>
35 #include <kparts/browserextension.h>
37 #include <QtCore/QDate>
38 #include <QtCore/QPointer>
39 #include <QtCore/QMap>
40 #include <QtCore/QTimer>
41 #include <QtCore/QList>
42 #include <QtCore/QQueue>
44 #include "html/html_formimpl.h"
45 #include "html/html_objectimpl.h"
46 #include "khtml_run.h"
47 #include "khtml_global.h"
48 #include "khtml_events.h"
49 #include "khtml_ext.h"
50 #include "khtml_settings.h"
51 #include <kencodingdetector.h>
52 #include "ecma/kjs_proxy.h"
53 #include "xml/dom_nodeimpl.h"
54 #include "editing/editing_p.h"
55 #include "find/khtmlfind_p.h"
57 class KFind;
58 class KFindDialog;
59 class KCodecAction;
60 class KUrlLabel;
61 class KJavaAppletContext;
62 class KJSErrorDlg;
63 class KToggleAction;
64 class KHTMLViewBar;
66 namespace KIO
68 class Job;
69 class TransferJob;
71 namespace KParts
73 class StatusBarExtension;
76 #include "khtml_wallet_p.h"
78 namespace khtml
80 class KHTML_EXPORT ChildFrame : public QObject
82 Q_OBJECT
83 public:
84 enum Type { Frame, IFrame, Object };
86 ChildFrame() : QObject (0) {
87 setObjectName( "khtml_child_frame" );
88 m_jscript = 0L;
89 #ifndef DIRECT_LINKAGE_TO_ECMA
90 m_kjs_lib = 0;
91 #endif
92 m_bCompleted = false; m_bPreloaded = false; m_type = Frame; m_bNotify = false;
93 m_bPendingRedirection = false;
96 ~ChildFrame() {
97 if (m_run) m_run->abort();
98 delete m_jscript;
99 #ifndef DIRECT_LINKAGE_TO_ECMA
100 if ( m_kjs_lib)
101 m_kjs_lib->unload();
102 #endif
105 QPointer<DOM::HTMLPartContainerElementImpl> m_partContainerElement;
106 QPointer<KParts::ReadOnlyPart> m_part;
107 QPointer<KParts::BrowserExtension> m_extension;
108 QPointer<KParts::LiveConnectExtension> m_liveconnect;
109 QString m_serviceName;
110 QString m_serviceType;
111 KJSProxy *m_jscript;
112 #ifndef DIRECT_LINKAGE_TO_ECMA
113 KLibrary *m_kjs_lib;
114 #endif
115 bool m_bCompleted;
116 QString m_name;
117 KParts::OpenUrlArguments m_args;
118 KParts::BrowserArguments m_browserArgs;
119 QPointer<KHTMLRun> m_run;
120 KUrl m_workingURL;
121 Type m_type;
122 QStringList m_params;
123 bool m_bPreloaded;
124 bool m_bNotify;
125 bool m_bPendingRedirection;
126 protected Q_SLOTS:
127 void liveConnectEvent(const unsigned long, const QString&, const KParts::LiveConnectExtension::ArgList&);
132 struct KHTMLFrameList : public QList<khtml::ChildFrame*>
134 Iterator find( const QString &name ) KDE_NO_EXPORT;
137 typedef KHTMLFrameList::ConstIterator ConstFrameIt;
138 typedef KHTMLFrameList::Iterator FrameIt;
142 class KHTMLPartPrivate
144 KHTMLPartPrivate(const KHTMLPartPrivate & other);
145 KHTMLPartPrivate& operator=(const KHTMLPartPrivate&);
146 public:
147 KHTMLPartPrivate(KHTMLPart* part, QObject* parent) :
148 m_find( part )
150 q = part;
151 m_doc = 0L;
152 m_decoder = 0L;
153 #ifndef KHTML_NO_WALLET
154 m_wallet = 0L;
155 #endif
156 m_bWalletOpened = false;
157 m_runningScripts = 0;
158 m_job = 0L;
159 m_bComplete = true;
160 m_bLoadEventEmitted = true;
161 m_cachePolicy = KIO::CC_Verify;
162 m_manager = 0L;
163 m_settings = new KHTMLSettings(*KHTMLGlobal::defaultHTMLSettings());
164 m_bClearing = false;
165 m_bCleared = false;
166 m_zoomFactor = 100;
167 m_fontScaleFactor = 100;
168 m_bDnd = true;
169 m_linkCursor = QCursor(Qt::PointingHandCursor);
170 m_loadedObjects = 0;
171 m_totalObjectCount = 0;
172 m_jobPercent = 0;
173 m_haveEncoding = false;
174 m_activeFrame = 0L;
175 m_ssl_in_use = false;
176 m_jsedlg = 0;
177 m_formNotification = KHTMLPart::NoNotification;
179 m_cacheId = 0;
180 m_frameNameId = 1;
182 m_restored = false;
183 m_restoreScrollPosition = false;
185 m_focusNodeNumber = -1;
186 m_focusNodeRestored = false;
188 m_bJScriptForce = false;
189 m_bJScriptOverride = false;
190 m_bJavaForce = false;
191 m_bJavaOverride = false;
192 m_bPluginsForce = false;
193 m_bPluginsOverride = false;
194 m_onlyLocalReferences = false;
195 m_bDNSPrefetch = KHTMLPart::DNSPrefetchDisabled;
196 m_bDNSPrefetchIsDefault = true;
197 m_DNSPrefetchTimer = -1;
198 m_DNSTTLTimer = -1;
199 m_numDNSPrefetchedNames = 0;
201 m_caretMode = false;
202 m_designMode = false;
204 m_metaRefreshEnabled = true;
205 m_statusMessagesEnabled = true;
207 m_bFirstData = true;
208 m_bStrictModeQuirk = true;
209 m_submitForm = 0;
210 m_delayRedirect = 0;
211 m_autoDetectLanguage = KEncodingDetector::SemiautomaticDetection;
213 // inherit settings from parent
214 if(parent && parent->inherits("KHTMLPart"))
216 KHTMLPart* part = static_cast<KHTMLPart*>(parent);
217 if(part->d)
219 m_bJScriptForce = part->d->m_bJScriptForce;
220 m_bJScriptOverride = part->d->m_bJScriptOverride;
221 m_bJavaForce = part->d->m_bJavaForce;
222 m_bJavaOverride = part->d->m_bJavaOverride;
223 m_bPluginsForce = part->d->m_bPluginsForce;
224 m_bPluginsOverride = part->d->m_bPluginsOverride;
225 m_bDNSPrefetch = part->d->m_bDNSPrefetch;
226 m_bDNSPrefetchIsDefault = part->d->m_bDNSPrefetchIsDefault;
227 // Same for SSL settings
228 m_ssl_in_use = part->d->m_ssl_in_use;
229 m_onlyLocalReferences = part->d->m_onlyLocalReferences;
230 m_caretMode = part->d->m_caretMode;
231 m_designMode = part->d->m_designMode;
232 m_zoomFactor = part->d->m_zoomFactor;
233 m_fontScaleFactor = part->d->m_fontScaleFactor;
234 m_autoDetectLanguage = part->d->m_autoDetectLanguage;
235 m_encoding = part->d->m_encoding;
236 m_haveEncoding = part->d->m_haveEncoding;
240 m_focusNodeNumber = -1;
241 m_focusNodeRestored = false;
242 m_opener = 0;
243 m_openedByJS = false;
244 m_newJSInterpreterExists = false;
245 m_jobspeed = 0;
246 m_statusBarWalletLabel = 0L;
247 m_statusBarUALabel = 0L;
248 m_statusBarJSErrorLabel = 0L;
249 m_userStyleSheetLastModified = 0;
250 #ifndef KHTML_NO_WALLET
251 m_wq = 0;
252 #endif
254 ~KHTMLPartPrivate()
256 delete m_statusBarExtension;
257 delete m_extension;
258 delete m_settings;
259 #ifndef KHTML_NO_WALLET
260 delete m_wallet;
261 #endif
262 #ifndef Q_WS_QWS
263 //delete m_javaContext;
264 #endif
267 KHTMLPart* q;
269 QPointer<khtml::ChildFrame> m_frame;
270 KHTMLFrameList m_frames;
271 KHTMLFrameList m_objects;
273 QPointer<KHTMLView> m_view;
274 QPointer<KHTMLViewBar> m_topViewBar;
275 QPointer<KHTMLViewBar> m_bottomViewBar;
276 KHTMLPartBrowserExtension *m_extension;
277 KParts::StatusBarExtension *m_statusBarExtension;
278 KHTMLPartBrowserHostExtension *m_hostExtension;
279 KUrlLabel* m_statusBarIconLabel;
280 KUrlLabel* m_statusBarWalletLabel;
281 KUrlLabel* m_statusBarUALabel;
282 KUrlLabel* m_statusBarJSErrorLabel;
283 KUrlLabel* m_statusBarPopupLabel;
284 QList<QPointer<KHTMLPart> > m_suppressedPopupOriginParts; // We need to guard these in case the origin
285 // is a child part.
286 int m_openableSuppressedPopups;
287 DOM::DocumentImpl *m_doc;
288 KEncodingDetector::AutoDetectScript m_autoDetectLanguage;
289 KEncodingDetector *m_decoder;
290 QString m_encoding;
291 QString m_sheetUsed;
292 qlonglong m_cacheId;
294 #ifndef KHTML_NO_WALLET
295 KWallet::Wallet* m_wallet;
296 #endif
297 int m_runningScripts;
298 bool m_bOpenMiddleClick;
299 bool m_bBackRightClick;
300 bool m_bJScriptEnabled;
301 bool m_bJScriptDebugEnabled;
302 bool m_bJavaEnabled;
303 bool m_bPluginsEnabled;
304 bool m_bJScriptForce;
305 bool m_bJScriptOverride;
306 bool m_bJavaForce;
307 bool m_bJavaOverride;
308 bool m_bPluginsForce;
309 bool m_metaRefreshEnabled;
310 bool m_bPluginsOverride;
311 bool m_restored;
312 bool m_restoreScrollPosition;
313 bool m_statusMessagesEnabled;
314 bool m_bWalletOpened;
315 bool m_urlSelectedOpenedURL; // KDE4: remove
316 bool m_bDNSPrefetchIsDefault;
317 int m_DNSPrefetchTimer;
318 int m_DNSTTLTimer;
319 int m_numDNSPrefetchedNames;
320 QQueue<QString> m_DNSPrefetchQueue;
321 KHTMLPart::DNSPrefetch m_bDNSPrefetch;
322 int m_frameNameId;
324 KHTMLSettings *m_settings;
326 KIO::TransferJob * m_job;
328 QString m_statusBarText[3];
329 unsigned long m_jobspeed;
330 QString m_lastModified;
331 QString m_httpHeaders;
332 QString m_pageServices;
334 // QStrings for SSL metadata
335 // Note: When adding new variables don't forget to update ::saveState()/::restoreState()!
336 QString m_ssl_peer_chain,
337 m_ssl_peer_ip,
338 m_ssl_cipher,
339 m_ssl_protocol_version,
340 m_ssl_cipher_used_bits,
341 m_ssl_cipher_bits,
342 m_ssl_cert_errors,
343 m_ssl_parent_ip,
344 m_ssl_parent_cert;
345 bool m_ssl_in_use;
347 bool m_bComplete;
348 bool m_bLoadEventEmitted;
349 bool m_haveEncoding;
350 bool m_onlyLocalReferences;
351 bool m_redirectLockHistory;
353 KUrl m_workingURL;
355 KIO::CacheControl m_cachePolicy;
356 QTimer m_redirectionTimer;
357 QTime m_parsetime;
358 int m_delayRedirect;
359 QString m_redirectURL;
361 KAction *m_paViewDocument;
362 KAction *m_paViewFrame;
363 KAction *m_paViewInfo;
364 KAction *m_paSaveBackground;
365 KAction *m_paSaveDocument;
366 KAction *m_paSaveFrame;
367 KAction *m_paSecurity;
368 KCodecAction *m_paSetEncoding;
369 KSelectAction *m_paUseStylesheet;
370 KSelectAction *m_paIncZoomFactor;
371 KSelectAction *m_paDecZoomFactor;
372 KAction *m_paLoadImages;
373 KAction *m_paFind;
374 KAction *m_paFindNext;
375 KAction *m_paFindPrev;
376 KAction *m_paFindAheadText;
377 KAction *m_paFindAheadLinks;
378 KAction *m_paPrintFrame;
379 KAction *m_paSelectAll;
380 KAction *m_paDebugScript;
381 KAction *m_paDebugDOMTree;
382 KAction *m_paDebugRenderTree;
383 KAction *m_paStopAnimations;
384 KToggleAction *m_paToggleCaretMode;
385 QMap<QAction*, int> m_paLanguageMap;
387 KParts::PartManager *m_manager;
389 KHTMLPart::GUIProfile m_guiProfile;
391 int m_zoomFactor;
392 int m_fontScaleFactor;
394 QString m_strSelectedURL;
395 QString m_strSelectedURLTarget;
396 QString m_referrer;
397 QString m_pageReferrer;
399 struct SubmitForm
401 const char *submitAction;
402 QString submitUrl;
403 QByteArray submitFormData;
404 QString target;
405 QString submitContentType;
406 QString submitBoundary;
409 SubmitForm *m_submitForm;
411 bool m_bMousePressed;
412 bool m_bRightMousePressed;
413 DOM::Node m_mousePressNode; //node under the mouse when the mouse was pressed (set in the mouse handler)
415 khtml::EditorContext editor_context;
417 QString m_overURL;
418 QString m_overURLTarget;
420 bool m_bDnd;
421 bool m_bFirstData;
422 bool m_bStrictModeQuirk;
423 bool m_bClearing;
424 bool m_bCleared;
425 bool m_focusNodeRestored;
427 int m_focusNodeNumber;
429 QPoint m_dragStartPos;
430 #ifdef KHTML_NO_SELECTION
431 QPoint m_dragLastPos;
432 #endif
434 bool m_designMode;
435 bool m_caretMode;
437 QCursor m_linkCursor;
438 QTimer m_scrollTimer;
440 unsigned long m_loadedObjects;
441 unsigned long m_totalObjectCount;
442 unsigned int m_jobPercent;
444 KHTMLPart::FormNotification m_formNotification;
445 QTimer m_progressUpdateTimer;
447 QStringList m_pluginPageQuestionAsked;
449 KHTMLFind m_find;
451 KJSErrorDlg *m_jsedlg;
453 //QGuardedPtr<KParts::Part> m_activeFrame;
454 KParts::Part * m_activeFrame;
455 QPointer<KHTMLPart> m_opener;
456 bool m_openedByJS;
457 bool m_newJSInterpreterExists; // set to 1 by setOpenedByJS, for window.open
459 void setFlagRecursively(bool KHTMLPartPrivate::*flag, bool value);
461 time_t m_userStyleSheetLastModified;
463 QSet<QString> m_lookedupHosts;
464 static bool s_dnsInitialised;
466 #ifndef KHTML_NO_WALLET
467 KHTMLWalletQueue *m_wq;
468 #endif
470 void clearRedirection();
472 bool isLocalAnchorJump(const KUrl& url);
473 void executeAnchorJump(const KUrl& url, bool lockHistory);
475 static bool isJavaScriptURL(const QString& url);
476 static QString codeForJavaScriptURL(const QString& url);
477 void executeJavascriptURL(const QString &u);
479 bool isInPageURL(const QString& url) {
480 return isLocalAnchorJump(KUrl(url)) || isJavaScriptURL(url);
483 void executeInPageURL(const QString& url, bool lockHistory) {
484 KUrl kurl(url);
485 if (isLocalAnchorJump(kurl))
486 executeAnchorJump(kurl, lockHistory);
487 else
488 executeJavascriptURL(url);
491 void propagateInitialDomainTo(KHTMLPart* kid);
494 #endif