30 #include "tdehtml_part.h"
32 #include "tdehtml_pagecache.h"
34 #include "dom/dom_string.h"
35 #include "dom/dom_element.h"
36 #include "dom/dom_exception.h"
37 #include "html/html_documentimpl.h"
38 #include "html/html_baseimpl.h"
39 #include "html/html_objectimpl.h"
40 #include "html/html_miscimpl.h"
41 #include "html/html_imageimpl.h"
42 #include "html/html_objectimpl.h"
43 #include "rendering/render_text.h"
44 #include "rendering/render_frames.h"
45 #include "rendering/render_layer.h"
46 #include "misc/htmlhashes.h"
47 #include "misc/loader.h"
48 #include "xml/dom2_eventsimpl.h"
49 #include "xml/dom2_rangeimpl.h"
50 #include "xml/xml_tokenizer.h"
51 #include "css/cssstyleselector.h"
52 #include "css/csshelper.h"
55 #include "tdehtmlview.h"
56 #include <tdeparts/partmanager.h>
57 #include "ecma/kjs_proxy.h"
58 #include "ecma/kjs_window.h"
59 #include "tdehtml_settings.h"
60 #include "kjserrordlg.h"
62 #include <kjs/function.h>
63 #include <kjs/interpreter.h>
65 #include "htmlpageinfo.h"
67 #include <sys/types.h>
73 #include <dcopclient.h>
75 #include <kstandarddirs.h>
76 #include <kstringhandler.h>
77 #include <tdeio/job.h>
78 #include <tdeio/global.h>
79 #include <tdeio/netaccess.h>
80 #include <tdeprotocolmanager.h>
82 #include <kiconloader.h>
84 #include <kcharsets.h>
85 #include <tdemessagebox.h>
86 #include <kstdaction.h>
87 #include <tdefiledialog.h>
89 #include <kdatastream.h>
90 #include <tdetempfile.h>
91 #include <tdeglobalsettings.h>
93 #include <tdeapplication.h>
94 #include <tdeparts/browserinterface.h>
95 #if !defined(TQT_NO_DRAGANDDROP)
96 #include <tdemultipledrag.h>
98 #include "../tdeutils/kfinddialog.h"
99 #include "../tdeutils/kfind.h"
101 #include <ksslcertchain.h>
102 #include <ksslinfodlg.h>
104 #include <tdefileitem.h>
105 #include <kurifilter.h>
106 #include <kstatusbar.h>
107 #include <kurllabel.h>
109 #include <tqclipboard.h>
111 #include <tqtooltip.h>
112 #include <tqmetaobject.h>
113 #include <private/tqucomextra_p.h>
115 #include "tdehtmlpart_p.h"
116 #include "kpassivepopup.h"
117 #include "tdepopupmenu.h"
118 #include "rendering/render_form.h"
121 #define HINT_UTF8 106
124 class PartStyleSheetLoader :
public CachedObjectClient
130 m_cachedSheet = dl->requestStyleSheet(url, TQString(),
"text/css",
133 m_cachedSheet->ref(
this );
135 virtual ~PartStyleSheetLoader()
137 if ( m_cachedSheet ) m_cachedSheet->deref(
this);
146 virtual void error(
int,
const TQString& ) {
149 TQGuardedPtr<TDEHTMLPart> m_part;
150 tdehtml::CachedCSSStyleSheet *m_cachedSheet;
154 void tdehtml::ChildFrame::liveConnectEvent(
const unsigned long,
const TQString & event,
const KParts::LiveConnectExtension::ArgList & args)
156 if (!m_part || !m_frame || !m_liveconnect)
161 script.sprintf(
"%s(",
event.latin1());
163 KParts::LiveConnectExtension::ArgList::const_iterator i = args.begin();
164 const KParts::LiveConnectExtension::ArgList::const_iterator argsBegin = i;
165 const KParts::LiveConnectExtension::ArgList::const_iterator argsEnd = args.end();
167 for ( ; i != argsEnd; ++i) {
170 if ((*i).first == KParts::LiveConnectExtension::TypeString) {
172 script += TQString((*i).second).replace(
'\\',
"\\\\").replace(
'"',
"\\\"");
175 script += (*i).second;
178 kdDebug(6050) <<
"tdehtml::ChildFrame::liveConnectEvent " << script <<
endl;
180 TDEHTMLPart * part = ::tqt_cast<TDEHTMLPart *>(m_part->parent());
188 m_jscript->evaluate(TQString(), 1, script, 0L, &cmp);
193 TDEHTMLFrameList::Iterator TDEHTMLFrameList::find(
const TQString &name )
195 Iterator it = begin();
196 const Iterator e =
end();
199 if ( (*it)->m_name==name )
209 TDEHTMLFactory::registerPart(
this );
213 init(
new TDEHTMLView(
this, parentWidget, widgetname ), prof );
220 TDEHTMLFactory::registerPart(
this );
228 void TDEHTMLPart::init(
TDEHTMLView *view, GUIProfile prof )
230 if ( prof == DefaultGUI )
232 else if ( prof == BrowserViewGUI )
235 d =
new TDEHTMLPartPrivate(parent());
240 d->m_guiProfile = prof;
242 d->m_hostExtension =
new TDEHTMLPartBrowserHostExtension(
this );
244 d->m_statusBarIconLabel = 0L;
245 d->m_statusBarPopupLabel = 0L;
246 d->m_openableSuppressedPopups = 0;
248 d->m_bSecurityInQuestion =
false;
249 d->m_paLoadImages = 0;
250 d->m_paDebugScript = 0;
251 d->m_bMousePressed =
false;
252 d->m_bRightMousePressed =
false;
253 d->m_bCleared =
false;
254 d->m_paViewDocument =
new TDEAction( i18n(
"View Do&cument Source" ), CTRL + Key_U,
this, TQ_SLOT( slotViewDocumentSource() ),
actionCollection(),
"viewDocumentSource" );
255 d->m_paViewFrame =
new TDEAction( i18n(
"View Frame Source" ), 0,
this, TQ_SLOT( slotViewFrameSource() ),
actionCollection(),
"viewFrameSource" );
256 d->m_paViewInfo =
new TDEAction( i18n(
"View Document Information" ), CTRL+Key_I,
this, TQ_SLOT( slotViewPageInfo() ),
actionCollection(),
"viewPageInfo" );
257 d->m_paSaveBackground =
new TDEAction( i18n(
"Save &Background Image As..." ), 0,
this, TQ_SLOT( slotSaveBackground() ),
actionCollection(),
"saveBackground" );
261 d->m_paSaveFrame =
new TDEAction( i18n(
"Save &Frame As..." ), 0,
this, TQ_SLOT( slotSaveFrame() ),
actionCollection(),
"saveFrame" );
262 d->m_paSecurity =
new TDEAction( i18n(
"Security..." ),
"decrypted", 0,
this, TQ_SLOT( slotSecurity() ),
actionCollection(),
"security" );
263 d->m_paSecurity->setWhatsThis( i18n(
"Security Settings<p>"
264 "Shows the certificate of the displayed page. Only "
265 "pages that have been transmitted using a secure, encrypted connection have a "
267 "Hint: If the image shows a closed lock, the page has been transmitted over a "
268 "secure connection.") );
269 d->m_paDebugRenderTree =
new TDEAction( i18n(
"Print Rendering Tree to STDOUT" ), ALT + CTRL + SHIFT + Key_A,
this, TQ_SLOT( slotDebugRenderTree() ),
actionCollection(),
"debugRenderTree" );
270 d->m_paDebugDOMTree =
new TDEAction( i18n(
"Print DOM Tree to STDOUT" ), ALT + CTRL + SHIFT + Key_D,
this, TQ_SLOT( slotDebugDOMTree() ),
actionCollection(),
"debugDOMTree" );
271 d->m_paStopAnimations =
new TDEAction( i18n(
"Stop Animated Images" ), 0,
this, TQ_SLOT( slotStopAnimations() ),
actionCollection(),
"stopAnimations" );
274 d->m_paSetEncoding->setDelayed(
false );
278 d->m_automaticDetection->insertItem( i18n(
"Semi-Automatic" ), 0 );
279 d->m_automaticDetection->insertItem( i18n(
"Arabic" ), 1 );
280 d->m_automaticDetection->insertItem( i18n(
"Baltic" ), 2 );
281 d->m_automaticDetection->insertItem( i18n(
"Central European" ), 3 );
283 d->m_automaticDetection->insertItem( i18n(
"Greek" ), 5 );
284 d->m_automaticDetection->insertItem( i18n(
"Hebrew" ), 6 );
285 d->m_automaticDetection->insertItem( i18n(
"Japanese" ), 7 );
287 d->m_automaticDetection->insertItem( i18n(
"Russian" ), 9 );
289 d->m_automaticDetection->insertItem( i18n(
"Turkish" ), 11 );
290 d->m_automaticDetection->insertItem( i18n(
"Ukrainian" ), 12 );
292 d->m_automaticDetection->insertItem( i18n(
"Western European" ), 14 );
294 connect( d->m_automaticDetection, TQ_SIGNAL( activated(
int ) ),
this, TQ_SLOT( slotAutomaticDetectionLanguage(
int ) ) );
296 d->m_paSetEncoding->popupMenu()->insertItem( i18n(
"Automatic Detection" ), d->m_automaticDetection, 0 );
301 d->m_manualDetection =
new TDESelectAction( i18n(
"short for Manual Detection",
"Manual" ), 0,
this, TQ_SLOT( slotSetEncoding() ),
actionCollection(),
"manualDetection" );
303 d->m_manualDetection->setItems( encodings );
304 d->m_manualDetection->setCurrentItem( -1 );
305 d->m_paSetEncoding->insert( d->m_manualDetection );
309 if ( config->
hasGroup(
"HTML Settings" ) ) {
310 config->
setGroup(
"HTML Settings" );
311 tdehtml::Decoder::AutoDetectLanguage language;
312 TQCString
name = TQTextCodec::codecForLocale()->name();
315 if ( name ==
"cp1256" || name ==
"iso-8859-6" ) {
316 language = tdehtml::Decoder::Arabic;
318 else if ( name ==
"cp1257" || name ==
"iso-8859-13" || name ==
"iso-8859-4" ) {
319 language = tdehtml::Decoder::Baltic;
321 else if ( name ==
"cp1250" || name ==
"ibm852" || name ==
"iso-8859-2" || name ==
"iso-8859-3" ) {
322 language = tdehtml::Decoder::CentralEuropean;
324 else if ( name ==
"cp1251" || name ==
"koi8-r" || name ==
"iso-8859-5" ) {
325 language = tdehtml::Decoder::Russian;
327 else if ( name ==
"koi8-u" ) {
328 language = tdehtml::Decoder::Ukrainian;
330 else if ( name ==
"cp1253" || name ==
"iso-8859-7" ) {
331 language = tdehtml::Decoder::Greek;
333 else if ( name ==
"cp1255" || name ==
"iso-8859-8" || name ==
"iso-8859-8-i" ) {
334 language = tdehtml::Decoder::Hebrew;
336 else if ( name ==
"jis7" || name ==
"eucjp" || name ==
"sjis" ) {
337 language = tdehtml::Decoder::Japanese;
339 else if ( name ==
"cp1254" || name ==
"iso-8859-9" ) {
340 language = tdehtml::Decoder::Turkish;
342 else if ( name ==
"cp1252" || name ==
"iso-8859-1" || name ==
"iso-8859-15" ) {
343 language = tdehtml::Decoder::WesternEuropean;
346 language = tdehtml::Decoder::SemiautomaticDetection;
348 int _id = config->
readNumEntry(
"AutomaticDetectionLanguage", language );
349 d->m_automaticDetection->setItemChecked( _id,
true );
350 d->m_paSetEncoding->popupMenu()->setItemChecked( 0,
true );
352 d->m_autoDetectLanguage =
static_cast< tdehtml::Decoder::AutoDetectLanguage
>( _id );
358 if ( prof == BrowserViewGUI ) {
359 d->m_paIncZoomFactor =
new TDEHTMLZoomFactorAction(
this,
true, i18n(
360 "Enlarge Font" ),
"zoom-in",
"CTRL++;CTRL+=",
this,
362 d->m_paIncZoomFactor->setWhatsThis( i18n(
"Enlarge Font<p>"
363 "Make the font in this window bigger. "
364 "Click and hold down the mouse button for a menu with all available font sizes." ) );
365 d->m_paDecZoomFactor =
new TDEHTMLZoomFactorAction(
this,
false, i18n(
366 "Shrink Font" ),
"zoom-out", CTRL + Key_Minus,
this,
368 d->m_paDecZoomFactor->setWhatsThis( i18n(
"Shrink Font<p>"
369 "Make the font in this window smaller. "
370 "Click and hold down the mouse button for a menu with all available font sizes." ) );
374 d->m_paFind->setWhatsThis( i18n(
"Find text<p>"
375 "Shows a dialog that allows you to find text on the displayed page." ) );
378 d->m_paFindNext->setWhatsThis( i18n(
"Find next<p>"
379 "Find the next occurrence of the text that you "
380 "have found using the <b>Find Text</b> function" ) );
383 d->m_paFindPrev->setWhatsThis( i18n(
"Find previous<p>"
384 "Find the previous occurrence of the text that you "
385 "have found using the <b>Find Text</b> function" ) );
387 d->m_paFindAheadText =
new TDEAction( i18n(
"Find Text as You Type"),
TDEShortcut(
'/' ),
this, TQ_SLOT( slotFindAheadText()),
389 d->m_paFindAheadLinks =
new TDEAction( i18n(
"Find Links as You Type"),
TDEShortcut(
'\'' ),
this, TQ_SLOT( slotFindAheadLink()),
391 d->m_paFindAheadText->setEnabled(
false );
392 d->m_paFindAheadLinks->setEnabled(
false );
400 d->m_paFindAheadLinks->setShortcut(
TDEShortcut());
403 d->m_paPrintFrame =
new TDEAction( i18n(
"Print Frame..." ),
"frameprint", 0,
this, TQ_SLOT( slotPrintFrame() ),
actionCollection(),
"printFrame" );
404 d->m_paPrintFrame->setWhatsThis( i18n(
"Print Frame<p>"
405 "Some pages have several frames. To print only a single frame, click "
406 "on it and then use this function." ) );
412 d->m_paToggleCaretMode =
new TDEToggleAction(i18n(
"Toggle Caret Mode"),
413 Key_F7,
this, TQ_SLOT(slotToggleCaretMode()),
417 d->m_paToggleCaretMode->setShortcut(
TDEShortcut());
420 d->m_bOpenMiddleClick = d->m_settings->isOpenMiddleClickEnabled();
421 d->m_bBackRightClick = d->m_settings->isBackRightClickEnabled();
422 d->m_bJScriptEnabled = d->m_settings->isJavaScriptEnabled();
423 setDebugScript( d->m_settings->isJavaScriptDebugEnabled() );
424 d->m_bJavaEnabled = d->m_settings->isJavaEnabled();
425 d->m_bPluginsEnabled = d->m_settings->isPluginsEnabled();
428 d->m_metaRefreshEnabled = d->m_settings->isAutoDelayedActionsEnabled ();
430 connect(
view, TQ_SIGNAL( zoomView(
int ) ), TQ_SLOT( slotZoomView(
int ) ) );
433 this, TQ_SLOT( updateActions() ) );
434 connect(
this, TQ_SIGNAL(
completed(
bool ) ),
435 this, TQ_SLOT( updateActions() ) );
436 connect(
this, TQ_SIGNAL(
started( TDEIO::Job * ) ),
437 this, TQ_SLOT( updateActions() ) );
439 d->m_popupMenuXML = KXMLGUIFactory::readConfigFile(
locate(
"data",
"tdehtml/tdehtml_popupmenu.rc", TDEHTMLFactory::instance() ) );
441 connect( tdehtml::Cache::loader(), TQ_SIGNAL( requestStarted( tdehtml::DocLoader*, tdehtml::CachedObject* ) ),
442 this, TQ_SLOT( slotLoaderRequestStarted( tdehtml::DocLoader*, tdehtml::CachedObject* ) ) );
443 connect( tdehtml::Cache::loader(), TQ_SIGNAL( requestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ),
444 this, TQ_SLOT( slotLoaderRequestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ) );
445 connect( tdehtml::Cache::loader(), TQ_SIGNAL( requestFailed( tdehtml::DocLoader*, tdehtml::CachedObject *) ),
446 this, TQ_SLOT( slotLoaderRequestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ) );
448 connect ( &d->m_progressUpdateTimer, TQ_SIGNAL( timeout() ),
this, TQ_SLOT( slotProgressUpdate() ) );
452 connect( &d->m_redirectionTimer, TQ_SIGNAL( timeout() ),
453 this, TQ_SLOT( slotRedirect() ) );
472 config->
setGroup(
"HTML Settings" );
473 config->
writeEntry(
"AutomaticDetectionLanguage", d->m_autoDetectLanguage );
475 delete d->m_automaticDetection;
476 delete d->m_manualDetection;
480 removeJSErrorExtension();
481 delete d->m_statusBarPopupLabel;
488 d->m_manager->setActivePart( 0 );
493 d->m_redirectionTimer.stop();
498 disconnect( tdehtml::Cache::loader(), TQ_SIGNAL( requestStarted( tdehtml::DocLoader*, tdehtml::CachedObject* ) ),
499 this, TQ_SLOT( slotLoaderRequestStarted( tdehtml::DocLoader*, tdehtml::CachedObject* ) ) );
500 disconnect( tdehtml::Cache::loader(), TQ_SIGNAL( requestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ),
501 this, TQ_SLOT( slotLoaderRequestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ) );
502 disconnect( tdehtml::Cache::loader(), TQ_SIGNAL( requestFailed( tdehtml::DocLoader*, tdehtml::CachedObject *) ),
503 this, TQ_SLOT( slotLoaderRequestDone( tdehtml::DocLoader*, tdehtml::CachedObject *) ) );
510 d->m_view->viewport()->hide();
511 d->m_view->m_part = 0;
522 TDEHTMLFactory::deregisterPart(
this );
525 bool TDEHTMLPart::restoreURL(
const KURL &url )
529 d->m_redirectionTimer.stop();
541 d->m_bComplete =
false;
542 d->m_bLoadEventEmitted =
false;
543 d->m_workingURL =
url;
546 d->m_bJScriptEnabled = TDEHTMLFactory::defaultHTMLSettings()->isJavaScriptEnabled(
url.
host());
547 setDebugScript( TDEHTMLFactory::defaultHTMLSettings()->isJavaScriptDebugEnabled() );
548 d->m_bJavaEnabled = TDEHTMLFactory::defaultHTMLSettings()->isJavaEnabled(
url.
host());
549 d->m_bPluginsEnabled = TDEHTMLFactory::defaultHTMLSettings()->isPluginsEnabled(
url.
host());
553 d->m_restoreScrollPosition =
true;
554 disconnect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
555 connect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
569 d->m_redirectionTimer.stop();
577 if( d->m_bJScriptEnabled )
578 d->m_statusBarText[BarOverrideText] = d->m_statusBarText[BarDefaultText] = TQString();
588 if ( urls.count() > 1 ) {
589 KURL mainURL = urls.first();
590 int error = mainURL.
queryItem(
"error" ).toInt();
592 if ( error == 0 ) error = TDEIO::ERR_UNKNOWN;
593 TQString errorText = mainURL.
queryItem(
"errText", HINT_UTF8 );
597 emit d->m_extension->setLocationBarURL( d->m_workingURL.prettyURL() );
598 htmlError( error, errorText, d->m_workingURL );
605 TQString userAgent = KProtocolManager::userAgentForHost(host);
606 if (userAgent != KProtocolManager::userAgentForHost(TQString())) {
607 if (!d->m_statusBarUALabel) {
608 d->m_statusBarUALabel =
new KURLLabel(d->m_statusBarExtension->statusBar());
610 d->m_statusBarUALabel->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
611 d->m_statusBarUALabel->setUseCursor(
false);
612 d->m_statusBarExtension->addStatusBarItem(d->m_statusBarUALabel, 0,
false);
613 d->m_statusBarUALabel->setPixmap(SmallIcon(
"agent",
instance()));
615 TQToolTip::remove(d->m_statusBarUALabel);
617 TQToolTip::add(d->m_statusBarUALabel, i18n(
"The fake user-agent '%1' is in use.").arg(userAgent));
618 }
else if (d->m_statusBarUALabel) {
619 d->m_statusBarExtension->removeStatusBarItem(d->m_statusBarUALabel);
620 delete d->m_statusBarUALabel;
621 d->m_statusBarUALabel = 0L;
635 bool isFrameSet =
false;
636 if ( d->m_doc && d->m_doc->isHTMLDocument() ) {
637 HTMLDocumentImpl* htmlDoc =
static_cast<HTMLDocumentImpl*
>(d->m_doc);
638 isFrameSet = htmlDoc->body() && (htmlDoc->body()->id() == ID_FRAMESET);
644 if (noReloadForced && urlcmp(
url.
url(),
m_url.
url(),
true, true ))
646 kdDebug( 6050 ) <<
"TDEHTMLPart::openURL, jumping to anchor. m_url = " <<
url.
url() <<
endl;
653 d->m_bComplete =
true;
655 d->m_doc->setParsing(
false);
666 args.
xOffset = d->m_view->contentsX();
667 args.
yOffset = d->m_view->contentsY();
668 d->m_extension->setURLArgs(args);
674 d->m_restoreScrollPosition = d->m_restored;
675 disconnect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
676 connect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
687 d->m_workingURL =
m_url;
690 args.
metaData().insert(
"ssl_parent_ip", d->m_ssl_parent_ip);
691 args.
metaData().insert(
"ssl_parent_cert", d->m_ssl_parent_cert);
692 args.
metaData().insert(
"PropagateHttpHeader",
"true");
693 args.
metaData().insert(
"ssl_was_in_use", d->m_ssl_in_use ?
"TRUE" :
"FALSE" );
694 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE" );
699 args.
metaData().insert(
"referrer", d->m_pageReferrer);
700 d->m_cachePolicy = TDEIO::CC_Cache;
703 d->m_cachePolicy = TDEIO::CC_Reload;
705 d->m_cachePolicy = KProtocolManager::cacheControl();
710 d->m_job->addMetaData(
"content-type", args.
contentType() );
714 d->m_job = TDEIO::get(
m_url,
false,
false );
715 d->m_job->addMetaData(
"cache", TDEIO::getCacheControlString(d->m_cachePolicy));
719 d->m_job->setWindow(
widget()->topLevelWidget());
720 d->m_job->addMetaData(args.
metaData());
722 connect( d->m_job, TQ_SIGNAL( result( TDEIO::Job* ) ),
723 TQ_SLOT( slotFinished( TDEIO::Job* ) ) );
724 connect( d->m_job, TQ_SIGNAL( data( TDEIO::Job*,
const TQByteArray& ) ),
725 TQ_SLOT( slotData( TDEIO::Job*,
const TQByteArray& ) ) );
726 connect ( d->m_job, TQ_SIGNAL( infoMessage( TDEIO::Job*,
const TQString& ) ),
727 TQ_SLOT( slotInfoMessage(TDEIO::Job*,
const TQString& ) ) );
728 connect( d->m_job, TQ_SIGNAL(redirection(TDEIO::Job*,
const KURL& ) ),
729 TQ_SLOT( slotRedirection(TDEIO::Job*,
const KURL&) ) );
731 d->m_bComplete =
false;
732 d->m_bLoadEventEmitted =
false;
735 if( d->m_bJScriptEnabled )
736 d->m_statusBarText[BarOverrideText] = d->m_statusBarText[BarDefaultText] = TQString();
739 d->m_bJScriptEnabled = TDEHTMLFactory::defaultHTMLSettings()->isJavaScriptEnabled(
url.
host());
740 setDebugScript( TDEHTMLFactory::defaultHTMLSettings()->isJavaScriptDebugEnabled() );
741 d->m_bJavaEnabled = TDEHTMLFactory::defaultHTMLSettings()->isJavaEnabled(
url.
host());
742 d->m_bPluginsEnabled = TDEHTMLFactory::defaultHTMLSettings()->isPluginsEnabled(
url.
host());
745 connect( d->m_job, TQ_SIGNAL( speed( TDEIO::Job*,
unsigned long ) ),
746 this, TQ_SLOT( slotJobSpeed( TDEIO::Job*,
unsigned long ) ) );
748 connect( d->m_job, TQ_SIGNAL( percent( TDEIO::Job*,
unsigned long ) ),
749 this, TQ_SLOT( slotJobPercent( TDEIO::Job*,
unsigned long ) ) );
751 connect( d->m_job, TQ_SIGNAL( result( TDEIO::Job* ) ),
752 this, TQ_SLOT( slotJobDone( TDEIO::Job* ) ) );
758 if ( args.
reload && !settings()->userStyleSheet().isEmpty() ) {
759 KURL url( settings()->userStyleSheet() );
760 TDEIO::StatJob *job = TDEIO::stat(
url,
false );
761 connect( job, TQ_SIGNAL( result( TDEIO::Job * ) ),
762 this, TQ_SLOT( slotUserSheetStatDone( TDEIO::Job * ) ) );
778 if ( d->m_doc && d->m_doc->isHTMLDocument() ) {
779 HTMLDocumentImpl* hdoc =
static_cast<HTMLDocumentImpl*
>( d->m_doc );
781 if ( hdoc->body() && d->m_bLoadEventEmitted ) {
782 hdoc->body()->dispatchWindowEvent( EventImpl::UNLOAD_EVENT,
false,
false );
784 d->m_doc->updateRendering();
785 d->m_bLoadEventEmitted =
false;
789 d->m_bComplete =
true;
790 d->m_bLoadEventEmitted =
true;
791 d->m_cachePolicy = KProtocolManager::cacheControl();
793 disconnect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
796 if ( d->m_doc && d->m_doc->parsing() )
798 kdDebug( 6050 ) <<
" was still parsing... calling end " <<
endl;
799 slotFinishedParsing();
800 d->m_doc->setParsing(
false);
803 if ( !d->m_workingURL.isEmpty() )
810 d->m_workingURL =
KURL();
812 if ( d->m_doc && d->m_doc->docLoader() )
813 tdehtml::Cache::loader()->cancelRequests( d->m_doc->docLoader() );
817 ConstFrameIt it = d->m_frames.begin();
818 const ConstFrameIt
end = d->m_frames.end();
819 for (; it !=
end; ++it )
822 (*it)->m_run->abort();
823 if ( !( *it )->m_part.isNull() )
824 ( *it )->m_part->closeURL();
829 ConstFrameIt it = d->m_objects.begin();
830 const ConstFrameIt
end = d->m_objects.end();
831 for (; it !=
end; ++it)
833 if ( !( *it )->m_part.isNull() )
834 ( *it )->m_part->closeURL();
838 if ( d && d->m_redirectionTimer.isActive() )
839 d->m_redirectionTimer.stop();
846 d->m_view->closeChildDialogs();
853 if (d->m_doc && d->m_doc->isHTMLDocument())
854 return static_cast<HTMLDocumentImpl*
>(d->m_doc);
856 return static_cast<HTMLDocumentImpl*
>(0);
869 TQByteArray sourceArray;
870 TQDataStream dataStream( sourceArray, IO_WriteOnly );
872 TQTextStream stream( sourceArray, IO_ReadOnly );
873 stream.setCodec( TQTextCodec::codecForName(
encoding().latin1() ) );
874 sourceStr = stream.read();
878 if( TDEIO::NetAccess::download(
m_url, tmpFile, NULL ) )
881 if ( f.open( IO_ReadOnly ) )
883 TQTextStream stream( &f );
884 stream.setCodec( TQTextCodec::codecForName(
encoding().latin1() ) );
885 sourceStr = stream.read();
888 TDEIO::NetAccess::removeTempFile( tmpFile );
898 return d->m_extension;
903 return d->m_hostExtension;
913 d->m_statusMessagesEnabled = enable;
918 KJSProxy *proxy = jScript();
919 if (!proxy || proxy->paused())
922 return proxy->interpreter();
927 return d->m_statusMessagesEnabled;
932 if ( !enable &&
jScriptEnabled() && d->m_frame && d->m_frame->m_jscript ) {
933 d->m_frame->m_jscript->clear();
935 d->m_bJScriptForce = enable;
936 d->m_bJScriptOverride =
true;
943 if ( d->m_bJScriptOverride )
944 return d->m_bJScriptForce;
945 return d->m_bJScriptEnabled;
950 d->m_metaRefreshEnabled = enable;
955 return d->m_metaRefreshEnabled;
965 #define DIRECT_LINKAGE_TO_ECMA
967 #ifdef DIRECT_LINKAGE_TO_ECMA
968 extern "C" { KJSProxy *kjs_html_init(tdehtml::ChildFrame * childframe); }
971 static bool createJScript(tdehtml::ChildFrame *frame)
973 #ifndef DIRECT_LINKAGE_TO_ECMA
976 setJScriptEnabled(
false );
980 void *sym = lib->
symbol(
"kjs_html_init");
983 setJScriptEnabled(
false );
986 typedef KJSProxy* (*initFunction)(tdehtml::ChildFrame *);
987 initFunction initSym = (initFunction) sym;
988 frame->m_jscript = (*initSym)(d->m_frame);
989 frame->m_kjs_lib = lib;
991 frame->m_jscript = kjs_html_init(frame);
997 KJSProxy *TDEHTMLPart::jScript()
1001 if ( !d->m_frame ) {
1004 d->m_frame =
new tdehtml::ChildFrame;
1005 d->m_frame->m_part =
this;
1007 ConstFrameIt it = p->d->m_frames.begin();
1008 const ConstFrameIt
end = p->d->m_frames.end();
1009 for (; it !=
end; ++it)
1010 if ((*it)->m_part.operator->() ==
this) {
1018 if ( !d->m_frame->m_jscript )
1019 if (!createJScript(d->m_frame))
1021 if (d->m_bJScriptDebugEnabled)
1022 d->m_frame->m_jscript->setDebugEnabled(
true);
1024 return d->m_frame->m_jscript;
1027 TQVariant TDEHTMLPart::crossFrameExecuteScript(
const TQString& target,
const TQString& script)
1031 TQString trg = target.lower();
1033 if (target ==
"_top") {
1037 else if (target ==
"_parent") {
1041 else if (target ==
"_self" || target ==
"_blank") {
1051 if (destpart ==
this)
1055 if (destpart->checkFrameAccess(
this))
1065 KJSErrorDlg *TDEHTMLPart::jsErrorExtension() {
1066 if (!d->m_settings->jsErrorsEnabled()) {
1074 if (!d->m_statusBarJSErrorLabel) {
1075 d->m_statusBarJSErrorLabel =
new KURLLabel(d->m_statusBarExtension->statusBar());
1077 d->m_statusBarJSErrorLabel->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
1078 d->m_statusBarJSErrorLabel->setUseCursor(
false);
1079 d->m_statusBarExtension->addStatusBarItem(d->m_statusBarJSErrorLabel, 0,
false);
1080 TQToolTip::add(d->m_statusBarJSErrorLabel, i18n(
"This web page contains coding errors."));
1081 d->m_statusBarJSErrorLabel->setPixmap(SmallIcon(
"bug",
instance()));
1082 connect(d->m_statusBarJSErrorLabel, TQ_SIGNAL(leftClickedURL()), TQ_SLOT(launchJSErrorDialog()));
1083 connect(d->m_statusBarJSErrorLabel, TQ_SIGNAL(rightClickedURL()), TQ_SLOT(jsErrorDialogContextMenu()));
1086 d->m_jsedlg =
new KJSErrorDlg;
1089 d->m_jsedlg->_clear->setIconSet(SmallIconSet(
"locationbar_erase"));
1090 d->m_jsedlg->_close->setIconSet(SmallIconSet(
"window-close"));
1096 void TDEHTMLPart::removeJSErrorExtension() {
1101 if (d->m_statusBarJSErrorLabel != 0) {
1102 d->m_statusBarExtension->removeStatusBarItem( d->m_statusBarJSErrorLabel );
1103 delete d->m_statusBarJSErrorLabel;
1104 d->m_statusBarJSErrorLabel = 0;
1110 void TDEHTMLPart::disableJSErrorExtension() {
1111 removeJSErrorExtension();
1116 d->m_settings->setJSErrorsEnabled(
false);
1117 DCOPClient::mainClient()->send(
"konqueror*",
"KonquerorIface",
"reparseConfiguration()", TQByteArray());
1120 void TDEHTMLPart::jsErrorDialogContextMenu() {
1122 m->insertItem(i18n(
"&Hide Errors"),
this, TQ_SLOT(removeJSErrorExtension()));
1123 m->insertItem(i18n(
"&Disable Error Reporting"),
this, TQ_SLOT(disableJSErrorExtension()));
1124 m->popup(TQCursor::pos());
1127 void TDEHTMLPart::launchJSErrorDialog() {
1128 KJSErrorDlg *dlg = jsErrorExtension();
1135 void TDEHTMLPart::launchJSConfigDialog() {
1137 args <<
"tdehtml_java_js";
1145 kdDebug(6070) <<
"executeScript: caller='" <<
name() <<
"' filename=" << filename <<
" baseLine=" << baseLine <<
endl;
1147 KJSProxy *proxy = jScript();
1149 if (!proxy || proxy->paused())
1152 KJS::Completion comp;
1154 TQVariant ret = proxy->evaluate(filename, baseLine, script, n, &comp);
1159 if (comp.complType() == KJS::Throw && !comp.value().isNull()) {
1160 KJSErrorDlg *dlg = jsErrorExtension();
1162 KJS::UString msg = comp.value().toString(proxy->interpreter()->globalExec());
1163 dlg->addError(i18n(
"<b>Error</b>: %1: %2").arg(filename, msg.qstring()));
1168 if ( !d->m_redirectURL.isEmpty() && d->m_delayRedirect == -1 )
1170 kdDebug(6070) <<
"executeScript done, handling immediate redirection NOW" <<
endl;
1172 tdehtml::Tokenizer* t = d->m_doc->tokenizer();
1175 d->m_redirectionTimer.start( 0,
true );
1189 kdDebug(6070) <<
"TDEHTMLPart::executeScript caller='" << name() <<
"' node=" << n.
nodeName().string().latin1() <<
"(" << (n.
isNull() ? 0 : n.
nodeType()) <<
") " <<
endl;
1191 KJSProxy *proxy = jScript();
1193 if (!proxy || proxy->paused())
1195 ++(d->m_runningScripts);
1196 KJS::Completion comp;
1197 const TQVariant ret = proxy->evaluate( TQString(), 1, script, n, &comp );
1198 --(d->m_runningScripts);
1203 if (comp.complType() == KJS::Throw && !comp.value().isNull()) {
1204 KJSErrorDlg *dlg = jsErrorExtension();
1206 KJS::UString msg = comp.value().toString(proxy->interpreter()->globalExec());
1207 dlg->addError(i18n(
"<b>Error</b>: node %1: %2").arg(n.
nodeName().string()).arg(msg.qstring()));
1211 if (!d->m_runningScripts && d->m_doc && !d->m_doc->parsing() && d->m_submitForm )
1215 kdDebug(6070) <<
"TDEHTMLPart::executeScript - done" <<
endl;
1220 bool TDEHTMLPart::scheduleScript(
const DOM::Node &n,
const TQString& script)
1224 d->scheduledScript = script;
1225 d->scheduledScriptNode = n;
1230 TQVariant TDEHTMLPart::executeScheduledScript()
1232 if( d->scheduledScript.isEmpty() )
1237 TQVariant ret =
executeScript( d->scheduledScriptNode, d->scheduledScript );
1238 d->scheduledScript = TQString();
1246 d->m_bJavaForce = enable;
1247 d->m_bJavaOverride =
true;
1255 if( d->m_bJavaOverride )
1256 return d->m_bJavaForce;
1257 return d->m_bJavaEnabled;
1275 d->m_bPluginsForce = enable;
1276 d->m_bPluginsOverride =
true;
1283 if ( d->m_bPluginsOverride )
1284 return d->m_bPluginsForce;
1285 return d->m_bPluginsEnabled;
1288 static int s_DOMTreeIndentLevel = 0;
1290 void TDEHTMLPart::slotDebugDOMTree()
1292 if ( d->m_doc && d->m_doc->firstChild() )
1293 tqDebug(
"%s", d->m_doc->firstChild()->toString().string().latin1());
1297 const int indentLevel = s_DOMTreeIndentLevel++;
1299 ConstFrameIt it = d->m_frames.begin();
1300 const ConstFrameIt
end = d->m_frames.end();
1301 for (; it !=
end; ++it )
1302 if ( !( *it )->m_part.isNull() && (*it)->m_part->inherits(
"TDEHTMLPart" ) ) {
1304 kdDebug(6050) << TQString().leftJustify(s_DOMTreeIndentLevel*4,
' ') <<
"FRAME " << p->name() <<
" " <<
endl;
1305 static_cast<TDEHTMLPart*
>( p )->slotDebugDOMTree();
1307 s_DOMTreeIndentLevel = indentLevel;
1310 void TDEHTMLPart::slotDebugScript()
1313 jScript()->showDebugWindow();
1316 void TDEHTMLPart::slotDebugRenderTree()
1320 d->m_doc->renderer()->printTree();
1330 void TDEHTMLPart::slotStopAnimations()
1337 if ( d->m_doc && d->m_doc->docLoader()->autoloadImages() == enable )
1341 d->m_doc->docLoader()->setAutoloadImages( enable );
1346 delete d->m_paLoadImages;
1347 d->m_paLoadImages = 0;
1349 else if ( !d->m_paLoadImages )
1350 d->m_paLoadImages =
new TDEAction( i18n(
"Display Images on Page" ),
"images_display", 0,
this, TQ_SLOT( slotLoadImages() ),
actionCollection(),
"loadImages" );
1352 if ( d->m_paLoadImages ) {
1353 TQPtrList<TDEAction> lst;
1354 lst.append( d->m_paLoadImages );
1362 return d->m_doc->docLoader()->autoloadImages();
1367 void TDEHTMLPart::clear()
1369 if ( d->m_bCleared )
1372 d->m_bCleared =
true;
1374 d->m_bClearing =
true;
1377 ConstFrameIt it = d->m_frames.begin();
1378 const ConstFrameIt
end = d->m_frames.end();
1379 for(; it !=
end; ++it )
1383 (*it)->m_run->abort();
1388 ConstFrameIt it = d->m_objects.begin();
1389 const ConstFrameIt
end = d->m_objects.end();
1390 for(; it !=
end; ++it )
1394 (*it)->m_run->abort();
1405 if (d->m_doc->attached())
1410 if ( d->m_frame && d->m_frame->m_jscript )
1411 d->m_frame->m_jscript->clear();
1414 if (d->m_doc && d->m_doc->renderer() && d->m_doc->renderer()->layer())
1415 d->m_doc->renderer()->layer()->suspendMarquees();
1427 delete d->m_decoder;
1433 this, TQ_SLOT( slotActiveFrameChanged(
KParts::Part * ) ) );
1436 if (d->m_frames.count())
1438 TDEHTMLFrameList frames = d->m_frames;
1439 d->m_frames.clear();
1440 ConstFrameIt it = frames.begin();
1441 const ConstFrameIt
end = frames.end();
1442 for(; it !=
end; ++it )
1444 if ( (*it)->m_part )
1452 d->m_suppressedPopupOriginParts.clear();
1454 if (d->m_objects.count())
1456 TDEHTMLFrameList objects = d->m_objects;
1457 d->m_objects.clear();
1458 ConstFrameIt oi = objects.begin();
1459 const ConstFrameIt oiEnd = objects.end();
1461 for (; oi != oiEnd; ++oi )
1468 this, TQ_SLOT( slotActiveFrameChanged(
KParts::Part * ) ) );
1471 d->m_delayRedirect = 0;
1472 d->m_redirectURL = TQString();
1473 d->m_redirectionTimer.stop();
1474 d->m_redirectLockHistory =
true;
1475 d->m_bClearing =
false;
1476 d->m_frameNameId = 1;
1477 d->m_bFirstData =
true;
1479 d->m_bMousePressed =
false;
1483 d->m_startOffset = 0;
1485 #ifndef TQT_NO_CLIPBOARD
1486 connect( kapp->clipboard(), TQ_SIGNAL(
selectionChanged()), TQ_SLOT( slotClearSelection()));
1489 d->m_jobPercent = 0;
1491 if ( !d->m_haveEncoding )
1492 d->m_encoding = TQString();
1494 d->m_parsetime.restart();
1503 DOM::HTMLDocumentImpl *TDEHTMLPart::docImpl()
const
1505 if ( d && d->m_doc && d->m_doc->isHTMLDocument() )
1506 return static_cast<HTMLDocumentImpl*
>(d->m_doc);
1510 DOM::DocumentImpl *TDEHTMLPart::xmlDocImpl()
const
1517 void TDEHTMLPart::slotInfoMessage(TDEIO::Job* tdeio_job,
const TQString& msg)
1519 assert(d->m_job == tdeio_job);
1522 setStatusBarText(msg, BarDefaultText);
1525 void TDEHTMLPart::setPageSecurity( PageSecurity sec )
1527 emit d->m_extension->setPageSecurity( sec );
1528 if ( sec != NotCrypted && !d->m_statusBarIconLabel && !
parentPart() ) {
1529 d->m_statusBarIconLabel =
new KURLLabel( d->m_statusBarExtension->statusBar() );
1531 d->m_statusBarIconLabel->setSizePolicy(TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ));
1532 d->m_statusBarIconLabel->setUseCursor(
false );
1533 d->m_statusBarExtension->addStatusBarItem( d->m_statusBarIconLabel, 0,
false );
1534 connect( d->m_statusBarIconLabel, TQ_SIGNAL( leftClickedURL() ), TQ_SLOT( slotSecurity() ) );
1535 }
else if (d->m_statusBarIconLabel) {
1536 TQToolTip::remove(d->m_statusBarIconLabel);
1539 if (d->m_statusBarIconLabel) {
1540 if (d->m_ssl_in_use)
1541 TQToolTip::add(d->m_statusBarIconLabel,
1542 i18n(
"Session is secured with %1 bit %2.").arg(d->m_ssl_cipher_used_bits).arg(d->m_ssl_cipher));
1543 else TQToolTip::add(d->m_statusBarIconLabel, i18n(
"Session is not secured."));
1549 iconName =
"decrypted";
1550 if ( d->m_statusBarIconLabel ) {
1551 d->m_statusBarExtension->removeStatusBarItem( d->m_statusBarIconLabel );
1552 delete d->m_statusBarIconLabel;
1553 d->m_statusBarIconLabel = 0L;
1557 iconName =
"encrypted";
1560 iconName =
"halfencrypted";
1563 d->m_paSecurity->setIcon( iconName );
1564 if ( d->m_statusBarIconLabel )
1565 d->m_statusBarIconLabel->setPixmap( SmallIcon( iconName,
instance() ) );
1568 void TDEHTMLPart::slotData( TDEIO::Job* tdeio_job,
const TQByteArray &data )
1570 assert ( d->m_job == tdeio_job );
1574 if ( !d->m_workingURL.isEmpty() )
1581 d->m_job->suspend();
1582 begin( d->m_workingURL, d->m_extension->urlArgs().xOffset, d->m_extension->urlArgs().yOffset );
1585 if (d->m_cachePolicy == TDEIO::CC_Refresh)
1586 d->m_doc->docLoader()->setCachePolicy(TDEIO::CC_Verify);
1588 d->m_doc->docLoader()->setCachePolicy(d->m_cachePolicy);
1590 d->m_workingURL =
KURL();
1595 d->m_httpHeaders = d->m_job->queryMetaData(
"HTTP-Headers");
1596 time_t cacheCreationDate = d->m_job->queryMetaData(
"cache-creation-date").toLong();
1597 d->m_doc->docLoader()->setCacheCreationDate(cacheCreationDate);
1599 d->m_pageServices = d->m_job->queryMetaData(
"PageServices");
1600 d->m_pageReferrer = d->m_job->queryMetaData(
"referrer");
1601 d->m_bSecurityInQuestion =
false;
1602 d->m_ssl_in_use = (d->m_job->queryMetaData(
"ssl_in_use") ==
"TRUE");
1606 if (p && p->d->m_ssl_in_use != d->m_ssl_in_use) {
1609 p->setPageSecurity( Mixed );
1610 p->d->m_bSecurityInQuestion =
true;
1614 setPageSecurity( d->m_ssl_in_use ? Encrypted : NotCrypted );
1617 d->m_ssl_parent_ip = d->m_job->queryMetaData(
"ssl_parent_ip");
1618 d->m_ssl_parent_cert = d->m_job->queryMetaData(
"ssl_parent_cert");
1619 d->m_ssl_peer_certificate = d->m_job->queryMetaData(
"ssl_peer_certificate");
1620 d->m_ssl_peer_chain = d->m_job->queryMetaData(
"ssl_peer_chain");
1621 d->m_ssl_peer_ip = d->m_job->queryMetaData(
"ssl_peer_ip");
1622 d->m_ssl_cipher = d->m_job->queryMetaData(
"ssl_cipher");
1623 d->m_ssl_cipher_desc = d->m_job->queryMetaData(
"ssl_cipher_desc");
1624 d->m_ssl_cipher_version = d->m_job->queryMetaData(
"ssl_cipher_version");
1625 d->m_ssl_cipher_used_bits = d->m_job->queryMetaData(
"ssl_cipher_used_bits");
1626 d->m_ssl_cipher_bits = d->m_job->queryMetaData(
"ssl_cipher_bits");
1627 d->m_ssl_cert_state = d->m_job->queryMetaData(
"ssl_cert_state");
1629 if (d->m_statusBarIconLabel) {
1630 TQToolTip::remove(d->m_statusBarIconLabel);
1631 if (d->m_ssl_in_use) {
1632 TQToolTip::add(d->m_statusBarIconLabel, i18n(
"Session is secured with %1 bit %2.").arg(d->m_ssl_cipher_used_bits).arg(d->m_ssl_cipher));
1634 TQToolTip::add(d->m_statusBarIconLabel, i18n(
"Session is not secured."));
1639 TQString qData = d->m_job->queryMetaData(
"charset");
1640 if ( !qData.isEmpty() && !d->m_haveEncoding )
1641 d->m_encoding = qData;
1645 qData = d->m_job->queryMetaData(
"http-refresh");
1646 if( !qData.isEmpty())
1647 d->m_doc->processHttpEquiv(
"refresh", qData);
1658 TQString language = d->m_job->queryMetaData(
"content-language");
1659 if (!language.isEmpty())
1660 d->m_doc->setContentLanguage(language);
1664 d->m_lastModified = d->m_job->queryMetaData(
"modified");
1666 d->m_lastModified = TQString();
1670 write( data.data(), data.size() );
1671 if (d->m_frame && d->m_frame->m_jscript)
1672 d->m_frame->m_jscript->dataReceived();
1675 void TDEHTMLPart::slotRestoreData(
const TQByteArray &data )
1678 if ( !d->m_workingURL.isEmpty() )
1680 long saveCacheId = d->m_cacheId;
1681 TQString savePageReferrer = d->m_pageReferrer;
1682 TQString saveEncoding = d->m_encoding;
1683 begin( d->m_workingURL, d->m_extension->urlArgs().xOffset, d->m_extension->urlArgs().yOffset );
1684 d->m_encoding = saveEncoding;
1685 d->m_pageReferrer = savePageReferrer;
1686 d->m_cacheId = saveCacheId;
1687 d->m_workingURL =
KURL();
1691 write( data.data(), data.size() );
1693 if (data.size() == 0)
1697 if (d->m_doc && d->m_doc->parsing())
1704 kdDebug(6050) <<
"TDEHTMLPart::showError d->m_bParsing=" << (d->m_doc && d->m_doc->parsing()) <<
" d->m_bComplete=" << d->m_bComplete
1705 <<
" d->m_bCleared=" << d->m_bCleared <<
endl;
1707 if (job->error() == TDEIO::ERR_NO_CONTENT)
1710 if ( (d->m_doc && d->m_doc->parsing()) || d->m_workingURL.isEmpty() )
1711 job->showErrorDialog( );
1714 htmlError( job->error(), job->errorText(), d->m_workingURL );
1721 kdDebug(6050) <<
"TDEHTMLPart::htmlError errorCode=" << errorCode <<
" text=" << text <<
endl;
1723 bool bJSFO = d->m_bJScriptForce;
1724 bool bJSOO = d->m_bJScriptOverride;
1725 d->m_bJScriptForce =
false;
1726 d->m_bJScriptOverride =
true;
1728 TQString errText = TQString::fromLatin1(
"<HTML dir=%1><HEAD><TITLE>" )
1729 .arg(TQApplication::reverseLayout() ?
"rtl" :
"ltr");
1730 errText += i18n(
"Error while loading %1" ).arg( reqUrl.
htmlURL() );
1731 errText += TQString::fromLatin1(
"</TITLE></HEAD><BODY><P>" );
1732 errText += i18n(
"An error occurred while loading <B>%1</B>:" ).arg( reqUrl.
htmlURL() );
1733 errText += TQString::fromLatin1(
"</P>" );
1734 errText += TQStyleSheet::convertFromPlainText( TDEIO::buildErrorString( errorCode, text ) );
1735 errText += TQString::fromLatin1(
"</BODY></HTML>" );
1739 d->m_bJScriptForce = bJSFO;
1740 d->m_bJScriptOverride = bJSOO;
1746 d->m_workingURL =
KURL();
1752 TQString errorName, techName, description;
1753 TQStringList causes, solutions;
1755 TQByteArray raw = TDEIO::rawErrorDetail( errorCode, text, &reqUrl );
1756 TQDataStream stream(raw, IO_ReadOnly);
1758 stream >> errorName >> techName >> description >> causes >> solutions;
1760 TQString
url, protocol, datetime;
1766 TQString doc = TQString::fromLatin1(
"<html><head><title>" );
1767 doc += i18n(
"Error: " );
1769 doc += TQString::fromLatin1(
" - %1</title></head><body><h1>" ).arg(
url );
1770 doc += i18n(
"The requested operation could not be completed" );
1771 doc += TQString::fromLatin1(
"</h1><h2>" );
1773 doc += TQString::fromLatin1(
"</h2>" );
1774 if ( !techName.isNull() ) {
1775 doc += TQString::fromLatin1(
"<h2>" );
1776 doc += i18n(
"Technical Reason: " );
1778 doc += TQString::fromLatin1(
"</h2>" );
1780 doc += TQString::fromLatin1(
"<h3>" );
1781 doc += i18n(
"Details of the Request:" );
1782 doc += TQString::fromLatin1(
"</h3><ul><li>" );
1783 doc += i18n(
"URL: %1" ).arg(
url );
1784 doc += TQString::fromLatin1(
"</li><li>" );
1785 if ( !protocol.isNull() ) {
1788 doc += TQString::fromLatin1(
"</li><li>" );
1790 doc += i18n(
"Date and Time: %1" ).arg( datetime );
1791 doc += TQString::fromLatin1(
"</li><li>" );
1792 doc += i18n(
"Additional Information: %1" ).arg( text );
1793 doc += TQString::fromLatin1(
"</li></ul><h3>" );
1794 doc += i18n(
"Description:" );
1795 doc += TQString::fromLatin1(
"</h3><p>" );
1797 doc += TQString::fromLatin1(
"</p>" );
1798 if ( causes.count() ) {
1799 doc += TQString::fromLatin1(
"<h3>" );
1800 doc += i18n(
"Possible Causes:" );
1801 doc += TQString::fromLatin1(
"</h3><ul><li>" );
1802 doc += causes.join(
"</li><li>" );
1803 doc += TQString::fromLatin1(
"</li></ul>" );
1805 if ( solutions.count() ) {
1806 doc += TQString::fromLatin1(
"<h3>" );
1807 doc += i18n(
"Possible Solutions:" );
1808 doc += TQString::fromLatin1(
"</h3><ul><li>" );
1809 doc += solutions.join(
"</li><li>" );
1810 doc += TQString::fromLatin1(
"</li></ul>" );
1812 doc += TQString::fromLatin1(
"</body></html>" );
1818 void TDEHTMLPart::slotFinished( TDEIO::Job * job )
1832 if (job->error() == TDEIO::ERR_IS_DIRECTORY)
1835 emit d->m_extension->openURLRequest( d->m_workingURL, args );
1839 emit
canceled( job->errorString() );
1847 TDEIO::TransferJob *tjob = ::tqt_cast<TDEIO::TransferJob*>(job);
1848 if (tjob && tjob->isErrorPage()) {
1849 tdehtml::RenderPart *renderPart = d->m_frame ?
static_cast<tdehtml::RenderPart *
>(d->m_frame->m_frame) : 0;
1851 HTMLObjectElementImpl* elt =
static_cast<HTMLObjectElementImpl *
>(renderPart->element());
1854 elt->renderAlternative();
1857 if (d->m_bComplete)
return;
1863 if (d->m_frame && d->m_frame->m_jscript)
1864 d->m_frame->m_jscript->dataReceived();
1866 if ( d->m_doc && d->m_doc->docLoader()->expireDate() &&
m_url.
protocol().lower().startsWith(
"http"))
1867 TDEIO::http_update_cache(
m_url,
false, d->m_doc->docLoader()->expireDate());
1869 d->m_workingURL =
KURL();
1871 if ( d->m_doc && d->m_doc->parsing())
1879 removeJSErrorExtension();
1881 d->m_openableSuppressedPopups = 0;
1882 for ( TQValueListIterator<TQGuardedPtr<TDEHTMLPart> > i = d->m_suppressedPopupOriginParts.begin();
1883 i != d->m_suppressedPopupOriginParts.end(); ++i ) {
1886 KJS::Window *w = KJS::Window::retrieveWindow( part );
1888 w->forgetSuppressedWindows();
1894 d->m_bCleared =
false;
1896 d->m_bComplete =
false;
1897 d->m_bLoadEventEmitted =
false;
1900 TQString urlString =
url.
url();
1901 TDEHTMLFactory::vLinks()->insert( urlString );
1903 if ( urlString != urlString2 ) {
1904 TDEHTMLFactory::vLinks()->insert( urlString2 );
1915 d->m_extension->setURLArgs( args );
1917 d->m_pageReferrer = TQString();
1920 d->m_referrer = ref.
protocol().startsWith(
"http") ? ref.
url() :
"";
1924 bool servedAsXHTML = args.
serviceType ==
"application/xhtml+xml";
1925 bool servedAsXML = KMimeType::mimeType(args.
serviceType)->is(
"text/xml" );
1927 if ( servedAsXML && !servedAsXHTML ) {
1928 d->m_doc = DOMImplementationImpl::instance()->createDocument( d->m_view );
1930 d->m_doc = DOMImplementationImpl::instance()->createHTMLDocument( d->m_view );
1932 static_cast<HTMLDocumentImpl *
>(d->m_doc)->setHTMLRequested( !servedAsXHTML );
1934 #ifndef TDEHTML_NO_CARET
1940 if (!d->m_doc->attached())
1941 d->m_doc->attach( );
1942 d->m_doc->setBaseURL(
KURL() );
1943 d->m_doc->docLoader()->setShowAnimations( TDEHTMLFactory::defaultHTMLSettings()->showAnimations() );
1946 d->m_paUseStylesheet->setItems(TQStringList());
1947 d->m_paUseStylesheet->setEnabled(
false );
1950 TQString userStyleSheet = TDEHTMLFactory::defaultHTMLSettings()->userStyleSheet();
1951 if ( !userStyleSheet.isEmpty() )
1954 d->m_doc->setRestoreState(args.
docState);
1956 connect(d->m_doc,TQ_SIGNAL(finishedParsing()),
this,TQ_SLOT(slotFinishedParsing()));
1958 emit d->m_extension->enableAction(
"print",
true );
1960 d->m_doc->setParsing(
true);
1965 if ( !d->m_decoder )
1966 d->m_decoder = createDecoder();
1969 len = strlen( str );
1974 TQString decoded = d->m_decoder->decode( str, len );
1976 if(decoded.isEmpty())
return;
1978 if(d->m_bFirstData) {
1980 d->m_doc->determineParseMode( decoded );
1981 d->m_bFirstData =
false;
1985 if(d->m_decoder->visuallyOrdered()) d->m_doc->setVisuallyOrdered();
1986 d->m_doc->setDecoderCodec(d->m_decoder->codec());
1987 d->m_doc->recalcStyle( NodeImpl::Force );
1990 tdehtml::Tokenizer* t = d->m_doc->tokenizer();
1992 t->write( decoded,
true );
2000 if(d->m_bFirstData) {
2002 d->m_doc->setParseMode( DocumentImpl::Strict );
2003 d->m_bFirstData =
false;
2005 tdehtml::Tokenizer* t = d->m_doc->tokenizer();
2007 t->write( str,
true );
2014 TQString decoded = d->m_decoder->flush();
2015 if (d->m_bFirstData) {
2016 d->m_bFirstData =
false;
2017 d->m_doc->determineParseMode(decoded);
2021 d->m_doc->finishParsing();
2027 KMimeType::Ptr mime = KMimeType::mimeType(mimeType);
2028 if ( mime->is(
"text/html" ) || mime->is(
"text/xml" ) )
2038 write( data.data(), data.size() );
2051 if (!d->m_view)
return;
2052 d->m_view->paint(p, rc, yOff, more);
2058 d->m_doc->docLoader()->setShowAnimations( TDEHTMLSettings::KAnimationDisabled );
2060 ConstFrameIt it = d->m_frames.begin();
2061 const ConstFrameIt
end = d->m_frames.end();
2062 for (; it !=
end; ++it )
2063 if ( !(*it)->m_part.isNull() && (*it)->m_part->inherits(
"TDEHTMLPart" ) ) {
2069 void TDEHTMLPart::resetFromScript()
2072 d->m_bComplete =
false;
2073 d->m_bLoadEventEmitted =
false;
2074 disconnect(d->m_doc,TQ_SIGNAL(finishedParsing()),
this,TQ_SLOT(slotFinishedParsing()));
2075 connect(d->m_doc,TQ_SIGNAL(finishedParsing()),
this,TQ_SLOT(slotFinishedParsing()));
2076 d->m_doc->setParsing(
true);
2081 void TDEHTMLPart::slotFinishedParsing()
2083 d->m_doc->setParsing(
false);
2084 checkEmitLoadEvent();
2085 disconnect(d->m_doc,TQ_SIGNAL(finishedParsing()),
this,TQ_SLOT(slotFinishedParsing()));
2093 void TDEHTMLPart::slotLoaderRequestStarted( tdehtml::DocLoader* dl, tdehtml::CachedObject *obj )
2095 if ( obj && obj->type() == tdehtml::CachedObject::Image && d->m_doc && d->m_doc->docLoader() == dl ) {
2099 ++(p->d->m_totalObjectCount);
2101 if ( !p && op->d->m_loadedObjects <= op->d->m_totalObjectCount
2102 && !op->d->m_progressUpdateTimer.isActive())
2103 op->d->m_progressUpdateTimer.start( 200,
true );
2108 void TDEHTMLPart::slotLoaderRequestDone( tdehtml::DocLoader* dl, tdehtml::CachedObject *obj )
2110 if ( obj && obj->type() == tdehtml::CachedObject::Image && d->m_doc && d->m_doc->docLoader() == dl ) {
2114 ++(p->d->m_loadedObjects);
2116 if ( !p && op->d->m_loadedObjects <= op->d->m_totalObjectCount && op->d->m_jobPercent <= 100
2117 && !op->d->m_progressUpdateTimer.isActive())
2118 op->d->m_progressUpdateTimer.start( 200,
true );
2125 void TDEHTMLPart::slotProgressUpdate()
2128 if ( d->m_loadedObjects < d->m_totalObjectCount )
2129 percent = d->m_jobPercent / 4 + ( d->m_loadedObjects*300 ) / ( 4*d->m_totalObjectCount );
2131 percent = d->m_jobPercent;
2133 if( d->m_bComplete )
2136 if (d->m_statusMessagesEnabled) {
2137 if( d->m_bComplete )
2138 emit d->m_extension->infoMessage( i18n(
"Page loaded." ));
2139 else if ( d->m_loadedObjects < d->m_totalObjectCount && percent >= 75 )
2140 emit d->m_extension->infoMessage( i18n(
"%n Image of %1 loaded.",
"%n Images of %1 loaded.", d->m_loadedObjects).arg(d->m_totalObjectCount) );
2143 emit d->m_extension->loadingProgress( percent );
2146 void TDEHTMLPart::slotJobSpeed( TDEIO::Job* ,
unsigned long speed )
2148 d->m_jobspeed = speed;
2153 void TDEHTMLPart::slotJobPercent( TDEIO::Job* ,
unsigned long percent )
2155 d->m_jobPercent = percent;
2158 d->m_progressUpdateTimer.start( 0,
true );
2161 void TDEHTMLPart::slotJobDone( TDEIO::Job* )
2163 d->m_jobPercent = 100;
2166 d->m_progressUpdateTimer.start( 0,
true );
2169 void TDEHTMLPart::slotUserSheetStatDone( TDEIO::Job *_job )
2171 using namespace TDEIO;
2173 if ( _job->error() ) {
2178 const UDSEntry entry =
dynamic_cast<TDEIO::StatJob *
>( _job )->statResult();
2179 UDSEntry::ConstIterator it = entry.begin();
2180 const UDSEntry::ConstIterator
end = entry.end();
2181 for ( ; it !=
end; ++it ) {
2182 if ( ( *it ).m_uds == UDS_MODIFICATION_TIME ) {
2190 const time_t
lastModified =
static_cast<time_t
>( ( *it ).m_long );
2191 if ( d->m_userStyleSheetLastModified >=
lastModified ) {
2200 void TDEHTMLPart::checkCompleted()
2207 if (d->m_doc && !d->m_doc->parsing() && !d->m_focusNodeRestored)
2209 if (d->m_focusNodeNumber >= 0)
2210 d->m_doc->setFocusNode(d->m_doc->nodeWithAbsIndex(d->m_focusNodeNumber));
2212 d->m_focusNodeRestored =
true;
2215 bool bPendingChildRedirection =
false;
2217 ConstFrameIt it = d->m_frames.begin();
2218 const ConstFrameIt
end = d->m_frames.end();
2219 for (; it !=
end; ++it ) {
2220 if ( !(*it)->m_bCompleted )
2226 if ( (*it)->m_bPendingRedirection )
2227 bPendingChildRedirection =
true;
2232 ConstFrameIt oi = d->m_objects.begin();
2233 const ConstFrameIt oiEnd = d->m_objects.end();
2235 for (; oi != oiEnd; ++oi )
2236 if ( !(*oi)->m_bCompleted )
2240 if ( d->m_bComplete || (d->m_doc && d->m_doc->parsing()) )
2245 if ( d->m_doc && d->m_doc->docLoader() )
2246 requests = tdehtml::Cache::loader()->numRequests( d->m_doc->docLoader() );
2256 d->m_bComplete =
true;
2257 d->m_cachePolicy = KProtocolManager::cacheControl();
2258 d->m_totalObjectCount = 0;
2259 d->m_loadedObjects = 0;
2265 if ( !p && !op->d->m_progressUpdateTimer.isActive())
2266 op->d->m_progressUpdateTimer.start( 0,
true );
2269 checkEmitLoadEvent();
2271 bool pendingAction =
false;
2273 if ( !d->m_redirectURL.isEmpty() )
2279 d->m_redirectionTimer.start( 1000 * d->m_delayRedirect,
true );
2284 pendingAction =
true;
2286 else if ( bPendingChildRedirection )
2288 pendingAction =
true;
2295 d->m_view->complete( pendingAction );
2298 TQStringList sheets;
2300 sheets = d->m_doc->availableStyleSheets();
2301 sheets.prepend( i18n(
"Automatic Detection" ) );
2302 d->m_paUseStylesheet->setItems( sheets );
2304 d->m_paUseStylesheet->setEnabled( sheets.count() > 2);
2305 if (sheets.count() > 2)
2307 d->m_paUseStylesheet->setCurrentItem(kMax(sheets.findIndex(d->m_sheetUsed), 0));
2308 slotUseStylesheet();
2314 kdDebug(6050) <<
"DONE: " <<d->m_parsetime.elapsed() <<
endl;
2318 void TDEHTMLPart::checkEmitLoadEvent()
2320 if ( d->m_bLoadEventEmitted || !d->m_doc || d->m_doc->parsing() )
return;
2322 ConstFrameIt it = d->m_frames.begin();
2323 const ConstFrameIt
end = d->m_frames.end();
2324 for (; it !=
end; ++it )
2325 if ( !(*it)->m_bCompleted )
2328 ConstFrameIt oi = d->m_objects.begin();
2329 const ConstFrameIt oiEnd = d->m_objects.end();
2331 for (; oi != oiEnd; ++oi )
2332 if ( !(*oi)->m_bCompleted )
2339 if ( d->m_doc && d->m_doc->docLoader() )
2340 requests = tdehtml::Cache::loader()->numRequests( d->m_doc->docLoader() );
2345 d->m_bLoadEventEmitted =
true;
2352 return d->m_settings;
2355 #ifndef KDE_NO_COMPAT
2356 KURL TDEHTMLPart::baseURL()
const
2358 if ( !d->m_doc )
return KURL();
2360 return d->m_doc->baseURL();
2363 TQString TDEHTMLPart::baseTarget()
const
2365 if ( !d->m_doc )
return TQString();
2367 return d->m_doc->baseTarget();
2373 if ( !d->m_doc )
return KURL(
url );
2376 return KURL(d->m_doc->completeURL(
url), d->m_decoder->codec()->mibEnum());
2378 return KURL( d->m_doc->completeURL(
url ) );
2385 kdDebug(6050) <<
"TDEHTMLPart::scheduleRedirection delay=" << delay <<
" url=" <<
url <<
endl;
2386 kdDebug(6050) <<
"current redirectURL=" << d->m_redirectURL <<
" with delay " << d->m_delayRedirect <<
endl;
2387 if( delay < 24*60*60 &&
2388 ( d->m_redirectURL.isEmpty() || delay <= d->m_delayRedirect) ) {
2389 d->m_delayRedirect = delay;
2390 d->m_redirectURL =
url;
2391 d->m_redirectLockHistory = doLockHistory;
2392 kdDebug(6050) <<
" d->m_bComplete=" << d->m_bComplete <<
endl;
2393 if ( d->m_bComplete ) {
2394 d->m_redirectionTimer.stop();
2395 d->m_redirectionTimer.start( kMax(0, 1000 * d->m_delayRedirect),
true );
2400 void TDEHTMLPart::slotRedirect()
2402 kdDebug(6050) <<
this <<
" slotRedirect()" <<
endl;
2403 TQString u = d->m_redirectURL;
2404 d->m_delayRedirect = 0;
2405 d->m_redirectURL = TQString();
2408 if ( u.find( TQString::fromLatin1(
"javascript:" ), 0,
false ) == 0 )
2411 kdDebug( 6050 ) <<
"TDEHTMLPart::slotRedirect script=" << script <<
endl;
2413 if ( res.type() == TQVariant::String ) {
2415 write( res.asString() );
2426 if ( openedByJS() && d->m_opener )
2427 cUrl = d->m_opener->url();
2429 if (!kapp || !kapp->authorizeURLAction(
"redirect", cUrl,
url))
2431 kdWarning(6050) <<
"TDEHTMLPart::scheduleRedirection: Redirection from " << cUrl <<
" to " <<
url <<
" REJECTED!" <<
endl;
2436 if ( urlcmp( u,
m_url.
url(),
true,
true ) )
2438 args.
metaData().insert(
"referrer", d->m_pageReferrer);
2452 d->m_urlSelectedOpenedURL =
true;
2453 urlSelected( u, 0, 0,
"_self", args );
2455 if ( !d->m_urlSelectedOpenedURL )
2459 void TDEHTMLPart::slotRedirection(TDEIO::Job*,
const KURL&
url)
2463 emit d->m_extension->setLocationBarURL(
url.
prettyURL() );
2464 d->m_workingURL =
url;
2469 d->m_encoding = name;
2470 d->m_haveEncoding =
override;
2477 d->m_restored =
true;
2479 d->m_restored =
false;
2487 if(d->m_haveEncoding && !d->m_encoding.isEmpty())
2488 return d->m_encoding;
2490 if(d->m_decoder && d->m_decoder->encoding())
2491 return TQString(d->m_decoder->encoding());
2493 return defaultEncoding();
2496 TQString TDEHTMLPart::defaultEncoding()
const
2498 TQString
encoding = settings()->encoding();
2503 if (
url().protocol().startsWith(
"http" ) )
2504 return "iso-8859-1";
2511 if ( d->m_doc && d->m_doc->docLoader() )
2512 (void)
new tdehtml::PartStyleSheetLoader(
this,
url.
url(), d->m_doc->docLoader());
2518 d->m_doc->setUserStyleSheet( styleSheet );
2526 HTMLCollectionImpl *anchors =
2527 new HTMLCollectionImpl( d->m_doc, HTMLCollectionImpl::DOC_ANCHORS);
2529 NodeImpl *n = anchors->namedItem(name);
2533 n = d->m_doc->getElementById( name );
2536 d->m_doc->setCSSTarget(n);
2539 bool quirkyName = !n && !d->m_doc->inStrictMode() && (name.isEmpty() || name.lower() ==
"top");
2542 d->m_view->setContentsPos(0, 0);
2545 kdDebug(6050) <<
"TDEHTMLPart::gotoAnchor node '" << name <<
"' not found" <<
endl;
2551 HTMLElementImpl *a =
static_cast<HTMLElementImpl *
>(n);
2553 a->getUpperLeftCorner(x, y);
2554 if (x <= d->m_view->contentsX())
2557 gox = d->m_view->contentsX();
2558 if ( x + 10 > d->m_view->contentsX()+d->m_view->visibleWidth()) {
2559 a->getLowerRightCorner(x, dummy);
2560 gox = x - d->m_view->visibleWidth() + 10;
2564 d->m_view->setContentsPos(gox, y);
2573 d->m_view->focusNextPrevNode (
true );
2582 d->m_view->focusNextPrevNode (
false );
2589 d->m_settings->setStdFontName(name);
2594 d->m_settings->setFixedFontName(name);
2599 d->m_linkCursor = c;
2604 return d->m_linkCursor;
2609 return d->m_onlyLocalReferences;
2614 d->m_onlyLocalReferences = enable;
2617 void TDEHTMLPartPrivate::setFlagRecursively(
2618 bool TDEHTMLPartPrivate::*flag,
bool value)
2621 this->*flag = value;
2625 TQValueList<tdehtml::ChildFrame*>::Iterator it = m_frames.begin();
2626 const TQValueList<tdehtml::ChildFrame*>::Iterator itEnd = m_frames.end();
2627 for (; it != itEnd; ++it) {
2629 if (part->inherits(
"TDEHTMLPart"))
2630 part->d->setFlagRecursively(flag, value);
2635 TQValueList<tdehtml::ChildFrame*>::Iterator it = m_objects.begin();
2636 const TQValueList<tdehtml::ChildFrame*>::Iterator itEnd = m_objects.end();
2637 for (; it != itEnd; ++it) {
2639 if (part->inherits(
"TDEHTMLPart"))
2640 part->d->setFlagRecursively(flag, value);
2647 #ifndef TDEHTML_NO_CARET
2648 kdDebug(6200) <<
"setCaretMode(" << enable <<
")" <<
endl;
2650 d->setFlagRecursively(&TDEHTMLPartPrivate::m_caretMode, enable);
2654 view()->initCaret(
true);
2655 view()->ensureCaretVisible();
2664 return d->m_caretMode;
2669 #ifndef TDEHTML_NO_CARET
2671 d->setFlagRecursively(&TDEHTMLPartPrivate::m_designMode, enable);
2675 view()->initCaret(
true);
2676 view()->ensureCaretVisible();
2685 return d->m_designMode;
2690 #ifndef TDEHTML_NO_CARET
2692 kdDebug(6200) << k_funcinfo <<
"node: " << node.handle() <<
" nodeName: "
2693 << node.
nodeName().string() <<
" offset: " << offset
2694 <<
" extendSelection " << extendSelection <<
endl;
2696 if (
view()->moveCaretTo(node.handle(), offset, !extendSelection))
2697 emitSelectionChanged();
2698 view()->ensureCaretVisible();
2704 #ifndef TDEHTML_NO_CARET
2707 return CaretInvisible;
2713 #ifndef TDEHTML_NO_CARET
2714 view()->setCaretDisplayPolicyNonFocused(policy);
2720 #ifndef TDEHTML_NO_CARET
2723 NodeImpl *caretNode = xmlDocImpl()->focusNode();
2725 || (caretNode && caretNode->contentEditable())) {
2741 d->m_findPosEnd = -1;
2742 d->m_findNodeEnd= 0;
2743 d->m_findPosStart = -1;
2744 d->m_findNodeStart = 0;
2745 d->m_findNodePrevious = 0;
2750 bool TDEHTMLPart::initFindNode(
bool selection,
bool reverse,
bool fromCursor )
2755 DOM::NodeImpl* firstNode = 0L;
2756 if (d->m_doc->isHTMLDocument())
2757 firstNode =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body();
2759 firstNode = d->m_doc;
2766 if ( firstNode->id() == ID_FRAMESET )
2777 d->m_findNode = reverse ? d->m_selectionEnd.handle() : d->m_selectionStart.handle();
2778 d->m_findPos = reverse ? d->m_endOffset : d->m_startOffset;
2780 d->m_findNodeEnd = reverse ? d->m_selectionStart.handle() : d->m_selectionEnd.handle();
2781 d->m_findPosEnd = reverse ? d->m_startOffset : d->m_endOffset;
2782 d->m_findNodeStart = !reverse ? d->m_selectionStart.handle() : d->m_selectionEnd.handle();
2783 d->m_findPosStart = !reverse ? d->m_startOffset : d->m_endOffset;
2784 d->m_findNodePrevious = d->m_findNodeStart;
2791 d->m_findNode = firstNode;
2792 d->m_findPos = reverse ? -1 : 0;
2794 d->m_findNodeEnd = reverse ? firstNode : 0;
2795 d->m_findPosEnd = reverse ? 0 : -1;
2796 d->m_findNodeStart = !reverse ? firstNode : 0;
2797 d->m_findPosStart = !reverse ? 0 : -1;
2798 d->m_findNodePrevious = d->m_findNodeStart;
2802 tdehtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
2806 while ( obj->lastChild() )
2808 obj = obj->lastChild();
2811 while ( !obj->element() && obj->objectAbove() )
2813 obj = obj->objectAbove();
2815 d->m_findNode = obj->element();
2825 if ( !initFindNode(
false, !forward, d->m_findNode ) )
2829 if( (d->m_findNode->nodeType() == Node::TEXT_NODE || d->m_findNode->nodeType() == Node::CDATA_SECTION_NODE) && d->m_findNode->renderer() )
2831 DOMString nodeText = d->m_findNode->nodeValue();
2832 DOMStringImpl *t = nodeText.implementation();
2833 TQConstString s(t->s, t->l);
2837 TQRegExp matcher( str );
2838 matcher.setCaseSensitive( caseSensitive );
2839 d->m_findPos = matcher.search(s.string(), d->m_findPos+1);
2840 if ( d->m_findPos != -1 )
2841 matchLen = matcher.matchedLength();
2844 d->m_findPos = s.string().find(str, d->m_findPos+1, caseSensitive);
2845 matchLen = str.length();
2848 if(d->m_findPos != -1)
2851 if(
static_cast<tdehtml::RenderText *
>(d->m_findNode->renderer())
2852 ->posOfChar(d->m_findPos, x, y))
2853 d->m_view->setContentsPos(x-50, y-50);
2855 d->m_selectionStart = d->m_findNode;
2856 d->m_startOffset = d->m_findPos;
2857 d->m_selectionEnd = d->m_findNode;
2858 d->m_endOffset = d->m_findPos + matchLen;
2859 d->m_startBeforeEnd =
true;
2861 d->m_doc->setSelection( d->m_selectionStart.handle(), d->m_startOffset,
2862 d->m_selectionEnd.handle(), d->m_endOffset );
2863 emitSelectionChanged();
2873 next = d->m_findNode->firstChild();
2875 if(!next) next = d->m_findNode->nextSibling();
2876 while(d->m_findNode && !next) {
2877 d->m_findNode = d->m_findNode->parentNode();
2878 if( d->m_findNode ) {
2879 next = d->m_findNode->nextSibling();
2885 next = d->m_findNode->lastChild();
2887 if (!next ) next = d->m_findNode->previousSibling();
2888 while ( d->m_findNode && !next )
2890 d->m_findNode = d->m_findNode->parentNode();
2893 next = d->m_findNode->previousSibling();
2898 d->m_findNode = next;
2899 if(!d->m_findNode)
return false;
2904 void TDEHTMLPart::slotFind()
2909 if (!part->inherits(
"TDEHTMLPart") )
2911 kdError(6000) <<
"slotFind: part is a " << part->className() <<
", can't do a search into it" <<
endl;
2917 void TDEHTMLPart::slotFindNext()
2922 if (!part->inherits(
"TDEHTMLPart") )
2924 kdError(6000) <<
"slotFindNext: part is a " << part->className() <<
", can't do a search into it" <<
endl;
2930 void TDEHTMLPart::slotFindPrev()
2935 if (!part->inherits(
"TDEHTMLPart") )
2937 kdError(6000) <<
"slotFindNext: part is a " << part->className() <<
", can't do a search into it" <<
endl;
2943 void TDEHTMLPart::slotFindDone()
2948 void TDEHTMLPart::slotFindAheadText()
2950 #ifndef TDEHTML_NO_TYPE_AHEAD_FIND
2954 if (!part->inherits(
"TDEHTMLPart") )
2956 kdError(6000) <<
"slotFindNext: part is a " << part->className() <<
", can't do a search into it" <<
endl;
2963 void TDEHTMLPart::slotFindAheadLink()
2965 #ifndef TDEHTML_NO_TYPE_AHEAD_FIND
2969 if (!part->inherits(
"TDEHTMLPart") )
2971 kdError(6000) <<
"slotFindNext: part is a " << part->className() <<
", can't do a search into it" <<
endl;
2978 void TDEHTMLPart::enableFindAheadActions(
bool enable )
2984 p->d->m_paFindAheadText->setEnabled( enable );
2985 p->d->m_paFindAheadLinks->setEnabled( enable );
2988 void TDEHTMLPart::slotFindDialogDestroyed()
2990 d->m_lastFindState.options = d->m_findDialog->options();
2991 d->m_lastFindState.history = d->m_findDialog->findHistory();
2992 d->m_findDialog->deleteLater();
2993 d->m_findDialog = 0L;
3003 if ( d->m_findDialog )
3010 #ifndef TQT_NO_CLIPBOARD
3011 disconnect( kapp->clipboard(), TQ_SIGNAL(
selectionChanged()),
this, TQ_SLOT(slotClearSelection()) );
3015 d->m_findDialog =
new KFindDialog(
false ,
widget(),
"tdehtmlfind" );
3017 d->m_findDialog->setHasCursor( d->m_findNode != 0 );
3018 if ( d->m_findNode )
3019 d->m_lastFindState.options |= KFindDialog::FromCursor;
3022 d->m_findDialog->setFindHistory( d->m_lastFindState.history );
3023 d->m_findDialog->setOptions( d->m_lastFindState.options );
3025 d->m_lastFindState.options = -1;
3026 d->m_lastFindState.last_dir = -1;
3028 d->m_findDialog->show();
3029 connect( d->m_findDialog, TQ_SIGNAL(okClicked()),
this, TQ_SLOT(slotFindNext()) );
3030 connect( d->m_findDialog, TQ_SIGNAL(finished()),
this, TQ_SLOT(slotFindDialogDestroyed()) );
3032 findText( d->m_findDialog->pattern(), 0 ,
widget(), d->m_findDialog );
3041 #ifndef TQT_NO_CLIPBOARD
3042 connect( kapp->clipboard(), TQ_SIGNAL(
selectionChanged()), TQ_SLOT(slotClearSelection()) );
3047 d->m_find =
new KFind( str, options, parent, findDialog );
3048 d->m_find->closeFindNextDialog();
3049 connect( d->m_find, TQ_SIGNAL( highlight(
const TQString &,
int,
int ) ),
3050 this, TQ_SLOT( slotHighlight(
const TQString &,
int,
int ) ) );
3056 d->m_lastFindState.options = options;
3057 initFindNode( options & KFindDialog::SelectedText,
3058 options & KFindDialog::FindBackwards,
3059 options & KFindDialog::FromCursor );
3078 view()->updateFindAheadTimeout();
3080 if ( d->m_findDialog )
3082 if ( d->m_find->pattern() != d->m_findDialog->pattern() ) {
3083 d->m_find->setPattern( d->m_findDialog->pattern() );
3084 d->m_find->resetCounts();
3086 options = d->m_findDialog->options();
3087 if ( d->m_lastFindState.options != options )
3089 d->m_find->setOptions( options );
3091 if ( options & KFindDialog::SelectedText )
3094 long difference = d->m_lastFindState.options ^ options;
3095 if ( difference & (KFindDialog::SelectedText | KFindDialog::FromCursor ) )
3098 (void) initFindNode( options & KFindDialog::SelectedText,
3099 options & KFindDialog::FindBackwards,
3100 options & KFindDialog::FromCursor );
3102 d->m_lastFindState.options = options;
3105 options = d->m_lastFindState.options;
3107 options = options ^ KFindDialog::FindBackwards;
3108 if( d->m_find->options() != options )
3109 d->m_find->setOptions( options );
3114 if( d->m_lastFindState.last_dir != -1
3115 &&
bool( d->m_lastFindState.last_dir ) != bool( options & KFindDialog::FindBackwards ))
3117 tqSwap( d->m_findNodeEnd, d->m_findNodeStart );
3118 tqSwap( d->m_findPosEnd, d->m_findPosStart );
3119 tqSwap( d->m_findNode, d->m_findNodePrevious );
3121 tdehtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
3122 tdehtml::RenderObject*
end = d->m_findNodeEnd ? d->m_findNodeEnd->renderer() : 0;
3128 obj = (options & KFindDialog::FindBackwards) ? obj->objectAbove() : obj->objectBelow();
3129 }
while ( obj && ( !obj->element() || obj->isInlineContinuation() ) );
3132 d->m_findNode = obj->element();
3136 d->m_lastFindState.last_dir = ( options & KFindDialog::FindBackwards ) ? 1 : 0;
3138 KFind::Result res = KFind::NoMatch;
3139 tdehtml::RenderObject* obj = d->m_findNode ? d->m_findNode->renderer() : 0;
3140 tdehtml::RenderObject*
end = d->m_findNodeEnd ? d->m_findNodeEnd->renderer() : 0;
3141 tdehtml::RenderTextArea *tmpTextArea=0L;
3143 while( res == KFind::NoMatch )
3145 if ( d->m_find->needData() )
3156 d->m_stringPortions.clear();
3157 bool newLine =
false;
3159 DOM::NodeImpl* lastNode = d->m_findNode;
3160 while ( obj && !newLine )
3164 bool renderAreaText = obj->parent() && (TQCString(obj->parent()->renderName())==
"RenderTextArea");
3165 bool renderLineText = (TQCString(obj->renderName())==
"RenderLineEdit");
3166 if ( renderAreaText )
3168 tdehtml::RenderTextArea *parent=
static_cast<tdehtml::RenderTextArea *
>(obj->parent());
3170 s = s.replace(0xa0,
' ');
3171 tmpTextArea = parent;
3173 else if ( renderLineText )
3175 tdehtml::RenderLineEdit *parentLine=
static_cast<tdehtml::RenderLineEdit *
>(obj);
3176 if (parentLine->widget()->echoMode() == TQLineEdit::Normal)
3177 s = parentLine->widget()->text();
3178 s = s.replace(0xa0,
' ');
3180 else if ( obj->isText() )
3182 bool isLink =
false;
3185 if ( options & FindLinksOnly )
3187 DOM::NodeImpl *parent = obj->element();
3190 if ( parent->nodeType() == Node::ELEMENT_NODE && parent->id() == ID_A )
3195 parent = parent->parentNode();
3203 if ( isLink && obj->parent()!=tmpTextArea )
3205 s =
static_cast<tdehtml::RenderText *
>(obj)->data().string();
3206 s = s.replace(0xa0,
' ');
3209 else if ( obj->isBR() )
3211 else if ( !obj->isInline() && !str.isEmpty() )
3214 if ( lastNode == d->m_findNodeEnd )
3215 s.truncate( d->m_findPosEnd );
3218 newLine = s.find(
'\n' ) != -1;
3219 if( !( options & KFindDialog::FindBackwards ))
3222 d->m_stringPortions.append( TDEHTMLPartPrivate::StringPortion( str.length(), lastNode ) );
3227 for( TQValueList<TDEHTMLPartPrivate::StringPortion>::Iterator it = d->m_stringPortions.begin();
3228 it != d->m_stringPortions.end();
3230 (*it).index += s.length();
3231 d->m_stringPortions.prepend( TDEHTMLPartPrivate::StringPortion( 0, lastNode ) );
3246 obj = (options & KFindDialog::FindBackwards) ? obj->objectAbove() : obj->objectBelow();
3247 }
while ( obj && ( !obj->element() || obj->isInlineContinuation() ) );
3250 lastNode = obj->element();
3255 if ( !str.isEmpty() )
3257 d->m_find->setData( str, d->m_findPos );
3261 d->m_findNodePrevious = d->m_findNode;
3262 d->m_findNode = lastNode;
3264 if ( !d->m_find->needData() )
3267 res = d->m_find->find();
3271 if ( res == KFind::NoMatch )
3274 if ( !(options & FindNoPopups) && d->m_find->shouldRestart() )
3277 initFindNode(
false, options & KFindDialog::FindBackwards,
false );
3278 d->m_find->resetCounts();
3286 initFindNode(
false, options & KFindDialog::FindBackwards,
false );
3287 d->m_find->resetCounts();
3288 slotClearSelection();
3293 return res == KFind::Match;
3296 void TDEHTMLPart::slotHighlight(
const TQString& ,
int index,
int length )
3299 TQValueList<TDEHTMLPartPrivate::StringPortion>::Iterator it = d->m_stringPortions.begin();
3300 const TQValueList<TDEHTMLPartPrivate::StringPortion>::Iterator itEnd = d->m_stringPortions.end();
3301 TQValueList<TDEHTMLPartPrivate::StringPortion>::Iterator prev = it;
3303 while ( it != itEnd && (*it).index <= index )
3308 Q_ASSERT ( prev != itEnd );
3309 DOM::NodeImpl* node = (*prev).node;
3312 d->m_selectionStart = node;
3313 d->m_startOffset = index - (*prev).index;
3315 tdehtml::RenderObject* obj = node->renderer();
3316 tdehtml::RenderTextArea *parent = 0L;
3317 tdehtml::RenderLineEdit *parentLine = 0L;
3318 bool renderLineText =
false;
3320 TQRect highlightedRect;
3321 bool renderAreaText =
false;
3326 renderAreaText = (TQCString(obj->parent()->renderName())==
"RenderTextArea");
3327 renderLineText = (TQCString(obj->renderName())==
"RenderLineEdit");
3330 if( renderAreaText )
3331 parent=
static_cast<tdehtml::RenderTextArea *
>(obj->parent());
3332 if ( renderLineText )
3333 parentLine=
static_cast<tdehtml::RenderLineEdit *
>(obj);
3334 if ( !renderLineText )
3339 static_cast<tdehtml::RenderText *
>(node->renderer())
3340 ->caretPos( d->m_startOffset,
false, x, y, dummy, dummy );
3342 if ( x != -1 || y != -1 )
3344 int gox = d->m_view->contentsX();
3345 if (x+50 > d->m_view->contentsX() + d->m_view->visibleWidth())
3346 gox = x - d->m_view->visibleWidth() + 50;
3347 if (x-10 < d->m_view->contentsX())
3348 gox = x - d->m_view->visibleWidth() - 10;
3349 if (gox < 0) gox = 0;
3350 d->m_view->setContentsPos(gox, y-50);
3351 highlightedRect.setTopLeft( d->m_view->mapToGlobal(TQPoint(x, y)) );
3357 while ( it != itEnd && (*it).index < index + length )
3362 Q_ASSERT ( prev != itEnd );
3364 d->m_selectionEnd = (*prev).node;
3365 d->m_endOffset = index + length - (*prev).index;
3366 d->m_startBeforeEnd =
true;
3369 if(d->m_selectionStart == d->m_selectionEnd)
3371 bool isLink =
false;
3374 DOM::NodeImpl *parent = d->m_selectionStart.handle();
3377 if ( parent->nodeType() == Node::ELEMENT_NODE && parent->id() == ID_A )
3382 parent = parent->parentNode();
3387 d->m_doc->setFocusNode( parent );
3392 kdDebug(6050) <<
"slotHighlight: " << d->m_selectionStart.handle() <<
"," << d->m_startOffset <<
" - " <<
3393 d->m_selectionEnd.handle() <<
"," << d->m_endOffset <<
endl;
3394 it = d->m_stringPortions.begin();
3395 for ( ; it != d->m_stringPortions.end() ; ++it )
3396 kdDebug(6050) <<
" StringPortion: from index=" << (*it).index <<
" -> node=" << (*it).node <<
endl;
3398 if( renderAreaText )
3401 parent->highLightWord( length, d->m_endOffset-length );
3403 else if ( renderLineText )
3406 parentLine->highLightWord( length, d->m_endOffset-length );
3410 d->m_doc->setSelection( d->m_selectionStart.handle(), d->m_startOffset,
3411 d->m_selectionEnd.handle(), d->m_endOffset );
3412 if (d->m_selectionEnd.handle()->renderer() )
3414 int x, y, height, dummy;
3415 static_cast<tdehtml::RenderText *
>(d->m_selectionEnd.handle()->renderer())
3416 ->caretPos( d->m_endOffset,
false, x, y, dummy, height );
3418 if ( x != -1 || y != -1 )
3422 highlightedRect.setBottomRight( d->m_view->mapToGlobal( TQPoint(x, y+height) ) );
3426 emitSelectionChanged();
3429 if ( d->m_findDialog && !highlightedRect.isNull() )
3431 highlightedRect.moveBy( -d->m_view->contentsX(), -d->m_view->contentsY() );
3440 kdDebug() <<
"selectedTextAsHTML(): selection is not valid. Returning empty selection" <<
endl;
3443 if(d->m_startOffset < 0 || d->m_endOffset <0) {
3444 kdDebug() <<
"invalid values for end/startOffset " << d->m_startOffset <<
" " << d->m_endOffset <<
endl;
3448 if(r.isNull() || r.isDetached())
3450 int exceptioncode = 0;
3451 return r.handle()->toHTML(exceptioncode).string();
3456 bool hasNewLine =
true;
3457 bool seenTDTag =
false;
3461 if(n.
nodeType() == DOM::Node::TEXT_NODE && n.handle()->renderer()) {
3462 DOM::DOMStringImpl *dstr =
static_cast<DOM::TextImpl*
>(n.handle())->renderString();
3463 TQString str(dstr->s, dstr->l);
3464 if(!str.isEmpty()) {
3470 if(n == d->m_selectionStart && n == d->m_selectionEnd)
3471 text = str.mid(d->m_startOffset, d->m_endOffset - d->m_startOffset);
3472 else if(n == d->m_selectionStart)
3473 text = str.mid(d->m_startOffset);
3474 else if(n == d->m_selectionEnd)
3475 text += str.left(d->m_endOffset);
3482 unsigned short id = n.elementId();
3485 text +=
static_cast<HTMLTextAreaElementImpl*
>(n.handle())->value().string();
3488 if (
static_cast<HTMLInputElementImpl*
>(n.handle())->inputType() != HTMLInputElementImpl::PASSWORD)
3489 text +=
static_cast<HTMLInputElementImpl*
>(n.handle())->value().string();
3492 text +=
static_cast<HTMLSelectElementImpl*
>(n.handle())->value().string();
3499 text +=
static_cast<HTMLImageElementImpl*
>(n.handle())->altText().string();
3533 if(n == d->m_selectionEnd)
break;
3539 unsigned short id = n.elementId();
3583 int end = text.length();
3586 while ((start <
end) && (text[start] ==
'\n'))
3590 while ((start < (
end-1)) && (text[
end-1] ==
'\n') && (text[
end-2] ==
'\n'))
3593 return text.mid(start,
end-start);
3598 if ( d->m_selectionStart.isNull() || d->m_selectionEnd.isNull() )
3600 if ( d->m_selectionStart == d->m_selectionEnd &&
3601 d->m_startOffset == d->m_endOffset )
3608 if( d->m_selectionStart.isNull() || d->m_selectionEnd.isNull() )
3609 return DOM::Range();
3611 RangeImpl *rng = r.handle();
3613 NodeImpl *n = d->m_selectionStart.handle();
3614 if(!n->parentNode() ||
3616 (!n->renderer()->isReplaced() && !n->renderer()->isBR())) {
3617 rng->setStart( n, d->m_startOffset, exception );
3619 kdDebug(6000) <<
"1 -selection() threw the exception " << exception <<
". Returning empty range." <<
endl;
3620 return DOM::Range();
3624 while ((n = n->previousSibling()))
3626 rng->setStart( d->m_selectionStart.parentNode().handle(), o_start + d->m_startOffset, exception );
3628 kdDebug(6000) <<
"2 - selection() threw the exception " << exception <<
". Returning empty range." <<
endl;
3629 return DOM::Range();
3634 n = d->m_selectionEnd.handle();
3635 if(!n->parentNode() ||
3637 (!n->renderer()->isReplaced() && !n->renderer()->isBR())) {
3639 rng->setEnd( n, d->m_endOffset, exception );
3641 kdDebug(6000) <<
"3 - selection() threw the exception " << exception <<
". Returning empty range." <<
endl;
3642 return DOM::Range();
3647 while ((n = n->previousSibling()))
3649 rng->setEnd( d->m_selectionEnd.parentNode().handle(), o_end + d->m_endOffset, exception);
3651 kdDebug(6000) <<
"4 - selection() threw the exception " << exception <<
". Returning empty range." <<
endl;
3652 return DOM::Range();
3662 s = d->m_selectionStart;
3663 so = d->m_startOffset;
3664 e = d->m_selectionEnd;
3665 eo = d->m_endOffset;
3672 if ( r.collapsed() )
3673 slotClearSelection();
3675 d->m_selectionStart = r.startContainer();
3676 d->m_startOffset = r.startOffset();
3677 d->m_selectionEnd = r.endContainer();
3678 d->m_endOffset = r.endOffset();
3679 d->m_doc->setSelection(d->m_selectionStart.handle(),d->m_startOffset,
3680 d->m_selectionEnd.handle(),d->m_endOffset);
3681 #ifndef TDEHTML_NO_CARET
3682 bool v = d->m_view->placeCaret();
3683 emitCaretPositionChanged(v ? d->caretNode() : 0, d->caretOffset());
3688 void TDEHTMLPart::slotClearSelection()
3691 #ifndef TDEHTML_NO_CARET
3696 d->m_selectionStart = 0;
3697 d->m_startOffset = 0;
3698 d->m_selectionEnd = 0;
3701 if ( d->m_doc ) d->m_doc->clearSelection();
3703 emitSelectionChanged();
3704 #ifndef TDEHTML_NO_CARET
3705 bool v = d->m_view->placeCaret();
3706 emitCaretPositionChanged(v ? d->caretNode() : 0, d->caretOffset());
3710 void TDEHTMLPart::resetHoverText()
3712 if( !d->m_overURL.isEmpty() )
3714 d->m_overURL = d->m_overURLTarget = TQString();
3715 emit
onURL( TQString() );
3717 setStatusBarText(TQString(), BarHoverText);
3718 emit d->m_extension->mouseOverInfo(0);
3722 void TDEHTMLPart::overURL(
const TQString &
url,
const TQString &target,
bool )
3733 setStatusBarText(u.
htmlURL(), BarHoverText);
3737 if (
url.find( TQString::fromLatin1(
"javascript:" ),0,
false ) == 0 ) {
3740 if (
url.startsWith(
"javascript:window.open"))
3741 jscode += i18n(
" (In new window)");
3742 setStatusBarText( TQStyleSheet::escape( jscode ), BarHoverText );
3746 KFileItem item(u, TQString(), KFileItem::Unknown);
3747 emit d->m_extension->mouseOverInfo(&item);
3751 KMimeType::Ptr typ = KMimeType::findByURL( u );
3754 com = typ->comment( u,
false );
3757 setStatusBarText(u.
htmlURL(), BarHoverText);
3765 TQCString path = TQFile::encodeName( u.
path() );
3768 bool ok = !stat( path.data(), &buff );
3771 if (ok) ok = !lstat( path.data(), &lbuff );
3774 TQString text2 = text;
3776 if (ok && S_ISLNK( lbuff.st_mode ) )
3780 tmp = i18n(
"Symbolic Link");
3782 tmp = i18n(
"%1 (Link)").arg(com);
3783 char buff_two[1024];
3785 int n = readlink ( path.data(), buff_two, 1022);
3790 setStatusBarText(text2, BarHoverText);
3799 else if ( ok && S_ISREG( buff.st_mode ) )
3801 if (buff.st_size < 1024)
3802 text = i18n(
"%2 (%1 bytes)").arg((
long) buff.st_size).arg(text2);
3805 float d = (float) buff.st_size/1024.0;
3811 else if ( ok && S_ISDIR( buff.st_mode ) )
3821 setStatusBarText(text, BarHoverText);
3826 if (target.lower() ==
"_blank")
3828 extra = i18n(
" (In new window)");
3830 else if (!target.isEmpty() &&
3831 (target.lower() !=
"_top") &&
3832 (target.lower() !=
"_self") &&
3833 (target.lower() !=
"_parent"))
3839 extra = i18n(
" (In new window)");
3841 extra = i18n(
" (In other frame)");
3844 if (u.
protocol() == TQString::fromLatin1(
"mailto")) {
3845 TQString mailtoMsg ;
3847 TQStringList queries = TQStringList::split(
'&', u.
query().mid(1));
3848 TQStringList::Iterator it = queries.begin();
3849 const TQStringList::Iterator itEnd = queries.end();
3850 for (; it != itEnd; ++it)
3851 if ((*it).startsWith(TQString::fromLatin1(
"subject=")))
3853 else if ((*it).startsWith(TQString::fromLatin1(
"cc=")))
3855 else if ((*it).startsWith(TQString::fromLatin1(
"bcc=")))
3857 mailtoMsg = TQStyleSheet::escape(mailtoMsg);
3858 mailtoMsg.replace(TQRegExp(
"([\n\r\t]|[ ]{10})"), TQString());
3859 setStatusBarText(
"<qt>"+mailtoMsg, BarHoverText);
3864 else if (u.
protocol() == TQString::fromLatin1(
"http")) {
3866 while (hrefNode.
nodeName().string() != TQString::fromLatin1(
"A") && !hrefNode.
isNull())
3869 if (!hrefNode.
isNull()) {
3871 if (!hreflangNode.
isNull()) {
3872 TQString countryCode = hreflangNode.
nodeValue().string().lower();
3874 if (countryCode == TQString::fromLatin1(
"en"))
3875 countryCode = TQString::fromLatin1(
"gb");
3876 TQString flagImg = TQString::fromLatin1(
"<img src=%1>").arg(
3877 locate(
"locale", TQString::fromLatin1(
"l10n/")
3879 + TQString::fromLatin1(
"/flag.png")));
3880 emit setStatusBarText(flagImg + u.
prettyURL() + extra);
3885 setStatusBarText(u.
htmlURL() + extra, BarHoverText);
3893 void TDEHTMLPart::urlSelected(
const TQString &
url,
int button,
int state,
const TQString &_target,
KParts::URLArgs args )
3898 d->m_urlSelectedOpenedURL = urlSelectedIntern(
url, button, state, _target, args );
3902 bool TDEHTMLPart::urlSelectedIntern(
const TQString &
url,
int button,
int state,
const TQString &_target,
KParts::URLArgs args )
3904 bool hasTarget =
false;
3906 TQString target = _target;
3907 if ( target.isEmpty() && d->m_doc )
3908 target = d->m_doc->baseTarget();
3909 if ( !target.isEmpty() )
3912 if (
url.find( TQString::fromLatin1(
"javascript:" ), 0,
false ) == 0 )
3927 kdDebug(6050) <<
this <<
" urlSelected: complete URL:" << cURL.
url() <<
" target=" << target <<
endl;
3929 if ( state & ControlButton )
3932 emit d->m_extension->createNewWindow( cURL, args );
3936 if ( button == TQt::LeftButton && ( state & ShiftButton ) )
3938 TDEIO::MetaData metaData;
3939 metaData[
"referrer"] = d->m_referrer;
3940 TDEHTMLPopupGUIClient::saveURL( d->m_view, i18n(
"Save As" ), cURL, metaData );
3944 if (!checkLinkSecurity(cURL,
3945 i18n(
"<qt>This untrusted page links to<BR><B>%1</B>.<BR>Do you want to follow the link?" ),
3951 args.
metaData().insert(
"main_frame_request",
3953 args.
metaData().insert(
"ssl_parent_ip", d->m_ssl_parent_ip);
3954 args.
metaData().insert(
"ssl_parent_cert", d->m_ssl_parent_cert);
3955 args.
metaData().insert(
"PropagateHttpHeader",
"true");
3956 args.
metaData().insert(
"ssl_was_in_use", d->m_ssl_in_use ?
"TRUE":
"FALSE");
3957 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
3959 if ( hasTarget && target !=
"_self" && target !=
"_top" && target !=
"_blank" && target !=
"_parent" )
3962 tdehtml::ChildFrame *frame = recursiveFrameRequest(
this, cURL, args,
false );
3965 args.
metaData()[
"referrer"] = d->m_referrer;
3966 requestObject( frame, cURL, args );
3971 if (!d->m_referrer.isEmpty() && !args.
metaData().contains(
"referrer"))
3972 args.
metaData()[
"referrer"] = d->m_referrer;
3975 if ( button == TQt::NoButton && (state & ShiftButton) && (state & ControlButton) )
3977 emit d->m_extension->createNewWindow( cURL, args );
3981 if ( state & ShiftButton)
3984 winArgs.lowerWindow =
true;
3986 emit d->m_extension->createNewWindow( cURL, args, winArgs, newPart );
3993 if (cURL.
hasRef() && (!hasTarget || target ==
"_self"))
3996 if (urlcmp(cURL.
url(), curUrl.
url(),
4001 emit d->m_extension->openURLNotify();
4009 if ( !d->m_bComplete && !hasTarget )
4012 view()->viewport()->unsetCursor();
4013 emit d->m_extension->openURLRequest( cURL, args );
4017 void TDEHTMLPart::slotViewDocumentSource()
4020 bool isTempFile =
false;
4023 KTempFile sourceFile(TQString(), defaultExtension());
4024 if (sourceFile.status() == 0)
4033 (void) KRun::runURL(
url, TQString::fromLatin1(
"text/plain"), isTempFile );
4036 void TDEHTMLPart::slotViewPageInfo()
4038 TDEHTMLInfoDlg *dlg =
new TDEHTMLInfoDlg(NULL,
"TDEHTML Page Info Dialog",
false, (WFlags)WDestructiveClose);
4039 dlg->_close->setGuiItem(KStdGuiItem::close());
4042 dlg->_title->setText(d->m_doc->title().string());
4045 if (
parentPart() && d->m_doc && d->m_doc->isHTMLDocument() ) {
4046 dlg->setCaption(i18n(
"Frame Information"));
4049 TQString editStr = TQString();
4051 if (!d->m_pageServices.isEmpty())
4052 editStr = i18n(
" <a href=\"%1\">[Properties]</a>").arg(d->m_pageServices);
4055 dlg->_url->setText(
"<a href=\"" +
url().
url() +
"\">" + squeezedURL +
"</a>" + editStr);
4058 dlg->_lastModified->hide();
4059 dlg->_lmLabel->hide();
4065 if (enc.isEmpty()) {
4066 dlg->_eLabel->hide();
4067 dlg->_encoding->hide();
4069 dlg->_encoding->setText(enc);
4072 const TQStringList headers = TQStringList::split(
"\n", d->m_httpHeaders);
4074 TQStringList::ConstIterator it = headers.begin();
4075 const TQStringList::ConstIterator itEnd = headers.end();
4077 for (; it != itEnd; ++it) {
4078 const TQStringList header = TQStringList::split(TQRegExp(
":[ ]+"), *it);
4079 if (header.count() != 2)
4081 new TQListViewItem(dlg->_headers, header[0], header[1]);
4089 void TDEHTMLPart::slotViewFrameSource()
4096 bool isTempFile =
false;
4099 long cacheId =
static_cast<TDEHTMLPart *
>(frame)->d->m_cacheId;
4103 KTempFile sourceFile(TQString(), defaultExtension());
4104 if (sourceFile.status() == 0)
4114 (void) KRun::runURL(
url, TQString::fromLatin1(
"text/plain"), isTempFile );
4120 if (!d->m_doc || !d->m_doc->isHTMLDocument())
4123 TQString relURL =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
4128 void TDEHTMLPart::slotSaveBackground()
4130 TDEIO::MetaData metaData;
4131 metaData[
"referrer"] = d->m_referrer;
4132 TDEHTMLPopupGUIClient::saveURL( d->m_view, i18n(
"Save Background Image As"),
backgroundURL(), metaData );
4135 void TDEHTMLPart::slotSaveDocument()
4139 if ( srcURL.fileName(
false).isEmpty() )
4140 srcURL.setFileName(
"index" + defaultExtension() );
4142 TDEIO::MetaData metaData;
4144 TDEHTMLPopupGUIClient::saveURL( d->m_view, i18n(
"Save As" ), srcURL, metaData,
"text/html", d->m_cacheId );
4147 void TDEHTMLPart::slotSecurity()
4167 KSSLInfoDlg *kid =
new KSSLInfoDlg(d->m_ssl_in_use,
widget(),
"kssl_info_dlg",
true );
4169 if (d->m_bSecurityInQuestion)
4170 kid->setSecurityInQuestion(
true);
4172 if (d->m_ssl_in_use) {
4173 KSSLCertificate *x = KSSLCertificate::fromString(d->m_ssl_peer_certificate.local8Bit());
4176 const TQStringList cl = TQStringList::split(TQString(
"\n"), d->m_ssl_peer_chain);
4177 TQPtrList<KSSLCertificate> ncl;
4179 ncl.setAutoDelete(
true);
4180 TQStringList::ConstIterator it = cl.begin();
4181 const TQStringList::ConstIterator itEnd = cl.end();
4182 for (; it != itEnd; ++it) {
4183 KSSLCertificate*
const y = KSSLCertificate::fromString((*it).local8Bit());
4184 if (y) ncl.append(y);
4187 if (ncl.count() > 0)
4188 x->chain().setChain(ncl);
4194 d->m_ssl_cipher_desc,
4195 d->m_ssl_cipher_version,
4196 d->m_ssl_cipher_used_bits.toInt(),
4197 d->m_ssl_cipher_bits.toInt(),
4198 (KSSLCertificate::KSSLValidation) d->m_ssl_cert_state.toInt()
4206 void TDEHTMLPart::slotSaveFrame()
4214 if ( srcURL.fileName(
false).isEmpty() )
4215 srcURL.setFileName(
"index" + defaultExtension() );
4217 TDEIO::MetaData metaData;
4219 TDEHTMLPopupGUIClient::saveURL( d->m_view, i18n(
"Save Frame As" ), srcURL, metaData,
"text/html" );
4222 void TDEHTMLPart::slotSetEncoding()
4224 d->m_automaticDetection->setItemChecked(
int( d->m_autoDetectLanguage ),
false );
4225 d->m_paSetEncoding->popupMenu()->setItemChecked( 0,
false );
4226 d->m_paSetEncoding->popupMenu()->setItemChecked( d->m_paSetEncoding->popupMenu()->idAt( 2 ),
true );
4232 void TDEHTMLPart::slotUseStylesheet()
4236 bool autoselect = (d->m_paUseStylesheet->currentItem() == 0);
4237 d->m_sheetUsed = autoselect ? TQString() : d->m_paUseStylesheet->currentText();
4238 d->m_doc->updateStyleSelector();
4242 void TDEHTMLPart::updateActions()
4244 bool frames =
false;
4246 TQValueList<tdehtml::ChildFrame*>::ConstIterator it = d->m_frames.begin();
4247 const TQValueList<tdehtml::ChildFrame*>::ConstIterator
end = d->m_frames.end();
4248 for (; it !=
end; ++it )
4249 if ( (*it)->m_type == tdehtml::ChildFrame::Frame )
4255 d->m_paViewFrame->setEnabled( frames );
4256 d->m_paSaveFrame->setEnabled( frames );
4259 d->m_paFind->setText( i18n(
"&Find in Frame..." ) );
4261 d->m_paFind->setText( i18n(
"&Find..." ) );
4268 bool enableFindAndSelectAll =
true;
4271 enableFindAndSelectAll = frame->inherits(
"TDEHTMLPart" );
4273 d->m_paFind->setEnabled( enableFindAndSelectAll );
4274 d->m_paSelectAll->setEnabled( enableFindAndSelectAll );
4276 bool enablePrintFrame =
false;
4282 enablePrintFrame = ext->metaObject()->slotNames().contains(
"print()" );
4285 d->m_paPrintFrame->setEnabled( enablePrintFrame );
4290 if ( d->m_doc && d->m_doc->isHTMLDocument() &&
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body() && !d->m_bClearing )
4291 bgURL =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body()->getAttribute( ATTR_BACKGROUND ).string();
4293 d->m_paSaveBackground->setEnabled( !bgURL.isEmpty() );
4295 if ( d->m_paDebugScript )
4296 d->m_paDebugScript->setEnabled( d->m_frame ? d->m_frame->m_jscript : 0L );
4300 const ConstFrameIt
end = d->m_objects.end();
4301 for(ConstFrameIt it = d->m_objects.begin(); it !=
end; ++it )
4302 if ((*it)->m_frame == frame)
4303 return (*it)->m_liveconnect;
4307 bool TDEHTMLPart::requestFrame( tdehtml::RenderPart *frame,
const TQString &
url,
const TQString &frameName,
4308 const TQStringList ¶ms,
bool isIFrame )
4311 FrameIt it = d->m_frames.find( frameName );
4312 if ( it == d->m_frames.end() )
4314 tdehtml::ChildFrame * child =
new tdehtml::ChildFrame;
4316 child->m_name = frameName;
4317 it = d->m_frames.append( child );
4320 (*it)->m_type = isIFrame ? tdehtml::ChildFrame::IFrame : tdehtml::ChildFrame::Frame;
4321 (*it)->m_frame = frame;
4322 (*it)->m_params = params;
4325 if (
url.find( TQString::fromLatin1(
"javascript:" ), 0,
false ) == 0 )
4327 if ( processObjectRequest(*it,
KURL(
"about:blank"), TQString(
"text/html") ) ) {
4332 if ( res.type() == TQVariant::String ) {
4334 p->
write( res.asString() );
4342 return requestObject( *it, u );
4345 TQString TDEHTMLPart::requestFrameName()
4347 return TQString::fromLatin1(
"<!--frame %1-->").arg(d->m_frameNameId++);
4350 bool TDEHTMLPart::requestObject( tdehtml::RenderPart *frame,
const TQString &
url,
const TQString &serviceType,
4351 const TQStringList ¶ms )
4354 tdehtml::ChildFrame *child =
new tdehtml::ChildFrame;
4355 FrameIt it = d->m_objects.append( child );
4356 (*it)->m_frame = frame;
4357 (*it)->m_type = tdehtml::ChildFrame::Object;
4358 (*it)->m_params = params;
4362 if (!requestObject( *it,
completeURL(
url ), args ) && !(*it)->m_run) {
4363 (*it)->m_bCompleted =
true;
4369 bool TDEHTMLPart::requestObject( tdehtml::ChildFrame *child,
const KURL &
url,
const KParts::URLArgs &_args )
4371 if (!checkLinkSecurity(
url))
4373 kdDebug(6005) <<
this <<
" TDEHTMLPart::requestObject checkLinkSecurity refused" <<
endl;
4376 if ( child->m_bPreloaded )
4378 kdDebug(6005) <<
"TDEHTMLPart::requestObject preload" <<
endl;
4379 if ( child->m_frame && child->m_part )
4380 child->m_frame->setWidget( child->m_part->widget() );
4382 child->m_bPreloaded =
false;
4391 child->m_run->abort();
4393 if ( child->m_part && !args.
reload && urlcmp( child->m_part->url().url(),
url.
url(),
true,
true ) )
4396 child->m_args = args;
4397 child->m_args.
reload = (d->m_cachePolicy == TDEIO::CC_Reload);
4398 child->m_serviceName = TQString();
4399 if (!d->m_referrer.isEmpty() && !child->m_args.metaData().contains(
"referrer" ))
4400 child->m_args.metaData()[
"referrer"] = d->m_referrer;
4402 child->m_args.metaData().insert(
"PropagateHttpHeader",
"true");
4403 child->m_args.metaData().insert(
"ssl_parent_ip", d->m_ssl_parent_ip);
4404 child->m_args.metaData().insert(
"ssl_parent_cert", d->m_ssl_parent_cert);
4405 child->m_args.metaData().insert(
"main_frame_request",
4407 child->m_args.metaData().insert(
"ssl_was_in_use",
4408 d->m_ssl_in_use ?
"TRUE":
"FALSE");
4409 child->m_args.metaData().insert(
"ssl_activate_warnings",
"TRUE");
4410 child->m_args.metaData().insert(
"cross-domain",
toplevelURL().
url());
4414 args.
serviceType = TQString::fromLatin1(
"text/html" );
4417 kdDebug(6050) <<
"Running new TDEHTMLRun for " <<
this <<
" and child=" << child <<
endl;
4418 child->m_run =
new TDEHTMLRun(
this, child,
url, child->m_args,
true );
4419 d->m_bComplete =
false;
4426 bool TDEHTMLPart::processObjectRequest( tdehtml::ChildFrame *child,
const KURL &_url,
const TQString &mimetype )
4436 if ( d->m_onlyLocalReferences || (
url.
isEmpty() && mimetype.isEmpty() ) )
4438 child->m_bCompleted =
true;
4443 if (child->m_bNotify)
4445 child->m_bNotify =
false;
4446 if ( !child->m_args.lockHistory() )
4447 emit d->m_extension->openURLNotify();
4450 if ( child->m_serviceType != mimetype || !child->m_part )
4455 if ( child->m_type != tdehtml::ChildFrame::Object )
4457 TQString suggestedFilename;
4459 suggestedFilename = child->m_run->suggestedFilename();
4462 url, mimetype, suggestedFilename );
4464 case KParts::BrowserRun::Save:
4465 TDEHTMLPopupGUIClient::saveURL(
widget(), i18n(
"Save As" ),
url, child->m_args.metaData(), TQString(), 0, suggestedFilename);
4467 case KParts::BrowserRun::Cancel:
4468 child->m_bCompleted =
true;
4477 KParts::ReadOnlyPart *part =
createPart( d->m_view->viewport(), child->m_name.ascii(),
this, child->m_name.ascii(), mimetype, child->m_serviceName, dummy, child->m_params );
4481 if ( child->m_frame )
4482 if (child->m_frame->partLoadingErrorNotify( child,
url, mimetype ))
4485 checkEmitLoadEvent();
4490 if ( child->m_part )
4492 if (!::tqt_cast<TDEHTMLPart*>(child->m_part) && child->m_jscript)
4493 child->m_jscript->clear();
4496 if (child->m_liveconnect) {
4497 disconnect(child->m_liveconnect, TQ_SIGNAL(partEvent(
const unsigned long,
const TQString &,
const KParts::LiveConnectExtension::ArgList &)), child, TQ_SLOT(liveConnectEvent(
const unsigned long,
const TQString&,
const KParts::LiveConnectExtension::ArgList &)));
4498 child->m_liveconnect = 0L;
4502 child->m_serviceType = mimetype;
4503 if ( child->m_frame && part->
widget() )
4504 child->m_frame->setWidget( part->
widget() );
4506 if ( child->m_type != tdehtml::ChildFrame::Object )
4511 child->m_part = part;
4513 if (::tqt_cast<TDEHTMLPart*>(part)) {
4514 static_cast<TDEHTMLPart*
>(part)->d->m_frame = child;
4515 }
else if (child->m_frame) {
4516 child->m_liveconnect = KParts::LiveConnectExtension::childObject(part);
4517 if (child->m_liveconnect)
4518 connect(child->m_liveconnect, TQ_SIGNAL(partEvent(
const unsigned long,
const TQString &,
const KParts::LiveConnectExtension::ArgList &)), child, TQ_SLOT(liveConnectEvent(
const unsigned long,
const TQString&,
const KParts::LiveConnectExtension::ArgList &)));
4522 sb->
setStatusBar( d->m_statusBarExtension->statusBar() );
4524 connect( part, TQ_SIGNAL(
started( TDEIO::Job *) ),
4525 this, TQ_SLOT( slotChildStarted( TDEIO::Job *) ) );
4526 connect( part, TQ_SIGNAL(
completed() ),
4527 this, TQ_SLOT( slotChildCompleted() ) );
4528 connect( part, TQ_SIGNAL(
completed(
bool) ),
4529 this, TQ_SLOT( slotChildCompleted(
bool) ) );
4530 connect( part, TQ_SIGNAL( setStatusBarText(
const TQString & ) ),
4531 this, TQ_SIGNAL( setStatusBarText(
const TQString & ) ) );
4532 if ( part->inherits(
"TDEHTMLPart" ) )
4534 connect(
this, TQ_SIGNAL(
completed() ),
4535 part, TQ_SLOT( slotParentCompleted() ) );
4536 connect(
this, TQ_SIGNAL(
completed(
bool) ),
4537 part, TQ_SLOT( slotParentCompleted() ) );
4540 connect( part, TQ_SIGNAL( docCreated() ),
4541 this, TQ_SLOT( slotChildDocCreated() ) );
4546 if ( child->m_extension )
4548 connect( child->m_extension, TQ_SIGNAL( openURLNotify() ),
4549 d->m_extension, TQ_SIGNAL( openURLNotify() ) );
4551 connect( child->m_extension, TQ_SIGNAL( openURLRequestDelayed(
const KURL &,
const KParts::URLArgs & ) ),
4554 connect( child->m_extension, TQ_SIGNAL( createNewWindow(
const KURL &,
const KParts::URLArgs & ) ),
4559 connect( child->m_extension, TQ_SIGNAL(
popupMenu(
const TQPoint &,
const KFileItemList & ) ),
4560 d->m_extension, TQ_SIGNAL(
popupMenu(
const TQPoint &,
const KFileItemList & ) ) );
4561 connect( child->m_extension, TQ_SIGNAL(
popupMenu(
KXMLGUIClient *,
const TQPoint &,
const KFileItemList & ) ),
4565 connect( child->m_extension, TQ_SIGNAL(
popupMenu(
const TQPoint &,
const KURL &,
const TQString &, mode_t ) ),
4566 d->m_extension, TQ_SIGNAL(
popupMenu(
const TQPoint &,
const KURL &,
const TQString &, mode_t ) ) );
4567 connect( child->m_extension, TQ_SIGNAL(
popupMenu(
KXMLGUIClient *,
const TQPoint &,
const KURL &,
const TQString &, mode_t ) ),
4572 connect( child->m_extension, TQ_SIGNAL( infoMessage(
const TQString & ) ),
4573 d->m_extension, TQ_SIGNAL( infoMessage(
const TQString & ) ) );
4578 child->m_extension->setBrowserInterface( d->m_extension->browserInterface() );
4581 else if ( child->m_frame && child->m_part &&
4582 child->m_frame->widget() != child->m_part->widget() )
4583 child->m_frame->setWidget( child->m_part->widget() );
4585 checkEmitLoadEvent();
4588 if ( !child->m_part )
4591 if ( child->m_bPreloaded )
4593 if ( child->m_frame && child->m_part )
4594 child->m_frame->setWidget( child->m_part->widget() );
4596 child->m_bPreloaded =
false;
4600 child->m_args.reload = (d->m_cachePolicy == TDEIO::CC_Reload);
4606 child->m_args.serviceType = mimetype;
4609 child->m_bCompleted = child->m_type == tdehtml::ChildFrame::Object;
4611 if ( child->m_extension )
4612 child->m_extension->setURLArgs( child->m_args );
4615 if (!child->m_part->inherits(
"TDEHTMLPart"))
4621 if (d->m_doc && p->d->m_doc)
4622 p->d->m_doc->setBaseURL(d->m_doc->baseURL());
4623 if (!
url.
url().startsWith(
"about:")) {
4628 p->
write(
"<HTML><TITLE></TITLE><BODY></BODY></HTML>");
4636 bool b = child->m_part->openURL(
url );
4637 if (child->m_bCompleted)
4643 child->m_bCompleted =
true;
4650 TQObject *parent,
const char *name,
const TQString &mimetype,
4651 TQString &serviceName, TQStringList &serviceTypes,
4652 const TQStringList ¶ms )
4655 if ( !serviceName.isEmpty() )
4656 constr.append( TQString::fromLatin1(
"Name == '%1'" ).arg( serviceName ) );
4658 TDETrader::OfferList offers = TDETrader::self()->query( mimetype,
"KParts/ReadOnlyPart", constr, TQString() );
4660 if ( offers.isEmpty() ) {
4661 int pos = mimetype.find(
"-plugin" );
4664 TQString stripped_mime = mimetype.left( pos );
4665 offers = TDETrader::self()->query( stripped_mime,
"KParts/ReadOnlyPart", constr, TQString() );
4666 if ( offers.isEmpty() )
4670 TDETrader::OfferList::ConstIterator it = offers.begin();
4671 const TDETrader::OfferList::ConstIterator itEnd = offers.end();
4672 for ( ; it != itEnd; ++it )
4674 KService::Ptr service = (*it);
4680 const char *className =
"KParts::ReadOnlyPart";
4681 if ( service->serviceTypes().contains(
"Browser/View" ) )
4682 className =
"Browser/View";
4684 if (
factory->inherits(
"KParts::Factory" ) )
4690 serviceTypes = service->serviceTypes();
4691 serviceName = service->name();
4696 kdWarning() << TQString(TQString(
"There was an error loading the module %1.\nThe diagnostics is:\n%2")
4705 if ( !d->m_manager && d->m_view )
4707 d->m_manager =
new KParts::PartManager( d->m_view->topLevelWidget(),
this,
"tdehtml part manager" );
4708 d->m_manager->setAllowNestedParts(
true );
4709 connect( d->m_manager, TQ_SIGNAL( activePartChanged(
KParts::Part * ) ),
4710 this, TQ_SLOT( slotActiveFrameChanged(
KParts::Part * ) ) );
4711 connect( d->m_manager, TQ_SIGNAL( partRemoved(
KParts::Part * ) ),
4715 return d->m_manager;
4718 void TDEHTMLPart::submitFormAgain()
4720 disconnect(
this, TQ_SIGNAL(
completed()),
this, TQ_SLOT(submitFormAgain()));
4721 if( d->m_doc && !d->m_doc->parsing() && d->m_submitForm)
4722 TDEHTMLPart::submitForm( d->m_submitForm->submitAction, d->m_submitForm->submitUrl, d->m_submitForm->submitFormData, d->m_submitForm->target, d->m_submitForm->submitContentType, d->m_submitForm->submitBoundary );
4724 delete d->m_submitForm;
4725 d->m_submitForm = 0;
4728 void TDEHTMLPart::submitFormProxy(
const char *
action,
const TQString &
url,
const TQByteArray &formData,
const TQString &_target,
const TQString& contentType,
const TQString& boundary )
4730 submitForm(
action,
url, formData, _target, contentType, boundary);
4733 void TDEHTMLPart::submitForm(
const char *
action,
const TQString &
url,
const TQByteArray &formData,
const TQString &_target,
const TQString& contentType,
const TQString& boundary )
4735 kdDebug(6000) <<
this <<
": TDEHTMLPart::submitForm target=" << _target <<
" url=" <<
url <<
endl;
4736 if (d->m_formNotification == TDEHTMLPart::Only) {
4739 }
else if (d->m_formNotification == TDEHTMLPart::Before) {
4763 if (!d->m_submitForm) {
4765 if (d->m_ssl_in_use) {
4767 "\nA third party may be able to intercept and view this information."
4768 "\nAre you sure you wish to continue?"),
4769 i18n(
"Network Transmission"),
KGuiItem(i18n(
"&Send Unencrypted")));
4770 if (rc == KMessageBox::Cancel)
4773 KSSLSettings kss(
true);
4774 if (kss.warnOnUnencrypted()) {
4776 i18n(
"Warning: Your data is about to be transmitted across the network unencrypted."
4777 "\nAre you sure you wish to continue?"),
4778 i18n(
"Network Transmission"),
4779 KGuiItem(i18n(
"&Send Unencrypted")),
4780 "WarnOnUnencryptedForm");
4783 TQString grpNotifMsgs = TQString::fromLatin1(
"Notification Messages");
4786 if (!config->
readBoolEntry(
"WarnOnUnencryptedForm",
true)) {
4789 kss.setWarnOnUnencrypted(
false);
4792 if (rc == KMessageBox::Cancel)
4800 i18n(
"This site is attempting to submit form data via email.\n"
4801 "Do you want to continue?"),
4802 i18n(
"Network Transmission"),
4804 "WarnTriedEmailSubmit");
4806 if (rc == KMessageBox::Cancel) {
4815 TQString urlstring = u.
url();
4817 if ( urlstring.find( TQString::fromLatin1(
"javascript:" ), 0,
false ) == 0 ) {
4819 crossFrameExecuteScript( _target, urlstring.right( urlstring.length() - 11) );
4823 if (!checkLinkSecurity(u,
4824 i18n(
"<qt>The form will be submitted to <BR><B>%1</B><BR>on your local filesystem.<BR>Do you want to submit the form?" ),
4830 if (!d->m_referrer.isEmpty())
4831 args.
metaData()[
"referrer"] = d->m_referrer;
4833 args.
metaData().insert(
"PropagateHttpHeader",
"true");
4834 args.
metaData().insert(
"ssl_parent_ip", d->m_ssl_parent_ip);
4835 args.
metaData().insert(
"ssl_parent_cert", d->m_ssl_parent_cert);
4836 args.
metaData().insert(
"main_frame_request",
4838 args.
metaData().insert(
"ssl_was_in_use", d->m_ssl_in_use ?
"TRUE":
"FALSE");
4839 args.
metaData().insert(
"ssl_activate_warnings",
"TRUE");
4843 args.
frameName = _target.isEmpty() ? d->m_doc->baseTarget() : _target ;
4848 TQString q = u.
query().mid(1);
4849 TQStringList nvps = TQStringList::split(
"&", q);
4850 bool triedToAttach =
false;
4852 TQStringList::Iterator nvp = nvps.begin();
4853 const TQStringList::Iterator nvpEnd = nvps.end();
4858 while (nvp != nvpEnd) {
4859 const TQStringList pair = TQStringList::split(
"=", *nvp);
4860 if (pair.count() >= 2) {
4861 if (pair.first().lower() ==
"attach") {
4862 nvp = nvps.remove(nvp);
4863 triedToAttach =
true;
4873 KMessageBox::information(NULL, i18n(
"This site attempted to attach a file from your computer in the form submission. The attachment was removed for your protection."), i18n(
"TDE"),
"WarnTriedAttach");
4877 if (contentType.lower() ==
"multipart/form-data") {
4881 }
else if (contentType.lower() ==
"text/plain") {
4883 TQString tmpbody = TQString::fromLatin1(formData.data(),
4885 tmpbody.replace(TQRegExp(
"[&]"),
"\n");
4886 tmpbody.replace(TQRegExp(
"[+]"),
" ");
4894 nvps.append(TQString(
"body=%1").arg(bodyEnc));
4899 if ( strcmp(
action,
"get" ) == 0 ) {
4901 u.
setQuery( TQString::fromLatin1( formData.data(), formData.size() ) );
4909 if (contentType.isNull() || contentType ==
"application/x-www-form-urlencoded")
4910 args.
setContentType(
"Content-Type: application/x-www-form-urlencoded" );
4912 args.
setContentType(
"Content-Type: " + contentType +
"; boundary=" + boundary );
4915 if ( d->m_doc->parsing() || d->m_runningScripts > 0 ) {
4916 if( d->m_submitForm ) {
4917 kdDebug(6000) <<
"TDEHTMLPart::submitForm ABORTING!" <<
endl;
4920 d->m_submitForm =
new TDEHTMLPartPrivate::SubmitForm;
4921 d->m_submitForm->submitAction =
action;
4922 d->m_submitForm->submitUrl =
url;
4923 d->m_submitForm->submitFormData = formData;
4924 d->m_submitForm->target = _target;
4925 d->m_submitForm->submitContentType = contentType;
4926 d->m_submitForm->submitBoundary = boundary;
4927 connect(
this, TQ_SIGNAL(
completed()),
this, TQ_SLOT(submitFormAgain()));
4931 emit d->m_extension->openURLRequest( u, args );
4941 KParts::BrowserExtension::PopupFlags itemflags=KParts::BrowserExtension::ShowBookmark | KParts::BrowserExtension::ShowReload;
4943 if ( linkUrl.isEmpty() ) {
4949 popupURL = tdehtmlPart->
url();
4952 itemflags = KParts::BrowserExtension::ShowTextSelectionItems;
4954 itemflags |= KParts::BrowserExtension::ShowNavigationItems;
4957 linkKURL = popupURL;
4960 if (!(d->m_strSelectedURLTarget).isEmpty() &&
4961 (d->m_strSelectedURLTarget.lower() !=
"_top") &&
4962 (d->m_strSelectedURLTarget.lower() !=
"_self") &&
4963 (d->m_strSelectedURLTarget.lower() !=
"_parent")) {
4964 if (d->m_strSelectedURLTarget.lower() ==
"_blank")
4978 TDEHTMLPopupGUIClient* client =
new TDEHTMLPopupGUIClient(
this, d->m_popupMenuXML, linkKURL );
4979 TQGuardedPtr<TQObject> guard( client );
4981 TQString mimetype = TQString::fromLatin1(
"text/html" );
4984 if (!linkUrl.isEmpty())
4988 mimetype = KMimeType::findByURL(popupURL,0,
true,
false)->name();
4992 const TQString fname(popupURL.
fileName(
false));
4993 if (!fname.isEmpty() && !popupURL.
hasRef() && popupURL.
query().isEmpty())
4995 KMimeType::Ptr pmt = KMimeType::findByPath(fname,0,
true);
5001 if (pmt->name() != KMimeType::defaultMimeType() &&
5002 !pmt->is(
"application/x-perl") &&
5003 !pmt->is(
"application/x-perl-module") &&
5004 !pmt->is(
"application/x-php") &&
5005 !pmt->is(
"application/x-python-bytecode") &&
5006 !pmt->is(
"application/x-python") &&
5007 !pmt->is(
"application/x-shellscript"))
5008 mimetype = pmt->name();
5015 emit d->m_extension->popupMenu( client, TQCursor::pos(), popupURL, args, itemflags, S_IFREG );
5017 if ( !guard.isNull() ) {
5019 emit
popupMenu(linkUrl, TQCursor::pos());
5020 d->m_strSelectedURL = d->m_strSelectedURLTarget = TQString();
5024 void TDEHTMLPart::slotParentCompleted()
5027 if ( !d->m_redirectURL.isEmpty() && !d->m_redirectionTimer.isActive() )
5030 d->m_redirectionTimer.start( 1000 * d->m_delayRedirect,
true );
5034 void TDEHTMLPart::slotChildStarted( TDEIO::Job *job )
5036 tdehtml::ChildFrame *child = frame( sender() );
5040 child->m_bCompleted =
false;
5042 if ( d->m_bComplete )
5048 emit d->m_extension->openURLNotify();
5051 d->m_bComplete =
false;
5056 void TDEHTMLPart::slotChildCompleted()
5058 slotChildCompleted(
false );
5061 void TDEHTMLPart::slotChildCompleted(
bool pendingAction )
5063 tdehtml::ChildFrame *child = frame( sender() );
5066 kdDebug(6050) <<
this <<
" slotChildCompleted child=" << child <<
" m_frame=" << child->m_frame <<
endl;
5067 child->m_bCompleted =
true;
5068 child->m_bPendingRedirection = pendingAction;
5074 void TDEHTMLPart::slotChildDocCreated()
5080 if ( d->m_doc && d->m_doc->isHTMLDocument() )
5082 if ( sender()->inherits(
"TDEHTMLPart") )
5084 DOMString domain =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->domain();
5085 if (htmlFrame->d->m_doc && htmlFrame->d->m_doc->isHTMLDocument() )
5087 static_cast<HTMLDocumentImpl*
>(htmlFrame->d->m_doc)->setDomain( domain );
5091 disconnect( htmlFrame, TQ_SIGNAL( docCreated() ),
this, TQ_SLOT( slotChildDocCreated() ) );
5096 tdehtml::ChildFrame *child = frame( sender()->parent() );
5100 TQString urlStr =
url.
url();
5101 if ( urlStr.find( TQString::fromLatin1(
"javascript:" ), 0, false ) == 0 ) {
5107 TQString frameName = args.
frameName.lower();
5108 if ( !frameName.isEmpty() ) {
5109 if ( frameName == TQString::fromLatin1(
"_top" ) )
5111 emit d->m_extension->openURLRequest(
url, args );
5114 else if ( frameName == TQString::fromLatin1(
"_blank" ) )
5116 emit d->m_extension->createNewWindow(
url, args );
5119 else if ( frameName == TQString::fromLatin1(
"_parent" ) )
5122 newArgs.frameName = TQString();
5124 emit d->m_extension->openURLRequest(
url, newArgs );
5127 else if ( frameName != TQString::fromLatin1(
"_self" ) )
5129 tdehtml::ChildFrame *_frame = recursiveFrameRequest( callingHtmlPart,
url, args );
5133 emit d->m_extension->openURLRequest(
url, args );
5141 if ( child && child->m_type != tdehtml::ChildFrame::Object ) {
5143 child->m_bNotify =
true;
5144 requestObject( child,
url, args );
5145 }
else if ( frameName==
"_self" )
5148 newArgs.frameName = TQString();
5149 emit d->m_extension->openURLRequest(
url, newArgs );
5155 emit d->m_extension->requestFocus(
this);
5158 tdehtml::ChildFrame *TDEHTMLPart::frame(
const TQObject *obj )
5160 assert( obj->inherits(
"KParts::ReadOnlyPart" ) );
5163 FrameIt it = d->m_frames.begin();
5164 const FrameIt
end = d->m_frames.end();
5165 for (; it !=
end; ++it )
5169 FrameIt oi = d->m_objects.begin();
5170 const FrameIt oiEnd = d->m_objects.end();
5171 for (; oi != oiEnd; ++oi )
5180 bool TDEHTMLPart::checkFrameAccess(
TDEHTMLPart *callingHtmlPart)
5182 if (callingHtmlPart ==
this)
5186 #ifdef DEBUG_FINDFRAME
5187 kdDebug(6050) <<
"TDEHTMLPart::checkFrameAccess: Empty part " <<
this <<
" URL = " <<
m_url <<
endl;
5198 #ifdef DEBUG_FINDFRAME
5199 kdDebug(6050) <<
"TDEHTMLPart::checkFrameAccess: actDomain = '" << actDomain.string() <<
"' destDomain = '" << destDomain.string() <<
"'" <<
endl;
5202 if (actDomain == destDomain)
5205 #ifdef DEBUG_FINDFRAME
5208 kdDebug(6050) <<
"TDEHTMLPart::checkFrameAccess: Unknown part/domain " << callingHtmlPart <<
" tries to access part " <<
this <<
endl;
5217 #ifdef DEBUG_FINDFRAME
5218 kdDebug(6050) <<
"TDEHTMLPart::findFrameParent: this = " <<
this <<
" URL = " <<
m_url <<
" name = " << name() <<
" findFrameParent( " << f <<
" )" <<
endl;
5223 if (!checkFrameAccess(callingHtmlPart))
5227 if (!childFrame && !
parentPart() && (TQString::fromLocal8Bit(name()) == f))
5230 FrameIt it = d->m_frames.find( f );
5231 const FrameIt
end = d->m_frames.end();
5234 #ifdef DEBUG_FINDFRAME
5235 kdDebug(6050) <<
"TDEHTMLPart::findFrameParent: FOUND!" <<
endl;
5242 it = d->m_frames.begin();
5243 for (; it !=
end; ++it )
5246 if ( p && p->inherits(
"TDEHTMLPart" ))
5259 tdehtml::ChildFrame *childFrame;
5264 if ( p && p->inherits(
"TDEHTMLPart" ))
5272 tdehtml::ChildFrame *childFrame;
5282 while ( part && part->inherits(
"TDEHTMLPart") &&
5283 static_cast<TDEHTMLPart *
>(part)->d->m_frames.count() > 0 ) {
5286 if ( !part )
return frameset;
5293 ConstFrameIt it = d->m_frames.find( frameName );
5294 if ( it == d->m_frames.end() )
5300 return (!(*it)->m_frame.isNull());
5305 TDEHTMLPart*
const kp = ::tqt_cast<TDEHTMLPart*>(framePart);
5307 return kp->jScript();
5309 FrameIt it = d->m_frames.begin();
5310 const FrameIt itEnd = d->m_frames.end();
5312 for (; it != itEnd; ++it)
5313 if (framePart == (*it)->m_part) {
5314 if (!(*it)->m_jscript)
5316 return (*it)->m_jscript;
5323 return ::tqt_cast<TDEHTMLPart *>( parent() );
5326 tdehtml::ChildFrame *TDEHTMLPart::recursiveFrameRequest(
TDEHTMLPart *callingHtmlPart,
const KURL &
url,
5329 #ifdef DEBUG_FINDFRAME
5330 kdDebug( 6050 ) <<
"TDEHTMLPart::recursiveFrameRequest this = " <<
this <<
", frame = " << args.
frameName <<
", url = " <<
url <<
endl;
5332 tdehtml::ChildFrame *childFrame;
5336 if (childPart ==
this)
5339 childPart->requestObject( childFrame,
url, args );
5345 tdehtml::ChildFrame *res =
parentPart()->recursiveFrameRequest( callingHtmlPart,
url, args, callParent );
5355 static int s_saveStateIndentLevel = 0;
5361 TQString indent = TQString().leftJustify( s_saveStateIndentLevel * 4,
' ' );
5362 const int indentLevel = s_saveStateIndentLevel++;
5363 kdDebug( 6050 ) << indent <<
"saveState this=" <<
this <<
" '" << name() <<
"' saving URL " <<
m_url.
url() <<
endl;
5366 stream <<
m_url << (TQ_INT32)d->m_view->contentsX() << (TQ_INT32)d->m_view->contentsY()
5367 << (TQ_INT32) d->m_view->contentsWidth() << (TQ_INT32) d->m_view->contentsHeight() << (TQ_INT32) d->m_view->marginWidth() << (TQ_INT32) d->m_view->marginHeight();
5370 int focusNodeNumber;
5371 if (!d->m_focusNodeRestored)
5372 focusNodeNumber = d->m_focusNodeNumber;
5373 else if (d->m_doc && d->m_doc->focusNode())
5374 focusNodeNumber = d->m_doc->nodeAbsIndex(d->m_doc->focusNode());
5376 focusNodeNumber = -1;
5377 stream << focusNodeNumber;
5380 stream << d->m_cacheId;
5383 TQStringList docState;
5386 docState = d->m_doc->docState();
5388 stream << d->m_encoding << d->m_sheetUsed << docState;
5390 stream << d->m_zoomFactor;
5392 stream << d->m_httpHeaders;
5393 stream << d->m_pageServices;
5394 stream << d->m_pageReferrer;
5397 stream << d->m_ssl_in_use
5398 << d->m_ssl_peer_certificate
5399 << d->m_ssl_peer_chain
5402 << d->m_ssl_cipher_desc
5403 << d->m_ssl_cipher_version
5404 << d->m_ssl_cipher_used_bits
5405 << d->m_ssl_cipher_bits
5406 << d->m_ssl_cert_state
5407 << d->m_ssl_parent_ip
5408 << d->m_ssl_parent_cert;
5411 TQStringList frameNameLst, frameServiceTypeLst, frameServiceNameLst;
5413 TQValueList<TQByteArray> frameStateBufferLst;
5415 ConstFrameIt it = d->m_frames.begin();
5416 const ConstFrameIt
end = d->m_frames.end();
5417 for (; it !=
end; ++it )
5419 if ( !(*it)->m_part )
5422 frameNameLst << (*it)->m_name;
5423 frameServiceTypeLst << (*it)->m_serviceType;
5424 frameServiceNameLst << (*it)->m_serviceName;
5425 frameURLLst << (*it)->m_part->url();
5428 TQDataStream frameStream( state, IO_WriteOnly );
5430 if ( (*it)->m_extension )
5431 (*it)->m_extension->saveState( frameStream );
5433 frameStateBufferLst << state;
5437 stream << (TQ_UINT32) frameNameLst.count();
5438 stream << frameNameLst << frameServiceTypeLst << frameServiceNameLst << frameURLLst << frameStateBufferLst;
5440 s_saveStateIndentLevel = indentLevel;
5447 TQ_INT32 xOffset, yOffset, wContents, hContents, mWidth, mHeight;
5448 TQ_UINT32 frameCount;
5449 TQStringList
frameNames, frameServiceTypes, docState, frameServiceNames;
5451 TQValueList<TQByteArray> frameStateBuffers;
5452 TQValueList<int> fSizes;
5454 long old_cacheId = d->m_cacheId;
5456 stream >> u >> xOffset >> yOffset >> wContents >> hContents >> mWidth >> mHeight;
5458 d->m_view->setMarginWidth( mWidth );
5459 d->m_view->setMarginHeight( mHeight );
5463 stream >> d->m_focusNodeNumber;
5464 d->m_focusNodeRestored =
false;
5466 stream >> d->m_cacheId;
5468 stream >>
encoding >> sheetUsed >> docState;
5471 d->m_sheetUsed = sheetUsed;
5477 stream >> d->m_httpHeaders;
5478 stream >> d->m_pageServices;
5479 stream >> d->m_pageReferrer;
5482 stream >> d->m_ssl_in_use
5483 >> d->m_ssl_peer_certificate
5484 >> d->m_ssl_peer_chain
5487 >> d->m_ssl_cipher_desc
5488 >> d->m_ssl_cipher_version
5489 >> d->m_ssl_cipher_used_bits
5490 >> d->m_ssl_cipher_bits
5491 >> d->m_ssl_cert_state
5492 >> d->m_ssl_parent_ip
5493 >> d->m_ssl_parent_cert;
5495 setPageSecurity( d->m_ssl_in_use ? Encrypted : NotCrypted );
5497 stream >> frameCount >>
frameNames >> frameServiceTypes >> frameServiceNames
5498 >> frameURLs >> frameStateBuffers;
5500 d->m_bComplete =
false;
5501 d->m_bLoadEventEmitted =
false;
5507 if (d->m_cacheId == old_cacheId)
5510 d->m_redirectionTimer.stop();
5512 FrameIt fIt = d->m_frames.begin();
5513 const FrameIt fEnd = d->m_frames.end();
5515 for (; fIt != fEnd; ++fIt )
5516 (*fIt)->m_bCompleted =
false;
5518 fIt = d->m_frames.begin();
5520 TQStringList::ConstIterator fNameIt =
frameNames.begin();
5521 TQStringList::ConstIterator fServiceTypeIt = frameServiceTypes.begin();
5522 TQStringList::ConstIterator fServiceNameIt = frameServiceNames.begin();
5523 KURL::List::ConstIterator fURLIt = frameURLs.begin();
5524 TQValueList<TQByteArray>::ConstIterator fBufferIt = frameStateBuffers.begin();
5526 for (; fIt != fEnd; ++fIt, ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt )
5528 tdehtml::ChildFrame*
const child = *fIt;
5532 if ( child->m_name != *fNameIt || child->m_serviceType != *fServiceTypeIt )
5534 child->m_bPreloaded =
true;
5535 child->m_name = *fNameIt;
5536 child->m_serviceName = *fServiceNameIt;
5537 processObjectRequest( child, *fURLIt, *fServiceTypeIt );
5539 if ( child->m_part )
5541 child->m_bCompleted =
false;
5542 if ( child->m_extension && !(*fBufferIt).isEmpty() )
5544 TQDataStream frameStream( *fBufferIt, IO_ReadOnly );
5545 child->m_extension->restoreState( frameStream );
5548 child->m_part->openURL( *fURLIt );
5556 d->m_extension->setURLArgs( args );
5558 d->m_view->resizeContents( wContents, hContents);
5559 d->m_view->setContentsPos( xOffset, yOffset );
5569 d->m_bCleared =
false;
5572 d->m_sheetUsed = sheetUsed;
5574 TQStringList::ConstIterator fNameIt =
frameNames.begin();
5575 const TQStringList::ConstIterator fNameEnd =
frameNames.end();
5577 TQStringList::ConstIterator fServiceTypeIt = frameServiceTypes.begin();
5578 TQStringList::ConstIterator fServiceNameIt = frameServiceNames.begin();
5579 KURL::List::ConstIterator fURLIt = frameURLs.begin();
5580 TQValueList<TQByteArray>::ConstIterator fBufferIt = frameStateBuffers.begin();
5582 for (; fNameIt != fNameEnd; ++fNameIt, ++fServiceTypeIt, ++fServiceNameIt, ++fURLIt, ++fBufferIt )
5584 tdehtml::ChildFrame*
const newChild =
new tdehtml::ChildFrame;
5585 newChild->m_bPreloaded =
true;
5586 newChild->m_name = *fNameIt;
5587 newChild->m_serviceName = *fServiceNameIt;
5591 const FrameIt childFrame = d->m_frames.append( newChild );
5593 processObjectRequest( *childFrame, *fURLIt, *fServiceTypeIt );
5595 (*childFrame)->m_bPreloaded =
true;
5597 if ( (*childFrame)->m_part )
5599 if ( (*childFrame)->m_extension ) {
5600 if ( (*childFrame)->m_extension && !(*fBufferIt).isEmpty() )
5602 TQDataStream frameStream( *fBufferIt, IO_ReadOnly );
5603 (*childFrame)->m_extension->restoreState( frameStream );
5606 (*childFrame)->m_part->openURL( *fURLIt );
5617 d->m_extension->setURLArgs( args );
5620 d->m_restored =
true;
5622 d->m_restored =
false;
5646 return d->m_view->nodeUnderMouse();
5651 return d->m_view->nonSharedNodeUnderMouse();
5654 void TDEHTMLPart::emitSelectionChanged()
5656 emit d->m_extension->enableAction(
"copy",
hasSelection() );
5657 if ( d->m_findDialog )
5666 return d->m_zoomFactor;
5670 static const int zoomSizes[] = { 20, 40, 60, 80, 90, 95, 100, 105, 110, 120, 140, 160, 180, 200, 250, 300 };
5671 static const int zoomSizeCount = (
sizeof(zoomSizes) /
sizeof(
int));
5672 static const int minZoom = 20;
5673 static const int maxZoom = 300;
5676 extern const int TDE_NO_EXPORT fastZoomSizes[] = { 20, 50, 75, 90, 100, 120, 150, 200, 300 };
5677 extern const int TDE_NO_EXPORT fastZoomSizeCount =
sizeof fastZoomSizes /
sizeof fastZoomSizes[0];
5679 void TDEHTMLPart::slotIncZoom()
5681 zoomIn(zoomSizes, zoomSizeCount);
5684 void TDEHTMLPart::slotDecZoom()
5686 zoomOut(zoomSizes, zoomSizeCount);
5689 void TDEHTMLPart::slotIncZoomFast()
5691 zoomIn(fastZoomSizes, fastZoomSizeCount);
5694 void TDEHTMLPart::slotDecZoomFast()
5696 zoomOut(fastZoomSizes, fastZoomSizeCount);
5699 void TDEHTMLPart::zoomIn(
const int stepping[],
int count)
5705 for (
int i = 0; i < count; ++i)
5714 void TDEHTMLPart::zoomOut(
const int stepping[],
int count)
5719 for (
int i = count-1; i >= 0; --i)
5730 if (percent < minZoom) percent = minZoom;
5731 if (percent > maxZoom) percent = maxZoom;
5732 if (d->m_zoomFactor == percent)
return;
5733 d->m_zoomFactor = percent;
5736 TQApplication::setOverrideCursor( TQt::waitCursor );
5737 if (d->m_doc->styleSelector())
5738 d->m_doc->styleSelector()->computeFontSizes(d->m_doc->paintDeviceMetrics(), d->m_zoomFactor);
5739 d->m_doc->recalcStyle( NodeImpl::Force );
5740 TQApplication::restoreOverrideCursor();
5743 ConstFrameIt it = d->m_frames.begin();
5744 const ConstFrameIt
end = d->m_frames.end();
5745 for (; it !=
end; ++it )
5746 if ( !( *it )->m_part.isNull() && (*it)->m_part->inherits(
"TDEHTMLPart" ) ) {
5751 if ( d->m_guiProfile == BrowserViewGUI ) {
5752 d->m_paDecZoomFactor->setEnabled( d->m_zoomFactor > minZoom );
5753 d->m_paIncZoomFactor->setEnabled( d->m_zoomFactor < maxZoom );
5757 void TDEHTMLPart::slotZoomView(
int delta )
5765 void TDEHTMLPart::setStatusBarText(
const TQString& text, StatusBarPriority p)
5767 if (!d->m_statusMessagesEnabled)
5770 d->m_statusBarText[p] = text;
5773 TQString tobe = d->m_statusBarText[BarHoverText];
5775 tobe = d->m_statusBarText[BarOverrideText];
5776 if (tobe.isEmpty()) {
5777 tobe = d->m_statusBarText[BarDefaultText];
5778 if (!tobe.isEmpty() && d->m_jobspeed)
5781 tobe += i18n(
"(%1/s)" ).arg( TDEIO::convertSize( d->m_jobspeed ) );
5785 emit ReadOnlyPart::setStatusBarText(tobe);
5791 setStatusBarText(text, BarOverrideText);
5796 setStatusBarText(text, BarDefaultText);
5801 return d->m_statusBarText[BarOverrideText];
5806 return d->m_statusBarText[BarDefaultText];
5811 return d->m_referrer;
5816 KURL referrerURL =
KURL( d->m_pageReferrer );
5819 TQString protocol = referrerURL.
protocol();
5821 if ((protocol ==
"http") ||
5824 referrerURL.
setRef(TQString());
5825 referrerURL.
setUser(TQString());
5826 referrerURL.
setPass(TQString());
5827 return referrerURL.
url();
5841 TQDateTime lastModif = TQFileInfo(
m_url.
path() ).lastModified();
5842 d->m_lastModified = lastModif.toString( TQt::LocalDate );
5845 return d->m_lastModified;
5848 void TDEHTMLPart::slotLoadImages()
5851 d->m_doc->docLoader()->setAutoloadImages( !d->m_doc->docLoader()->autoloadImages() );
5853 ConstFrameIt it = d->m_frames.begin();
5854 const ConstFrameIt
end = d->m_frames.end();
5855 for (; it !=
end; ++it )
5856 if ( !( *it )->m_part.isNull() && (*it)->m_part->inherits(
"TDEHTMLPart" ) ) {
5862 void TDEHTMLPart::reparseConfiguration()
5869 d->m_doc->docLoader()->setShowAnimations( settings->showAnimations() );
5871 d->m_bOpenMiddleClick = settings->isOpenMiddleClickEnabled();
5872 d->m_bBackRightClick = settings->isBackRightClickEnabled();
5873 d->m_bJScriptEnabled = settings->isJavaScriptEnabled(
m_url.
host());
5874 setDebugScript( settings->isJavaScriptDebugEnabled() );
5875 d->m_bJavaEnabled = settings->isJavaEnabled(
m_url.
host());
5876 d->m_bPluginsEnabled = settings->isPluginsEnabled(
m_url.
host());
5877 d->m_metaRefreshEnabled = settings->isAutoDelayedActionsEnabled ();
5879 delete d->m_settings;
5880 d->m_settings =
new TDEHTMLSettings(*TDEHTMLFactory::defaultHTMLSettings());
5882 TQApplication::setOverrideCursor( TQt::waitCursor );
5883 tdehtml::CSSStyleSelector::reparseConfiguration();
5884 if(d->m_doc) d->m_doc->updateStyleSelector();
5885 TQApplication::restoreOverrideCursor();
5887 if (TDEHTMLFactory::defaultHTMLSettings()->isAdFilterEnabled())
5895 ConstFrameIt it = d->m_frames.begin();
5896 const ConstFrameIt
end = d->m_frames.end();
5897 for (; it !=
end; ++it )
5898 if (!(*it)->m_bPreloaded)
5899 res += (*it)->m_name;
5904 TQPtrList<KParts::ReadOnlyPart> TDEHTMLPart::frames()
const
5906 TQPtrList<KParts::ReadOnlyPart> res;
5908 ConstFrameIt it = d->m_frames.begin();
5909 const ConstFrameIt
end = d->m_frames.end();
5910 for (; it !=
end; ++it )
5911 if (!(*it)->m_bPreloaded)
5912 res.append( (*it)->m_part );
5919 kdDebug( 6050 ) <<
this <<
"TDEHTMLPart::openURLInFrame " <<
url <<
endl;
5920 FrameIt it = d->m_frames.find( urlArgs.
frameName );
5922 if ( it == d->m_frames.end() )
5926 if ( !urlArgs.lockHistory() )
5927 emit d->m_extension->openURLNotify();
5929 requestObject( *it,
url, urlArgs );
5944 void TDEHTMLPart::customEvent( TQCustomEvent *event )
5946 if ( tdehtml::MousePressEvent::test( event ) )
5952 if ( tdehtml::MouseDoubleClickEvent::test( event ) )
5958 if ( tdehtml::MouseMoveEvent::test( event ) )
5964 if ( tdehtml::MouseReleaseEvent::test( event ) )
5970 if ( tdehtml::DrawContentsEvent::test( event ) )
5976 KParts::ReadOnlyPart::customEvent( event );
5984 static bool firstRunAt(tdehtml::RenderObject *renderNode,
int y, NodeImpl *&startNode,
long &startOffset)
5986 for (tdehtml::RenderObject *n = renderNode; n; n = n->nextSibling()) {
5988 tdehtml::RenderText*
const textRenderer =
static_cast<tdehtml::RenderText *
>(n);
5989 const tdehtml::InlineTextBoxArray &runs = textRenderer->inlineTextBoxes();
5990 const unsigned lim = runs.count();
5991 for (
unsigned i = 0; i != lim; ++i) {
5992 if (runs[i]->m_y == y && textRenderer->element()) {
5993 startNode = textRenderer->element();
5994 startOffset = runs[i]->m_start;
6000 if (firstRunAt(n->firstChild(), y, startNode, startOffset)) {
6013 static bool lastRunAt(tdehtml::RenderObject *renderNode,
int y, NodeImpl *&endNode,
long &endOffset)
6015 tdehtml::RenderObject *n = renderNode;
6019 tdehtml::RenderObject *
next;
6020 while ((next = n->nextSibling())) {
6025 if (lastRunAt(n->firstChild(), y, endNode, endOffset)) {
6030 tdehtml::RenderText*
const textRenderer =
static_cast<tdehtml::RenderText *
>(n);
6031 const tdehtml::InlineTextBoxArray &runs = textRenderer->inlineTextBoxes();
6032 for (
int i = (
int)runs.count()-1; i >= 0; --i) {
6033 if (runs[i]->m_y == y && textRenderer->element()) {
6034 endNode = textRenderer->element();
6035 endOffset = runs[i]->m_start + runs[i]->m_len;
6041 if (n == renderNode) {
6045 n = n->previousSibling();
6052 TQMouseEvent *_mouse =
event->qmouseEvent();
6053 DOM::Node innerNode =
event->innerNode();
6054 d->m_mousePressNode = innerNode;
6056 d->m_dragStartPos = _mouse->pos();
6058 if ( !event->url().isNull() ) {
6059 d->m_strSelectedURL =
event->url().string();
6060 d->m_strSelectedURLTarget =
event->target().string();
6063 d->m_strSelectedURL = d->m_strSelectedURLTarget = TQString();
6065 if ( _mouse->button() == TQt::LeftButton ||
6066 _mouse->button() == TQt::MidButton )
6068 d->m_bMousePressed =
true;
6070 #ifndef TDEHTML_NO_SELECTION
6071 if ( _mouse->button() == TQt::LeftButton )
6073 if ( (!d->m_strSelectedURL.isNull() && !
isEditable())
6074 || (!d->m_mousePressNode.isNull() && d->m_mousePressNode.elementId() == ID_IMG) )
6076 if ( !innerNode.
isNull() && innerNode.handle()->renderer()) {
6078 DOM::NodeImpl* node = 0;
6079 tdehtml::RenderObject::SelPointState state;
6080 innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
6081 event->absX()-innerNode.handle()->renderer()->xPos(),
6082 event->absY()-innerNode.handle()->renderer()->yPos(), node, offset, state );
6083 d->m_extendMode = d->ExtendByChar;
6084 #ifdef TDEHTML_NO_CARET
6085 d->m_selectionStart = node;
6086 d->m_startOffset = offset;
6092 d->m_selectionEnd = d->m_selectionStart;
6093 d->m_endOffset = d->m_startOffset;
6094 d->m_doc->clearSelection();
6096 d->m_view->moveCaretTo(node, offset, (_mouse->state() & ShiftButton) == 0);
6098 d->m_initialNode = d->m_selectionStart;
6099 d->m_initialOffset = d->m_startOffset;
6104 #ifndef TDEHTML_NO_CARET
6111 emitSelectionChanged();
6115 d->m_dragLastPos = _mouse->globalPos();
6119 if ( _mouse->button() == TQt::RightButton &&
parentPart() != 0 && d->m_bBackRightClick )
6121 d->m_bRightMousePressed =
true;
6122 }
else if ( _mouse->button() == TQt::RightButton )
6131 TQMouseEvent *_mouse =
event->qmouseEvent();
6132 if ( _mouse->button() == TQt::LeftButton )
6134 d->m_bMousePressed =
true;
6135 DOM::Node innerNode =
event->innerNode();
6137 if ( !innerNode.
isNull() && innerNode.handle()->renderer()) {
6139 DOM::NodeImpl* node = 0;
6140 tdehtml::RenderObject::SelPointState state;
6141 innerNode.handle()->renderer()->checkSelectionPoint( event->x(), event->y(),
6142 event->absX()-innerNode.handle()->renderer()->xPos(),
6143 event->absY()-innerNode.handle()->renderer()->yPos(), node, offset, state);
6147 if ( node && node->renderer() )
6150 bool selectLine = (
event->clickCount() == 3);
6151 d->m_extendMode = selectLine ? d->ExtendByLine : d->ExtendByWord;
6154 if (_mouse->state() & ShiftButton) {
6155 d->caretNode() = node;
6156 d->caretOffset() = offset;
6157 d->m_startBeforeEnd = RangeImpl::compareBoundaryPoints(
6158 d->m_selectionStart.handle(), d->m_startOffset,
6159 d->m_selectionEnd.handle(), d->m_endOffset) <= 0;
6160 d->m_initialNode = d->m_extendAtEnd ? d->m_selectionStart : d->m_selectionEnd;
6161 d->m_initialOffset = d->m_extendAtEnd ? d->m_startOffset : d->m_endOffset;
6163 d->m_selectionStart = d->m_selectionEnd = node;
6164 d->m_startOffset = d->m_endOffset = offset;
6165 d->m_startBeforeEnd =
true;
6166 d->m_initialNode = node;
6167 d->m_initialOffset = offset;
6172 extendSelection( d->m_selectionStart.handle(), d->m_startOffset, d->m_selectionStart, d->m_startOffset, !d->m_startBeforeEnd, selectLine );
6174 extendSelection( d->m_selectionEnd.handle(), d->m_endOffset, d->m_selectionEnd, d->m_endOffset, d->m_startBeforeEnd, selectLine );
6179 emitSelectionChanged();
6181 ->setSelection(d->m_selectionStart.handle(),d->m_startOffset,
6182 d->m_selectionEnd.handle(),d->m_endOffset);
6183 #ifndef TDEHTML_NO_CARET
6184 bool v = d->m_view->placeCaret();
6185 emitCaretPositionChanged(v ? d->caretNode() : 0, d->caretOffset());
6193 void TDEHTMLPart::extendSelection( DOM::NodeImpl* node,
long offset,
DOM::Node& selectionNode,
long& selectionOffset,
bool right,
bool selectLines )
6195 tdehtml::RenderObject* obj = node->renderer();
6197 if (obj->isText() && selectLines) {
6199 tdehtml::RenderText *renderer =
static_cast<tdehtml::RenderText *
>(obj);
6200 tdehtml::InlineTextBox *run = renderer->findInlineTextBox( offset, pos );
6202 DOM::NodeImpl* selNode = 0;
6208 int selectionPointY = run->m_y;
6211 tdehtml::RenderObject *renderNode = renderer;
6212 while (renderNode && renderNode->isInline())
6213 renderNode = renderNode->parent();
6215 renderNode = renderNode->firstChild();
6220 if (!lastRunAt (renderNode, selectionPointY, selNode, selOfs))
6225 if (!firstRunAt (renderNode, selectionPointY, selNode, selOfs))
6229 selectionNode = selNode;
6230 selectionOffset = selOfs;
6236 if ( obj->isText() ) {
6237 str =
static_cast<tdehtml::RenderText *
>(obj)->data().string();
6245 selectionNode = node;
6246 selectionOffset = offset;
6250 while ( obj && ( (right && offset >= len-1) || (!right && offset <= 0) ) )
6252 obj = right ? obj->objectBelow() : obj->objectAbove();
6257 if ( obj->isText() )
6258 str =
static_cast<tdehtml::RenderText *
>(obj)->data().string();
6259 else if ( obj->isBR() )
6261 else if ( !obj->isInline() ) {
6276 node = obj->element();
6279 Q_ASSERT( offset < len-1 );
6284 Q_ASSERT( offset > 0 );
6289 ch = str[ (int)offset ];
6291 }
while ( !ch.isSpace() && !ch.isPunct() );
6294 if (right) ++selectionOffset;
6297 #ifndef TDEHTML_NO_SELECTION
6298 void TDEHTMLPart::extendSelectionTo(
int x,
int y,
int absX,
int absY,
const DOM::Node &innerNode)
6302 DOM::NodeImpl* node=0;
6303 tdehtml::RenderObject::SelPointState state;
6304 innerNode.handle()->renderer()->checkSelectionPoint( x, y,
6305 absX-innerNode.handle()->renderer()->xPos(),
6306 absY-innerNode.handle()->renderer()->yPos(), node, offset, state);
6307 if (!node || !node->renderer())
return;
6312 bool withinNode = innerNode == node;
6316 if (d->m_selectionStart.isNull() || d->m_selectionEnd.isNull() ||
6317 d->m_initialNode.isNull() ||
6318 !d->m_selectionStart.handle()->renderer() ||
6319 !d->m_selectionEnd.handle()->renderer())
return;
6321 if (d->m_extendMode != d->ExtendByChar) {
6323 bool caretBeforeInit = RangeImpl::compareBoundaryPoints(
6324 d->caretNode().handle(), d->caretOffset(),
6325 d->m_initialNode.handle(), d->m_initialOffset) <= 0;
6326 bool nodeBeforeInit = RangeImpl::compareBoundaryPoints(node, offset,
6327 d->m_initialNode.handle(), d->m_initialOffset) <= 0;
6329 if (caretBeforeInit != nodeBeforeInit) {
6331 extendSelection(d->m_initialNode.handle(), d->m_initialOffset,
6332 d->m_extendAtEnd ? d->m_selectionStart : d->m_selectionEnd,
6333 d->m_extendAtEnd ? d->m_startOffset : d->m_endOffset,
6334 nodeBeforeInit, d->m_extendMode == d->ExtendByLine);
6338 d->caretNode() = node;
6339 d->caretOffset() = offset;
6342 d->m_startBeforeEnd = RangeImpl::compareBoundaryPoints(
6343 d->m_selectionStart.handle(), d->m_startOffset,
6344 d->m_selectionEnd.handle(), d->m_endOffset) <= 0;
6346 if ( !d->m_selectionStart.isNull() && !d->m_selectionEnd.isNull() )
6349 if (d->m_extendMode != d->ExtendByChar && withinNode)
6350 extendSelection( node, offset, d->caretNode(), d->caretOffset(), d->m_startBeforeEnd ^ !d->m_extendAtEnd, d->m_extendMode == d->ExtendByLine );
6352 if (d->m_selectionEnd == d->m_selectionStart && d->m_endOffset < d->m_startOffset)
6354 ->setSelection(d->m_selectionStart.handle(),d->m_endOffset,
6355 d->m_selectionEnd.handle(),d->m_startOffset);
6356 else if (d->m_startBeforeEnd)
6358 ->setSelection(d->m_selectionStart.handle(),d->m_startOffset,
6359 d->m_selectionEnd.handle(),d->m_endOffset);
6362 ->setSelection(d->m_selectionEnd.handle(),d->m_endOffset,
6363 d->m_selectionStart.handle(),d->m_startOffset);
6365 #ifndef TDEHTML_NO_CARET
6366 d->m_view->placeCaret();
6370 bool TDEHTMLPart::isExtendingSelection()
const
6375 return d->m_bMousePressed;
6381 TQMouseEvent *_mouse =
event->qmouseEvent();
6383 if( d->m_bRightMousePressed &&
parentPart() != 0 && d->m_bBackRightClick )
6386 d->m_strSelectedURL = d->m_strSelectedURLTarget = TQString();
6387 d->m_bRightMousePressed =
false;
6392 DOM::Node innerNode =
event->innerNode();
6394 #ifndef TQT_NO_DRAGANDDROP
6395 if( d->m_bDnd && d->m_bMousePressed &&
6396 ( (!d->m_strSelectedURL.isEmpty() && !
isEditable())
6397 || (!d->m_mousePressNode.isNull() && d->m_mousePressNode.elementId() == ID_IMG) ) ) {
6402 HTMLImageElementImpl *img = 0L;
6403 TQDragObject *drag = 0;
6410 if (
url.length() == 0 && innerNode.handle() && innerNode.handle()->id() == ID_IMG )
6412 img =
static_cast<HTMLImageElementImpl *
>(innerNode.handle());
6413 u =
KURL(
completeURL( tdehtml::parseURL(img->getAttribute(ATTR_SRC)).string() ) );
6426 if ( !d->m_referrer.isEmpty() )
6427 urlDrag->
metaData()[
"referrer"] = d->m_referrer;
6429 if( img && img->complete()) {
6431 mdrag->
addDragObject(
new TQImageDrag( img->currentImage(), 0L ) );
6438 if ( !pix.isNull() )
6439 drag->setPixmap( pix );
6446 d->m_bMousePressed =
false;
6447 d->m_strSelectedURL = d->m_strSelectedURLTarget = TQString();
6453 if ( !d->m_bMousePressed )
6458 bool shiftPressed = ( _mouse->state() & ShiftButton );
6461 if ( !innerNode.
isNull() && innerNode.elementId() == ID_IMG )
6463 HTMLImageElementImpl *i =
static_cast<HTMLImageElementImpl *
>(innerNode.handle());
6464 if ( i && i->isServerMap() )
6466 tdehtml::RenderObject *r = i->renderer();
6469 int absx, absy, vx, vy;
6470 r->absolutePosition(absx, absy);
6471 view()->contentsToViewport( absx, absy, vx, vy );
6473 int x(_mouse->x() - vx), y(_mouse->y() - vy);
6475 d->m_overURL =
url.string() + TQString(
"?%1,%2").arg(x).arg(y);
6476 d->m_overURLTarget = target.string();
6477 overURL( d->m_overURL, target.string(), shiftPressed );
6484 if ( d->m_overURL.isEmpty() || d->m_overURL !=
url || d->m_overURLTarget != target )
6486 d->m_overURL =
url.string();
6487 d->m_overURLTarget = target.string();
6488 overURL( d->m_overURL, target.string(), shiftPressed );
6498 #ifndef TDEHTML_NO_SELECTION
6500 if( d->m_bMousePressed && innerNode.handle() && innerNode.handle()->renderer() &&
6501 ( (_mouse->state() & TQt::LeftButton) != 0 )) {
6502 extendSelectionTo(event->x(), event->y(),
6503 event->absX(), event->absY(), innerNode);
6505 if ( d->m_doc && d->m_view ) {
6506 TQPoint diff( _mouse->globalPos() - d->m_dragLastPos );
6508 if ( abs( diff.x() ) > 64 || abs( diff.y() ) > 64 ) {
6509 d->m_view->scrollBy( -diff.x(), -diff.y() );
6510 d->m_dragLastPos = _mouse->globalPos();
6520 DOM::Node innerNode =
event->innerNode();
6523 if ( d->m_bMousePressed ) {
6524 setStatusBarText(TQString(), BarHoverText);
6530 d->m_bMousePressed =
false;
6532 TQMouseEvent *_mouse =
event->qmouseEvent();
6533 if ( _mouse->button() == TQt::RightButton &&
parentPart() != 0 && d->m_bBackRightClick )
6535 d->m_bRightMousePressed =
false;
6538 tmp_iface->
callMethod(
"goHistory(int)", -1 );
6541 #ifndef TQT_NO_CLIPBOARD
6542 if ((d->m_guiProfile == BrowserViewGUI) && (_mouse->button() == TQt::MidButton) && (event->url().isNull())) {
6543 kdDebug( 6050 ) <<
"TDEHTMLPart::tdehtmlMouseReleaseEvent() MMB shouldOpen="
6544 << d->m_bOpenMiddleClick <<
endl;
6546 if (d->m_bOpenMiddleClick) {
6549 p->d->m_extension->pasteRequest();
6554 #ifndef TDEHTML_NO_SELECTION
6556 if(d->m_selectionStart == d->m_selectionEnd && d->m_startOffset == d->m_endOffset) {
6557 #ifndef TDEHTML_NO_CARET
6558 d->m_extendAtEnd =
true;
6560 d->m_selectionStart = 0;
6561 d->m_selectionEnd = 0;
6562 d->m_startOffset = 0;
6565 emitSelectionChanged();
6570 d->m_startBeforeEnd =
false;
6571 if( d->m_selectionStart == d->m_selectionEnd ) {
6572 if( d->m_startOffset < d->m_endOffset )
6573 d->m_startBeforeEnd =
true;
6577 if(n == d->m_selectionEnd) {
6578 d->m_startBeforeEnd =
true;
6591 if (d->m_selectionStart.isNull() || d->m_selectionEnd.isNull() ||
6592 !d->m_selectionStart.handle()->renderer() ||
6593 !d->m_selectionEnd.handle()->renderer())
return;
6594 d->m_startBeforeEnd = RangeImpl::compareBoundaryPoints(
6595 d->m_selectionStart.handle(), d->m_startOffset,
6596 d->m_selectionEnd.handle(), d->m_endOffset) <= 0;
6599 if(!d->m_startBeforeEnd)
6601 DOM::Node tmpNode = d->m_selectionStart;
6602 int tmpOffset = d->m_startOffset;
6603 d->m_selectionStart = d->m_selectionEnd;
6604 d->m_startOffset = d->m_endOffset;
6605 d->m_selectionEnd = tmpNode;
6606 d->m_endOffset = tmpOffset;
6607 d->m_startBeforeEnd =
true;
6608 d->m_extendAtEnd = !d->m_extendAtEnd;
6610 #ifndef TDEHTML_NO_CARET
6611 bool v = d->m_view->placeCaret();
6612 emitCaretPositionChanged(v ? d->caretNode() : 0, d->caretOffset());
6615 #ifndef TQT_NO_CLIPBOARD
6617 text.replace(TQChar(0xa0),
' ');
6618 disconnect( kapp->clipboard(), TQ_SIGNAL(
selectionChanged()),
this, TQ_SLOT( slotClearSelection()));
6619 kapp->clipboard()->setText(text,TQClipboard::Selection);
6620 connect( kapp->clipboard(), TQ_SIGNAL(
selectionChanged()), TQ_SLOT( slotClearSelection()));
6623 emitSelectionChanged();
6627 d->m_initialNode = 0;
6628 d->m_initialOffset = 0;
6638 if ( event->activated() )
6640 emitSelectionChanged();
6641 emit d->m_extension->enableAction(
"print", d->m_doc != 0 );
6643 if ( !d->m_settings->autoLoadImages() && d->m_paLoadImages )
6645 TQPtrList<TDEAction> lst;
6646 lst.append( d->m_paLoadImages );
6652 void TDEHTMLPart::slotPrintFrame()
6654 if ( d->m_frames.count() == 0 )
6666 TQMetaObject *mo = ext->metaObject();
6668 int idx = mo->findSlot(
"print()",
true );
6671 ext->tqt_invoke( idx, o );
6675 void TDEHTMLPart::slotSelectAll()
6678 if (part && part->inherits(
"TDEHTMLPart"))
6682 void TDEHTMLPart::startAutoScroll()
6684 connect(&d->m_scrollTimer, TQ_SIGNAL( timeout() ),
this, TQ_SLOT( slotAutoScroll() ));
6685 d->m_scrollTimer.start(100,
false);
6688 void TDEHTMLPart::stopAutoScroll()
6690 disconnect(&d->m_scrollTimer, TQ_SIGNAL( timeout() ),
this, TQ_SLOT( slotAutoScroll() ));
6691 if (d->m_scrollTimer.isActive())
6692 d->m_scrollTimer.stop();
6696 void TDEHTMLPart::slotAutoScroll()
6699 d->m_view->doAutoScroll();
6704 void TDEHTMLPart::runAdFilter()
6712 TQPtrDictIterator<tdehtml::CachedObject> it( d->m_doc->docLoader()->m_docObjects );
6713 for ( ; it.current(); ++it )
6714 if ( it.current()->type() == tdehtml::CachedObject::Image ) {
6715 tdehtml::CachedImage *image =
static_cast<tdehtml::CachedImage *
>(it.current());
6716 bool wasBlocked = image->m_wasBlocked;
6717 image->m_wasBlocked = TDEHTMLFactory::defaultHTMLSettings()->isAdFiltered( d->m_doc->completeURL( (*it).url().string() ) );
6718 if ( image->m_wasBlocked != wasBlocked )
6719 image->do_notify(image->pixmap(), image->valid_rect());
6722 if ( TDEHTMLFactory::defaultHTMLSettings()->isHideAdsEnabled() ) {
6723 for ( NodeImpl *nextNode, *node = d->m_doc; node; node = nextNode ) {
6726 nextNode = node->traverseNextNode();
6728 if ( node->id() == ID_IMG ||
6729 node->id() == ID_IFRAME ||
6730 (node->id() == ID_INPUT &&
static_cast<HTMLInputElementImpl *
>(node)->inputType() == HTMLInputElementImpl::IMAGE ))
6732 if ( TDEHTMLFactory::defaultHTMLSettings()->isAdFiltered( d->m_doc->completeURL(
static_cast<ElementImpl *
>(node)->getAttribute(ATTR_SRC).string() ) ) )
6736 NodeImpl *parent = node->parent();
6740 parent->removeChild(node, exception);
6751 if (!d->m_doc)
return;
6754 if (d->m_doc->isHTMLDocument())
6755 first =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body();
6762 while ( first && !(first->renderer()
6763 && ((first->nodeType() == Node::TEXT_NODE || first->nodeType() == Node::CDATA_SECTION_NODE)
6764 || (first->renderer()->isReplaced() && !first->renderer()->firstChild()))))
6766 next = first->firstChild();
6767 if ( !next ) next = first->nextSibling();
6768 while( first && !next )
6770 first = first->parentNode();
6772 next = first->nextSibling();
6778 if (d->m_doc->isHTMLDocument())
6779 last =
static_cast<HTMLDocumentImpl*
>(d->m_doc)->body();
6786 while ( last && !(last->renderer()
6787 && ((last->nodeType() == Node::TEXT_NODE || last->nodeType() == Node::CDATA_SECTION_NODE)
6788 || (last->renderer()->isReplaced() && !last->renderer()->lastChild()))))
6790 next = last->lastChild();
6791 if ( !next ) next = last->previousSibling();
6792 while ( last && !next )
6794 last = last->parentNode();
6796 next = last->previousSibling();
6801 if ( !first || !last )
6803 Q_ASSERT(first->renderer());
6804 Q_ASSERT(last->renderer());
6805 d->m_selectionStart = first;
6806 d->m_startOffset = 0;
6807 d->m_selectionEnd = last;
6808 d->m_endOffset = last->nodeValue().length();
6809 d->m_startBeforeEnd =
true;
6811 d->m_doc->setSelection( d->m_selectionStart.handle(), d->m_startOffset,
6812 d->m_selectionEnd.handle(), d->m_endOffset );
6814 emitSelectionChanged();
6817 bool TDEHTMLPart::checkLinkSecurity(
const KURL &linkURL,
const TQString &message,
const TQString &button)
6819 bool linkAllowed =
true;
6822 linkAllowed = kapp && kapp->authorizeURLAction(
"redirect",
url(), linkURL);
6824 if ( !linkAllowed ) {
6825 tdehtml::Tokenizer *tokenizer = d->m_doc->tokenizer();
6827 tokenizer->setOnHold(
true);
6829 int response = KMessageBox::Cancel;
6830 if (!message.isEmpty())
6833 message.arg(linkURL.
htmlURL()),
6834 i18n(
"Security Warning" ),
6840 i18n(
"<qt>Access by untrusted page to<BR><B>%1</B><BR> denied.").arg(linkURL.
htmlURL()),
6841 i18n(
"Security Alert" ));
6845 tokenizer->setOnHold(
false);
6846 return (response==KMessageBox::Continue);
6851 void TDEHTMLPart::slotPartRemoved(
KParts::Part *part )
6854 if ( part == d->m_activeFrame )
6856 d->m_activeFrame = 0L;
6857 if ( !part->inherits(
"TDEHTMLPart" ) )
6869 void TDEHTMLPart::slotActiveFrameChanged(
KParts::Part *part )
6874 kdError(6050) <<
"strange error! we activated ourselves" <<
endl;
6879 if ( d->m_activeFrame && d->m_activeFrame->widget() && d->m_activeFrame->widget()->inherits(
"TQFrame" ) )
6881 TQFrame *frame =
static_cast<TQFrame *
>( d->m_activeFrame->widget() );
6882 if (frame->frameStyle() != TQFrame::NoFrame)
6884 frame->setFrameStyle( TQFrame::StyledPanel | TQFrame::Sunken);
6889 if( d->m_activeFrame && !d->m_activeFrame->inherits(
"TDEHTMLPart" ) )
6896 if( part && !part->inherits(
"TDEHTMLPart" ) )
6905 d->m_activeFrame = part;
6907 if ( d->m_activeFrame && d->m_activeFrame->widget()->inherits(
"TQFrame" ) )
6909 TQFrame *frame =
static_cast<TQFrame *
>( d->m_activeFrame->widget() );
6910 if (frame->frameStyle() != TQFrame::NoFrame)
6912 frame->setFrameStyle( TQFrame::StyledPanel | TQFrame::Plain);
6915 kdDebug(6050) <<
"new active frame " << d->m_activeFrame <<
endl;
6926 if (!d->m_doc || !d->m_view)
6930 d->m_doc->setFocusNode(node.handle());
6933 TQRect rect = node.handle()->getRect();
6934 d->m_view->ensureVisible(rect.right(), rect.bottom());
6935 d->m_view->ensureVisible(rect.left(), rect.top());
6940 return DOM::Node(d->m_doc?d->m_doc->focusNode():0);
6943 DOM::EventListener *TDEHTMLPart::createHTMLEventListener( TQString code, TQString name, NodeImpl* node )
6945 KJSProxy *proxy = jScript();
6950 return proxy->createHTMLEventHandler(
m_url.
url(), name, code, node );
6960 d->m_opener = _opener;
6963 bool TDEHTMLPart::openedByJS()
6965 return d->m_openedByJS;
6968 void TDEHTMLPart::setOpenedByJS(
bool _openedByJS)
6970 d->m_openedByJS = _openedByJS;
6975 tdehtml::Cache::preloadStyleSheet(
url, stylesheet);
6980 tdehtml::Cache::preloadScript(
url, script);
6983 TQCString TDEHTMLPart::dcopObjectId()
const
6986 id.sprintf(
"html-widget%d", d->m_dcop_counter);
6990 long TDEHTMLPart::cacheId()
const
6992 return d->m_cacheId;
6995 bool TDEHTMLPart::restored()
const
6997 return d->m_restored;
7000 bool TDEHTMLPart::pluginPageQuestionAsked(
const TQString& mimetype)
const
7005 return parent->pluginPageQuestionAsked(mimetype);
7007 return d->m_pluginPageQuestionAsked.contains(mimetype);
7010 void TDEHTMLPart::setPluginPageQuestionAsked(
const TQString& mimetype)
7013 parentPart()->setPluginPageQuestionAsked(mimetype);
7015 d->m_pluginPageQuestionAsked.append(mimetype);
7018 void TDEHTMLPart::slotAutomaticDetectionLanguage(
int _id )
7020 d->m_automaticDetection->setItemChecked( _id,
true );
7024 d->m_autoDetectLanguage = tdehtml::Decoder::SemiautomaticDetection;
7027 d->m_autoDetectLanguage = tdehtml::Decoder::Arabic;
7030 d->m_autoDetectLanguage = tdehtml::Decoder::Baltic;
7033 d->m_autoDetectLanguage = tdehtml::Decoder::CentralEuropean;
7036 d->m_autoDetectLanguage = tdehtml::Decoder::Chinese;
7039 d->m_autoDetectLanguage = tdehtml::Decoder::Greek;
7042 d->m_autoDetectLanguage = tdehtml::Decoder::Hebrew;
7045 d->m_autoDetectLanguage = tdehtml::Decoder::Japanese;
7048 d->m_autoDetectLanguage = tdehtml::Decoder::Korean;
7051 d->m_autoDetectLanguage = tdehtml::Decoder::Russian;
7054 d->m_autoDetectLanguage = tdehtml::Decoder::Thai;
7057 d->m_autoDetectLanguage = tdehtml::Decoder::Turkish;
7060 d->m_autoDetectLanguage = tdehtml::Decoder::Ukrainian;
7063 d->m_autoDetectLanguage = tdehtml::Decoder::Unicode;
7066 d->m_autoDetectLanguage = tdehtml::Decoder::WesternEuropean;
7069 d->m_autoDetectLanguage = tdehtml::Decoder::SemiautomaticDetection;
7073 for (
int i = 0; i <= 14; ++i ) {
7075 d->m_automaticDetection->setItemChecked( i,
false );
7078 d->m_paSetEncoding->popupMenu()->setItemChecked( 0,
true );
7082 if( d->m_manualDetection )
7083 d->m_manualDetection->setCurrentItem( -1 );
7084 d->m_paSetEncoding->popupMenu()->setItemChecked( d->m_paSetEncoding->popupMenu()->idAt( 2 ),
false );
7087 tdehtml::Decoder *TDEHTMLPart::createDecoder()
7089 tdehtml::Decoder *dec =
new tdehtml::Decoder();
7090 if( !d->m_encoding.isNull() )
7091 dec->setEncoding( d->m_encoding.latin1(),
7092 d->m_haveEncoding ? tdehtml::Decoder::UserChosenEncoding : tdehtml::Decoder::EncodingFromHTTPHeader);
7096 ?
parentPart()->d->m_decoder->encoding() : settings()->encoding().latin1();
7097 dec->setEncoding(defaultEncoding, tdehtml::Decoder::DefaultEncoding);
7099 #ifdef APPLE_CHANGES
7101 d->m_doc->setDecoder(d->m_decoder);
7103 dec->setAutoDetectLanguage( d->m_autoDetectLanguage );
7107 void TDEHTMLPart::emitCaretPositionChanged(
const DOM::Node &node,
long offset) {
7111 void TDEHTMLPart::restoreScrollPosition()
7116 if ( !d->m_doc || !d->m_doc->parsing() )
7117 disconnect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
7127 if (d->m_view->contentsHeight() - d->m_view->visibleHeight() >= args.
yOffset
7128 || d->m_bComplete) {
7130 disconnect(d->m_view, TQ_SIGNAL(finishedLayout()),
this, TQ_SLOT(restoreScrollPosition()));
7135 void TDEHTMLPart::openWallet(DOM::HTMLFormElementImpl *form)
7137 #ifndef TDEHTML_NO_WALLET
7144 p->openWallet(form);
7153 if (d->m_bWalletOpened) {
7154 if (d->m_wallet->isOpen()) {
7155 form->walletOpened(d->m_wallet);
7158 d->m_wallet->deleteLater();
7160 d->m_bWalletOpened =
false;
7165 TDEWallet::Wallet *wallet = TDEWallet::Wallet::openWallet(TDEWallet::Wallet::NetworkWallet(),
widget() ?
widget()->topLevelWidget()->winId() : 0, TDEWallet::Wallet::Asynchronous);
7166 d->m_wq =
new TDEHTMLWalletQueue(
this);
7167 d->m_wq->wallet = wallet;
7168 connect(wallet, TQ_SIGNAL(walletOpened(
bool)), d->m_wq, TQ_SLOT(walletOpened(
bool)));
7169 connect(d->m_wq, TQ_SIGNAL(walletOpened(TDEWallet::Wallet*)),
this, TQ_SLOT(walletOpened(TDEWallet::Wallet*)));
7172 d->m_wq->callers.append(TDEHTMLWalletQueue::Caller(form, form->getDocument()));
7177 void TDEHTMLPart::saveToWallet(
const TQString& key,
const TQMap<TQString,TQString>& data)
7179 #ifndef TDEHTML_NO_WALLET
7186 p->saveToWallet(key, data);
7191 if (d->m_bWalletOpened) {
7192 if (d->m_wallet->isOpen()) {
7193 if (!d->m_wallet->hasFolder(TDEWallet::Wallet::FormDataFolder())) {
7194 d->m_wallet->createFolder(TDEWallet::Wallet::FormDataFolder());
7196 d->m_wallet->setFolder(TDEWallet::Wallet::FormDataFolder());
7197 d->m_wallet->writeMap(key, data);
7200 d->m_wallet->deleteLater();
7202 d->m_bWalletOpened =
false;
7207 TDEWallet::Wallet *wallet = TDEWallet::Wallet::openWallet(TDEWallet::Wallet::NetworkWallet(),
widget() ?
widget()->topLevelWidget()->winId() : 0, TDEWallet::Wallet::Asynchronous);
7208 d->m_wq =
new TDEHTMLWalletQueue(
this);
7209 d->m_wq->wallet = wallet;
7210 connect(wallet, TQ_SIGNAL(walletOpened(
bool)), d->m_wq, TQ_SLOT(walletOpened(
bool)));
7211 connect(d->m_wq, TQ_SIGNAL(walletOpened(TDEWallet::Wallet*)),
this, TQ_SLOT(walletOpened(TDEWallet::Wallet*)));
7213 d->m_wq->savers.append(qMakePair(key, data));
7218 void TDEHTMLPart::dequeueWallet(DOM::HTMLFormElementImpl *form) {
7219 #ifndef TDEHTML_NO_WALLET
7226 p->dequeueWallet(form);
7231 d->m_wq->callers.remove(TDEHTMLWalletQueue::Caller(form, form->getDocument()));
7237 void TDEHTMLPart::walletOpened(TDEWallet::Wallet *wallet) {
7238 #ifndef TDEHTML_NO_WALLET
7239 assert(!d->m_wallet);
7242 d->m_wq->deleteLater();
7246 d->m_bWalletOpened =
false;
7250 d->m_wallet = wallet;
7251 d->m_bWalletOpened =
true;
7252 connect(d->m_wallet, TQ_SIGNAL(walletClosed()), TQ_SLOT(slotWalletClosed()));
7254 if (!d->m_statusBarWalletLabel) {
7255 d->m_statusBarWalletLabel =
new KURLLabel(d->m_statusBarExtension->statusBar());
7257 d->m_statusBarWalletLabel->setSizePolicy(TQSizePolicy(TQSizePolicy::Fixed, TQSizePolicy::Fixed));
7258 d->m_statusBarWalletLabel->setUseCursor(
false);
7259 d->m_statusBarExtension->addStatusBarItem(d->m_statusBarWalletLabel, 0,
false);
7260 d->m_statusBarWalletLabel->setPixmap(SmallIcon(
"wallet_open",
instance()));
7261 connect(d->m_statusBarWalletLabel, TQ_SIGNAL(leftClickedURL()), TQ_SLOT(launchWalletManager()));
7262 connect(d->m_statusBarWalletLabel, TQ_SIGNAL(rightClickedURL()), TQ_SLOT(walletMenu()));
7264 TQToolTip::remove(d->m_statusBarWalletLabel);
7266 TQToolTip::add(d->m_statusBarWalletLabel, i18n(
"The wallet '%1' is open and being used for form data and passwords.").arg(TDEWallet::Wallet::NetworkWallet()));
7271 TDEWallet::Wallet *TDEHTMLPart::wallet()
7273 #ifndef TDEHTML_NO_WALLET
7287 void TDEHTMLPart::slotWalletClosed()
7289 #ifndef TDEHTML_NO_WALLET
7291 d->m_wallet->deleteLater();
7294 d->m_bWalletOpened =
false;
7295 if (d->m_statusBarWalletLabel) {
7296 d->m_statusBarExtension->removeStatusBarItem(d->m_statusBarWalletLabel);
7297 delete d->m_statusBarWalletLabel;
7298 d->m_statusBarWalletLabel = 0L;
7303 void TDEHTMLPart::launchWalletManager()
7305 #ifndef TDEHTML_NO_WALLET
7306 if (!DCOPClient::mainClient()->isApplicationRegistered(
"tdewalletmanager")) {
7309 DCOPRef r(
"tdewalletmanager",
"tdewalletmanager-mainwindow#1");
7316 void TDEHTMLPart::walletMenu()
7318 #ifndef TDEHTML_NO_WALLET
7320 m->insertItem(i18n(
"&Close Wallet"),
this, TQ_SLOT(slotWalletClosed()));
7321 m->popup(TQCursor::pos());
7325 void TDEHTMLPart::slotToggleCaretMode()
7331 d->m_formNotification = fn;
7335 return d->m_formNotification;
7355 return d->m_doc->unsubmittedFormChanges();
7358 void TDEHTMLPart::setDebugScript(
bool enable )
7362 if (!d->m_paDebugScript) {
7363 d->m_paDebugScript =
new TDEAction( i18n(
"JavaScript &Debugger" ), 0,
this, TQ_SLOT( slotDebugScript() ),
actionCollection(),
"debugScript" );
7365 d->m_paDebugScript->setEnabled( d->m_frame ? d->m_frame->m_jscript : 0L );
7366 TQPtrList<TDEAction> lst;
7367 lst.append( d->m_paDebugScript );
7370 d->m_bJScriptDebugEnabled = enable;
7385 if ( enable && originPart ) {
7386 d->m_openableSuppressedPopups++;
7387 if ( d->m_suppressedPopupOriginParts.findIndex( originPart ) == -1 )
7388 d->m_suppressedPopupOriginParts.append( originPart );
7391 if ( enable && !d->m_statusBarPopupLabel ) {
7392 d->m_statusBarPopupLabel =
new KURLLabel( d->m_statusBarExtension->statusBar() );
7394 d->m_statusBarPopupLabel->setSizePolicy( TQSizePolicy( TQSizePolicy::Fixed, TQSizePolicy::Fixed ));
7395 d->m_statusBarPopupLabel->setUseCursor(
false );
7396 d->m_statusBarExtension->addStatusBarItem( d->m_statusBarPopupLabel, 0,
false );
7397 d->m_statusBarPopupLabel->setPixmap( SmallIcon(
"window_suppressed",
instance() ) );
7398 TQToolTip::add( d->m_statusBarPopupLabel, i18n(
"This page was prevented from opening a new window via JavaScript." ) );
7400 connect(d->m_statusBarPopupLabel, TQ_SIGNAL(leftClickedURL()), TQ_SLOT(suppressedPopupMenu()));
7401 if (d->m_settings->jsPopupBlockerPassivePopup()) {
7403 px = MainBarIcon(
"window_suppressed" );
7404 KPassivePopup::message(i18n(
"Popup Window Blocked"),i18n(
"This page has attempted to open a popup window but was blocked.\nYou can click on this icon in the status bar to control this behavior\nor to open the popup."),px,d->m_statusBarPopupLabel);
7406 }
else if ( !enable && d->m_statusBarPopupLabel ) {
7407 TQToolTip::remove( d->m_statusBarPopupLabel );
7408 d->m_statusBarExtension->removeStatusBarItem( d->m_statusBarPopupLabel );
7409 delete d->m_statusBarPopupLabel;
7410 d->m_statusBarPopupLabel = 0L;
7414 void TDEHTMLPart::suppressedPopupMenu() {
7416 m->setCheckable(
true);
7417 if ( d->m_openableSuppressedPopups )
7418 m->insertItem(i18n(
"&Show Blocked Popup Window",
"Show %n Blocked Popup Windows", d->m_openableSuppressedPopups),
this, TQ_SLOT(showSuppressedPopups()));
7419 m->insertItem(i18n(
"Show Blocked Window Passive Popup &Notification"),
this, TQ_SLOT(togglePopupPassivePopup()),0,57);
7420 m->setItemChecked(57,d->m_settings->jsPopupBlockerPassivePopup());
7421 m->insertItem(i18n(
"&Configure JavaScript New Window Policies..."),
this, TQ_SLOT(launchJSConfigDialog()));
7422 m->popup(TQCursor::pos());
7425 void TDEHTMLPart::togglePopupPassivePopup() {
7427 d->m_settings->setJSPopupBlockerPassivePopup( !d->m_settings->jsPopupBlockerPassivePopup() );
7428 DCOPClient::mainClient()->send(
"konqueror*",
"KonquerorIface",
"reparseConfiguration()", TQByteArray());
7431 void TDEHTMLPart::showSuppressedPopups() {
7432 for ( TQValueListIterator<TQGuardedPtr<TDEHTMLPart> > i = d->m_suppressedPopupOriginParts.begin();
7433 i != d->m_suppressedPopupOriginParts.end(); ++i ) {
7435 KJS::Window *w = KJS::Window::retrieveWindow( part );
7437 w->showSuppressedWindows();
7438 w->forgetSuppressedWindows();
7443 d->m_openableSuppressedPopups = 0;
7444 d->m_suppressedPopupOriginParts.clear();
7449 TQString TDEHTMLPart::defaultExtension()
const
7453 if ( !d->m_doc->isHTMLDocument() )
7455 return d->m_doc->htmlMode() == DOM::DocumentImpl::XHtml ?
".xhtml" :
".html";
7458 bool TDEHTMLPart::inProgress()
const
7460 if (d->m_runningScripts || (d->m_doc && d->m_doc->parsing()))
7464 ConstFrameIt it = d->m_frames.begin();
7465 const ConstFrameIt
end = d->m_frames.end();
7466 for (; it !=
end; ++it ) {
7467 if ((*it)->m_run || !(*it)->m_bCompleted)
7471 return d->m_submitForm || !d->m_redirectURL.isEmpty() || d->m_redirectionTimer.isActive() || d->m_job;
7474 using namespace KParts;
7475 #include "tdehtml_part.moc"
7476 #include "tdehtmlpart_p.moc"
This class implements the basic string we use in the DOM.
The Document interface represents the entire HTML or XML document.
Range createRange()
Introduced in DOM Level 2 This method is from the DocumentRange interface.
Introduced in DOM Level 2.
An HTMLDocument is the root of the HTML hierarchy and holds the entire content.
DOMString domain() const
The domain name of the server that served the document, or a null string if the server cannot be iden...
Node getNamedItem(const DOMString &name) const
Retrieves a node specified by name.
The Node interface is the primary datatype for the entire Document Object Model.
Node nextSibling() const
The node immediately following this node.
bool isNull() const
tests if this Node is 0.
DOMString nodeValue() const
The value of this node, depending on its type; see the table above.
Node parentNode() const
The parent of this node.
Node firstChild() const
The first child of this node.
NamedNodeMap attributes() const
A NamedNodeMap containing the attributes of this node (if it is an Element ) or null otherwise.
unsigned short nodeType() const
A code representing the type of the underlying object, as defined above.
DOMString nodeName() const
The name of this node, depending on its type; see the table above.
TQString encodingForName(const TQString &descriptiveName)
TQStringList descriptiveEncodingNames()
static bool avoidArea(TQWidget *widget, const TQRect &area, int screen=-1)
static KLibLoader * self()
TQString lastErrorMessage() const
virtual KLibrary * library(const char *libname)
KLibFactory * factory(const char *libname)
void * symbol(const char *name) const
static void information(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const TQString &dontShowAgainName=TQString::null, int options=Notify)
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
static int warningContinueCancel(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, const KGuiItem &buttonContinue=KStdGuiItem::cont(), const TQString &dontAskAgainName=TQString::null, int options=Notify)
void addDragObject(TQDragObject *dragObject)
static BrowserExtension * childObject(TQObject *obj)
void callMethod(const char *name, const TQVariant &argument)
static AskSaveResult askEmbedOrSave(const KURL &url, const TQString &mimeType, const TQString &suggestedFilename=TQString::null, int flags=0)
virtual void setInstance(TDEInstance *instance)
virtual void removePart(Part *part)
virtual Part * activePart() const
virtual void addPart(Part *part, bool setActive=true)
virtual void setWidget(TQWidget *widget)
virtual TQWidget * widget()
void canceled(const TQString &errMsg)
void started(TDEIO::Job *)
void setStatusBar(KStatusBar *status)
static StatusBarExtension * childObject(TQObject *obj)
static TQString rsqueeze(const TQString &str, uint maxlen=40)
static TQString csqueeze(const TQString &str, uint maxlen=40)
TQMap< TQString, TQString > & metaData()
void setUser(const TQString &_txt)
TQString encodedHtmlRef() const
void setRef(const TQString &_txt)
static TQString encode_string(const TQString &str, int encoding_hint=0)
void setPath(const TQString &path)
void setPass(const TQString &_txt)
static List split(const TQString &_url)
TQString protocol() const
TQString queryItem(const TQString &item) const
static KURL join(const List &_list)
void setQuery(const TQString &_txt, int encoding_hint=0)
TQString fileName(bool _ignore_trailing_slash_in_path=true) const
TQString url(int _trailing=0, int encoding_hint=0) const
static TQString decode_string(const TQString &str, int encoding_hint=0)
void setFileName(const TQString &_txt)
TQString prettyURL(int _trailing=0) const
static void activateWindow(WId win, long time=0)
void plugActionList(const TQString &name, const TQPtrList< TDEAction > &actionList)
void unplugActionList(const TQString &name)
void removeChildClient(KXMLGUIClient *child)
virtual TDEInstance * instance() const
virtual void setXMLFile(const TQString &file, bool merge=false, bool setXMLDoc=true)
KXMLGUIFactory * factory() const
TDEAction * action(const char *name) const
const TQPtrList< KXMLGUIClient > * childClients()
virtual TDEActionCollection * actionCollection() const
void insertChildClient(KXMLGUIClient *child)
void removeClient(KXMLGUIClient *client)
void addClient(KXMLGUIClient *client)
static int tdeinitExec(const TQString &name, const TQStringList &args, TQString *error, int *pid, const TQCString &startup_id)
static int startServiceByDesktopName(const TQString &_name, const TQString &URL, TQString *error=0, TQCString *dcopService=0, int *pid=0, const TQCString &startup_id="", bool noWait=false)
int readNumEntry(const TQString &pKey, int nDefault=0) const
bool readBoolEntry(const TQString &pKey, bool bDefault=false) const
void deleteEntry(const TQString &pKey, bool bNLS=false, bool bGlobal=false)
bool hasGroup(const TQString &group) const
void writeEntry(const TQString &pKey, const TQString &pValue, bool bPersistent=true, bool bGlobal=false, bool bNLS=false)
void setGroup(const TQString &group)
static bool showIconsOnPushButtons()
static int dndEventDelay()
static TDEConfig * config()
static KCharsets * charsets()
static TDELocale * locale()
long createCacheEntry()
Create a new cache entry.
void addData(long id, const TQByteArray &data)
Add data to the cache entry with id id.
void endData(long id)
Signal end of data for the cache entry with id id.
void saveData(long id, TQDataStream *str)
Save the data of cache entry id to the datastream str.
static TDEHTMLPageCache * self()
static "constructor".
void fetchData(long id, TQObject *recvObj, const char *recvSlot)
Fetch data for cache entry id and send it to slot recvSlot in the object recvObj.
void cancelEntry(long id)
Cancel the entry.
void cancelFetch(TQObject *recvObj)
Cancel sending data to recvObj.
This is the BrowserExtension for a TDEHTMLPart document.
DCOP interface for TDEHTML.
This class is tdehtml's main class.
KURL toplevelURL()
Returns the toplevel (origin) URL of this document, even if this part is a frame or an iframe.
DOM::Range selection() const
Returns the selected part of the HTML.
bool isModified() const
Checks whether the page contains unsubmitted form changes.
TQStringList frameNames() const
Returns a list of names of all frame (including iframe) objects of the current document.
void setEditable(bool enable)
Makes the document editable.
TDEHTMLPart * findFrameParent(KParts::ReadOnlyPart *callingPart, const TQString &f, tdehtml::ChildFrame **childFrame=0)
Recursively finds the part containing the frame with name f and checks if it is accessible by calling...
TQString jsStatusBarText() const
Called by KJS.
TQVariant executeScript(const DOM::Node &n, const TQString &script)
Same as executeScript( const TQString & ) except with the Node parameter specifying the 'this' value.
DOM::Document document() const
Returns a reference to the DOM document.
KJavaAppletContext * createJavaContext()
Returns the java context of the applets.
void setSelection(const DOM::Range &)
Sets the current selection.
virtual bool doCloseStream()
Implements the streaming API of KParts::ReadOnlyPart.
void popupMenu(const TQString &url, const TQPoint &point)
Emitted when the user clicks the right mouse button on the document.
virtual void tdehtmlMouseDoubleClickEvent(tdehtml::MouseDoubleClickEvent *)
Eventhandler for the tdehtml::MouseDoubleClickEvent.
bool pluginsEnabled() const
Returns true if plugins are enabled/disabled.
void selectAll()
Marks all text in the document as selected.
CaretDisplayPolicy caretDisplayPolicyNonFocused() const
Returns the current caret policy when the view is not focused.
CaretDisplayPolicy
Enumeration for displaying the caret.
DOM::Node nonSharedNodeUnderMouse() const
Returns the Node currently under the mouse that is not shared.
bool prevAnchor()
Go to previous anchor.
TQString pageReferrer() const
Referrer used to obtain this page.
void setJSDefaultStatusBarText(const TQString &text)
Called by KJS.
void setCaretMode(bool enable)
Enables/disables caret mode.
virtual bool openFile()
Internal empty reimplementation of KParts::ReadOnlyPart::openFile .
KJSProxy * framejScript(KParts::ReadOnlyPart *framePart)
Returns child frame framePart its script interpreter.
void setSuppressedPopupIndicator(bool enable)
Shows or hides the suppressed popup indicator.
void setURLCursor(const TQCursor &c)
Sets the cursor to use when the cursor is on a link.
int zoomFactor() const
Returns the current zoom factor.
TQString encoding() const
Returns the encoding the page currently uses.
KParts::BrowserExtension * browserExtension() const
Returns a pointer to the KParts::BrowserExtension.
void setStandardFont(const TQString &name)
Sets the standard font style.
TQCursor urlCursor() const
Returns the cursor which is used when the cursor is on a link.
void setMetaRefreshEnabled(bool enable)
Enable/disable automatic forwarding by <meta http-equiv="refresh" ....
DOM::HTMLDocument htmlDocument() const
Returns a reference to the DOM HTML document (for non-HTML documents, returns null)
void setJSStatusBarText(const TQString &text)
Called by KJS.
bool isCaretMode() const
Returns whether caret mode is on/off.
bool onlyLocalReferences() const
Returns whether only file:/ or data:/ references are allowed to be loaded ( default false ).
virtual bool doWriteStream(const TQByteArray &data)
Implements the streaming API of KParts::ReadOnlyPart.
TDEHTMLView * view() const
Returns a pointer to the HTML document's view.
bool dndEnabled() const
Returns whether Dragn'n'Drop support is enabled or not.
virtual void saveState(TQDataStream &stream)
Saves the TDEHTMLPart's complete state (including child frame objects) to the provided TQDataStream.
bool hasSelection() const
Has the user selected anything?
void preloadStyleSheet(const TQString &url, const TQString &stylesheet)
Loads a style sheet into the stylesheet cache.
KJS::Interpreter * jScriptInterpreter()
Returns the JavaScript interpreter the part is using.
virtual void guiActivateEvent(KParts::GUIActivateEvent *event)
Internal reimplementation of KParts::Part::guiActivateEvent .
TQString selectedTextAsHTML() const
Return the text the user has marked.
void caretPositionChanged(const DOM::Node &node, long offset)
This signal is emitted whenever the caret position has been changed.
void setJavaEnabled(bool enable)
Enables/disables Java applet support.
TQString referrer() const
Referrer used for links in this page.
bool setEncoding(const TQString &name, bool override=false)
Sets the encoding the page uses.
bool nextAnchor()
Go to the next anchor.
bool gotoAnchor(const TQString &name)
Finds the anchor named name.
TQString documentSource() const
Returns the content of the source document.
virtual bool openURL(const KURL &url)
Opens the specified URL url.
virtual TQString selectedText() const
Returns the text the user has marked.
KURL backgroundURL() const
Returns the URL for the background Image (used by save background)
virtual void showError(TDEIO::Job *job)
Called when a certain error situation (i.e.
virtual void tdehtmlMousePressEvent(tdehtml::MousePressEvent *event)
Eventhandler of the tdehtml::MousePressEvent.
KParts::PartManager * partManager()
Returns a reference to the partmanager instance which manages html frame objects.
bool statusMessagesEnabled() const
Returns true if status messages are enabled.
virtual void begin(const KURL &url=KURL(), int xOffset=0, int yOffset=0)
Clears the widget and prepares it for new content.
void findTextBegin()
Initiates a text search.
void setFormNotification(FormNotification fn)
Determine if signal should be emitted before, instead or never when a submitForm() happens.
DOM::Node activeNode() const
Returns the node that has the keyboard focus.
virtual ~TDEHTMLPart()
Destructor.
void setOnlyLocalReferences(bool enable)
Security option.
void setZoomFactor(int percent)
Sets the Zoom factor.
bool autoloadImages() const
Returns whether images contained in the document are loaded automatically or not.
void stopAnimations()
Stops all animated images on the current and child pages.
void htmlError(int errorCode, const TQString &text, const KURL &reqUrl)
presents a detailed error message to the user.
void setDNDEnabled(bool b)
Enables or disables Drag'n'Drop support.
void show()
Convenience method to show the document's view.
void setJScriptEnabled(bool enable)
Enable/disable Javascript support.
void onURL(const TQString &url)
Emitted if the cursor is moved over an URL.
FormNotification formNotification() const
Determine if signal should be emitted before, instead or never when a submitForm() happens.
bool isEditable() const
Returns true if the document is editable, false otherwise.
TDEHTMLPart(TQWidget *parentWidget=0, const char *widgetname=0, TQObject *parent=0, const char *name=0, GUIProfile prof=DefaultGUI)
Constructs a new TDEHTMLPart.
virtual bool doOpenStream(const TQString &mimeType)
Implements the streaming API of KParts::ReadOnlyPart.
virtual void write(const char *str, int len=-1)
Writes another part of the HTML code to the widget.
KParts::ReadOnlyPart * currentFrame() const
Return the current frame (the one that has focus) Not necessarily a direct child of ours,...
bool frameExists(const TQString &frameName)
Returns whether a frame with the specified name is exists or not.
virtual void end()
Call this after your last call to write().
void setCaretVisible(bool show)
Sets the visibility of the caret.
TQString lastModified() const
Last-modified date (in raw string format), if received in the [HTTP] headers.
bool findTextNext()
Finds the next occurence of a string set by findText()
void setPluginsEnabled(bool enable)
Enables or disables plugins, default is enabled.
TQString jsDefaultStatusBarText() const
Called by KJS.
virtual KParts::ReadOnlyPart * createPart(TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQString &mimetype, TQString &serviceName, TQStringList &serviceTypes, const TQStringList ¶ms)
This method is called when a new embedded object (include html frames) is to be created.
TDEHTMLPart * findFrame(const TQString &f)
Finds a frame by name.
DOM::Node nodeUnderMouse() const
Returns the Node currently under the mouse.
bool metaRefreshEnabled() const
Returns true if automatic forwarding is enabled.
void setCaretDisplayPolicyNonFocused(CaretDisplayPolicy policy)
Sets the caret display policy when the view is not focused.
void setUserStyleSheet(const KURL &url)
Sets a user defined style sheet to be used on top of the HTML 4 default style sheet.
void setStatusMessagesEnabled(bool enable)
Enable/disable statusbar messages.
void paint(TQPainter *, const TQRect &, int=0, bool *=0)
Paints the HTML page to a TQPainter.
void nodeActivated(const DOM::Node &)
This signal is emitted when an element retrieves the keyboard focus.
void formSubmitNotification(const char *action, const TQString &url, const TQByteArray &formData, const TQString &target, const TQString &contentType, const TQString &boundary)
If form notification is on, this will be emitted either for a form submit or before the form submit a...
void hide()
Convenience method to hide the document's view.
KParts::ReadOnlyPart * findFramePart(const TQString &f)
Finds a frame by name.
virtual bool closeURL()
Stops loading the document and kills all data requests (for images, etc.)
void setActiveNode(const DOM::Node &node)
Sets the focused node of the document to the specified node.
virtual void tdehtmlDrawContentsEvent(tdehtml::DrawContentsEvent *)
Eventhandler for the tdehtml::DrawContentsEvent.
virtual void tdehtmlMouseReleaseEvent(tdehtml::MouseReleaseEvent *event)
Eventhandler for the tdehtml::MouseMouseReleaseEvent.
bool javaEnabled() const
Return true if Java applet support is enabled, false if disabled.
virtual void tdehtmlMouseMoveEvent(tdehtml::MouseMoveEvent *event)
Eventhandler for the tdehtml::MouseMouseMoveEvent.
bool jScriptEnabled() const
Returns true if Javascript support is enabled or false otherwise.
void findText()
Starts a new search by popping up a dialog asking the user what he wants to search for.
void selectionChanged()
This signal is emitted when the selection changes.
void scheduleRedirection(int delay, const TQString &url, bool lockHistory=true)
Schedules a redirection after delay seconds.
void setCaretPosition(DOM::Node node, long offset, bool extendSelection=false)
Sets the caret to the given position.
KURL completeURL(const TQString &url)
returns a KURL object for the given url.
TDEHTMLPart * parentPart()
Returns a pointer to the parent TDEHTMLPart if the part is a frame in an HTML frameset.
void setAutoloadImages(bool enable)
Specifies whether images contained in the document should be loaded automatically or not.
virtual void restoreState(TQDataStream &stream)
Restores the TDEHTMLPart's previously saved state (including child frame objects) from the provided T...
void setFixedFont(const TQString &name)
Sets the fixed font style.
void preloadScript(const TQString &url, const TQString &script)
Loads a script into the script cache.
KJavaAppletContext * javaContext()
Returns the java context of the applets.
Settings for the HTML view.
void init()
Called by constructor and reparseConfiguration.
Renders and displays HTML in a TQScrollView.
TQString formatDateTime(const TQDateTime &pDateTime, bool shortFormat=true, bool includeSecs=false) const
void removeCatalogue(const TQString &catalog)
const char * encoding() const
TQString formatNumber(double num, int precision=-1) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdWarning(int area=0)
kdbgstream kdError(int area=0)
kdbgstream kdDebug(int area=0)
TQString locate(const char *type, const TQString &filename, const TDEInstance *instance=TDEGlobal::instance())
The Document Object Model (DOM) is divided into two parts, the COREDOM core DOM, specifying some core...
int event(const TQString &message, const TQString &text=TQString::null) TDE_DEPRECATED
TDEAction * selectAll(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * findPrev(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * findNext(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * find(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
TDEAction * saveAs(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)
const TDEShortcut & next()
TQString name(StdAccel id)
const TDEShortcut & end()
void setContentType(const TQString &contentType)
TQString contentType() const
void setNewTab(bool newTab)
void setDoPost(bool enable)
bool redirectedRequest() const
TQMap< TQString, TQString > & metaData()
void setLockHistory(bool lock)
void setForcesNewWindow(bool forcesNewWindow)